Jump to content
  • Advertisement
Sign in to follow this  

Directional light position in shadow mapping

This topic is 1170 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've got a basic cascaded shadow mapping working, but there's alot to improve. Something thats nagging me is this:

 

Technically, the light must have a position when rendering the shadow maps. But, it is not supposed to have one. So how do you determine what position to use when rendering depth for each of the cascade frustrums?

The way I imagine it (and do currently) is to simply offset it some amount of distance from the cameras position. It must be trickier though because this does not take geometry into account. Do you simply sum up all the geometry in each cascade to get the max height, and then offset from that? If so, how much?

 

Generally the resources I've found on the net simply offsets it abit from the camera, but it must be more complex than that. Any pointers on how to do this?

 

 

EDIT: another, not too unrelated question is this: how do you do culling for directional lights? do you view frustrum culling for each cascade, each frame?

Edited by KaiserJohan

Share this post


Link to post
Share on other sites
Advertisement

 

Technically, the light must have a position when rendering the shadow maps.

No it doesn’t. You only need a projection matrix (orthogonal in this case).
 

So how do you determine what position to use when rendering depth for each of the cascade frustrums?

how do you do culling for directional lights? do you view frustrum culling for each cascade, each frame?

  • .....
  • For each cascade.
    • Determine where you split the camera frustum.
    • Create a frustum (usually not 6 planes) based on this information.
      • The first 3 planes are the camera frustum planes that face away from the light.  This creates the set of far planes (there is no single far plane).
      • The next few planes shoot in the direction of the sun and create an outline around the camera frustum where, on the camera frustum, one plane faces away from the light and the border plane faces towards the light.  
      • There is no near plane unless you have a tool chain that allows artists to set one.

L. Spiro

 

 

I'm having a little trouble visualizing this step. I keep thinking of a conventional view frustrum with a near, far, top, bottom, left, right plane. Do you have any references or images?

Share this post


Link to post
Share on other sites

What should face culling be set to - back or front faces? I find if a object is caught between two cascades and for example back-face culling is on, it won't cast any shadows.

 

EDIT: also, on orthographic projection matrices... are the near/far parameters supposed to be positive? I find if I pass -0.1f as zNear and -7.0f as zFar, it seems to catch objects in the 0.1 - 7.0 range instead. 

 

EDIT2: Also, I'm not sure why the position isn't needed. If no light view matrix, the orthographic matrix has to be atleast rotated somehow? By the light direction?

Edited by KaiserJohan

Share this post


Link to post
Share on other sites

What should face culling be set to - back or front faces?

Shadow-mapping should always use back faces.

I find if a object is caught between two cascades and for example back-face culling is on, it won't cast any shadows.

It shouldn’t matter which face is culled in this case. You have a strange bug. Of course I can’t help with that right now, but if you make another topic with more information on it…

also, on orthographic projection matrices... are the near/far parameters supposed to be positive?

Typically. But you can hard-code the near plane in this case. Conceptually you are just putting the camera right behind all the objects that were culled into it. After transformation, there is no reason for an object to be “behind” the camera.

EDIT2: Also, I'm not sure why the position isn't needed. If no light view matrix, the orthographic matrix has to be atleast rotated somehow? By the light direction?

It will be rotated when you multiply it by the (light’s) view matrix. I already said that every light has a forward, up, and right vector. These go into making the light’s view matrix.


L. Spiro

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!