Graphics Reference
In-Depth Information
5.
The new vertex shader is an exact copy of our original vertex shader with the following
highlighted changes:
GS_DualMapInput VS_DualMap(VertexShaderInput vertex)
{
GS_DualMapInput result = (GS_DualMapInput)0;
...SNIP vertex skinning
// We use the Paraboloid's view within the
// WorldViewProjection with an Identity matrix for the
// projection.
result.Position = mul(vertex.Position,
WorldViewProjection);
...SNIP set other vertex output properties
// We are relative to the DPM's view, the length of
// result.Position is the distance from Paraboloid's origin
// to result.Position
float L = length(result.Position); // => for depth
result.Position = result.Position / L; // normalize
result.DualMapZ = result.Position.z; // Keep normalized
// Scale depth to [0, 1]
result.Position.z = (L - NearClip) / (FarClip - NearClip);
result.Position.w = 1.0f; // No perspective distortion
return result;
}
6.
The instanced geometry shader is very similar to that used in the previous recipe,
Implementing multithreaded dynamic cubic environment mapping . The differences
are highlighted in the following code snippet:
[maxvertexcount(3)] // Outgoing vertex count (1 triangle)
[ instance(2) ] // Number of times to execute for each input
void GS_DualMap(triangle GS_DualMapInput input[3],
uint instanceId: SV_GSInstanceID,
inout TriangleStream< GS_DualMapOutput > stream)
{
// Output the input triangle and calculate whether
// the vertex is in the +ve or -ve half of the DPM
GS_DualMapOutput output = (GS_DualMapOutput)0;
// Assign the render target instance
// i.e. 0 = front half, 1 = back half
output.RTIndex = instanceId;
// Direction (1.0f front, -1.0f back)
float direction = 1.0f - instanceId*2;
 
Search WWH ::




Custom Search