Skip to main content
Concrete advise
Source Link
Miklas
  • 413
  • 2
  • 10

If we look at the documentation, we see that a SamplerComparisonState is not a regular SamplerState:

[in] SamplerComparisonState: A sampler-comparison state, which is the sampler state plus a comparison state (a comparison function and a comparison filter).

As your two other parameters do seem to match, my guess is that you forgot to set the ComparisonFunc inChange your SamplerState. If this is not the case, please post your creation code into a SamplerStateSamplerComparisonState creation code. If this is the case, aA good example (that seems to match your shadowing purposes) can be found on the Sampler Type bottom example:

SamplerComparisonState ShadowSampler
{
   // sampler state
   Filter = COMPARISON_MIN_MAG_LINEAR_MIP_POINT;
   AddressU = MIRROR;
   AddressV = MIRROR;

   // sampler comparison state
   ComparisonFunc = LESS;  
};
        
float3 vModProjUV;
  ...
float fShadow = g_ShadowMap.SampleCmpLevelZero( ShadowSampler, vModProjUV.xy, vModProjUV.z);

If we look at the documentation, we see that a SamplerComparisonState is not a regular SamplerState:

[in] SamplerComparisonState: A sampler-comparison state, which is the sampler state plus a comparison state (a comparison function and a comparison filter).

As your two other parameters do seem to match, my guess is that you forgot to set the ComparisonFunc in your SamplerState. If this is not the case, please post your SamplerState creation code. If this is the case, a good example (that seems to match your shadowing purposes) can be found on the Sampler Type bottom example:

SamplerComparisonState ShadowSampler
{
   // sampler state
   Filter = COMPARISON_MIN_MAG_LINEAR_MIP_POINT;
   AddressU = MIRROR;
   AddressV = MIRROR;

   // sampler comparison state
   ComparisonFunc = LESS;  
};
        
float3 vModProjUV;
  ...
float fShadow = g_ShadowMap.SampleCmpLevelZero( ShadowSampler, vModProjUV.xy, vModProjUV.z);

If we look at the documentation, we see that a SamplerComparisonState is not a regular SamplerState:

[in] SamplerComparisonState: A sampler-comparison state, which is the sampler state plus a comparison state (a comparison function and a comparison filter).

Change your SamplerState creation code into a SamplerComparisonState. A good example (that seems to match your shadowing purposes) can be found on the Sampler Type bottom example:

SamplerComparisonState ShadowSampler
{
   // sampler state
   Filter = COMPARISON_MIN_MAG_LINEAR_MIP_POINT;
   AddressU = MIRROR;
   AddressV = MIRROR;

   // sampler comparison state
   ComparisonFunc = LESS;  
};
        
float3 vModProjUV;
  ...
float fShadow = g_ShadowMap.SampleCmpLevelZero( ShadowSampler, vModProjUV.xy, vModProjUV.z);
Source Link
Miklas
  • 413
  • 2
  • 10

If we look at the documentation, we see that a SamplerComparisonState is not a regular SamplerState:

[in] SamplerComparisonState: A sampler-comparison state, which is the sampler state plus a comparison state (a comparison function and a comparison filter).

As your two other parameters do seem to match, my guess is that you forgot to set the ComparisonFunc in your SamplerState. If this is not the case, please post your SamplerState creation code. If this is the case, a good example (that seems to match your shadowing purposes) can be found on the Sampler Type bottom example:

SamplerComparisonState ShadowSampler
{
   // sampler state
   Filter = COMPARISON_MIN_MAG_LINEAR_MIP_POINT;
   AddressU = MIRROR;
   AddressV = MIRROR;

   // sampler comparison state
   ComparisonFunc = LESS;  
};
        
float3 vModProjUV;
  ...
float fShadow = g_ShadowMap.SampleCmpLevelZero( ShadowSampler, vModProjUV.xy, vModProjUV.z);