PDA

View Full Version : Common function mod()



mmoerth
04-19-2006, 08:13 AM
Hi Everyone!

I'm having some trouble with the builtin mod() function on NVIDIA hardware. Shouldn't

float x = IDX;
while (x >= SIZE) x -= SIZE;lead to the same result as

float x = mod(IDX, SIZE);At least in my case it does not. In fact
mod(IDX, SIZE)seems to be returning a value equal to SIZE. Could this be some floating point precision issue? Is the while loop exeuted on hardware as well or is there some software emulation going on? At least that would be an explanation for the different results then...

SIZE is a component of a uniform vec3 and IDX is a component of the first texture coordinate set.


uniform vec3 u_sec_size
#define SIZE u_sec_size[0]
#define IDX gl_MultiTexCoord0[0] Hardware/driver configuration (http://www.sbox.tugraz.at/home/m/mmoerth/tmp/hwinfo.htm) available online.

Thanx for any help!

Martin