Breaking bright

- Fix crumbling having an incorrect draw buffer bound, causing it to
  appear too bright on indirect
This commit is contained in:
Jozufozu 2024-11-17 12:24:14 -08:00
parent 3b7f9c7770
commit 7148ff3f31
3 changed files with 6 additions and 11 deletions

View file

@ -109,11 +109,9 @@ public class IndirectBuffers {
GlBufferType.DRAW_INDIRECT_BUFFER.bind(draw.handle()); GlBufferType.DRAW_INDIRECT_BUFFER.bind(draw.handle());
} }
/**
* Bind all buffers except the draw command buffer.
*/
public void bindForCrumbling() { 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) { private void multiBind(int base, int count) {

View file

@ -2,7 +2,6 @@ package dev.engine_room.flywheel.backend.engine.indirect;
import static org.lwjgl.opengl.GL11.GL_TRIANGLES; import static org.lwjgl.opengl.GL11.GL_TRIANGLES;
import static org.lwjgl.opengl.GL11.GL_UNSIGNED_INT; 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.GL_COMMAND_BARRIER_BIT;
import static org.lwjgl.opengl.GL42.glMemoryBarrier; import static org.lwjgl.opengl.GL42.glMemoryBarrier;
import static org.lwjgl.opengl.GL43.glDispatchCompute; import static org.lwjgl.opengl.GL43.glDispatchCompute;
@ -215,8 +214,8 @@ public class IndirectCullingGroup<I extends Instance> {
} }
} }
public void bindWithContextShader(ContextShader override, Material material) { public void bindForCrumbling(Material material) {
var program = programs.getIndirectProgram(instanceType, override, material); var program = programs.getIndirectProgram(instanceType, ContextShader.CRUMBLING, material);
program.bind(); program.bind();
@ -224,8 +223,7 @@ public class IndirectCullingGroup<I extends Instance> {
drawBarrier(); drawBarrier();
var flwBaseDraw = program.getUniformLocation("_flw_baseDraw"); program.setUInt("_flw_baseDraw", 0);
glUniform1ui(flwBaseDraw, 0);
} }
private void drawBarrier() { private void drawBarrier() {

View file

@ -17,7 +17,6 @@ import dev.engine_room.flywheel.api.instance.Instance;
import dev.engine_room.flywheel.api.instance.InstanceType; import dev.engine_room.flywheel.api.instance.InstanceType;
import dev.engine_room.flywheel.api.visualization.VisualType; import dev.engine_room.flywheel.api.visualization.VisualType;
import dev.engine_room.flywheel.backend.Samplers; 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.compile.IndirectPrograms;
import dev.engine_room.flywheel.backend.engine.AbstractInstancer; import dev.engine_room.flywheel.backend.engine.AbstractInstancer;
import dev.engine_room.flywheel.backend.engine.CommonCrumbling; import dev.engine_room.flywheel.backend.engine.CommonCrumbling;
@ -235,7 +234,7 @@ public class IndirectDrawManager extends DrawManager<IndirectInstancer<?>> {
// Transform the material to be suited for crumbling. // Transform the material to be suited for crumbling.
CommonCrumbling.applyCrumblingProperties(crumblingMaterial, draw.material()); CommonCrumbling.applyCrumblingProperties(crumblingMaterial, draw.material());
cullingGroup.bindWithContextShader(ContextShader.CRUMBLING, crumblingMaterial); cullingGroup.bindForCrumbling(crumblingMaterial);
MaterialRenderState.setup(crumblingMaterial); MaterialRenderState.setup(crumblingMaterial);