Jump to content



ShadowVolume

  • You cannot reply to this topic
4 replies to this topic

#1 Jeason   Members   -  Reputation: 95

Like
0Likes
Like

Posted 22 February 2012 - 02:39 AM

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
		    [color=#ff0000]PosView = float4( LightVecView, 0.0f );[/color]

	    // Transform the position from view space to homogeneous projection space
	    oPos = mul( PosView, g_mProj );
    } else
 
	    oPos = mul( vPos, g_mWorldViewProjection );
}

I can't understand the red line.

When the vertex is closer to viewer than light, we can also add PosView with some LightVecView.
But it just changes the position to a vector.Posted Image
What is the meaning of the red line?

Ad:

#2 Jeason   Members   -  Reputation: 95

Like
0Likes
Like

Posted 22 February 2012 - 06:06 AM

The red line doesn't present.

It's PosView = float4( LightVecView, 0.0f );.

#3 Hodgman   Moderators   -  Reputation: 3232

Like
0Likes
Like

Posted 22 February 2012 - 07:38 AM

"If the light is between the camera and the vertex, then the vertex is moved off into the distance, else the vertex is moved behind the camera by "LightVecView" (PosView.z - g_vLightView.z) units.".

#4 Jeason   Members   -  Reputation: 95

Like
0Likes
Like

Posted 22 February 2012 - 07:58 AM

View PostHodgman, on 22 February 2012 - 07:38 AM, said:

"If the light is between the camera and the vertex, then the vertex is moved off into the distance, else the vertex is moved behind the camera by "LightVecView" (PosView.z - g_vLightView.z) units.".

Thank you, Hodgman.

If you are right, then the vertex doesn't move along the line between light and vertex, but the line between light and camera when the vertex is closer to camera than light.
But we should move along the line between light and vertex.

#5 Jeason   Members   -  Reputation: 95

Like
0Likes
Like

Posted 22 February 2012 - 08:31 AM

And why does it make float4( LightVecView, 0 ), not float4( LightVecView, 1 );






We are working on generating results for this topic
PARTNERS