Shadow Mapping: Bleed through?

Started by
5 comments, last by larspensjo 11 years, 4 months ago
Hello,

I have recently started working on implementing shadows in my rendering engine using shadow mapping with Direct3D10 and HLSL. So far, the algorithm is working nicely, except for a small problem.

When I move the camera behind an object that is lit on one side by a light source, the areas where the shadow is bleed through onto the other side of the model. For example, a character model has it's arm crossed in front of it's chest, and when you move behind the model you can see the shadow on the model's back. I'm assuming this is because the shader is just testing the depth values to see if the pixel is behind an occluder, and the back of the model is determined to be behind an occluder.

So, my question is, what would be the best and easiest way to fix this?


Thanks in advance!
Advertisement
Simplest way is to not do the shadow check when an object is facing away from the light source.

e.g.: shadowing = (dot(faceNormal, lightTangent) > 0.0)?1.0:shadowCalc();

Simplest way is to not do the shadow check when an object is facing away from the light source.

e.g.: shadowing = (dot(faceNormal, lightTangent) > 0.0)?1.0:shadowCalc();


How is lightTangent calculated? I have the light direction and position.
What you're describing doesn't really make any sense. The back of the character should be completely occluded by the front, and so you shouldn't see any light at all.
Some tips:
Try rendering BACKFACES to the shadow map rather than frontfaces.
Combine with eppo's trick
Add a little epsilon value when you compare the shadow map depth to the pixel depth. (start with about 0.00001 and experiment experiment experiment, a suitable value is different for every shader/light matrix setup
draw linear Z into the light shadow map, because it gives more depth precision further away from the light source
With tangent I mean direction. Where the light is facing.
There are some neat tricks, but nothing that solves everything. See opengl-tutorials that looks into several of the artifacts and what can be done to them.

There is also another trick: Instead of storing the depth value in a shadowmap, you store an ID for every object or polygon. When rendering from the camera, you check the ID for each pixel with the ID from the shadowmap. If they are not the same, it is not seen by the light, and so it is in shadow. Apart from the need to generate IDs, this algorithm has the disadvantage that it can't handle objects that should shadow part of itself (e.g. concave geometries).
[size=2]Current project: Ephenation.
[size=2]Sharing OpenGL experiences: http://ephenationopengl.blogspot.com/

This topic is closed to new replies.

Advertisement