PDA

View Full Version : texture coordinate look up problem

iris_raj
12-11-2006, 01:47 AM
Dear GPU Programmers,

We are facing a problem of texture lookup problem.
We have a 1Dimensional texture of size 100 and as we know texture coordinates vary from 0.0 to 1.0. But as per chapter 24 of GPU Gems a texture coordinate can vary from 1 / (2*100) to 1 - 1 / (2*100) //Reference GPU Gems2 Page number387, 388. The calculation formula is ((1 - 1 / n) / n) where n is the size of texture. and
the interpolation type is LINEAR using GPU

When we try to look for texture coordinate having 10th value, the returned value differs from the actual 10th value. But if GPU interpolation is set as “POINT” then the correct value is returned.

As per the book GPU Gems2 the texture coordinate calculation is changed and the resulting formula is given above. Kindly notify us if any material regarding the above said issue is available. Also notify us if you have any concerns regarding the above assumptions or calculations.

RAJESH.R
NEST,TVM

k_szczech
12-11-2006, 06:00 AM
And what exactly is the difference? If it's a small fraction then it could be just precision problem. You could try to sample unfiltered texture at multiple points very close to each other to see if edge between two texels is exaclty where you expect it to be.
Also, make sure you do not have any anisotropic filtering or FSAA forced by your driver.

def
12-11-2006, 06:04 AM
The formula stated in GPU Gems2 would be:

(n-1.0)/n * <sample coordinate> + 1.0/(2.0*n) The first part is the scaling factor which reduces your lookup texture size by one pixel. The second part is the offset of half a pixel.

Xmas
12-11-2006, 06:25 AM
The calculation formula is ((1 - 1 / n) / n) where n is the size of texture.That's a constant. What do you do with it?

Assuming x is in the range [0,n-1], what you want is (0.5 + x) / n. In your example that would be (0.5 + x) / 100 for x in the range [0,99].
If your x is in the range [0,1] instead, you need (1-1/n) * x + 0.5 / n.