Sampling float from texture(rect)

Hi there,

I wanted to use a texture/buffer to access my heightfield on my vertex shader. However, the heights are floats and it seems like all methods that sample 2dtextures return vec4, which has 4 bytes.
Any idea how i can sample floats? Can i combine the four ints/bytes back into the original floats? Or did i miss some other functions that can help me with this?

For clarity: the texture/buffer is a simple array of floats.

Thanks for any help!

Texture fetch functions always return vec4s (or ivec4s or uvec4s for integer textures), but that shouldn’t confuse you.

In case you have a one, two, or three channel texture, e.g. R32F, RG16F or RGB8, you still get a vec4 at fetch time, just the unavailable channels get default data, thus in case of a single channel R texture you get the result (r,0,0,1), where r is the actual component from the texture.

Ahh i understand now, thank you very much! I though it would always read 4 values per texel.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.