I need to use a texture(rgba) where each channel can store unsigned integer value from a range <0,7> I set a texture this way:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32UI, screenWidth, screenHeight, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL);
First I fill a texture with some data. Then when I read a texture I use sampler2D and vec2 as a texture coordinate (<0,1>, <0,1>).
The following texture function with sampler2D returns float:
float data = texture(mySampler, texCoord).x;
but I can use that value this way:
if(data == 0)
{
//do something
}
and it works. I realize that I can improve my code. I try to change GL_RGBA32UI to GL_RGBA16UI but then the program doesn’t work
(RGBA12UI seems to be minimum internal format to store value from a range <0,7> in each channel). Can I use a usampler2D with vec2 as a
texture coordinate ? What should I change in the above code ?