From 16025206246ae615233cc7b594bd1e4c4d0760cc Mon Sep 17 00:00:00 2001 From: Klesti Selimaj Date: Sun, 27 Sep 2026 18:26:42 +0200 Subject: [PATCH] Blur behind Saturn's screens on 1.21.6+ From 1.21.6 vanilla's renderBackground drew its own panorama and blurred at the vanilla setting, then Saturn's panorama was drawn unblurred on top. SaturnScreenFabric now draws Saturn's panorama in renderBackground, blurs it and keeps vanilla's darkening in a world, and GameRendererMixin gives the blur shader Saturn's strength while a Saturn screen is open. Before 1.21.6 the existing blur reads the same setting. Co-Authored-By: Claude Opus 5.5 --- .../mixins/render/GameRendererMixin.java | 22 +++++++++ .../impl/ui/SaturnScreenFabric.java | 45 +++++++++++++------ 2 files changed, 54 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/saturnclient/impl/features/mixins/render/GameRendererMixin.java b/src/main/java/org/saturnclient/impl/features/mixins/render/GameRendererMixin.java index 82ccd2c..be65e23 100644 --- a/src/main/java/org/saturnclient/impl/features/mixins/render/GameRendererMixin.java +++ b/src/main/java/org/saturnclient/impl/features/mixins/render/GameRendererMixin.java @@ -1,12 +1,20 @@ package org.saturnclient.impl.features.mixins.render; +//? if >=1.21.6 +import net.minecraft.client.MinecraftClient; +//? if >=1.21.6 +import net.minecraft.client.option.GameOptions; import net.minecraft.client.render.GameRenderer; +//? if >=1.21.6 +import org.saturnclient.impl.ui.SaturnScreenFabric; import org.saturnclient.mod.mods.FreelookMod; import org.saturnclient.mod.mods.ZoomMod; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; +//? if >=1.21.6 +import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; /** @@ -38,4 +46,18 @@ public class GameRendererMixin { cir.setReturnValue(zoomedFov); } } + + //? if >=1.21.6 { + // From 1.21.6 the menu blur's strength is the vanilla setting, read here every frame. While a + // Saturn screen is open, it's Saturn's background blur instead, faded in with the screen. + @Redirect(method = "render", at = @At(value = "INVOKE", + target = "Lnet/minecraft/client/option/GameOptions;getMenuBackgroundBlurrinessValue()I")) + private int useSaturnBlur(GameOptions options) { + if (MinecraftClient.getInstance().currentScreen instanceof SaturnScreenFabric saturnScreen) { + return saturnScreen.screen.getBackgroundBlur(); + } + + return options.getMenuBackgroundBlurrinessValue(); + } + //?} } diff --git a/src/main/java/org/saturnclient/impl/ui/SaturnScreenFabric.java b/src/main/java/org/saturnclient/impl/ui/SaturnScreenFabric.java index ece14a2..827db8a 100644 --- a/src/main/java/org/saturnclient/impl/ui/SaturnScreenFabric.java +++ b/src/main/java/org/saturnclient/impl/ui/SaturnScreenFabric.java @@ -89,25 +89,18 @@ public class SaturnScreenFabric extends Screen implements ScreenProvider { mouseX *= 2; mouseY *= 2; - // From 1.21.6 the panorama renderer has no opacity (and takes no delta), so it's drawn fully - // opaque there. - if (panoramaReady && client.world == null && client.getCurrentServerEntry() == null) { - //? if >=1.21.6 { - ROTATING_PANORAMA_RENDERER.render(context, this.width, this.height, true); - //?} else - //ROTATING_PANORAMA_RENDERER.render(context, this.width, this.height, screen.backgroundOpacity, delta); + // From 1.21.6 the background, blur included, is drawn in renderBackground. + //? if <1.21.6 { + /*if (isShowingPanorama()) { + ROTATING_PANORAMA_RENDERER.render(context, this.width, this.height, screen.backgroundOpacity, delta); } - // TODO: the background blur (screen.backgroundBlur) is only drawn before 1.21.6 so far. See - // also issue #23. - - //? if <1.21.6 { - /*PostEffectProcessor postEffectProcessor = this.client.getShaderLoader().loadPostEffect( + PostEffectProcessor postEffectProcessor = this.client.getShaderLoader().loadPostEffect( Identifier.ofVanilla("blur"), DefaultFramebufferSet.MAIN_ONLY); if (postEffectProcessor != null) { - float radius = screen.backgroundBlur * Math.min((float) elapsed / 700, 1.0f); + float radius = screen.getBackgroundBlur(); //? if >=1.21.5 postEffectProcessor.render(this.client.getFramebuffer(), this.pool, pass -> pass.setUniform("Radius", radius)); //? if <1.21.5 @@ -122,6 +115,32 @@ public class SaturnScreenFabric extends Screen implements ScreenProvider { screen.render(renderScope, mouseX, mouseY, delta, elapsed); } + //? if >=1.21.6 { + // Vanilla's background would cover Saturn's panorama, and blurs by the vanilla setting. The + // strength of this blur comes from GameRendererMixin, which gives Saturn's setting instead. + @Override + public void renderBackground(DrawContext context, int mouseX, int mouseY, float delta) { + // The panorama renderer has no opacity (and takes no delta) from 1.21.6, so it's drawn fully + // opaque. + if (isShowingPanorama()) { + ROTATING_PANORAMA_RENDERER.render(context, this.width, this.height, true); + } + + if (screen.getBackgroundBlur() >= 1) { + context.applyBlur(); + } + + if (client.world != null) { + renderDarkening(context); + } + } + //?} + + /** Whether Saturn's panorama is behind the screen: outside a world, once it's loaded. */ + private boolean isShowingPanorama() { + return panoramaReady && client.world == null && client.getCurrentServerEntry() == null; + } + // 1.21.9 moved mouse and key events to Click and KeyInput. //? if >=1.21.9 { @Override