Graphics Reference
In-Depth Information
This completes our HLSL changes. Before updating our render loop, be sure
to compile the MSAA pixel shaders within LightRenderer . By placing the
MSAA pixel shaders in a new file and using the existing isMSAA variable within
CreateDeviceDependentResources to conditionally compile the MSAA
and non-MSAA shaders, we can support both scenarios.
4.
Within our D3DApp class we need to enable multisampling for the swap chain,
as shown in the following code:
protected override SwapChainDescription1
CreateSwapChainDescription()
{ var description = base.CreateSwapChainDescription();
description.SampleDescription =new SampleDescription(4,0);
return description;
}
5.
We can then put it all together in our D3DApp.Run method as shown in the
following code sample:
GBuffer gbufferMS = ToDispose(new
GBuffer(this.RenderTargetSize.Width,
this.RenderTargetSize.Height,
new SampleDescription(4, 0),
Format.R8G8B8A8_UNorm,
Format.R32_UInt,
Format.R8G8B8A8_UNorm));
gbufferMS.Initialize(this);
...
var lightRendererMS = ToDispose(new LightRenderer(sphereRenderer,
saQuad, gbufferMS));
... add lights
lightRendererMS.Initialize(this);
...
// Fill G-Buffer
...
gbufferMS.Unbind();
// Lighting pass
...
lightRendererMS.Unbind();
context.OutputMerger.SetRenderTargets(this.DepthStencilView, this.
RenderTargetView);
saQuadMS.Shader = null; // use default shader
saQuadMS.ShaderResources = new[] { lightRendererMS.SRV };
saQuadMS.Render();
 
Search WWH ::




Custom Search