Graphics Reference
In-Depth Information
activePixelShader = blinnPhongShader;
// Initialize context (also resetting the render targets)
InitializeContext(context, true);
// Render the final scene
renderScene(context, viewMatrix, projectionMatrix,
RenderTargetView, DepthStencilView, null);
#endregion
How it works…
The following screenshot shows the dynamic cube map from this recipe used with seven
reflective surfaces. The 100 cubes in the sky are rotating around the y axis, and the cube
maps are updated dynamically. The close up of the spheres illustrates how reflections
include the reflections on other surfaces:
A scene with seven reflective surfaces using cubic environment maps
Rather than rendering the entire scene six times per cube map, we use multiple render
targets and the instance attribute of the geometry shader to do this in a single render
pass in a fraction of the time (approximately three to four times faster). For each triangle
output from the vertex shader, the Direct3D pipeline calls the geometry shader six times
as per the instance attribute. The SV_GSInstanceID input semantic contains the
zero-based instance ID; this ID is used to index the view/projections that we calculated
for each cube face. We indicate which render target to send the fragment to by setting the
SV_RenderTargetArrayIndex input semantic ( GS_CubeMapOutput.RTIndex in our
example HLSL) to the value of the geometry shader's instance ID.
 
Search WWH ::




Custom Search