Sign in to follow this  
bearsomg

Shadow Mapping: Bleed through?

Recommended Posts

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! Edited by bearsomg

Share this post


Link to post
Share on other sites
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();

Share this post


Link to post
Share on other sites
[quote name='eppo' timestamp='1353494615' post='5002887']
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();
[/quote]

How is lightTangent calculated? I have the light direction and position.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
There are some neat tricks, but nothing that solves everything. See [url="http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-16-shadow-mapping/"]opengl-tutorials[/url] 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).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this