Jump to content

  • Log In with Google      Sign In   
  • Create Account

Cascaded shadow maps


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
2 replies to this topic

#1 george7378   Members   -  Reputation: 1291

Like
0Likes
Like

Posted 15 April 2013 - 07:34 AM

I've got basic shadow mapping working in my game right now and I'd like to sort out a few issues - the biggest being that I am trying to project the shadow of a small object onto a large terrain, which should also self-shadow. So, I need to create a cascaded shadow map (I think!)

So what's the process? Do I need to loop through each cascade and chain the view/projection matrices accordingly, all while rendering to the same map?

Sponsor:

#2 VladR   Members   -  Reputation: 722

Like
1Likes
Like

Posted 17 April 2013 - 11:02 AM

Perhaps you might not have to deal with CSM at all, and just play/tweak the SM`s projection matrix.

 

I am too having a large terrain where you can have a visibility of few kms, but most of the time, the camera is about 20 meters above the player (but player can zoom in/out at any time).

 

I came up with a very simple workaround where I can get a reasonable detail in a shadow map for both near and far objects. My SM is either 2048x2048 or 4096x4096.

 

At run-time, you set the near/far plane of SM based on the camera - if it is a mostly top-down camera, move the far plane as close as possible - this gives you maximum detail in view space, since with that camera you don't see very far anyway.

 

When the camera view changes into the distance, adjust the far plane accordingly. Now, you will loose some detail in foreground, but will gain the shadows in the distance, so it's a reasonable trade-off.

 

To avoid the ugly "pop" in a shadow, I just fluently lerp between Max_Far_SM_Plane and Min_Far_SM_Plane every frame. This way, you will get the fluent transition even during the camera flythroughs over waypoints, without having to set anything, fully automatically. 

 

Considering it took me about 15 minutes to come up with this, I consider it a pretty neat and cheap trick without having to bother myself with implementation of yet another  different Shadow technique smile.png


VladR    My 3rd person action RPG on GreenLight:    http://steamcommunity.com/sharedfiles/filedetails/?id=92951596

 


#3 george7378   Members   -  Reputation: 1291

Like
0Likes
Like

Posted 18 April 2013 - 06:28 AM

Hey - there are some interesting ideas there! I actually tried to make a dynamic projection matrix myself, but I don't think my problem is the same as yours. What I'm trying to do is get my object to cast a shadow on the distant terrain, while also self-shadowing and casting shadows on itself. At the moment, I can only get one or the other - i.e. I can have shadows on the terrain, but this doesn't give enough depth resolution for self shadowing, or I can bring the far plane right up to the object and it will self-shadow, but it won't cast onto the terrain if I do that:

 

lem3dterrainshadow.jpg

 

...or...

 

lem3dselfshadow.jpg






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