Add GUI scale and glass on every version #40

Merged
selimaj-dev merged 11 commits from glass-blur into master 2026-09-28 20:02:50 +00:00
3 changed files with 60 additions and 5 deletions
Showing only changes of commit 254a37d757 - Show all commits
+1 -1
Submodule common updated: 524fc36bf3...7cc37b7c74
@@ -28,6 +28,7 @@ import com.mojang.blaze3d.textures.FilterMode;
import com.mojang.blaze3d.textures.GpuTextureView; import com.mojang.blaze3d.textures.GpuTextureView;
import com.mojang.serialization.JsonOps; import com.mojang.serialization.JsonOps;
import org.saturnclient.config.Config;
import org.saturnclient.saturnclient.SaturnClient; import org.saturnclient.saturnclient.SaturnClient;
import net.minecraft.client.gl.Framebuffer; import net.minecraft.client.gl.Framebuffer;
@@ -86,6 +87,7 @@ public final class GlassRenderer {
processor.render(backdrop, POOL); processor.render(backdrop, POOL);
} }
POOL.decrementLifespan(); POOL.decrementLifespan();
release(blur);
} }
// The mask, then the copy blurred by blur, as the glass pipeline samples them // The mask, then the copy blurred by blur, as the glass pipeline samples them
@@ -97,6 +99,28 @@ public final class GlassRenderer {
//return TextureSetup.of(mask.getGlTextureView(), backdrop); //return TextureSetup.of(mask.getGlTextureView(), backdrop);
} }
// Frees the copies and blurs of strengths that are no longer set, besides kept
private static void release(int kept) {
BACKDROPS.entrySet().removeIf(entry -> {
boolean unused = entry.getKey() != kept && !isSet(entry.getKey());
if (unused) {
entry.getValue().delete();
}
return unused;
});
BLURS.entrySet().removeIf(entry -> {
boolean unused = entry.getKey() != kept && !isSet(entry.getKey());
if (unused && entry.getValue() != null) {
entry.getValue().close();
}
return unused;
});
}
private static boolean isSet(int blur) {
return blur == Config.menuBlur.value || blur == Config.widgetBlur.value;
}
private static PostEffectProcessor getBlur(int blur) { private static PostEffectProcessor getBlur(int blur) {
if (!BLURS.containsKey(blur)) { if (!BLURS.containsKey(blur)) {
BLURS.put(blur, loadBlur(blur)); BLURS.put(blur, loadBlur(blur));
@@ -141,6 +165,7 @@ import com.mojang.blaze3d.pipeline.RenderPipeline;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.textures.FilterMode; import com.mojang.blaze3d.textures.FilterMode;
import org.saturnclient.config.Config;
import org.saturnclient.saturnclient.SaturnClient; import org.saturnclient.saturnclient.SaturnClient;
import net.minecraft.client.gl.Framebuffer; import net.minecraft.client.gl.Framebuffer;
@@ -191,6 +216,7 @@ public final class GlassRenderer {
processor.render(backdrop, POOL, pass -> pass.setUniform("Radius", (float) blur)); processor.render(backdrop, POOL, pass -> pass.setUniform("Radius", (float) blur));
} }
POOL.decrementLifespan(); POOL.decrementLifespan();
release(blur);
} }
// Draws glass through mask with the copy blurred by blur // Draws glass through mask with the copy blurred by blur
@@ -206,6 +232,18 @@ public final class GlassRenderer {
.build(false))); .build(false)));
} }
// Frees the copies of strengths that are no longer set, besides kept
private static void release(int kept) {
BACKDROPS.entrySet().removeIf(entry -> {
boolean unused = entry.getKey() != kept && entry.getKey() != Config.menuBlur.value
&& entry.getKey() != Config.widgetBlur.value;
if (unused) {
entry.getValue().delete();
}
return unused;
});
}
// Copies from into to, made or resized to match // Copies from into to, made or resized to match
private static SimpleFramebuffer copy(Framebuffer from, SimpleFramebuffer to, String name) { private static SimpleFramebuffer copy(Framebuffer from, SimpleFramebuffer to, String name) {
int width = from.textureWidth; int width = from.textureWidth;
@@ -233,6 +271,7 @@ import org.lwjgl.opengl.GL30;
import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import org.saturnclient.config.Config;
import org.saturnclient.saturnclient.SaturnClient; import org.saturnclient.saturnclient.SaturnClient;
import net.minecraft.client.gl.Defines; import net.minecraft.client.gl.Defines;
@@ -284,6 +323,7 @@ public final class GlassRenderer {
processor.render(backdrop, POOL); processor.render(backdrop, POOL);
} }
POOL.decrementLifespan(); POOL.decrementLifespan();
release(blur);
SaturnClient.client.getFramebuffer().beginWrite(false); SaturnClient.client.getFramebuffer().beginWrite(false);
} }
@@ -302,6 +342,18 @@ public final class GlassRenderer {
.build(false))); .build(false)));
} }
// Frees the copies of strengths that are no longer set, besides kept
private static void release(int kept) {
BACKDROPS.entrySet().removeIf(entry -> {
boolean unused = entry.getKey() != kept && entry.getKey() != Config.menuBlur.value
&& entry.getKey() != Config.widgetBlur.value;
if (unused) {
entry.getValue().delete();
}
return unused;
});
}
// Copies from into to, made or resized to match // Copies from into to, made or resized to match
private static SimpleFramebuffer copy(Framebuffer from, SimpleFramebuffer to) { private static SimpleFramebuffer copy(Framebuffer from, SimpleFramebuffer to) {
int width = from.textureWidth; int width = from.textureWidth;
@@ -3,6 +3,7 @@ package org.saturnclient.impl.ui;
import java.time.Duration; import java.time.Duration;
import java.time.Instant; import java.time.Instant;
import org.saturnclient.config.Config;
import org.saturnclient.ui.RenderScope; import org.saturnclient.ui.RenderScope;
import org.saturnclient.ui.SaturnScreen; import org.saturnclient.ui.SaturnScreen;
import org.saturnclient.ui.SaturnScreen.ScreenProvider; import org.saturnclient.ui.SaturnScreen.ScreenProvider;
@@ -98,15 +99,17 @@ public class SaturnScreenFabric extends Screen implements ScreenProvider {
} }
// Glass is blurred from the game as it is before this screen blurs it. // Glass is blurred from the game as it is before this screen blurs it.
context.draw(); if (Config.usesGlass()) {
GlassRenderer.saveBackground(); context.draw();
GlassRenderer.saveBackground();
}
PostEffectProcessor postEffectProcessor = this.client.getShaderLoader().loadPostEffect( float radius = screen.getBackgroundBlur();
PostEffectProcessor postEffectProcessor = radius < 1 ? null : this.client.getShaderLoader().loadPostEffect(
Identifier.ofVanilla("blur"), Identifier.ofVanilla("blur"),
DefaultFramebufferSet.MAIN_ONLY); DefaultFramebufferSet.MAIN_ONLY);
if (postEffectProcessor != null) { if (postEffectProcessor != null) {
float radius = screen.getBackgroundBlur();
//? if >=1.21.5 //? if >=1.21.5
postEffectProcessor.render(this.client.getFramebuffer(), this.pool, pass -> pass.setUniform("Radius", radius)); postEffectProcessor.render(this.client.getFramebuffer(), this.pool, pass -> pass.setUniform("Radius", radius));
//? if <1.21.5 //? if <1.21.5