Graphics Reference
In-Depth Information
To remain consistent, we have used a right-handed coordinate
system for the view. However, the TextureCube resource will be
a little backwards unless we also scale -1 along the x axis. We will
also need to reverse the vertex winding order (as we have done
in the geometry shader GS_CubeMap ) or switch the culling from
back face to front face (or use no culling).
21. For the scene to be rendered in its entirety while generating the cube map, it is
necessary to pass through delegate that will perform the rendering logic. Therefore,
we will not use the DynamicCubeMap.DoRender override and instead create a new
public function named UpdateSinglePass .
protected override void DoRender()
{
throw new NotImplementedException("Use UpdateSinglePass
instead.");
}
// Update the 6-sides of the cube map using a single pass
// via Geometry shader instancing with the provided context
// renderScene: The method that will render the scene
public void UpdateSinglePass(
DeviceContext context,
Action<DeviceContext, Matrix, Matrix, RenderTargetView,
DepthStencilView, DynamicCubeMap> renderScene)
{
// Don't render the reflector itself
if (Reflector != null)
Reflector.Show = false;
// Prepare pipeline
context.OutputMerger.SetRenderTargets(EnvMapDSV,
EnvMapRTV);
context.Rasterizer.SetViewport(Viewport);
// Prepare the view projections
Matrix[] viewProjections = new Matrix[6];
for (var i = 0; i < 6; i++)
viewProjections[i] = Matrix.Transpose(
Cameras[i].View * Cameras[i].Projection);
// Update perEnvMapBuffer with the ViewProjections
context.UpdateSubresource(viewProjections,
PerEnvMapBuffer);
// Assign perEnvMapBuffer to the GS stage slot 4
context.GeometryShader
 
Search WWH ::




Custom Search