Half-texel offset in D3D with ATI and NVIDIA

vindos

Newcomer
Hi
While mapping a texture on to full screen quad i get blocky image on Nvidia and a good image on ATI. Now the blocky Image in NVidia was resolved by the following method
float u_adjust = 0.5f / width;
float v_adjust = 0.5f / height;
and Adding these offset while texture look up.
In ATI i think u just need to lookup the texture without adding this adjustment factor. My doubt is whether
1. I should add this adjustment factor for both ATI and NVidia
2. Check the card and add this factor only if its NVidia??
i am using Directx 9.0
 
You always have to do the adjustment. The center of the top-left pixel gets coordinates (0.0, 0.0), so the top-left corner is (-0.5, -0.5), measured in pixels.

You should try to absolutely never have any brand specific code. I don't know exactly why the ATI card gives you a 'correct image' without the adjustment, but it should work as expected with it.
 
Yeah D3D has a kind of strange texel alignment... I think it's changing to the same as OGL in D3D10 and there's state that can change it on the XB360. Also note that there's a control panel override in ATI's drivers to use the alternate texel alignment, although you should *never* rely on users to enable this!

I don't know exactly why the ATI card gives you a 'correct image' without the adjustment, but it should work as expected with it.
My guess is that he's simply using a texture format that filters on NVIDIA but not on ATI or vice versa.
 
My guess is that he's simply using a texture format that filters on NVIDIA but not on ATI or vice versa.

Not neccesarily. I've seen the same thing happening where it looks fine on ATI and blocky on Nvidia. I guess it comes down to precision or some tiny implementation specific issue since he'll end up sampling exactly at the border between texels.

Also, for fullscreen quads, it's actually better to offset the vertices instead of the texture coordinates to avoid issues with pixel centers ending up outside the quad. Especially with multisampling this can be a problem. You may see it as a thin leakage at the top pixel row and left pixel column.
 
Back
Top