blend state setup

This commit is contained in:
mcrcortex
2025-08-18 12:37:23 +10:00
parent 3b113e4914
commit 9c74f92147
2 changed files with 31 additions and 1 deletions

View File

@@ -15,6 +15,7 @@ import java.util.function.IntSupplier;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL33.*;
import static org.lwjgl.opengl.GL40.glBlendFuncSeparatei;
public class IrisShaderPatch {
public static final int VERSION = ((IntSupplier)()->1).getAsInt();
@@ -160,6 +161,35 @@ public class IrisShaderPatch {
return this.patchData.translucentDrawBuffers;
}
public Runnable createBlendSetup() {
if (this.patchData.blending == null || this.patchData.blending.isEmpty()) {
return ()->{};//No blending change
}
return ()->{
final var BS = this.patchData.blending;
//Set inital state
var init = BS.getOrDefault(-1, null);
if (init != null) {
if (init.off) {
glDisable(GL_BLEND);
} else {
glEnable(GL_BLEND);
glBlendFuncSeparate(init.sRBG, init.dRGb, init.sA, init.dA);
}
}
for (var entry:BS.int2ObjectEntrySet()) {
if (entry.getIntKey() == -1) continue;
final var s = entry.getValue();
if (s.off) {
glDisablei(GL_BLEND, s.buffer);
} else {
glEnablei(GL_BLEND, s.buffer);
glBlendFuncSeparatei(s.buffer, s.sRBG, s.dRGb, s.sA, s.dA);
}
}
};
}
private static final Gson GSON = new GsonBuilder()
.excludeFieldsWithModifiers(Modifier.PRIVATE)
.setStrictness(Strictness.LENIENT)

View File

@@ -73,7 +73,7 @@ public class IrisVoxyRenderPipelineData {
//TODO: need to transform the string patch with the uniform decleration aswell as sampler declerations
return new IrisVoxyRenderPipelineData(patch, opaqueDrawTargets, translucentDrawTargets, uniforms, null);
return new IrisVoxyRenderPipelineData(patch, opaqueDrawTargets, translucentDrawTargets, uniforms, patch.createBlendSetup());
}
private static int[] getDrawBuffers(int[] targets, ImmutableSet<Integer> stageWritesToAlt, RenderTargets rt) {