From 283b0786417e5ff2f17bdb010402011e2a0a4ed0 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Mon, 7 Dec 2020 14:42:02 -0800 Subject: [PATCH] instanced g buffer draws work now --- Effects/FXB/DeferredPBR_GBufferEffect.fxb | 4 ++-- Effects/HLSL/DeferredPBR_GBufferEffect.fx | 4 ++-- Renderer.cs | 2 +- VertexDeclarations.cs | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Effects/FXB/DeferredPBR_GBufferEffect.fxb b/Effects/FXB/DeferredPBR_GBufferEffect.fxb index 5c38c1e..4ad7c73 100644 --- a/Effects/FXB/DeferredPBR_GBufferEffect.fxb +++ b/Effects/FXB/DeferredPBR_GBufferEffect.fxb @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a0fde33abf96c838d507d637922e614e8490f41b700846c87f5d344e14699959 -size 9228 +oid sha256:7c70594ec60f6f791f6d836d0ca1736284e8158f11ce439a18ad120fc440ad10 +size 9148 diff --git a/Effects/HLSL/DeferredPBR_GBufferEffect.fx b/Effects/HLSL/DeferredPBR_GBufferEffect.fx index 328ad7c..13c48c2 100644 --- a/Effects/HLSL/DeferredPBR_GBufferEffect.fx +++ b/Effects/HLSL/DeferredPBR_GBufferEffect.fx @@ -26,7 +26,7 @@ struct VertexInput struct InstanceInput { - float4x4 World : COLOR0; + float4x4 World : TEXCOORD2; }; struct PixelInput @@ -69,7 +69,7 @@ PixelInput instanced_vs(VertexInput input, InstanceInput instanceInput) output.NormalWorld = normalize(mul(input.Normal, instanceInput.World)); output.TexCoord = input.TexCoord; - float4x4 worldViewProjection = mul(World, ViewProjection); + float4x4 worldViewProjection = mul(instanceInput.World, ViewProjection); output.Position = mul(input.Position, worldViewProjection); return output; diff --git a/Renderer.cs b/Renderer.cs index ccdef63..45afee8 100644 --- a/Renderer.cs +++ b/Renderer.cs @@ -8,7 +8,7 @@ namespace Kav { public class Renderer { - private const int MAX_INSTANCE_VERTEX_COUNT = 1000000; + private const int MAX_INSTANCE_VERTEX_COUNT = 1000; private const int MAX_SHADOW_CASCADES = 4; private int ShadowMapSize { get; } diff --git a/VertexDeclarations.cs b/VertexDeclarations.cs index 1e8b869..d77327b 100644 --- a/VertexDeclarations.cs +++ b/VertexDeclarations.cs @@ -6,10 +6,10 @@ namespace Kav { public static VertexDeclaration GBufferInstanceDeclaration = new VertexDeclaration ( - new VertexElement(0, VertexElementFormat.HalfVector4, VertexElementUsage.Color, 0), - new VertexElement(16, VertexElementFormat.HalfVector4, VertexElementUsage.Color, 1), - new VertexElement(32, VertexElementFormat.HalfVector4, VertexElementUsage.Color, 2), - new VertexElement(48, VertexElementFormat.HalfVector4, VertexElementUsage.Color, 3) + new VertexElement(0, VertexElementFormat.Vector4, VertexElementUsage.TextureCoordinate, 2), + new VertexElement(16, VertexElementFormat.Vector4, VertexElementUsage.TextureCoordinate, 3), + new VertexElement(32, VertexElementFormat.Vector4, VertexElementUsage.TextureCoordinate, 4), + new VertexElement(48, VertexElementFormat.Vector4, VertexElementUsage.TextureCoordinate, 5) ); } }