Common function mod()

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 available online.

Thanx for any help!


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