NPOT texture

vindos

Newcomer
Helloo..

I have a doubt regarding the normalised texture address of an Npot texture inside a shader. Say am passing a npot texture of size 420 X 420 to an Opengl shader. Then can i get back the texture position by multiplying address with dimension of texture??

My need is to identify the even and odd texture addresses of an npot texture inside a shader.

Thankzzz
 
I assume you're sampling the texture 1:1? If so, floor(texCoord * dimension) should return the integer locations of the texels. To be clear, for a 4 texel wide texture, the texels are located at addresses 0.5 / 4.0, 1.5 / 4.0, 2.5 / 4.0 and 3.5 / 4.0. To discern between odd and even texels you can do fract(texCoord * halfDimension), which will return 0.25, 0.75, 0.25, 0.75 ... so you can compare < 0.5 to see if it's odd or even.
 
Back
Top