Shadow mapping in a Large Enviroment

Started by
30 comments, last by Johnhl 17 years ago
Hi I am trying to figure out can I use just 1 shadowmap for a large virtual scene or do I need 4 shadowmaps (4 light sources - 1 light source for each direction the character can face). Basically right now I have everything working with one directional light source. I am using orthogonal projection for this so that everything in the distance can be nicely stored into the depth map. My dilemma, like I explained before, this is a large scene (think something like World Of Warcraft or Oblivion). I was hoping I could just use one shadowmap and maybe rotate the light source to face same direction my character is facing. Problem is- all the objects in my scene rotate as well of course and you see all the shadows rotate. I cannot find any examples of a full working system really. I have tried looking at the NeL engine to see how they overcome this problem but got lost in piles of source code. Honestly all I need to know is can this be done with 1 shadowmap and if so, how am I supposed to get this working? According to my sources I need a shadowmap for each light source. And right now it appears I need 4 lights (North, South, East, and West). I saw an earlier post on this topic about a year or two ago and I think YannL replied its best to use 4 just wanted to double check Thanks
Advertisement
Hello,

I'm not exactly sure about what you're really trying to do, but I think you might be looking for something like Perspective Shadowmapping. There are quite a few techniques available, but none of them solve all the problems. PSM is considered very hard to implement and doesn't provide very good quality in the end. LiSPSM and TSM provide better bang for the buck, but they too have their issue's, and sometimes this means UNACCEPTABLE artifacts. I don't think shadowmapping with just one shadowmap is going to cut it with large environments like you're describing. I would give PSSM's a shot. It's surprisingly fast these days and there are 2 demo's available with full source for both Direct3D and OpenGL (I made the last one).

Go check it out: --> http://hax.fi/asko/PSSM.html

Hope I've been able to help,
Jeroen
Thanks I'm aware of LispSM, Parellel Split, etc. Right now I'm not interested in cleaning up the shadows per se. I just want to make sure I'm on the right track (use 4 shadowmaps for a large virtual enviroment). I'm kind of confused because my friend that worked on True Crime (its like GTA) claims they did it with just one shadowmap. And I thought that game had a huge, virtual enviroment. Maybe he was mistaken
There are problems rendering a large world's shadows with a single shadow map. It's next to impossible to get a good shadowing setup. Perspective/Trapezoidal/etc shadow maps CAN look good, but only under the most ideal circumstances. Every single-shadowmap setup that I've ever seen has some sort of singularity, in which it looks either no better or, in many cases, much WORSE than not using the technique at all.

Interestingly, I started a topic on the same idea a few years ago (with almost the same title: Shadow mapping in large environments

The Gist of it is, a single shadow map doesn't give you optimal-enough resolution. We came up with a way to generate a more optimal shadow projection, but it ended up requiring a logarithmic projection, which gets ugly real fast.

Today, I would suggest something simpler:

Use Cascading Shadow Maps.

Now, that doesn't give you a SINGLE shadow map, but it is, I think, the best (and one of the easiest) ways to handle large-scale shadowing. It's what games like Crysis are using.
Hi Drilian yes I was thinking of your original post when I wrote this.

From reading your post, it sounds like it should be possible that I can do this with one shadowmap (even though everything will look messed up)?

Right now my light source is sort of positioned overhead right behind my character. Perhaps I messed up a matrix somewhere because right now I cant even get to the point where I can produce a shadowmap in any direction the character faces. For instance, I have two mushrooms in my scene. If I look to the right, I would like to be able to generate a shadowmap for that direction. However, if I rotate my light source to face that direction, my shadows on the mushrooms also rotates. When I get home I can try to FRAPS it into a video right fast.

So my problem is perhaps I messed up the basic implementation. I'm not really at the point whereas I need to cleanup the shadows per se. Right now, I am having trouble rotating my light source w/o distorting the existing shadows the viewer was looking at.

I just checked some article on Lost Planet and it appears they used different shadowmaps to breakup the view frustum. My problem is I havent made it to that point yet because it appears I might have errored in my LightViewProj matrix.
The trick with most directional light shadowing methods is that you have to rerender the shadows essentially every frame. It's not really that you have shadow maps for what's to the left and right, it's that you keep the shadow map positioned over the view's area and move it as the view moves.

After you move it, you of course have to re-do the shadow map render.
Interesting, been playing around with the NVidia SDK 9.5 example from their browser. In their world, you can move around the entire scene. The shadowmap appears to update as you move around, etc. And when you rotate the view, the shadows when in ortho view do 'swim' a bit like my engine does. But when I switch their browser to LispSM the shadows dont swim when I rotate the light source. LispSM doesnt appear to be too difficult to implement hopefully tonight when I get home I'll plug it in.

Yeah right now I update my shadowmap every frame and everything is fine when I walk around. But where I'm having probs is when I try to rotate my light source to face the same direction as the character. I am seeing the shadow swim with the light source. So let's say I circle around my mushroom, what happens as I rotate around it I see my shadows swim around. But from looking at this demo, it appears once I switch to LispSM or something that should fix. Guess I'll see when I get time to implement.

Thanks for all of your advice

edit- Bah nevermind, you cannot move the light source around in their PSM demo. It is a fixed light source apparently just like all the other examples. And when I tell it to let the light source move I see the shadows swim with it. What I wanted was a way to always have my objects maintain their same depth / shadow as I move around the scene and remain the scene no matter what angle the light source is facing
PSSM or cascaded shadows look fine, however the shadow can't be blurred correctly using the normal techniques such as a poisson disk because the shadow is discontinuous.

I would try a static shadow mask. This involves rendering a massive shadow map for all of the static objects in the scene once at the start of the program. The shadow mask is then reused throughout the program frames as a normal shadow map - without the render-to-texture stage. The trick is to combine the shadow mask with a dynamic shadow map for the character - preferebaly allowing the shadows to blend seamlessly (i.e. you dont see a character shadow when the character is behind a wall to the light).

you could use a shader code of the form:-

float3 shadow_mask = tex2D( mask_sampler, coords1 );
float3 dynamic_shadow = tex2D( shadow_sampler, coords2 );

float shad1 = shadow_mask > length( pos- light_pos ) ? 1.0f, 0.0f;
flaot shad2 = dynamic_shadow > length( pos - light_pos ) ? 1.0f, 0.0f;

float shadow = shad1 * shad2; //



if the pixel is in shadow the variable 'shadow' is zero, therefore color is the shadow or ambient color ...
Quote:Original post by vajuras
I just checked some article on Lost Planet and it appears they used different shadowmaps to breakup the view frustum. My problem is I havent made it to that point yet because it appears I might have errored in my LightViewProj matrix.


That technique is what Drilian meant by Cascading Shadow Maps or CSM.
Somewhat off-topic, but does anyone have a link to a paper on cascading shadow maps? I've seen all of the PSSM work (and it certainly is a good idea - probably the best current solution really), but I've been unable to find detailed information on exactly how cascading shadow maps differs from it.

This topic is closed to new replies.

Advertisement