Is it possible to get texture Integer Coordinate?

I am using OpenGL ES 2.0. Is it possible to pass the texture coordinates as integers? I remember setting up the vertex in numbers bigger than 1.0 and specify int2 as texture coordinates and it worked before, but I can no longer do it now.

Although I don’t know about GLES, you can sample any texture with any value. Still, a (2D) texture will always be parameterized by values in the range [0…1].

What’s normally done when using integers or integer offsets when doing texture lookups is division by the dimensions of the texture in the corresponding direction to get a value in [0…1].

Adding to what thokra has said. GL_TEXTURE_2D needs normalized texture coordinates in (0-1) range for both s and t. If you want to use integers, you can use GL_TEXTURE_RECTANGLE which go from (0-w,0-h);

Are you talking about passing integer values to the vertex shader? If so, you sound like you’re talking about normalized vertex attributes. That’s where you specify values on the range (for example) [0, 255] which get mapped to the range [0, 1]. That is done by using glVertexAttribArray with GL_UNSIGNED_BYTE and GL_TRUE for the normalized field. You can use shorts as well (range [0, 65535] maps to [0, 1]), and signed values (GL_SIGNED_BYTE goes from [-128, 127] to [-1, 1]).

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