Sign in to follow this  
Telanor

SampleCmp giving weird results

Recommended Posts

Telanor    1486
I'm trying to use SampleCmpLevelZero for hardware PCF shadow filtering but for some reason it's making my shadow maps successively darker in further cascades (I'm using cascaded shadow maps as well).

This is what the scene looks like with shadows turned off (also looks identical to doing a standard Sample):

[attachment=17922:RuinValor 2013-09-17 02-29-53-75.png]

And with the shadow maps on:

[attachment=17923:RuinValor 2013-09-17 02-29-56-55.png]

And again with the debug output:

[attachment=17924:RuinValor 2013-09-17 02-29-58-98.png]

Bottom image is the depth from the player's perspective, middle is the 4 cascades showing the depth from the light's perspective, and the top is the combined shadow map. This is my sampler state:
 
SamplerComparisonState cmpSampler
{
	Filter = COMPARISON_MIN_MAG_MIP_LINEAR;
	AddressU = CLAMP;
	AddressV = CLAMP;
	ComparisonFunc = LESS_EQUAL;
};
And sampling code:
 
return ShadowMap.SampleCmpLevelZero(cmpSampler, shadowTexCoord, lightDepth - SHADOW_BIAS);
If I change to using just a regular sample, there's no problem
 
float sample = ShadowMap.Sample(DepthMapSampler, shadowTexCoord).r;

return sample > lightDepth - SHADOW_BIAS;
Any ideas?

Share this post


Link to post
Share on other sites
Telanor    1486
Found the problem. Turns out SampleCmp only works on a very small number of formats. I switched to a compatible one and the problem went away. Edited by Telanor

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