Original Post
in dx sample:Shadow volume, in the shader file: ShadowVolume.fx, on the function which deal with extrde the vertex away, you can get the why when it set w=0 when PosView.z <= g_vLightView.z, it works and otherwise it doesn't; what happened in the clipping stage? when I set w=0 on all situations, there is one more strange shadow; sorry I don't know how to paste picture here; you can see it by modify the code; the homogeneous coordinates, the clipping algorithm, puzzle me;
float4 PosView = mul( vPos, g_mWorldView );
// Light-to-vertex vector in view space
float3 LightVecView = PosView - g_vLightView;
// Perform reverse vertex extrusion
// Extrude the vertex away from light if it's facing away from the light.
if( dot( N, -LightVecView ) < 0.0f )
{
if( PosView.z > g_vLightView.z )
PosView.xyz += LightVecView * ( g_fFarClip - PosView.z ) / LightVecView.z;
else
PosView = float4(LightVecView,0);
// Transform the position from view space to homogeneous projection space
oPos = mul( PosView, g_mProj );
} else
oPos = mul( vPos, g_mWorldViewProjection );