diff --git a/src/main/java/net/coderbot/iris/gl/state/StateUpdateNotifiers.java b/src/main/java/net/coderbot/iris/gl/state/StateUpdateNotifiers.java index ea8bbb9f6..29b9d4baf 100644 --- a/src/main/java/net/coderbot/iris/gl/state/StateUpdateNotifiers.java +++ b/src/main/java/net/coderbot/iris/gl/state/StateUpdateNotifiers.java @@ -6,4 +6,5 @@ package net.coderbot.iris.gl.state; public class StateUpdateNotifiers { public static ValueUpdateNotifier normalTextureChangeNotifier; public static ValueUpdateNotifier specularTextureChangeNotifier; + public static ValueUpdateNotifier phaseChangeNotifier; } diff --git a/src/main/java/net/coderbot/iris/layer/GbufferPrograms.java b/src/main/java/net/coderbot/iris/layer/GbufferPrograms.java index 75810c325..0a29899ac 100644 --- a/src/main/java/net/coderbot/iris/layer/GbufferPrograms.java +++ b/src/main/java/net/coderbot/iris/layer/GbufferPrograms.java @@ -4,6 +4,7 @@ import net.coderbot.iris.Iris; import net.coderbot.iris.gbuffer_overrides.matching.SpecialCondition; import com.gtnewhorizons.angelica.glsm.GLStateManager; import net.coderbot.iris.gl.shader.ProgramCreator; +import net.coderbot.iris.gl.state.StateUpdateNotifiers; import net.coderbot.iris.pipeline.WorldRenderingPhase; import net.coderbot.iris.pipeline.WorldRenderingPipeline; @@ -11,7 +12,12 @@ public class GbufferPrograms { private static boolean entities; private static boolean blockEntities; private static boolean outline; - + private static Runnable phaseChangeListener; + + static { + StateUpdateNotifiers.phaseChangeNotifier = listener -> phaseChangeListener = listener; + } + private static void checkReentrancy() { if (entities || blockEntities || outline) { throw new IllegalStateException("GbufferPrograms in weird state, tried to call begin function when entities = " @@ -106,7 +112,13 @@ public class GbufferPrograms { public static void teardownSpecialRenderCondition() { Iris.getPipelineManager().getPipeline().ifPresent(p -> p.setSpecialCondition(null)); } - + + public static void runPhaseChangeNotifier() { + if (phaseChangeListener != null) { + phaseChangeListener.run(); + } + } + public static void init() { // Empty initializer to run static } diff --git a/src/main/java/net/coderbot/iris/pipeline/DeferredWorldRenderingPipeline.java b/src/main/java/net/coderbot/iris/pipeline/DeferredWorldRenderingPipeline.java index 5e17a542c..bcd2be94a 100644 --- a/src/main/java/net/coderbot/iris/pipeline/DeferredWorldRenderingPipeline.java +++ b/src/main/java/net/coderbot/iris/pipeline/DeferredWorldRenderingPipeline.java @@ -41,6 +41,7 @@ import net.coderbot.iris.gl.state.FogMode; import net.coderbot.iris.gl.texture.DepthBufferFormat; import net.coderbot.iris.gl.texture.TextureType; import net.coderbot.iris.helpers.Tri; +import net.coderbot.iris.layer.GbufferPrograms; import net.coderbot.iris.pipeline.transform.PatchShaderType; import net.coderbot.iris.pipeline.transform.TransformPatcher; import net.coderbot.iris.postprocess.BufferFlipper; @@ -774,10 +775,10 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R if (!isRenderingWorld || isRenderingFullScreenPass || isPostChain || !isMainBound) { return; } - + final RenderCondition condition = getCondition(getPhase()); final Pass matched = table.match(condition, inputs); - + beginPass(matched); } @@ -1656,12 +1657,14 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R public void setOverridePhase(WorldRenderingPhase phase) { this.overridePhase = phase; matchPass(); + GbufferPrograms.runPhaseChangeNotifier(); } @Override public void setPhase(WorldRenderingPhase phase) { this.phase = phase; matchPass(); + GbufferPrograms.runPhaseChangeNotifier(); } @Override diff --git a/src/main/java/net/coderbot/iris/uniforms/CommonUniforms.java b/src/main/java/net/coderbot/iris/uniforms/CommonUniforms.java index 04acc25db..b4b36f259 100644 --- a/src/main/java/net/coderbot/iris/uniforms/CommonUniforms.java +++ b/src/main/java/net/coderbot/iris/uniforms/CommonUniforms.java @@ -9,6 +9,7 @@ import com.gtnewhorizons.angelica.client.rendering.TextureTracker; import com.gtnewhorizons.angelica.mixins.interfaces.EntityRendererAccessor; import net.coderbot.iris.compat.dh.DHCompat; import net.coderbot.iris.gl.state.FogMode; +import net.coderbot.iris.gl.state.StateUpdateNotifiers; import net.coderbot.iris.gl.state.ValueUpdateNotifier; import net.coderbot.iris.gl.uniform.DynamicUniformHolder; import net.coderbot.iris.gl.uniform.UniformHolder; @@ -100,7 +101,7 @@ public final class CommonUniforms { return ZERO_VECTOR_4i; }, ValueUpdateNotifier.NONE); - uniforms.uniform1i("renderStage", () -> GbufferPrograms.getCurrentPhase().ordinal(), ValueUpdateNotifier.NONE); + uniforms.uniform1i("renderStage", () -> GbufferPrograms.getCurrentPhase().ordinal(), StateUpdateNotifiers.phaseChangeNotifier); uniforms.uniform4f("entityColor", CapturedRenderingState.INSTANCE::getCurrentEntityColor, CapturedRenderingState.INSTANCE.getEntityColorNotifier());