Accname
2D-Graphics enthusiast
- Reaction score
- 1,462
Hi guys, quick question.
Is it possible to get the RGBA values for a pixel in a texture as bytes instead of floats?
I am writing a fragment shader by the way.
I know i can do this:
Then i can call:
To get the r value for the pixel as a float between 0 and 1.
But i want to use these as an index in an array and i would like to have them as raw byte data between 0 and 255.
I know i could multiply by 255 but i dont think this will have perfect precision.
Is it possible to get the RGBA values for a pixel in a texture as bytes instead of floats?
I am writing a fragment shader by the way.
I know i can do this:
Code:
vec4 color = texture2D(tex, gl_TexCoord[0].st);
Code:
float red = color.r;
But i want to use these as an index in an array and i would like to have them as raw byte data between 0 and 255.
I know i could multiply by 255 but i dont think this will have perfect precision.