Shadow mapping artifacts behind the light


apart from my little 2D game, I’m learning 3D with OpenGL. My shadow mapping is almost working fine but I can see various shadow artifacts behind the light. It seems with using shaders it’s easy to remove them but I’d like to know if it’s possible and how to remove those artifacts without using shaders.

Use glPolygonOffset() when rendering the shadow map.
(…if we mean the usual shadow map artifacts here…)

I already use glPolygonOffset.
What I meant is that I can see the shadow behind the light, thing that should never happend. So I have the shadow twice, once in front of the light, which is good, the seconde behind the light which is “bad mapped”. (sorry for my poor english and bad explanation).

You have to set up a clip plane to stop any polygons from rendering behind the light.

Thanks for the tip.

I did it but as I expected, all things behind the light is not lit but full shadowed.

Should I use another pass to render what’s behing the light ?

I assume you are using a spotLight, with only one shadowmap.

You have two solutions:

1/ You go for a pointLight, which will lead you to render two shadowMap (one for the front and one for the back of the light, setting a fov 179.)

2/ In your GLSL, you test the w coordinate of the vertex after transformation. If it’s <0, then just drop the shadow calculation and apply ambient lighting only.


I guess I’ll go on for the 2 shadow maps.

I don’t understand your second method, but since I’ve not still have learnt shaders, just forget it.