• Advertisement
Sign in to follow this  

Percentage Closer Filtering

This topic is 1652 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 create PCF from my Shadows but when I perform PCF filtering I get always 0.0

SamplerComparisonState cmpSampler
{
   // sampler state
   Filter = COMPARISON_MIN_MAG_MIP_LINEAR;
   AddressU = MIRROR;
   AddressV = MIRROR;
 
   // sampler comparison state
   ComparisonFunc = LESS_EQUAL;
};

..............

float2 texOffset( int u, int v )
{
    return float2( u * 1.0f/2048.0f, v * 1.0f/2048.0f );
}

...............

//PCF sampling for shadow map
float sum = 0;
float x, y;	
//perform PCF filtering on a 4 x 4 texel neighborhood
for (y = -1.5; y <= 1.5; y += 1.0)
{
        for (x = -1.5; x <= 1.5; x += 1.0)
	{
		sum += localShadowTextures[1].SampleCmpLevelZero( cmpSampler, input.localLightViewPosition.xy + texOffset(x,y), input.localLightViewPosition.z );			
	}
}
float shadowFactor = sum / 16; // <--- no matter what i always get a 0 here.

Edited by xlope01

Share this post


Link to post
Share on other sites
Advertisement

Are you creating your device with the D3D11_CREATE_DEVICE_DEBUG flag and checking for warnings/errors in your debugger output? It's possible that you messed something up when creating the sampler state, and that's screwing up the shader.

Share this post


Link to post
Share on other sites

Are you creating your device with the D3D11_CREATE_DEVICE_DEBUG flag and checking for warnings/errors in your debugger output? It's possible that you messed something up when creating the sampler state, and that's screwing up the shader.

 

I donot have D3D11_CREATE_DEVICE_DEBUG flag. Also I dident create sampler state for "cmpSampler" or you mean SamplerComparisonState ?

Share this post


Link to post
Share on other sites

texOffset() takes ints, youre passing floats and returning floats?

 

good point, but this don't solve the problem.

Share this post


Link to post
Share on other sites

 

Are you creating your device with the D3D11_CREATE_DEVICE_DEBUG flag and checking for warnings/errors in your debugger output? It's possible that you messed something up when creating the sampler state, and that's screwing up the shader.

 

I donot have D3D11_CREATE_DEVICE_DEBUG flag.

 

 

You should always, always, *always* be using it for debug builds. Always.

Share this post


Link to post
Share on other sites

 

 

Are you creating your device with the D3D11_CREATE_DEVICE_DEBUG flag and checking for warnings/errors in your debugger output? It's possible that you messed something up when creating the sampler state, and that's screwing up the shader.

 

I donot have D3D11_CREATE_DEVICE_DEBUG flag.

 

 

You should always, always, *always* be using it for debug builds. Always.

 

only if i knew how to use this debug thing

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement