From 7148ff3f3124fec6ceea7117c12c8a95b87dfe6a Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Sun, 17 Nov 2024 12:24:14 -0800 Subject: [PATCH] Breaking bright - Fix crumbling having an incorrect draw buffer bound, causing it to appear too bright on indirect --- .../flywheel/backend/engine/indirect/IndirectBuffers.java | 6 ++---- .../backend/engine/indirect/IndirectCullingGroup.java | 8 +++----- .../backend/engine/indirect/IndirectDrawManager.java | 3 +-- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/common/src/backend/java/dev/engine_room/flywheel/backend/engine/indirect/IndirectBuffers.java b/common/src/backend/java/dev/engine_room/flywheel/backend/engine/indirect/IndirectBuffers.java index 866150347..6280dfc6e 100644 --- a/common/src/backend/java/dev/engine_room/flywheel/backend/engine/indirect/IndirectBuffers.java +++ b/common/src/backend/java/dev/engine_room/flywheel/backend/engine/indirect/IndirectBuffers.java @@ -109,11 +109,9 @@ public void bindForDraw() { GlBufferType.DRAW_INDIRECT_BUFFER.bind(draw.handle()); } - /** - * Bind all buffers except the draw command buffer. - */ public void bindForCrumbling() { - multiBind(1, 4); + // All we need is the instance buffer. Crumbling uses its own draw buffer. + multiBind(BufferBindings.INSTANCE, 1); } private void multiBind(int base, int count) { diff --git a/common/src/backend/java/dev/engine_room/flywheel/backend/engine/indirect/IndirectCullingGroup.java b/common/src/backend/java/dev/engine_room/flywheel/backend/engine/indirect/IndirectCullingGroup.java index 0f6e8ef57..9b56968d2 100644 --- a/common/src/backend/java/dev/engine_room/flywheel/backend/engine/indirect/IndirectCullingGroup.java +++ b/common/src/backend/java/dev/engine_room/flywheel/backend/engine/indirect/IndirectCullingGroup.java @@ -2,7 +2,6 @@ import static org.lwjgl.opengl.GL11.GL_TRIANGLES; import static org.lwjgl.opengl.GL11.GL_UNSIGNED_INT; -import static org.lwjgl.opengl.GL30.glUniform1ui; import static org.lwjgl.opengl.GL42.GL_COMMAND_BARRIER_BIT; import static org.lwjgl.opengl.GL42.glMemoryBarrier; import static org.lwjgl.opengl.GL43.glDispatchCompute; @@ -215,8 +214,8 @@ public void submit(VisualType visualType) { } } - public void bindWithContextShader(ContextShader override, Material material) { - var program = programs.getIndirectProgram(instanceType, override, material); + public void bindForCrumbling(Material material) { + var program = programs.getIndirectProgram(instanceType, ContextShader.CRUMBLING, material); program.bind(); @@ -224,8 +223,7 @@ public void bindWithContextShader(ContextShader override, Material material) { drawBarrier(); - var flwBaseDraw = program.getUniformLocation("_flw_baseDraw"); - glUniform1ui(flwBaseDraw, 0); + program.setUInt("_flw_baseDraw", 0); } private void drawBarrier() { diff --git a/common/src/backend/java/dev/engine_room/flywheel/backend/engine/indirect/IndirectDrawManager.java b/common/src/backend/java/dev/engine_room/flywheel/backend/engine/indirect/IndirectDrawManager.java index 65c0d4aba..7fab5d55e 100644 --- a/common/src/backend/java/dev/engine_room/flywheel/backend/engine/indirect/IndirectDrawManager.java +++ b/common/src/backend/java/dev/engine_room/flywheel/backend/engine/indirect/IndirectDrawManager.java @@ -17,7 +17,6 @@ import dev.engine_room.flywheel.api.instance.InstanceType; import dev.engine_room.flywheel.api.visualization.VisualType; import dev.engine_room.flywheel.backend.Samplers; -import dev.engine_room.flywheel.backend.compile.ContextShader; import dev.engine_room.flywheel.backend.compile.IndirectPrograms; import dev.engine_room.flywheel.backend.engine.AbstractInstancer; import dev.engine_room.flywheel.backend.engine.CommonCrumbling; @@ -235,7 +234,7 @@ public void renderCrumbling(List crumblingBlocks) { // Transform the material to be suited for crumbling. CommonCrumbling.applyCrumblingProperties(crumblingMaterial, draw.material()); - cullingGroup.bindWithContextShader(ContextShader.CRUMBLING, crumblingMaterial); + cullingGroup.bindForCrumbling(crumblingMaterial); MaterialRenderState.setup(crumblingMaterial);