Skip to content

Commit 6dcb7c5

Browse files
committed
Shader Background
1 parent e1afcac commit 6dcb7c5

12 files changed

Lines changed: 1160 additions & 0 deletions
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright (c) 2014-2026 Wurst-Imperium and contributors.
3+
*
4+
* This source code is subject to the terms of the GNU General Public
5+
* License, version 3. If a copy of the GPL was not distributed with this
6+
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
7+
*/
8+
package net.wurstclient;
9+
10+
import com.mojang.blaze3d.pipeline.RenderPipeline;
11+
import net.minecraft.client.renderer.BindGroupLayouts;
12+
import net.minecraft.client.renderer.RenderPipelines;
13+
import net.minecraft.resources.Identifier;
14+
15+
public enum TitleScreenShaderPipelines
16+
{
17+
;
18+
19+
public static final RenderPipeline TITLE_SHADERTOY_BACKGROUND =
20+
RenderPipelines.register(RenderPipeline
21+
.builder(RenderPipelines.GUI_SNIPPET)
22+
.withLocation(
23+
Identifier.parse("wurst:pipeline/title_shadertoy_background"))
24+
.withVertexShader(
25+
Identifier.parse("wurst:core/title_shadertoy_background"))
26+
.withFragmentShader(
27+
Identifier.parse("wurst:core/title_shadertoy_background"))
28+
.withBindGroupLayout(BindGroupLayouts.SAMPLER0).build());
29+
}

src/main/java/net/wurstclient/mixin/ScreenMixin.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,15 @@
1010
import org.spongepowered.asm.mixin.Mixin;
1111
import org.spongepowered.asm.mixin.injection.At;
1212
import org.spongepowered.asm.mixin.injection.Inject;
13+
import org.spongepowered.asm.mixin.injection.Redirect;
1314
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
1415
import net.minecraft.client.gui.GuiGraphicsExtractor;
1516
import net.minecraft.client.gui.components.Renderable;
1617
import net.minecraft.client.gui.components.events.AbstractContainerEventHandler;
1718
import net.minecraft.client.gui.screens.Screen;
19+
import net.minecraft.client.renderer.Panorama;
1820
import net.wurstclient.WurstClient;
21+
import net.wurstclient.util.TitleScreenBackgroundRenderer;
1922

2023
@Mixin(value = Screen.class, remap = false)
2124
public abstract class ScreenMixin extends AbstractContainerEventHandler
@@ -35,4 +38,22 @@ public void onExtractBackground(GuiGraphicsExtractor context, int mouseX,
3538
.shouldCancelBackground((Screen)(Object)this))
3639
ci.cancel();
3740
}
41+
42+
@Redirect(
43+
method = "extractPanorama(Lnet/minecraft/client/gui/GuiGraphicsExtractor;F)V",
44+
at = @At(value = "INVOKE",
45+
target = "Lnet/minecraft/client/renderer/Panorama;extractRenderState(Lnet/minecraft/client/gui/GuiGraphicsExtractor;II)V"))
46+
private void onExtractPanorama(Panorama panorama,
47+
GuiGraphicsExtractor context, int width, int height)
48+
{
49+
if(WurstClient.INSTANCE.shouldHideWurstUiMixins()
50+
|| !WurstClient.INSTANCE.getOtfs().wurstOptionsOtf
51+
.isTitleScreenShadertoyBackgroundEnabled())
52+
{
53+
panorama.extractRenderState(context, width, height);
54+
return;
55+
}
56+
57+
TitleScreenBackgroundRenderer.addBackground(context, width, height);
58+
}
3859
}

src/main/java/net/wurstclient/options/WurstOptionsScreen.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ private void addCoreSection()
165165
options.getCustomMojangLogoBackgroundSetting();
166166
CheckboxSetting customMultiplayerLayout =
167167
options.getCustomMultiplayerLayoutSetting();
168+
CheckboxSetting titleScreenShadertoyBackground =
169+
options.getTitleScreenShadertoyBackgroundSetting();
168170
ColorSetting mojangLogoBgColor =
169171
options.getMojangLogoBackgroundColorSetting();
170172
CheckboxSetting hideEnableButton =
@@ -209,6 +211,13 @@ private void addCoreSection()
209211
b -> customMultiplayerLayout
210212
.setChecked(!customMultiplayerLayout.isChecked()));
211213

214+
addButton(column,
215+
() -> "Shadertoy Background: "
216+
+ onOff(titleScreenShadertoyBackground.isChecked()),
217+
"Render a Shadertoy-style animated background behind the title screen.",
218+
b -> titleScreenShadertoyBackground
219+
.setChecked(!titleScreenShadertoyBackground.isChecked()));
220+
212221
addButton(column,
213222
() -> "Hide Enable Button: " + onOff(hideEnableButton.isChecked()),
214223
hideEnableButton.getDescription(),

src/main/java/net/wurstclient/other_features/WurstOptionsOtf.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ public final class WurstOptionsOtf extends OtherFeature
4646
"Custom multiplayer layout",
4747
"Use Wurst's custom multiplayer server panels and search bar.", true);
4848

