ESM Artifacts

Started by
4 comments, last by Pragma 14 years, 2 months ago
Hi, I've been working on getting ESM working correctly and I am getting some weird self shadowing errors, I think its best explained by a screenshot. http://img204.imageshack.us/img204/5209/artifacts.png As you can see their are clearly some errors. Anyways here's my code:


float ESM_K = 60.0f; // Range [0, 80]
float ESM_MIN = -0.5f; // Range [0, -oo]
float ESM_DIFFUSE_SCALE = 1.39f; // Range [1, 10]

float3 GetShadow(half fSplitIndex, float2 splitUV[4], float4 lightDepths)
{
	float shadow = 0.0f;
    float receiver = lightDepths[fSplitIndex];
	float occluder = tex2D(sampShadowMap, splitUV[fSplitIndex].xy)[fSplitIndex];
	shadow = saturate(exp(max(ESM_MIN, ESM_K * (occluder - receiver))));
    
	shadow = 1.0f - (ESM_DIFFUSE_SCALE * (1.0f - shadow));
	
    return shadow;
}


I have tried playing around with the parameters but nothing seems to work right. I get the same results with and without the blur so I know its not the blur. I'm fairly certain it isn't the PSSM stuff either, as that works fine without the ESM. Anyways thank you for any help you can give! -Toaster
Advertisement
I can't see your image, but are you sure it is the ESM aspect which is at fault? I mean, what if you replace it with a regular depth test, something like:

float3 GetShadow(half fSplitIndex, float2 splitUV[4], float4 lightDepths){    float shadow = 0.0f;    float receiver = lightDepths[fSplitIndex];    float occluder = tex2D(sampShadowMap, splitUV[fSplitIndex].xy)[fSplitIndex];    shadow = occluder < receiver ? 0 : 1;	    return shadow;}


I guess I'm saying is it a case of bad shadow setup, or it the choice of values/constants for the ESM?

You'll need to remove the blur pass for this to make sense... in fact does the blur pass affect the problem?
Edit: Hmm after some playing around I have the same artifact with no ESM and no blur. So it must be something wrong with my PSSM.

New screenshot:
http://img237.imageshack.us/img237/5209/artifacts.png

Thanks for the help so far! :)

-Toaster
Quote:Original post by toasterthegamerSo it must be something wrong with my PSSM.

So does the issue disappear is you reduce the number of cascades to one? To me it looks a bit like there is some depth biasing taking place. And are you only rendering the back-facing triangles into your shadow map?
Yeah I use back-facing only. It has something to do with the bias but no matter what I set I get this:

http://img30.imageshack.us/img30/1969/biasartifacts.png

-Toaster
There are two different artifacts in your first picture, both should be fixable.

1. The bias errors you see come mostly on back faces. Back faces should always be in shadow. The way to solve this is to include some shading - multiply by dot(n,l) for your light.

2. There is some light leaking associated to ESM. There are lots of ways to improve this, but foremost you should render front faces in your shadow map when working with ESM.
"Math is hard" -Barbie

This topic is closed to new replies.

Advertisement