Deferred shading

This commit is contained in:
dexy
2019-12-04 00:52:22 +11:00
Unverified
parent 755477590d
commit 9a53c2147b
60 changed files with 2724 additions and 509 deletions
+14 -8
View File
@@ -59,8 +59,9 @@ namespace CodeWalker.Rendering
{
bool disposed = false;
VertexShader basicvs;
PixelShader basicps;
VertexShader vs;
PixelShader ps;
PixelShader psdef;
GpuVarsBuffer<TreesLodShaderVSSceneVars> VSSceneVars;
GpuVarsBuffer<TreesLodShaderVSEntityVars> VSEntityVars;
GpuVarsBuffer<TreesLodShaderVSModelVars> VSModelVars;
@@ -71,14 +72,18 @@ namespace CodeWalker.Rendering
private Dictionary<VertexType, InputLayout> layouts = new Dictionary<VertexType, InputLayout>();
public bool Deferred = false;
public TreesLodShader(Device device)
{
byte[] vsbytes = File.ReadAllBytes("Shaders\\TreesLodVS.cso");
byte[] psbytes = File.ReadAllBytes("Shaders\\TreesLodPS.cso");
byte[] psdefbytes = File.ReadAllBytes("Shaders\\TreesLodPS_Deferred.cso");
basicvs = new VertexShader(device, vsbytes);
basicps = new PixelShader(device, psbytes);
vs = new VertexShader(device, vsbytes);
ps = new PixelShader(device, psbytes);
psdef = new PixelShader(device, psdefbytes);
VSSceneVars = new GpuVarsBuffer<TreesLodShaderVSSceneVars>(device);
VSEntityVars = new GpuVarsBuffer<TreesLodShaderVSEntityVars>(device);
@@ -112,8 +117,8 @@ namespace CodeWalker.Rendering
public override void SetShader(DeviceContext context)
{
context.VertexShader.Set(basicvs);
context.PixelShader.Set(basicps);
context.VertexShader.Set(vs);
context.PixelShader.Set(Deferred ? psdef : ps);
}
public override bool SetInputLayout(DeviceContext context, VertexType type)
@@ -311,8 +316,9 @@ namespace CodeWalker.Rendering
PSSceneVars.Dispose();
PSEntityVars.Dispose();
basicps.Dispose();
basicvs.Dispose();
psdef.Dispose();
ps.Dispose();
vs.Dispose();
disposed = true;
}