Graphics Reference
In-Depth Information
if (envMap != null)
{
renderContext.VertexShader.SetConstantBuffer(4,
envMap.PerEnvMapBuffer);
renderContext.PixelShader.SetConstantBuffer(4,
envMap.PerEnvMapBuffer);
}
How it works…
The following screenshot shows the result of using dual paraboloid mapping using a
similar scene as used in the previous recipe, Implementing multithreaded cubic
environment mapping :
Results using the dual paraboloid mapping.
The DPM is generated by first applying the reflective surfaces' view affine transform to the
vertices; this differs from the generation of the cubic environment map as there is only one
view matrix required, and we can use the existing WorldViewProjection constant buffer
property. Then, we calculate the distance from the vertex to the origin and prepare the z value
for the depth buffer for further processing within the geometry shader (to apply the paraboloid
projection). The implementation of the GS_DualMap geometry shader is similar to creating
the cubic environment map; however, we are only generating two instances. As there is only
one view, we can simply reverse the direction along the z axis for the second copy of each
vertex. First, we determine the direction based on the current instance, set the vertex winding
order accordingly, and then manually project the vertex onto the paraboloid.
// Project the xy based on which half of DPM we are in
float projection = input[indx[v]].DualMapZ * direction + 1.0f;
output.Position.xy = input[indx[v]].Position.xy / projection;
 
Search WWH ::




Custom Search