Jump to content
Posted 15 April 2013 - 07:34 AM
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
VladR My 3rd person action RPG on GreenLight: http://steamcommunity.com/sharedfiles/filedetails/?id=92951596
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: