Percentage Closer Filtering

Started by
7 comments, last by MJP 10 years, 8 months ago

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.

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.

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

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 ?

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

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

Does anyone have any idea what is wrong with the SamplerComparisonState ?

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.

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

It's passed to D3D11CreateDevice, through the Flags parameter.

This topic is closed to new replies.

Advertisement