mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2026-05-17 14:14:46 +08:00
Deferred shading
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user