shadows with holes on transparent objects

This topic is 1152 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I am trying to render plants with transparent textures. I use discard in the shader that creates the shadow map, but I get blocky holes in the shadow:

This is the shader that I'm using:

		uniform mediump vec2 uvOffset;
uniform highp mat4 matrixPVM;
attribute highp vec3 inVertex;
attribute mediump vec2 texCoordAttr;
varying mediump vec2 texCoordVar;
void main(void)
{
gl_Position = matrixPVM * vec4(inVertex, 1.0);
texCoordVar = texCoordAttr.st + uvOffset.st;
}

uniform sampler2D sampler2d;
varying mediump vec2 texCoordVar;
void main(void)
{
lowp vec4 texColor = texture2D(sampler2d, texCoordVar);
}



As you can see the opaque objects have the shadow rendered correctly. I tried doubling the resolution of the map and changing the alpha compare number, but makes no difference.

Anyone know a solution to this problem?

Share on other sites

Does it help if you set gl_FragColor to something (e.g. vec4(1.0, 1.0, 1.0, 1.0)) ?

Share on other sites

Does it help if you set gl_FragColor to something (e.g. vec4(1.0, 1.0, 1.0, 1.0)) ?

No. Makes no difference

Share on other sites

If it is only happening on transparent objects, then I would check the alpha values of your textures. But then I see that floating leather (?) patch that clearly isn't transparent and it too has holes in the shadow. :/

Maybe a precision issue? Have you tried removing the "lowp" qualifier?

Share on other sites

Maybe a precision issue?

I've seen some really weird blocky texture sampling artifacts on some hardware when the UV precision is comprimised. Can you make sure that texCoordAttr and texCoordVar are both between -1.0 and 1.0. If you try using coordinates too far away from zero you can get some quite severe sampling issues.

Share on other sites

Finally, I figured it out.

When creating the shadow I called glActiveTexture(GL_TEXTURE1) to deactivate the shadow map texture, but I forgot to call glActiveTexture(GL_TEXTURE0) again when creating the shadow, so the texture being read was just random jibberish.

Thanks for the help anyways ;)

1. 1
Rutin
32
2. 2
3. 3
4. 4
5. 5

• 13
• 66
• 11
• 10
• 14
• Forum Statistics

• Total Topics
632967
• Total Posts
3009567
• Who's Online (See full list)

There are no registered users currently online

×