Texture coordinate precision

Hi, I’m into medical visualizations from 3D data. When doing precision tests of our system I’ve noticed some irritating effects.

Let’s say that I’ve got a 3D texture with 1x1x5 voxels (to keep it simple…) and the voxel data are 0 0.1 0.2 0.5 1. Doing a nearest neightbour texture lookup at 0.5 0.5 0.8 gives me the last voxel value, since I’m sampling exactly on the texel border. However, to get the value in the previous voxel (i.e. 0.5), I have to change the texture coordinate to something as low as around 0.7983.

Isn’t that a bit low?

What video card do you have?
Does it still happen when you use a power of two texture? (eg 1x1x8 ?)

Yes, it’s just as bad when using a power of two texture. I have an ATI HD2900xt card, and I’m about to try it on a Nvidia 8800 in a couple of minutes when my collegue gets back.

Tried it on a Geforce 7600 Go:

sampling at 0.799999 returns 0.5
sampling at 0.800000 returns 0.5
sampling at 0.800001 returns 1.0

N.

Could there be some texture parameter which would make this effect appear? I don’t really see which one that would be…

I still haven’t tried my test-app on a Nvidia card. Must do that.

No idea…
I only used the parameters below:

glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_REPEAT);

N.

Ouch, I think we might have found an ATI issue here. I finally got around to try it on a computer with a Geforce 8800, and it worked exactly as you said Nico (and thus, exactly as I want).

My extremely slim test-application gives these results:

Nvidia:
texcoord 0.79999 returns 0.5
texcoord 0.8 returns 0.5
texcoord 0.80001 returns 1.0
(might even get better precision here, didn’t try it)

ATI:
texcoord 0.7984 returns 0.5
texcoord 0.7985 returns 1.0

I’m using the latest drivers. It would be nice to have someone with an ATI card to verify so it isn’t just me.

I experience the same errors when using a 2D texture…

This thread should really not be in the GLSL-forum, since it is an error that appears even if texturing without shaders.

Anyone interested can download my test application here: http://www.mediafire.com/?82h212tx2et

To switch the z texture coordinate, use keys 1 through 5. If working properly the quad should be grey for all keys except 5.

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