I use OpenGL ES 2.0 on Android and I wrote a sample shader that uses texture2d
to get an image RGB value.
vec4 v1 = texture2D(sTexture,textCoord);
float r = v1.r;
so , is the value of r
in the range [0.0, 1.0]
or [0.0 255.0]
?
OpenGL ES 2.0 only supports textures with normalized values, which means that the float values returned by texture sampling operations are in the range [0.0, 1.0].
This means that the original integer values are divided by the maximum value supported by the range. For example, for 8-bit values, the original value is divided by 255.0, for 5-bit values it is divided by 31.0, etc.
OpenGL versions with more feature content often have texture types where this does not apply. They can have integer type textures where you get the original integer value when you sample them in a shader, or float textures that contain floats of various precisions/ranges. But none of these types are supported in ES 2.0.