shadow mapping

Started by
15 comments, last by AndyTX 17 years, 6 months ago
I have problems with depth biasing on my shadow map. I keep getting either banded circles and rings or shadows appearing in the wrong place - can anyone direct me to a link that shows how this problem is solved?
Advertisement
I would check out the numerous threads here. Just search for depth bias or surface acne and you should find what you are looking for. You probably also want to search for variance shadow maps.
thanks, the technique I had in mind was a gradient shadow map. heres a section of code that I have been using, its based on the directX sdk:

    //transform from RT space to texture space.    float2 ShadowTexC = 0.5 * vPosLight.xy / vPosLight.w + float2( 0.5, 0.5 );    ShadowTexC.y = 1.0f - ShadowTexC.y;    // transform to texel space    float2 texelpos = SMAP_SIZE * ShadowTexC;        // Determine the lerp amounts               float2 lerps = frac( texelpos );	float4 spotlight = tex2D( g_samSpotlight, ShadowTexC );			//	//	This ensures that the spotlight faces fowards only	//	if( spotlight.z > vPosLight.z ) spotlight.xyzw= 0.0f;	//	//	compute the linearized depth value		//    float depth = (vPosLight.z +fNear) / (fFar-fNear);        //    //	compute the shadow map bias    //    SHADOW_EPSILON = fz( depth );        depth -= SHADOW_EPSILON;



however I am not sure about the contents of the function fz().

The problem is that I get surface acne on objects for a large SHADOW_EPSILON setting and shadows that don't appear in the correct place for a different value. Edit: Also if the objects are further away from the light the shadow seems more offset from the correct position, hence the need for a function.
thanks I'll search for gradient shadow maps.

I'll probably attempt to implement variance shadow mapping a bit later, since my first attempt to run the effect in my demo failed.
The usual method is to use two parameters: depth bias and slope bias. Basically depth bias is a constant factor offset and slope bias is a multiplier based on the "slope" of the polygon with respect to the depth (i.e. a near-silhouette polygon will have a high value here). It's basically trial and error for your scene though and it's certainly possible to construct a scene that will break any given values.

A decent explanation of the above is found in the GL documentation.

Variance shadow maps help since by adding a small epsilon to the compute variance (rather than the computed depth), one can pretty much fully eliminate surface acne without "pulling the shadows away" from the bases very much - if at all. However VSMs currently have their own set of issues (mainly light bleeding) that may be a problem depending on your scene. Hybrid techniques certainly look promising!
Quote:
It's basically trial and error for your scene though and it's certainly possible to construct a scene that will break any given values.


I thought slope scale and depth bias could be tuned in the function fz(...) and silhouette polygons could be handled dynamically.

Quote:
one can pretty much fully eliminate surface acne without "pulling the shadows away" from the bases very much - if at all.


the variance shadow map would solve both problems then ... (edit: next on my todo list).
I wonder if the "light-bleeding" problem could be solved using a depth related function.

My first idea for a hybrid is to implement "percentage closer soft shadows" with variance shadow mapping, and also to revert back to spotlight textures for the pixel shader.

[Edited by - cyber_wiz_2007 on October 1, 2006 6:56:16 PM]
Quote:Original post by cyber_wiz_2007
I thought slope scale and depth bias could be tuned in the function fz(...) and silhouette polygons could be handled dynamically.

There's no perfect solution - there's finite precision in the shadow map and a scene can be constructed with arbitrarily large precision requirements, regardless of any depth transformation functions.

Quote:Original post by cyber_wiz_2007
I wonder if the "light-bleeding" problem could be solved using a depth related function.

It can only be solved with either 1) more information about the depth distribution stored or 2) a hybrid method that falls back on a conservative solution. Chebyshev's inequality is a *tight* upper bound for arbitrary distributions and thus cannot be improved upon with only two moments.

Quote:Original post by cyber_wiz_2007
My first idea for a hybrid is to implement "percentage closer soft shadows" with variance shadow mapping...

You should be able to do something like that, i.e. #2 above. Seems like a promising approach to me.

In addition to aforesaid:
1. Usage of the 'max filter'. After rendering, shadow map postprocessed with the max filter (radius = 1 texel). It's an interesting method, but it has some disadvantages: Decrease of a shadow (one texel) on a silhouette. And small artifacts in 'inner corners'.
2. Instead depth - save more detailed information. For example - save per fragment plane (four coefficients), and using appropriate calculations. It gives good quality, but demands additional memory and more per fragment calculations. (Plane-map shadows).

VSM (or just depth bilinear interpolation) also not completely resolve depth aliasing. It's give false shadowing artifacts in 'inner corners' (in such situations, depth interpolation - incorrect).
Quote:Original post by _sav_
VSM (or just depth bilinear interpolation) also not completely resolve depth aliasing. It's give false shadowing artifacts in 'inner corners' (in such situations, depth interpolation - incorrect).

Maybe I'm just misunderstanding what you're saying, but VSM is not simply "depth bilinear interpolation" - it's probabilistically based and guaranteed to give an upper bound. Simply interpolating depth and comparing is *always* incorrect, not just in "inner corners".

That said, VSM does not completely solve depth biasing issues (as I explained, nothing can as long as we have finite precision :)), but it can easily make it a non-issue in all but the most bizarre cases.
Quote:Original post by AndyTX
Maybe I'm just misunderstanding what you're saying, but VSM is not simply "depth bilinear interpolation" - it's probabilistically based and guaranteed to give an upper bound. Simply interpolating depth and comparing is *always* incorrect, not just in "inner corners".

If forget about 'soft' shadows, - we can simply interpolate depth (no variance calculation). In this case the depth bias issues will be solved identical VSM. You agree?

Quote:
That said, VSM does not completely solve depth biasing issues (as I explained, nothing can as long as we have finite precision :)), but it can easily make it a non-issue in all but the most bizarre cases.

When I speak about VSM problems I do not mean numerical precision (usage small bias for resolve this - not criminally). I mean concrete algorithmic limitations. The example with 'inner corners' - shows it.

Quote:Original post by _sav_
If forget about 'soft' shadows, - we can simply interpolate depth (no variance calculation).

No - interpolating depth without something like the VSM calculations is wrong. In particular, interpolating before doing a depth comparison is incorrect.

Quote:Original post by _sav_
I mean concrete algorithmic limitations. The example with 'inner corners' - shows it.

I don't know what you mean... VSM doesn't really have any sort of geometry limitations - it's the same as shadow maps that way. Also the currentversions of VSM do not attempt to create plausible soft shadows (although a hybrid that does could be very cool), merely to reduce aliasing.

This topic is closed to new replies.

Advertisement