Jump to content

  • Log In with Google      Sign In   
  • Create Account

Shadow Mapping: Bleed through?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 bearsomg   Members   -  Reputation: 117

Like
0Likes
Like

Posted 20 November 2012 - 03:53 PM

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, 20 November 2012 - 03:55 PM.


Sponsor:

#2 eppo   Crossbones+   -  Reputation: 2466

Like
0Likes
Like

Posted 21 November 2012 - 04:43 AM

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();

#3 bearsomg   Members   -  Reputation: 117

Like
0Likes
Like

Posted 21 November 2012 - 01:53 PM

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.

#4 MJP   Moderators   -  Reputation: 11450

Like
0Likes
Like

Posted 21 November 2012 - 04:21 PM

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.

#5 hupsilardee   Members   -  Reputation: 486

Like
0Likes
Like

Posted 21 November 2012 - 06:59 PM

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

#6 eppo   Crossbones+   -  Reputation: 2466

Like
0Likes
Like

Posted 22 November 2012 - 03:38 AM

With tangent I mean direction. Where the light is facing.

#7 larspensjo   Members   -  Reputation: 1541

Like
0Likes
Like

Posted 23 November 2012 - 03:09 AM

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).
Current project: Ephenation.
Sharing OpenGL experiences: http://ephenationopengl.blogspot.com/




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS