Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following fragment shader for my scene

#extension GL_EXT_shadow_samplers : require
vec4 color = texture2D(uTextureUnit0, varTexCoord0);

if (colorTransformEnabled != 0) {
    vec3 transformedColor = colorTransform * color.rgb;
    color = vec4(transformedColor, color.a);
gl_FragColor = color;

this works like expected.

Now I add this line:

float shadow = shadow2DProjEXT(uShadowTexture, varShadowCoord);

and boom my shader does not produce any output at all. GL_COMPILE_STATUS and GL_LINK_STATUS do not return any error messages. Any idea where to go from here to debug this?


I'm on iOS and GL_EXT_shadow_samplers is supported.


I forgot to check for error at some point. Now I get a GL_INVALID_OPERATION on glDrawElements. Any idea what could cause this problem? Since I do not get the error when I don't use the shadow2D functions.


The following state change overview might help some more: a busy cat

Where GL_TEXTURE0+1 is the depth texture and GL_TEXTURE0 is the objects texturea


I found out that it produces the error as soon as the shader contains a call to shadow2DProj the invalid operation error is thrown. Although the shadow2DProj function is never called in the shader. And it still throws the error if shadow2DProj is called.

share|improve this question
is 'shadow' used anywhere? – Jari Komppa Apr 25 '13 at 14:17
no it's not, but i just checked if I e.g. do color.r = shadow * color.r; i still got nothing – V1ru8 Apr 25 '13 at 14:30
If it's not used anywhere, the shader compiler should optimize the whole line out.. sounds like a driver bug, and a rather odd one. – Jari Komppa Apr 25 '13 at 15:28
That does not seem to be the case. Since it still produces no output even when the result is used. – V1ru8 Apr 29 '13 at 14:08
GL_INVALID_OPERATIONS has a lot of meanings, can you check for the exact error code that it returns? (Errors) – Cristina May 2 '13 at 12:18

The problem was, that the texture was not correct mapped to the shader. There was a check for the type of texture before calling glUniform1iv that ignored the shadow map.

share|improve this answer
Thanks for posting the solution. – Jari Komppa Jun 3 '13 at 8:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.