Sign in to follow this  
solenoidz

Shadow maps penumbra

Recommended Posts

solenoidz    591
Hey, I have a simple question. If I use directional or spot light shadow maps, how can I prevent the scene out of the light boundaries , or out of the light frustum boundaries to remain intact from lighting. I'm getting the rest of the scene that is not lit directly by the spot light like it is in shadow. Well, that's OK , but I'm using directional lights using same method and the rest of the scene, that fall outside the light-view frustum should be filly lit with no shadows. Here's a simple picture. I wanna get rid gradually of the dark area in the corner. shadow map Right now, I'm using things like ShadowTerm = 1.0f -IN.TexCoord.y ;; and ShadowTerm += abs((IN.TexCoord.y / 2.0f) - 1.0f) ; To fade the corners of the shadow map, but this affects the "shadow darkness" across the scene, and I don't want that. How you go about fading the shadows to no-shadows on the shadow map corners ?

Share this post


Link to post
Share on other sites
Jason Z    6436
I think you are trying to solve the effects of the problem, rather than eliminating the problem itself. You should find a way to make sure your shadow map covers the entire area that the light will affect, and then let your lighting terms take care of fading from lit to unlit.

For example, your image has a spotlight that doesn't include the corner of the floor. The transition from the lit area of the floor to the non-lit area should be automatically handled by your spotlight equations, and will transition due to the lighting attenuation from the distance away from the center of the spotlight.

So your shadowing is done correctly and tells you what is visible to your light, you just need to use the lighting equations to correctly apply the lighting to the visible surfaces.

Share this post


Link to post
Share on other sites
solenoidz    591
First of all, thank you for your reply!
Yes, with spot-light it works alright, despite of the fact that it actually projects a rectangular (the light view) light spot, but that's OK.
My concern is, that I'm using the same approach to render directional light like sun, and I want to keep the area that the sun light casts shadows relatively small and around the player camera, so I could use smaller shadow map size. I don't want to use a directional (sun like) light with a huge shadow map only to be able to cover the entire visible world.

Share this post


Link to post
Share on other sites
PolyVox    712
I think you just need to set your texture map clamping/bordering mode so that areas outside of the shadow map automatically receive full light? Your shadow map does not need to be large enough to cover your whole scene, it only need to be large enough to cover the casting objects as these are the ones which are rendered into the shadowmap.

Share this post


Link to post
Share on other sites
solenoidz    591
Thanks, I managed to do it by "hand made bordering" in the pixel shader if the texture coordinate of the current pixel falls outside a defined 2D boundary.

Share this post


Link to post
Share on other sites
solenoidz    591
When shadow mapping meshes, I get that black outlining as visible on the above picture. Looks like a cartoon shader, but in my case it's annyoing :D
Appears to be several pixels thick, no matter of the view distance, so it looks horrible when the mesh is far away, and those few black pixels almost cover it completely.
Maybe I should provide a bit of shader code, but anyways - how to remove it?

EDIT :
Never mind, I figured it out. Applied an offset of the screen space texture coorddinates, so that the shadow sampling cannot bleed around the outline edges.

[Edited by - solenoidz on February 23, 2010 8:08:07 AM]

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