• Advertisement
Sign in to follow this  

Question about directx9.0 shadow volume example. Please help me!

This topic is 3403 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, all. I am going to implement shadow volume. I have read the document for about 4 days. Now I am reading the directx shadow volume example. I have some questions. The shadow volume example in directx9.0 is somewhat different with the document( http://www.gamasutra.com/features/20021011/lengyel_01.htm ) there. It is a simplified solution. It dosen't change the projection matrix, but only add a epsilon to the far plane, so that the back cap will not be clipped by far plane. The question is about the code in the VertShadowVolume function. ========================================================================= if( PosView.z > g_vLightView.z ) { // I know the mean of this line is to make the vertex extruded infinity, // and make the z value equal to "farPlane - epsilon" PosView.xyz += LightVecView * ( g_fFarClip - PosView.z ) / LightVecView.z; } else { // But What's the mean of this line? // make w to equal, the send to projection matrix will make the // vertex extrude to the position that point to camera infinity? // But the demo dosen't change the projection matrix as the document, // why infinity? PosView = float4( LightVecView, 0.0f ); } ============================================================================ My question is in the comment, can someone help me? Thanks I'm sorry for my poor english. below is the whole VertShadowVolume function in the example of directx9.0 void VertShadowVolume( float4 vPos : POSITION, float3 vNormal : NORMAL, out float4 oPos : POSITION ) { // Compute view space normal float3 N = mul( vNormal, (float3x3)g_mWorldView ); // Obtain view space position 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.0f ); } // Transform the position from view space to homogeneous projection space oPos = mul( PosView, g_mProj ); } else oPos = mul( vPos, g_mWorldViewProjection ); }

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement