Graphics Reference
In-Depth Information
// Vertex winding
uint3 indx = uint3(0,2,1);
if (direction < 0)
indx = uint3(0,1,2);
[unroll]
// for each input vertex
for (int v = 0; v < 3; v++)
{
// Calculate the projection for the the DPM, taking
// into consideration which half of the DPM we are
// rendering.
float projection = input[indx[v]].DualMapZ * direction
+ 1.0f;
output.Position.xy = input[indx
v]].Position.xy / projection;
output.Position.z = input[indx[v]].Position.z;
output.Position.w = 1; // no further perspective change
output.DualMapZ = input[indx[v]].DualMapZ * direction;
...SNIP copy other vertex properties unchanged
// Append to the stream
stream.Append(output);
}
stream.RestartStrip();
}
7.
Lastly, we will implement our modified pixel shader for generating the DPM.
float4 PS_DualMap(GS_DualMapOutput pixel) : SV_Target
{
// Ignore this pixel if located behind.
// We add a little additional room to ensure that
// the two halves of the dual paraboloid meet at the
// seams.
clip(pixel.DualMapZ + 0.4f);
... SNIP pixel shader code
}
8. The existing pixel shaders will now implement DPM reflections by including the
EnvironmentMap.hlsl file and using the following snippet:
// Calculate reflection (if any)
if (IsReflective) {
float3 reflection = reflect(-toEye, normal);
color = lerp(color, SampleEnvMap(Sampler, reflection) ,
ReflectionAmount);
}
 
Search WWH ::




Custom Search