Graphics Reference
In-Depth Information
OUT.z_value = OUT.position.z ;
II Store the distance to the vertex for use in the depth buffer.
OUT.position.z = L / 500 ;
II Set w to 1 since we aren't doing any perspective distortion.
OUT.position.w = 1;
II Find the world space position of the vertex.
float4 WorldPos = mul( float4( IN.position, 1 ), WorldMatrix );
// Find world space normal and eye vectors.
OUT.normal
= normalize( mul( IN.normal, (float3x3)WorldMatrix ) );
OUT.eye
= normalize( WorldPos.xyz - ViewPosition.xyz );
return OUT;
}
Listing 13.6. The vertex shader for rendering a reflective object into another object's paraboloid map.
The geometry shader is also a combination of the previous methods. The parabo-
loid projection calculations are performed (including the render target selection and vertex
winding modification), then the world-space vectors are passed to the pixel shader. This
geometry shader uses the same instancing technique we have seen previously to fill both
paraboloid maps.
[maxvertexcount(3)]
[instance(2)]
void GSMAIN( triangle GS_INPUT input[3],
uint id : SV_GSInstanceID,
inout TriangleStream<PS_INPUT> OutputStream )
{
PS_INPUT output;
// Initialize the vertex order and the direction of the paraboloid.
uint3 order = uint3( 0, 1, 2 );
float direction = 1.0f;
// Check to see which copy of the primitive this is. If it is 0, then it
// is considered the front facing paraboloid. If it is 1, then it is
// considered the back facing paraboloid. For back facing, we reverse
// the output vertex winding order,
if ( id == 1 )
{
order.xyz = order.xzy;
direction = -1.0f;
}
// Emit three vertices for one complete triangle.
Search WWH ::




Custom Search