MattOwnby
Posts: 58
Joined: Thu Aug 16, 2012 7:22 pm

Problem with mod/floor in GLES2 fragment shader

Sat Sep 01, 2012 11:32 pm

hey all,

I am trying to use the "mod" function (which can be replaced with the "floor" function) in a fragment shader I wrote and it's working fine on my windows desktop PC but when I try to run it on the raspberry pi, I am getting this error:

OpenGL Shader Link Failed: ERROR:CUSTOM-11 (line 6) No declared overload matches function call arguments

The shader is:


const char *cpszRGBAFragmentShader =
"uniform sampler2D RGBAtexEven, RGBAtexOdd;\n"
"uniform float fFrameHeight;\n"
"varying vec2 fragTexCoord;\n"
"void main(void) {\n"
" float fY = fragTexCoord.y * fFrameHeight;\n"
" float fMod = mod(fY,2);\n"
" if (fMod < 1.0) gl_FragColor=texture2D(RGBAtexEven,fragTexCoord);\n"
" else if (fMod > 1.0) gl_FragColor=texture2D(RGBAtexOdd,fragTexCoord);\n"
" else gl_FragColor=vec4(1, 0, 1, 1);\n"
"}\n";

The compile process adds precision definitions for GLES2 (as I mentioned I test this on a desktop PC also which isn't completely compatible with GLES2).

Neither mod nor floor seem to work. Does anyone know what I am doing wrong?

MattOwnby
Posts: 58
Joined: Thu Aug 16, 2012 7:22 pm

Re: Problem with mod/floor in GLES2 fragment shader

Sat Sep 01, 2012 11:42 pm

ehhh I just had to change the 2 to 2.0 inside the mod function and now it works. *sigh*

Janq
Posts: 36
Joined: Sat Jun 02, 2012 3:36 pm

Re: Problem with mod/floor in GLES2 fragment shader

Sun Sep 02, 2012 1:40 am

MattOwnby wrote:ehhh I just had to change the 2 to 2.0 inside the mod function and now it works. *sigh*
This is (afaik) correct behaviour with GLSL. GLSL is much more strict (far more strict than is necessary) about implicit conversions - HLSL is much more sensible imo ;)

Return to “OpenGLES”