Sign in to follow this  
toasterthegamer

ESM Artifacts

Recommended Posts

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

Share this post


Link to post
Share on other sites
PolyVox    712
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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
PolyVox    712
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?

Share this post


Link to post
Share on other sites
Pragma    395
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.

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