implement variance shadow map in PC DirectX9

Yu Min Ye

Newcomer
Currently i am trying to implement "variance shadow map" in PC DirectX9(our game doesn't support DX10) , but i have some trouble as floating point filtering problem...

Anyone had some experience in it , could you give me any suggestions? Thanks !
 
I have run all my DX9 VSM tests using G16R16 (unsigned) render targets and textures. You do not need floating point surfaces for VSM, signed fixed point surfaces are enough.
 
Thanks!
I already tried using G16R16 format to implement VSM.

my code:

PixelInput VS_VSM(VertexInput IN)
{
PixelInput OUT;
OUT.Position = mul(IN.Position , WorldViewProjection);
OUT.Depth = PixelInput.Position.zw;
return OUT;
}

float4 PS_VSM(PixelInput IN) : COLOR
{
float d = IN.Depth.x / IN.Depth.y;

return float4(d , d * d , 0 , 1);
}

calculate shadow:

float GetShadowVSM(float3 shadowCoord)
{
float2 vsm = tex2D(shadowMap, shadowCoord.xy).rg;
float t = shadowCoord.z;
float Z = vsm.x;
float Z2 = vsm.y;
float cmpEq = ((Z - Z2) <= 0.0);
float p = (t <= Z);
float variance = max(Z2 - (Z*Z), 0.0005f);
float d = (t - Z);
float pMax = variance / (variance + d*d);
return max(cmpEq, max(max(p, pMax)));
}

currently it still has some problem :
1. rendering high object , the shadow at the bottom is very weak.
2. numerical precision.
3. blurring.

so how to solve these?
could you show me some details? Thank you advance!
 
Back
Top