Graphics Reference
In-Depth Information
width = depthTexture.Description.Width;
height = depthTexture.Description.Height;
sampleDesc = depthTexture.Description
.SampleDescription;
// Initialize read-only DSV
var dsvDesc = gbuffer.DSV.Description;
dsvDesc.Flags = DepthStencilViewFlags.ReadOnlyDepth |
DepthStencilViewFlags.ReadOnlyStencil;
DSVReadonly = ToDispose(new DepthStencilView(device,
depthTexture, dsvDesc));
}
// Check if GBuffer is multi-sampled
bool isMSAA = sampleDesc.Count > 1;
12. Next, we define the light render target texture and its Render Target View (RTV)
and Shader Resource View (SRV). This is done exactly as we have done within the
recipe Filling the G-Buffer .
// Initialize the light render target
var texDesc = new Texture2DDescription();
texDesc.BindFlags = BindFlags.ShaderResource | BindFlags.
RenderTarget;
...
texDesc.SampleDescription = sampleDesc;
texDesc.Format = Format.R8G8B8A8_UNorm;
lightBuffer = ToDispose(new Texture2D(device, texDesc));
// Render Target View description
var rtvDesc = new RenderTargetViewDescription();
...
RTV = ToDispose(new RenderTargetView(device, lightBuffer,
rtvDesc));
// SRV description
var srvDesc = new ShaderResourceViewDescription();
...
SRV = ToDispose(new ShaderResourceView(device, lightBuffer,
srvDesc));
13. To allow rendering multiple lights onto each other, we will use additive blending.
The following code snippet shows how to initialize this blend state:
// Initialize additive blend state (assuming single RT)
BlendStateDescription bsDesc = new BlendStateDescription();
bsDesc.RenderTarget[0].IsBlendEnabled = true;
 
Search WWH ::




Custom Search