Graphics Reference
In-Depth Information
How to do it…
We will begin by creating a new class to manage rendering to the G-Buffer:
1.
Let's create a new C# class, GBuffer , descending from Common.RendererBase
and with the following public and private member fields:
// List of render target textures
public List<Texture2D> RTs = new List<Texture2D>();
// List of SRVs to the render targets
public List<ShaderResourceView> SRVs = new
List<ShaderResourceView>();
// List of RTVs to the render targets
public List<RenderTargetView> RTVs = new
List<RenderTargetView>();
// The Depth/Stencil buffer
public Texture2D DS0;
public ShaderResourceView DSSRV;
public DepthStencilView DSV;
// Dimensions
int width;
int height;
// The sample description (e.g. for MSAA)
SampleDescription sampleDescription;
// The Render target formats to be used
SharpDX.DXGI.Format[] RTFormats;
2.
The only constructor initializes the width, height, and the number and format of
render targets:
public GBuffer(int width, int height, SampleDescription
sampleDesc, params SharpDX.DXGI.Format[] targetFormats)
{
System.Diagnostics.Debug.Assert(targetFormats != null
&& targetFormats.Length > 0 && targetFormats.Length <
9, "Between 1 and 8 render target formats must be
provided");
this.width = width;
this.height = height;
this.sampleDescription = sampleDesc;
RTFormats = targetFormats;
}
 
Search WWH ::




Custom Search