Graphics Reference
In-Depth Information
8.
First let's add the following C# light type enumeration and PerLight constant buffer
structure for use in our renderer.
public enum LightType : uint
{
Ambient = 0,
Directional = 1,
Point = 2,
}
[StructLayout(LayoutKind.Sequential)]
public struct PerLight
{
public Vector3 Direction;
public LightType Type;
public Vector3 Position;
public float Range;
public Color4 Color;
}
9.
Declare the LightRenderer class and add the following private and public
member fields:
public class LightRenderer: Common.RendererBase
{
#region Initialized by CreateDeviceDepenedentResources
// PerLight constant buffer
Buffer perLightBuffer;
// Light texture and its RTV and SRV
Texture2D lightBuffer;
RenderTargetView RTV;
public ShaderResourceView SRV;
VertexShader vertexShader;
PixelShader psAmbientLight;
PixelShader psDirectionalLight;
PixelShader psPointLight;
RasterizerState rsCullBack;
RasterizerState rsCullFront;
RasterizerState rsWireframe;
// Additive blend state
BlendState blendStateAdd;
 
Search WWH ::




Custom Search