   [DiretcX 10] Shadow mapping
  I've tried many different shadow mapping techniques but none worked...This is my effect file to create the shadow map:RasterizerState EyeRender_RS{    CullMode = Back;    FillMode = Solid;    MultisampleEnable = TRUE;    DepthBias = 0.0;    SlopeScaledDepthBias = 0.0;};cbuffer cbPerFrame{float4x4 gLightWVP;};Texture2D gDiffuseMap;SamplerState gTriLinearSam{Filter = MIN_MAG_MIP_POINT;AddressU = Wrap;AddressV = Wrap;};struct VS_IN{float3 posL: POSITION;float3 tangentL : TANGENT;float3 normalL  : NORMAL;float2 texC: TEXCOORD;};struct VS_OUT{float4 posH : SV_POSITION;float2 texC : TEXCOORD0;float fDepth : TEXCOORD1;}; VS_OUT VS(VS_IN vIn){VS_OUT vOut;vOut.posH = mul(float4(vIn.posL, 1.0f), gLightWVP);vOut.texC = vIn.texC;vOut.fDepth = vOut.posH.z;return vOut;}float4 PS(VS_OUT pIn) : SV_TARGET{float4 diffuse = gDiffuseMap.Sample( gTriLinearSam, pIn.texC );// Don't write transparent pixels to the shadow map.clip(diffuse.a - 0.15f);return float4( pIn.fDepth, pIn.fDepth, pIn.fDepth, 1.0f );}technique10 ShadowMapTech{    pass P0    {   SetVertexShader( CompileShader( vs_4_0, VS() ) );   SetGeometryShader( NULL );   SetPixelShader( CompileShader( ps_4_0, PS() ) );SetRasterizerState( EyeRender_RS );    }}and this is the function to calculate the shadow factor:SamplerState gShadowSam{Filter = MIN_MAG_MIP_POINT;AddressU = Clamp;AddressV = Clamp;};float CalcShadowFactor(Texture2D gShadowMap, float4 projTexC){projTexC.xyz /= projTexC.w;if( projTexC.x &lt; -1.0f || projTexC.x &gt; 1.0f ||projTexC.y &lt; -1.0f || projTexC.y &gt; 1.0f ||    projTexC.z &lt; 0.0f )    return 0.0f;projTexC.x = +0.5f*projTexC.x + 0.5f;projTexC.y = -0.5f*projTexC.y + 0.5f;// Depth in NDC space.float depth = projTexC.z;float litDepth = gShadowMap.Sample(gShadowSam, projTexC.xy).r;if(depth &lt;= litDepth){return 1.0f;} else{return 0.0f;}}I'm using orthogonal projection and a map resolution of 1024x1024Why all zones that shouldn't be in the shadow have shadow stripes?   
  Looks like a bias problem, try:float litDepth = gShadowMap.Sample(gShadowSam, projTexC.xy).r+.01;;  I set the bias to 0.005 and it looks better. How can I know if I'm using the correct bias?Also how do PCF work? Will PCF resolve this problem?;  PCF (percentage closest filtering) will not fix that issue of shadows being offset from the object. That is cause by your bias.PCF works by sampling multiple times from the shadow map at slightly different texture coordinates, and then interpolating in between the results of the shadow depth tests in between the samples and the fragment depth value to soften up the shadows. It is helpful to reduce shadow aliasing (blockiness) and make them look a bit more "real"/soft.There are other techniques which do not suffer from shadow acne/biasing issues which you can use, which also provide soft shadows without doing PCF, such as variance shadow mapping, exponential shadow mapping, etc. If you have difficulties making standard shadow mapping + PCF looking food, I recommend you look in that area.[Edited by - ATEFred on April 12, 2010 3:27:34 AM];  One general solution for Bias is to render two shadow maps, one with front facing culling and another with back facing, then get the average value from the two shadow maps and use it as bias (John Carmack's 2004 keynote solution)   