I have a problem with precision on AMD in shaders (hlsl
). In vertex shader I calculate UVs
for particle using modulus operator on float. With simple %
there is a problem on Nvidia and on AMD (e.g. 7 % 7 = 7
) so I have written modulus as:
float Mod( float x, float y )
{
return x - floor(x / y) * y;
}
This have fixed the problem on Nvidia but AMD still returns wrong values.
Any idea what is going on? And how to fixed it?
I know I can use:
float( int( x ) % int( y ) )
but I think it is slower and I wonder if there is any better way.