View Full Version : How to get texture coordinates for a rendering.

GL Starter
07-14-2010, 08:08 AM
Is there any way to get the texture coordinates, that are created by opengl rendering pipeline ?

I have a texture of width 100, and height 100.
When I rendering a small region of this texture[In x direction 0 to 20 and in Y direction 0 to 20] to a big area[100*100], opengl will calculate the texture coordinates
for each pixels[100*100= 1000 pixels].
I want to know the coordinates for each of these pixels.

One option is to use a pixel shader,and output the texture coordinate, and that's working.
But I want to know the texture coordinate without a rendering.
IS there any equation for getting the texture coordinates for each pixels of rendering ?

carsten neumann
07-14-2010, 03:38 PM
I guess it depends a bit on how precise you need the computed values to match what your fragment shader writes. Basically the texture coordinates for a fragment are linearly interpolated from the texture coordinates of the primitive's (triangle) vertices.
However OpenGL is not specified to rasterize pixel exact, so different implementations (drivers/hardware) can yield slightly different results.