Jump to content
  • Advertisement
Sign in to follow this  
soconne

Shadow projection problems [IMAGES]

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm creating a shadow generation system for outdoor terrain by using orthogonally projected shadow maps. My problem is that the shadow is ending up in places where I don't "want" it to be, but I know that it happens anyway. Here are some shots of what I'm talking about. Correct shadowing What I don't want I was thinking of doing the following to get rid of the shadow where it isn't suppose to be. 1) When rendering the object shadows to a backbuffer and copying that to a shadow texture, also copy the corresponding depth buffer to a texture. 2) When projecting the shadow onto the ground geometry, also project the depth texture onto geometry ( GRAYSCALE DEPTH VALUES )......then loop through each pixel in the viewport and read back the depth value. If the distance between the depth value read from the screen and the corresponding depth value in the projected texture is too large, then color that pixel white in the shadow map. I was just wondering if anyone else ran into this problem and how they solved it. Any suggestions?

Share this post


Link to post
Share on other sites
Advertisement
I don't know about "orthogonally projected shadow maps" algorithm, but isn't that just projection of textures? If yes, then in Game Programming Gems #1 there's chapter 5.5 written by Ryan Woodland, where author explains common problem, which arises when projecting textures on geometry. He calls it: "lighting through" (sorry, lame translation :-))

Ie. when projecting texture on sphere at point X, texture will appear on its other side too, because "vertices in front and behind are projected on correct texture space" (another lame translation). Not sure if it's the same in your case, but looking on GPG and your screenshots... they look similiar.

Methods to eliminate this problem, are:

1. "Compute dot product between vertex normal and light normal, and see if vertex is positioned backwards to light. If yes, just set texture coordinates outside [0,1].". Probably also you need to set GL_CLAMP...

2. "Set second light on place of texture projector. If color that you get for particular vertex is black, then you know that this vertex is positioned backwards to light, because the only way for it to have black color, is that its normal is pointing in reverse direction than light". Hmmm, he didn't write what to do next in this case, maybe also set texture coords outside [0,1] ... :-?

That's all, HTH.

Share this post


Link to post
Share on other sites
Well the problem I see with that solution is that what if your mesh is sitting on the top of a hill, and the shadow is being projected backwards. Then the back of the hill, whose normal is facing away from the light source, should STILL have the shadow projected onto it. But with the game programming gems method, the shadow would be taken out.

Share this post


Link to post
Share on other sites
with the shadowmapping draw everthing into the shadowbuffer and not just the tree but also the terrain,
for the thirdscreenshot youre getting backwards projected shadowmaps theres a couple of things u can do, IIRC this problem was just mention recently on another forum here i think -> Graphics Programming and Theory

Share this post


Link to post
Share on other sites
i dont understand the problem then i assume its -> u can see the tree shadow through the terrain (on the other side of the hill)

Share this post


Link to post
Share on other sites
Quote:
Original post by oconnellseanm
drawing the terrain into the shadowmap would make no difference at all concerning my problem.
Yes, it will, the Terrain will become an occluder as well, and the tree's shadow wouldn't be visible. (this is ofcourse assuming your doing "proper" depth shadows and not just projecting a dynamic silheoute texture.

me thinks you're going to need a fragment program to sus this out effectively.

Share this post


Link to post
Share on other sites
Quote:
Original post by silvermace
Quote:
Original post by oconnellseanm
drawing the terrain into the shadowmap would make no difference at all concerning my problem.
Yes, it will, the Terrain will become an occluder as well, and the tree's shadow wouldn't be visible. (this is ofcourse assuming your doing "proper" depth shadows and not just projecting a dynamic silheoute texture.

me thinks you're going to need a fragment program to sus this out effectively.


I'm sorry. I am not actually using depth shadows, just regular shadow texture projection. That is why drawing the terrain as an occluder will not work. I'm sorry I forgot to mention this.

Share this post


Link to post
Share on other sites
I can't remember the maths, but removing the back projection can be done with an extra 1d texture. This is aligned with the projection vector and is full alpha (visible) in the projected direction, and zero alpha (invisible) when behind the projection point.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!