49+
private final CheckboxSetting titleScreenShadertoyBackground =
50+
new CheckboxSetting("Shadertoy background",
51+
"Render the animated Shadertoy-style background on the title screen.",
52+
true);
53+
4954
private final ColorSetting mojangLogoBackgroundColor =
5055
new ColorSetting("Mojang logo background color", Color.BLACK);
5156

@@ -82,6 +87,7 @@ public void linkAdditionalSettings(DisableOtf disableOtf,
8287
addSetting(hackToggleChatFeedback);
8388
addSetting(customMojangLogoBackground);
8489
addSetting(customMultiplayerLayout);
90+
addSetting(titleScreenShadertoyBackground);
8591
addSetting(mojangLogoBackgroundColor);
8692
addSetting(disableOtf.getHideEnableButtonSetting());
8793
addSetting(noTelemetryOtf.getDisableTelemetrySetting());
@@ -126,6 +132,16 @@ public CheckboxSetting getCustomMultiplayerLayoutSetting()
126132
return customMultiplayerLayout;
127133
}
128134

135+
public CheckboxSetting getTitleScreenShadertoyBackgroundSetting()
136+
{
137+
return titleScreenShadertoyBackground;
138+
}
139+
140+
public boolean isTitleScreenShadertoyBackgroundEnabled()
141+
{
142+
return titleScreenShadertoyBackground.isChecked();
143+
}
144+
129145
public boolean isCustomMultiplayerLayoutEnabled()
130146
{
131147
return customMultiplayerLayout.isChecked();

src/main/java/net/wurstclient/util/CustomQuadRenderState.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,24 @@ public CustomQuadRenderState(Matrix3x2f pose, float x1, float y1, float x2,
4141
scissorArea);
4242
}
4343

44+
public CustomQuadRenderState(RenderPipeline pipeline, Matrix3x2f pose,
45+
float x1, float y1, float x2, float y2, float x3, float y3, float x4,
46+
float y4, int color1, int color2, int color3, int color4,
47+
@Nullable ScreenRectangle scissorArea)
48+
{
49+
this(pipeline, TextureSetup.noTexture(), pose, x1, y1, x2, y2, x3, y3,
50+
x4, y4, color1, color2, color3, color4, scissorArea,
51+
createBounds(x1, y1, x2, y2, x3, y3, x4, y4, pose, scissorArea));
52+
}
53+
54+
public CustomQuadRenderState(RenderPipeline pipeline, Matrix3x2f pose,
55+
float x1, float y1, float x2, float y2, float x3, float y3, float x4,
56+
float y4, int color, @Nullable ScreenRectangle scissorArea)
57+
{
58+
this(pipeline, pose, x1, y1, x2, y2, x3, y3, x4, y4, color, color,
59+
color, color, scissorArea);
60+
}
61+
4462
@Override
4563
public void buildVertices(VertexConsumer vertices)
4664
{
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (c) 2014-2026 Wurst-Imperium and contributors.
3+
*
4+
* This source code is subject to the terms of the GNU General Public
5+
* License, version 3. If a copy of the GPL was not distributed with this
6+
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
7+
*/
8+
package net.wurstclient.util;
9+
10+
import org.joml.Matrix3x2f;
11+
12+
import net.minecraft.client.gui.GuiGraphicsExtractor;
13+
import net.minecraft.client.gui.navigation.ScreenRectangle;
14+
import net.minecraft.client.gui.render.TextureSetup;
15+
import net.minecraft.client.Minecraft;
16+
import net.minecraft.client.renderer.texture.AbstractTexture;
17+
import net.minecraft.resources.Identifier;
18+
import net.wurstclient.TitleScreenShaderPipelines;
19+
20+
public enum TitleScreenBackgroundRenderer
21+
{
22+
;
23+
24+
private static final Identifier BLOCK_ATLAS =
25+
Identifier.parse("wurst:textures/shader_blocks.png");
26+
27+
public static void addBackground(GuiGraphicsExtractor context, int width,
28+
int height)
29+
{
30+
Matrix3x2f pose = new Matrix3x2f();
31+
ScreenRectangle bounds = new ScreenRectangle(0, 0, width, height);
32+
int time = (int)((System.currentTimeMillis() / 50L) & 0xFFFF);
33+
int timeColor = 0xFF0000FF | ((time >> 8) << 16) | ((time & 0xFF) << 8);
34+
AbstractTexture texture =
35+
Minecraft.getInstance().getTextureManager().getTexture(BLOCK_ATLAS);
36+
context.guiRenderState.addGuiElement(new CustomQuadRenderState(
37+
TitleScreenShaderPipelines.TITLE_SHADERTOY_BACKGROUND,
38+
TextureSetup.singleTexture(texture.getTextureView(),
39+
texture.getSampler()),
40+
pose, -1, -1, 1, -1, 1, 1, -1, 1, timeColor, timeColor, timeColor,
41+
timeColor, null, bounds));
42+
}
43+
}

0 commit comments

Comments
 (0)