Shadowmapping & Quality improvement

Started by
4 comments, last by Schrompf 16 years, 9 months ago
I've recently implemented shadow mapping, but the quality isn't what I expected. I'm using the highest resolution for the texture (2048²) with D3DFMT_R32F as its format, so I can get a 32bit resolution for the pixel depth. Video link As you can see in this video, I do have aliasing problems (apart from some artifacts) with the shadows. How can I improve the quality of the shadows? I've heard about perspective shadow mapping, but I don't have a clue how I could implement them.
Advertisement
Avoid Perspective Shadow Mapping. It has some dead ends, better alternatives do exist. Such as Light Space Perspective Shadow Mapping, Trapezoidal Shadow Mapping and some others I forgot. All of them work by applying a perspective projection on the shadow map, but due to the nature of it all of them fall back to uniform shadow mapping if the view direction and light direction are close to parallel.

There are other techniques. Among the most popular are Cascaded Shadow Mapping and Parallel Split Shadow Mapping, two names for nearly the same technique: applying multiple (uniformly distributed) shadow maps for different distances. Easy to implement, excellent results, but at the cost of rendering multiple shadow maps.

And there's an own developed technique, recently named Circular Distorted Shadow Mapping. It works by applying a lense effect on the shadow map so that close objects are much larger at the shadow map, therefore providing better resolution close to the viewer at the expense of distant regions. You can find a rough description under http://www.gamedev.net/community/forums/topic.asp?topic_id=405955 Of course there are downsides as well: the distortion is non-linear, meaning that triangle edges above a certain length get noticable distortions. The maximum gain possible by this technique is limited, around 20x for my personal use case. It had some additional problems on certain angles that are mentioned at the linked thread but they're no actually not a problem: they're already solved in the code presented there, I just didn't realise it.

Make your choice. If you want to be safe, PSSM is propably the best choice.

Bye, Thomas
----------
Gonna try that "Indie" stuff I keep hearing about. Let's start with Splatter.
I have implemented Shrompf's method and it works very well in most cases (but only for directional lights).

However, I strongly recommend doing the shadow projection distortion in the pixel shader, not the vertex shader, as that will have far fewer artifacts.

However, I don't think your video looks so bad, at least nothing that couldnt be fixed by a nice percentage-closer filtering.
Now that I had a look at the video I have to agree with Matt: for the camera in the video the shadows are good... they won't get much better. All techniques I proposed in my first post will be only necessary if you aim for a first person camera walking through the church. At the moment, PCF or maybe Variance Shadow Mapping might provide a better gain in visual quality.

@Matt:

<900 rating? Did you post in the lounge lately? :-)
----------
Gonna try that "Indie" stuff I keep hearing about. Let's start with Splatter.
Quote:Original post by Schrompf
Now that I had a look at the video I have to agree with Matt: for the camera in the video the shadows are good... they won't get much better. All techniques I proposed in my first post will be only necessary if you aim for a first person camera walking through the church. At the moment, PCF or maybe Variance Shadow Mapping might provide a better gain in visual quality.


I am aiming for a first person camera. The video was made with flying mode, to have a better look at the shadows.

About the techniques you proposed. I had a look at the link you posted and I also ran the demo. Looks really impressive, however I don't think I'm advanced enough to implement it yet. I think I'll try out several techniques and stick to the one that looks the best.

I'll start with perspective shadow mapping, I think. You said something about a flaw, the algorithm has. However I have a question about that. If I'm understanding perspective shadow mapping right, the only thing different is, that the shadowmap has the dimensions of the standard viewport and that the depth values are stored in camera screen space, but with their distance to the light source. Thus, there won't be the case as in normal shadow mapping, when one shadowed pixel is mapped to about 10 screen pixels. How can this be a "problem" when the view and light direction are nearly aligned? In any case, one shadowed pixel should be mapped to one screen pixel, shouldn't it?
Quote:
I'll start with perspective shadow mapping, I think. You said something about a flaw, the algorithm has. However I have a question about that. If I'm understanding perspective shadow mapping right, the only thing different is, that the shadowmap has the dimensions of the standard viewport and that the depth values are stored in camera screen space, but with their distance to the light source. Thus, there won't be the case as in normal shadow mapping, when one shadowed pixel is mapped to about 10 screen pixels. How can this be a "problem" when the view and light direction are nearly aligned? In any case, one shadowed pixel should be mapped to one screen pixel, shouldn't it?


Only if your scene is a single plane in parallel to the far plane, for example. As soon as there's some depth complexity all mapping work is in vain. If you read the Perspective Shadow Mapping paper you'll soon notice there are numerous problematic areas where the technique is not just looking ugly but failing completely. As mentioned before, Light Space Perspective Shadow Mapping is a better place to start - it's basically an enhancement of PSM.

Bye, Thomas
----------
Gonna try that "Indie" stuff I keep hearing about. Let's start with Splatter.

This topic is closed to new replies.

Advertisement