views:

83

answers:

1

When executing a pixel shader under Direct3D, do the limits on texture coordinates imposed by MaxTextureRepeat only become an issue during calls to texture lookup functions such as Tex2D(), or do they come into play anytime the texture coordinates are accessed within the shader?

I wish to know whether it's possible to avoid the MaxTextureRepeat limitation by calling something like frac() on the texture coordinates before passing them on to the texture lookup function.

A: 

Texture coordinates are at native interpolator precision. On pixel shader 2.0 capable hardware, this is at least 24 bits floating point (or perhaps 32 bits, not sure). Internally the calculations in pixel shader must be at least 24 bits floating point. Most modern GPUs run at 32 bits floating point precision.

The MaxTextureRepeat is the capability of the texture sampling hardware.

So, yes, if you don't run into floating point precision limitations, then limiting the range before sampling is one way to avoid the texture repeat limits.

However, where frac turns from 0 to 1 you'll get large gradients, so at those places the GPU will want to use very low resolution mip level. This can be not a problem depending on your situation of course; but it's one point of potential problem(s).

NeARAZ