View Full Version : Is it possible to get texture Integer Coordinate?
registerme
12-08-2011, 07:14 PM
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.
thokra
12-09-2011, 02:19 AM
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].
mobeen
12-09-2011, 07:45 AM
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);
Alfonse Reinheart
12-09-2011, 09:27 AM
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]).
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.