Sampling float from texture(rect)
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.
Disclaimer: This is my personal profile. Whatever I write here is my personal opinion and none of my statements or speculations are anyhow related to my employer and as such should not be treated as accurate or valid and in no case should those be considered to represent the opinions of my employer.
Technical Blog: http://www.rastergrid.com/blog/
Ahh i understand now, thank you very much! I though it would always read 4 values per texel.