• Advertisement
Sign in to follow this  

ShadowVolume

This topic is 2158 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

[CODE]
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 );
}
[/CODE]

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.[img]http://public.gamedev.net//public/style_emoticons/default/mellow.png[/img]
What is the meaning of the red line?

Share this post


Link to post
Share on other sites
Advertisement
The red line doesn't present.

It's [color="#880000"]PosView = float4( LightVecView, 0.0f );[/color][color="#000000"].[/color]

Share this post


Link to post
Share on other sites
"[b]If [/b]the light is between the camera and the vertex, [b]then [/b]the vertex is moved off into the distance, [b]else [/b][color=#b22222]the vertex is moved behind the camera by "LightVecView" (PosView.z - g_vLightView.z[/color][color=#B22222]) units[/color].".

Share this post


Link to post
Share on other sites
[quote name='Hodgman' timestamp='1329917887' post='4915481']
"[b]If [/b]the light is between the camera and the vertex, [b]then [/b]the vertex is moved off into the distance, [b]else [/b][color=#b22222]the vertex is moved behind the camera by "LightVecView" (PosView.z - g_vLightView.z[/color][color=#b22222]) units[/color].".
[/quote]

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.

Share this post


Link to post
Share on other sites
And why does it make float4( [color="#880000"]LightVecView[/color], 0 ), not float4( [color="#880000"]LightVecView[/color], 1 );

Share this post


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

  • Advertisement