Skip to content

Commit

Permalink
Breaking bright
Browse files Browse the repository at this point in the history
- Fix crumbling having an incorrect draw buffer bound, causing it to
  appear too bright on indirect
  • Loading branch information
Jozufozu committed Nov 17, 2024
1 parent 3b7f9c7 commit 7148ff3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -215,17 +214,16 @@ 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();

buffers.bindForCrumbling();

drawBarrier();

var flwBaseDraw = program.getUniformLocation("_flw_baseDraw");
glUniform1ui(flwBaseDraw, 0);
program.setUInt("_flw_baseDraw", 0);
}

private void drawBarrier() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -235,7 +234,7 @@ public void renderCrumbling(List<Engine.CrumblingBlock> 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);

Expand Down

0 comments on commit 7148ff3

Please sign in to comment.