diff --git a/src/main/java/net/coderbot/iris/compliance/ComplianceVersion.java b/src/main/java/net/coderbot/iris/compliance/ComplianceVersion.java new file mode 100644 index 0000000000..a0a3c16d4a --- /dev/null +++ b/src/main/java/net/coderbot/iris/compliance/ComplianceVersion.java @@ -0,0 +1,30 @@ +package net.coderbot.iris.compliance; + +import net.coderbot.iris.Iris; + +public enum ComplianceVersion { + NO_COMPLIANCE, + v1; + + public int getInternalComplianceLevel() { + switch (this) { + case NO_COMPLIANCE -> { + return 0; + } + case v1 -> { + return 1; + } + default -> throw new IllegalStateException("Impossible, compliance is not existing? " + this.name()); + } + } + + public static ComplianceVersion getComplianceLevel(String compliance) { + try { + int complianceL = Integer.parseInt(compliance); + return ComplianceVersion.valueOf("v" + complianceL); + } catch (IllegalArgumentException e) { + Iris.logger.warn("Unknown compliance: " + compliance + "; defaulting to NONCOMPLIANT."); + return NO_COMPLIANCE; + } + } +} diff --git a/src/main/java/net/coderbot/iris/gl/BooleanStateExtended.java b/src/main/java/net/coderbot/iris/gl/BooleanStateExtended.java new file mode 100644 index 0000000000..6abb45414d --- /dev/null +++ b/src/main/java/net/coderbot/iris/gl/BooleanStateExtended.java @@ -0,0 +1,5 @@ +package net.coderbot.iris.gl; + +public interface BooleanStateExtended { + void setUnknownState(); +} diff --git a/src/main/java/net/coderbot/iris/gl/IrisRenderSystem.java b/src/main/java/net/coderbot/iris/gl/IrisRenderSystem.java index 440d213b36..6b4e84fb8a 100644 --- a/src/main/java/net/coderbot/iris/gl/IrisRenderSystem.java +++ b/src/main/java/net/coderbot/iris/gl/IrisRenderSystem.java @@ -299,11 +299,13 @@ public static boolean supportsBufferBlending() { public static void disableBufferBlend(int buffer) { RenderSystem.assertOnRenderThreadOrInit(); GL32C.glDisablei(GL32C.GL_BLEND, buffer); + ((BooleanStateExtended) GlStateManagerAccessor.getBLEND().mode).setUnknownState(); } public static void enableBufferBlend(int buffer) { RenderSystem.assertOnRenderThreadOrInit(); GL32C.glEnablei(GL32C.GL_BLEND, buffer); + ((BooleanStateExtended) GlStateManagerAccessor.getBLEND().mode).setUnknownState(); } public static void blendFuncSeparatei(int buffer, int srcRGB, int dstRGB, int srcAlpha, int dstAlpha) { diff --git a/src/main/java/net/coderbot/iris/mixin/MixinBooleanState.java b/src/main/java/net/coderbot/iris/mixin/MixinBooleanState.java new file mode 100644 index 0000000000..edb1815624 --- /dev/null +++ b/src/main/java/net/coderbot/iris/mixin/MixinBooleanState.java @@ -0,0 +1,42 @@ +package net.coderbot.iris.mixin; + +import com.mojang.blaze3d.platform.GlStateManager; +import net.coderbot.iris.gl.BooleanStateExtended; +import org.lwjgl.opengl.GL11; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(GlStateManager.BooleanState.class) +public class MixinBooleanState implements BooleanStateExtended { + @Shadow + @Final + private int state; + @Shadow + public boolean enabled; + @Unique + private boolean stateUnknown; + + @Inject(method = "setEnabled", at = @At("HEAD"), cancellable = true) + private void iris$setUnknownState(boolean enable, CallbackInfo ci) { + if (stateUnknown) { + ci.cancel(); + this.enabled = enable; + stateUnknown = false; + if (enable) { + GL11.glEnable(this.state); + } else { + GL11.glDisable(this.state); + } + } + } + + @Override + public void setUnknownState() { + stateUnknown = true; + } +} diff --git a/src/main/java/net/coderbot/iris/mixin/MixinTweakFarPlane.java b/src/main/java/net/coderbot/iris/mixin/MixinTweakFarPlane.java index e5ad02f97b..f67f9db3d2 100644 --- a/src/main/java/net/coderbot/iris/mixin/MixinTweakFarPlane.java +++ b/src/main/java/net/coderbot/iris/mixin/MixinTweakFarPlane.java @@ -31,6 +31,10 @@ * * Fun. */ + +/** + * Due to shader devs moving forward with removing legacy code, I have decided to disable this Mixin. It will be stored here for reference. -IMS + */ @Mixin(GameRenderer.class) public class MixinTweakFarPlane { @Shadow diff --git a/src/main/java/net/coderbot/iris/pipeline/ShadowRenderer.java b/src/main/java/net/coderbot/iris/pipeline/ShadowRenderer.java index f0a4570e68..feeda4fcbe 100644 --- a/src/main/java/net/coderbot/iris/pipeline/ShadowRenderer.java +++ b/src/main/java/net/coderbot/iris/pipeline/ShadowRenderer.java @@ -340,7 +340,7 @@ private FrustumHolder createShadowFrustum(float renderMultiplier, FrustumHolder if (isReversed) { return holder.setInfo(new ReversedAdvancedShadowCullingFrustum(CapturedRenderingState.INSTANCE.getGbufferModelView(), - CapturedRenderingState.INSTANCE.getGbufferProjection(), shadowLightVectorFromOrigin, boxCuller), distanceInfo, cullingInfo); + CapturedRenderingState.INSTANCE.getGbufferProjection(), shadowLightVectorFromOrigin, boxCuller, new BoxCuller(halfPlaneLength * renderMultiplier)), distanceInfo, cullingInfo); } else { return holder.setInfo(new AdvancedShadowCullingFrustum(CapturedRenderingState.INSTANCE.getGbufferModelView(), CapturedRenderingState.INSTANCE.getGbufferProjection(), shadowLightVectorFromOrigin, boxCuller), distanceInfo, cullingInfo); diff --git a/src/main/java/net/coderbot/iris/postprocess/CompositeRenderer.java b/src/main/java/net/coderbot/iris/postprocess/CompositeRenderer.java index f42a6dbc9f..9bda863650 100644 --- a/src/main/java/net/coderbot/iris/postprocess/CompositeRenderer.java +++ b/src/main/java/net/coderbot/iris/postprocess/CompositeRenderer.java @@ -278,6 +278,8 @@ public void renderAll() { renderPass.program.use(); if (renderPass.blendModeOverride != null) { renderPass.blendModeOverride.apply(); + } else { + RenderSystem.disableBlend(); } // program is the identifier for composite :shrug: diff --git a/src/main/java/net/coderbot/iris/shadows/frustum/advanced/ReversedAdvancedShadowCullingFrustum.java b/src/main/java/net/coderbot/iris/shadows/frustum/advanced/ReversedAdvancedShadowCullingFrustum.java index c2dd4c889c..c9ea92b922 100644 --- a/src/main/java/net/coderbot/iris/shadows/frustum/advanced/ReversedAdvancedShadowCullingFrustum.java +++ b/src/main/java/net/coderbot/iris/shadows/frustum/advanced/ReversedAdvancedShadowCullingFrustum.java @@ -7,12 +7,27 @@ import org.joml.Vector3f; public class ReversedAdvancedShadowCullingFrustum extends AdvancedShadowCullingFrustum { - public ReversedAdvancedShadowCullingFrustum(Matrix4f playerView, Matrix4f playerProjection, Vector3f shadowLightVectorFromOrigin, BoxCuller boxCuller) { - super(playerView, playerProjection, shadowLightVectorFromOrigin, boxCuller); + private final BoxCuller distanceCuller; + + public ReversedAdvancedShadowCullingFrustum(Matrix4f playerView, Matrix4f playerProjection, Vector3f shadowLightVectorFromOrigin, BoxCuller voxelCuller, BoxCuller distanceCuller) { + super(playerView, playerProjection, shadowLightVectorFromOrigin, voxelCuller); + this.distanceCuller = distanceCuller; + } + + @Override + public void prepare(double cameraX, double cameraY, double cameraZ) { + if (this.distanceCuller != null) { + this.distanceCuller.setPosition(cameraX, cameraY, cameraZ); + } + super.prepare(cameraX, cameraY, cameraZ); } @Override public boolean isVisible(AABB aabb) { + if (distanceCuller != null && distanceCuller.isCulled(aabb)) { + return false; + } + if (boxCuller != null && !boxCuller.isCulled(aabb)) { return true; } @@ -22,6 +37,10 @@ public boolean isVisible(AABB aabb) { @Override public int fastAabbTest(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) { + if (distanceCuller != null && distanceCuller.isCulled(minX, minY, minZ, maxX, maxY, maxZ)) { + return 0; + } + if (boxCuller != null && !boxCuller.isCulled(minX, minY, minZ, maxX, maxY, maxZ)) { return 2; } diff --git a/src/main/resources/iris.accesswidener b/src/main/resources/iris.accesswidener index edaf35905d..6d3e780aea 100644 --- a/src/main/resources/iris.accesswidener +++ b/src/main/resources/iris.accesswidener @@ -1,6 +1,7 @@ accessWidener v1 named accessible class com/mojang/blaze3d/platform/GlStateManager$BlendState +accessible class com/mojang/blaze3d/platform/GlStateManager$BooleanState accessible class com/mojang/blaze3d/platform/GlStateManager$TextureState accessible class com/mojang/blaze3d/platform/GlStateManager$ColorMask accessible class com/mojang/blaze3d/platform/GlStateManager$DepthState @@ -30,3 +31,4 @@ mutable field net/minecraft/client/renderer/ShaderInstance COLOR_MODULATOR Lcom/ accessible field net/minecraft/client/renderer/ShaderInstance uniforms Ljava/util/List; mutable field net/minecraft/client/renderer/LevelRenderer renderBuffers Lnet/minecraft/client/renderer/RenderBuffers; accessible class net/minecraft/client/gui/components/AbstractSelectionList$Entry +accessible field com/mojang/blaze3d/platform/GlStateManager$BooleanState enabled Z diff --git a/src/main/resources/mixins.iris.json b/src/main/resources/mixins.iris.json index 9f9e1ab27b..d8887faa96 100644 --- a/src/main/resources/mixins.iris.json +++ b/src/main/resources/mixins.iris.json @@ -14,6 +14,7 @@ "MixinBiome", "MixinBiomes", "MixinChainedJsonException", + "MixinBooleanState", "MixinClientLanguage", "MixinClientPacketListener", "MixinDebugScreenOverlay", @@ -47,7 +48,6 @@ "MixinShaderInstance", "MixinTheEndPortalRenderer", "MixinTitleScreen", - "MixinTweakFarPlane", "MixinLightTexture", "MixinWindow", "MixinSystemReport",