Shadow mapping in a Large Enviroment

Started by
30 comments, last by Johnhl 17 years ago
Cascading Shadow Maps rock. Period. There are issues but right now they are the best solution. Static shadows are so 2002 :-). I watch the Crysis Engine Editor video nearly daily as inspiration to code. If you're going to invest the time, make it look GREAT.
Advertisement
AndyTX: Cascaded Shadow Maps in ShaderX5 :-) ... then there are articles by Brandon Loyd ... the parallel split shadow maps are not that efficient. I do not know anything about Brandon's implementation.
I see I'll have to order shaderX5 now :)

Okay below is the depth map from the light source. Below is the overhead view I wanted because since I'm using orthogonal projection I can see actors, etc far into the distance. My dilemma is that I can see a lot of objects into the distance however not to the left / right / behind the toon. If I try to rotate the light source so that it will always face direction character is facing then the existing shadows will also rotate which looks hella wrong. Which goes back to my original question. Am I just simply supposed to 'never' rotate my sunlight to face the direction my character is facing? It seems to me it is okay to 'movve' the sunlight along with the character but never rotate it to face the direction he is facing.



Below is the image that is above the scene that my friend told me I should do (I need to make sure light source can see everything the player can see). This seems like a lot fo work to me if I go this route because it doesnt seem like I am benefiting much from the orthogonal projection? I will have to work to clip everything the character see in every possible direction. Looking at the shadowmaps from Lost Planet from the article I read I dont think their light source is top down like this....



So- I guess what I'm trying to ask is it okay to position my light source at whatever angle I choose as long as it can see all the objects encompassed by the view frustum? Right now the images above are obviously not optimized to only see the 3 objects but I was trying to get a feel how this would work with a huge scene populated by a lot of objects.

I want to use the position used in image #1 which can see objectsfar into the distance. it takes full advantage of the orthogonal projection. However, when my character moves left/right/back the shadowmap generated from that angle is no longer valid / needed and if I try to generate a new shadowmap for the new view direction I see the existing shadows sort of rotate along with the light source (because they rotate around in my depth map).

What I cant figure out is why doesnt anyone else have this problem and what did I do wrong....


In any case I'll go ahead and move forward with an algorithm. until I get the shaderx5 book, I'll probably have to go with LispPM since it looks easy to implement. Will also have to build a better orthogonal proj matrix that tightly encompasses the objects. hoping this mystery will unravel itself. once the wife goes to sleep maybe I'll have time to FRAPS this right fast I'll try to make the video filesize real small

Okay this is the link to the film (please right click to Save Target As). When I rotate my orthogonal light source I get this sort of effect. I show it in the test scene + the shadowmap itself. Was wondering if I'm doing something wrong. The .wmv file is only 3mb or you can look at the pics above.
It looks like you have the light locked in place relative to the camera. My guess is, you're transforming the stuff in the shadow map by the view transform, when you should only be moving it with the world transform. (or maybe you're transforming the light direction by the view matrix? I'm not sure which it is, it's late)

Just a guess, I could be wrong. It's something along those lines.
One important consideration (between the lines of praising cascaded and other prespective corrected techniques) - the prespective corrected shadowmaps require update every (or almost) frame, and this effectively add another heap of vertices to process, etc.
Add here 'large environments'. Add reflection. Add sophisticated motion blur. Z-pass. All this things shrink your potential budget for vertices per scene down.
So, for distant part of the scene I would consider using shadowing methods that don't require updated every frame...
Yeah I hooked up the light source to the view matrix to demonstrate what happens if I try to rotate it (shadows swim along with the light source). I suppose thats how a shadow camera is supposed to work and I've been probably worried over nothing it appears. I just expected orthogonal lights to work a bit differently I guess. Like, allow me to look in 'all' directions at once not just a single direction. Guess this makes perfect sense now that all of this is soaking in. Once I build the enclosing volume for all the objects that exist within the light frustum I think everything will work and everything will become a lot clearer

Now I need to try to get my hands on that shader x5 book I could not find an CSM implementation online.... I hope it includes good examples hehe. Was tempted to look at Parellel Split as well I wonder if CSM is much simpler then that? Does CSM naturally work with orthogonal light sources? Will have to remember to ask my friend to bring that book tomorrow

Thanks
To bring a different perspective to the topic: there are solution to do shadow mapping in one pass with one shadow map. It's just... it has issues, just like any other technique. Mine is presented here: http://www.gamedev.net/community/forums/topic.asp?topic_id=405955 Haven't made it to produce a english paper on it, yet, but it works quite nicely here.

In our case we're mostly cpu bound, even with heavy shaders. That's why I don't want to afford rendering the scene x times as required by CSM or PSSM. If you don't have this limits, CSM might be the way to go for you.

To summarize:

Perspective Shadow Mapping: depends on the angle between view direction and light direction. Has dead points.

Light Space Perspective Shadow Mapping: as above, but without the dead points. Scales back to uniform shadow mapping the closer your view direction gets to the light direction.

Cascaded Shadow Mapping / Parallel Split Shadow Mapping: perfect shadows everywhere due to multiple shadow maps or passes for different distances. To my knowledge the shadow maps itsself are projected uniformly, so it's simple to implement as well.

Nameless Shadow Mapping: my version of it. Works by distorting the shadow map texture coords like a lens effect that makes closer objects larger on the shadow map, thus improving the resolution for them. Works for all view angles and light angles, works with a single shadow map and a single pass, the difference is just some additional vertex shader instructions. But its improvement potential is limited and there's an unsolved problem with certain viewing angles where parts of very the distant scene end up outside the shadow map. Demo available in the thread linked above, but without source.

Hope it helps.

Bye, Thomas
----------
Gonna try that "Indie" stuff I keep hearing about. Let's start with Splatter.
Quote:Original post by Schrompf
...


What is exactly the differense of your method and other perspective corrected single-pass ones?
The function of 'scene pyramid' -> 'shadowmap square' transformation?
And why it is better, then?
Just interested.
> And why it is better, then?
Hi Schrompf, did you fix your algorithm such that it's guaranteed that no portion of the scene is warped outside the shadow map? (Otherwise I wouldn't consider it an alternative.)

This topic is closed to new replies.

Advertisement