Graphics Reference
In-Depth Information
// Depth stencil states
DepthStencilState depthLessThan;
DepthStencilState depthGreaterThan;
DepthStencilState depthDisabled;
// Read-only depth stencil view
DepthStencilView DSVReadonly;
#endregion
// Initialized by caller
public List<PerLight> Lights { get; private set; }
public BoundingFrustum Frustum { get; set;}
public ConstantBuffers.PerObject PerObject { get; set;}
public Buffer PerObjectBuffer { get; set; }
...
}
10. And then add the following constructor and additional field members:
MeshRenderer pointLightVolume;
ScreenAlignedQuadRenderer saQuad;
GBuffer gbuffer;
public LightRenderer(
MeshRenderer pointLightVolume,
ScreenAlignedQuadRenderer saQuad,
GBuffer gbuffer)
{
this.Lights = new List<PerLight>();
this.pointLightVolume = pointLightVolume;
this.saQuad = saQuad;
this.gbuffer = gbuffer;
}
11. Now within the light renderer's protected override void
CreateDeviceDependentResources() method, we will initialize the
necessary Direct3D resources. First we use the G-Buffer depth buffer to
determine the width/height and initialize the read-only Depth Stencil View (DSV).
... RemoveAndDispose(ref <all disposable resources>);
var device = this.DeviceManager.Direct3DDevice;
int width, height;
SampleDescription sampleDesc;
// Retrieve DSV from GBuffer, extract width/height then
// create a new read-only DSV
using (var depthTexture = gbuffer.DSV.ResourceAs<Texture2D>())
{
 
Search WWH ::




Custom Search