1
\$\begingroup\$

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?

Edit:

I'm on iOS and GL_EXT_shadow_samplers is supported.

Edit:

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.

Edit:

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

Edit:

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.

\$\endgroup\$
6
  • \$\begingroup\$ is 'shadow' used anywhere? \$\endgroup\$ Commented Apr 25, 2013 at 14:17
  • \$\begingroup\$ no it's not, but i just checked if I e.g. do color.r = shadow * color.r; i still got nothing \$\endgroup\$
    – V1ru8
    Commented Apr 25, 2013 at 14:30
  • \$\begingroup\$ 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. \$\endgroup\$ Commented Apr 25, 2013 at 15:28
  • \$\begingroup\$ That does not seem to be the case. Since it still produces no output even when the result is used. \$\endgroup\$
    – V1ru8
    Commented Apr 29, 2013 at 14:08
  • \$\begingroup\$ GL_INVALID_OPERATIONS has a lot of meanings, can you check for the exact error code that it returns? khronos.org/opengles/sdk/docs/man/xhtml/glDrawElements.xml (Errors) \$\endgroup\$
    – Cristina
    Commented May 2, 2013 at 12:18

1 Answer 1

1
\$\begingroup\$

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.

\$\endgroup\$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .