• Advertisement

# SampleCmp giving weird results

This topic is 1590 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

## Recommended Posts

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

##### Share on other sites
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. Edited by Telanor

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement
• ### Popular Tags

• Advertisement
• ### Popular Now

• 11
• 17
• 10
• 11
• 12
• Advertisement