SampleCmp giving weird results

Started by
0 comments, last by Telanor 10 years, 7 months ago
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?
Advertisement
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.

This topic is closed to new replies.

Advertisement