Sign in to follow this  
_Camus_

Shadow Map scale problem

Recommended Posts

Hi, i´m trying to use the maximum texture space for get the less aliasing problem and the best use of a 2048*2048 map, so, i´m using the function D3DXMatrixOrthoLH... I know this is a classic problem with shadow map, and a common question in so many aspects, but i just don´t get it, if i use values of 45.0 for width and height: D3DXMatrixOrthoLH( &LProj,45.0f,45.0f, 0.01f, 1024.0f ); The Shadows appears in the correct place: http://img191.imageshack.us/img191/6755/shadowerror.png See, the shadow resolution is high and look bad even with the PCF, and i know its because the values of the width and height, its just too much map for a small caster (the zombie), i thought, maybe increasing the size of the Frustum with width and height values of, i dunno 15.0f: D3DXMatrixOrthoLH( &LProj,15.0,15.0, 0.01f, 1024.0f ); http://img188.imageshack.us/img188/9836/shadowerror2.png As you can see, the shadow itself looks better now, but is not in the right place to be, is away from the model, if the model moves far away the origin, the offset of the shadow and the model are bigger and bigger. Can someone explain me why, i don´t need Cascaded Shadow Maps, is only a small room, but i want the best use of the shadow buffer. Thanks [Edited by - _Camus_ on June 20, 2009 8:51:19 PM]

Share this post


Link to post
Share on other sites
Hi,

This issue is called Depth Bias Problem. It's the most terrible thing in shadow mapping. I've found a way to avoid this type of shadow artifacts. You can see the details here.

Quote:
i´m trying to use the maximum texture space for get the less
aliasing problem and the best use of a 2048*2048 map

You don't need to do this. I recommend you to use maximum 1024 x 1024 one (a 512x512 one may be ideal) and soft shadows. With this, edge aliasing problem will be solved and your shadow will look more realistic as well. You can google for "soft shadows" and I think there's an article about that here.

Hope this helps.
Rohat.

Share this post


Link to post
Share on other sites
Quote:
Original post by programci_84
This issue is called Depth Bias Problem. It's the most terrible thing in shadow mapping. I've found a way to avoid this type of shadow artifacts. You can see the details here.


Your approach to make the constant bias dependent on the light distance seems interesting. However, the robustness of this method is to me quite uncertain. It would be useful to see comparisons from different kinds of scenes and setups. You did not specify what value you store in the shadow map, or if it has any specific conserns for the shadow map precision. Do you store absolute depth value? The relative depth (at near plane=0.f, at far plane=1.f)? The distance from fragment to camera?

Also, the object (a pillar) you used is not the most difficult with respect to shadowing. Perhaps testing different setups, say, an object that has a hard edge, like a sword that has one side of the blade in shadow, and the other totally lit. Also, a very difficult case is one where there's a long edge that is nearly parallel to the shadow direction. (a big box suffices). What happens in the dueling frusta case or with lower res shadow maps?

I think I might try your method in my setup at some point to see if it yields noticeable improvements.


Share this post


Link to post
Share on other sites
Thank you for your interest, clb.

First, I must say that this techniqe is not working with directional light shadows (only working with spotlight shadows); but still I'm working on it.

Quote:
You did not specify what value you store in the shadow map, or if it has any specific conserns for the shadow map precision. Do you store absolute depth value? The relative depth (at near plane=0.f, at far plane=1.f)? The distance from fragment to camera?

I'm writing light's projection space z/w value (light-space depth, the classical projective shadow map value).

Quote:
Also, the object (a pillar) you used is not the most difficult with respect to shadowing. Perhaps testing different setups, say, an object that has a hard edge, like a sword that has one side of the blade in shadow, and the other totally lit.

Pillar object was the best to show how the shadow gone away from the occluder because of using constant bias. Be sure I've tested so many kinds of objects. For example, look at this picture (Taken from my "Deferred HDR Experience" thread in forum, "Image of The Day"). There's an animating soldier model, a monster model, a spaceship model, car model, and a gate model with that pillars.

Quote:
Also, a very difficult case is one where there's a long edge that is nearly parallel to the shadow direction. (a big box suffices). What happens in the dueling frusta case or with lower res shadow maps?

I can't say anything about the first case you've pointed out; but about the second case (lower resolution maps), I can say that this technique is size-independent. Because, you know, there's a dx value equals to one over map size. This value is used with PCF (in s0, ..., s3 values) and is the same dx as the value I use with calculating s0, ..., s3 values. Also I tested 256x256, 512x512 and 1024x1024 (just to improve map quality, not to test size-dependence); and worked well. But with higher than 1024, or lower than 256, there may be some artifacts (I didn't do any test with these sizes).

Quote:
I think I might try your method in my setup at some point to see if it yields noticeable improvements.

Please try and tell me the results you got. This help will be appreciated.

Regards,
Rohat.

Share this post


Link to post
Share on other sites
Hi, thanks for reply

I already checked your theory, but it seems that is not the problem
i have, or maybe i´m not doing well the implementation:

fShadowTerm = (tex2D( ShadowSampler, In.texCoordShadow.xy ).r + In.ep) < ( In.texCoordShadow.z/In.texCoordShadow.w ) ? 0.1f : 1.0f;

were In.ep is the epsilon computed on the vertex shader as:

float d = length(light1_Position - worldSpacePos);
Out.ep = 1.0f / (d*d - 2.0f*d);

were light1_Position position is the position of my active light, and
worldSpacePos is the position of the vertex.

Well, the problem Remains, the shadow is units far away from the models =(,
and only happens with values != 45.0f on the OrthoLH,

how did you build your LightSpace Projection MAtrix?

thank Again

Share this post


Link to post
Share on other sites
Hi,

Sorry but my approach is not working with directional light shadows. For this reason, you've to use constant values as epsilon.

Quote:
how did you build your LightSpace Projection MAtrix?

For dir-light shadows, I use D3DXMatrixOrthoLH() function. I only know that we have to equalize w and h. I'm using some values but when I change the light direction, shadow artifacts occur. Also while I was working with directional shadows on my demo, I saw that increasing w and h values makes shadow quality worse. Still I couldn't find an absolute technique for it. So, I find the correct values with try & error.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this