I've implemented a cubic shadow map for dealing with omni-directional light sources in my scene. By defualt it produces hard shadows
Obviously a shadow map with higher resolution (currently using 512x512) would produce a finer edge but that would also result in larger memory footprint for the application.
I'm currently using a very simple approach to sample the cubic shadow map using the TextureCube::SampleCmp method
float depthBias = 0.002f;
float shadowFactor = omniShadowMap.SampleCmp( omniShadowSampler, -lightVec, lightVecLength / pointLight.positionAndRadius.w - depthBias );
if( shadowFactor == 0.0f )
shadowFactor = 0.5f;
return float4( ( finalDiffuse + finalSpecular.xyz ) * shadowFactor , 1.0f );
The SamplerComparisonState is configuered like this
D3D11_SAMPLER_DESC samplerDesc;
samplerDesc.Filter = D3D11_FILTER_COMPARISON_MIN_MAG_MIP_POINT;
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
samplerDesc.MipLODBias = 0;
samplerDesc.MaxAnisotropy = 1;
samplerDesc.ComparisonFunc = D3D11_COMPARISON_LESS_EQUAL;
samplerDesc.BorderColor[0] = 0.0f;
samplerDesc.BorderColor[1] = 0.0f;
samplerDesc.BorderColor[2] = 0.0f;
samplerDesc.BorderColor[3] = 0.0f;
samplerDesc.MinLOD = 0.0f;
samplerDesc.MaxLOD = 0.0f;
A logic approach would be to use Percentage-Closer Filtering but I don't know how to access the texels in a TextureCube.
Any suggestions? Thank you!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire