Hey everyone,
I have the following loop in my main shader which samples my shadow map with a 3x3 PCF grid to achieve anti-aliased shadows:
int shadowFactor = 0;
for (int y = -1; y <= 1; y++)
{
for (int x = -1; x <= 1; x++)
{
float2 shadowSampleOffset = float2(x/ShadowMapSize, y/ShadowMapSize);
if (tex2D(ShadowMapTextureSampler, projectedTextureCoordinatesLight + shadowSampleOffset).r < input.ProjectedPositionLight.z - 0.002f)
{
shadowFactor += 1;
}
}
}
float lightingCorrectionFactor = 1 - shadowFactor/9.0f;
diffuseLightingFactor *= lightingCorrectionFactor;
specularLightingFactor *= lightingCorrectionFactor;
...however, it always pushes the number of instructions up to the point where I normally need to use a higher shader model (in MonoGame, it causes me to go from the default 4_0_level_9_1 up to 4_0_level_9_3).
Can anyone see a more obvious and efficient way to do the PCF operation?
Thanks!