I'm implementing a simple shadow map hlsl shader. Everything was just fine but something odd is happening to my shadow map.
Here is the screenshot -
[attachment=31895:shadow_map_art.png]
I don't know what is this artifact called. Maybe Shadow Acne. I'm not so sure. I'm already using normal offset bias in my vertex shader.
Here is my current pixel shader implemention of shadow map. I'm using the tex2Dproj function to get a free hardware PCF filter -
float4 pixelMain
(
float4 SMPos : TEXCOORD0,
float2 texCoords : TEXCOORD2,
float3 vWorldNormal : TEXCOORD3
) : COLOR0
{
float4 mapColor = tex2D(gColorMap, texCoords);
float shadow = tex2Dproj(gDepthMap, SMPos);
float cDiffuse = dot(vWorldNormal, normalize(gLightDir));
float4 totalDiffuse = (cDiffuse * gLightDiffuse) * shadow;
// Compose the final color:
float4 finalCol = (gLightAmbient + totalDiffuse) * mapColor;
return finalCol;
}
The gDepthMap is a depth surface and contains only depth information.
If I remove the ambient term from the final color calculation -
// Compose the final color:
float4 finalCol = totalDiffuse * mapColor;
return finalCol;
The result looks like following -
[attachment=31896:shadow_map_art_2.png]
Acceptable but the shadow is too dark. Is there any way to lighten the shadow?
So I have no idea what to do now and what the big mistake I did in my pixel shader. Is my final color calculation wrong?
Please help!