View Full Version : Operator '%' doesn't work on floats?

09-13-2010, 08:32 AM
I'm trying to do a modulo on two floats, but the shader compiler complains.

error(#162) Wrong operand types no operation '%' exists that takes a left-hand operand of type 'float' and a right operand of type 'float' (or there is no acceptable conversion).

The code that causes this is:

vec2 pixelOffset = vec2(shadowCoord.x % invShadowSize, shadowCoord.y % invShadowSize);

It is strange that the modulo operation does not work on floats, it certianly does in DirectX.

09-13-2010, 08:42 AM
Isn't that written as mod on the reference card ?

EDIT: yes it is : http://www.opengl.org/documentation/specs/

09-14-2010, 09:55 AM
You're right, the mod() function works.

That makes me wonder why openGL didn't do away with either the operator or the function, and just use 1 of them.