Skip to content

Instantly share code, notes, and snippets.

@superblaubeere27
Last active June 9, 2020 12:29
Show Gist options
  • Select an option

  • Save superblaubeere27/c09e4f85f1e3f0b19d3e4d7dd1313df9 to your computer and use it in GitHub Desktop.

Select an option

Save superblaubeere27/c09e4f85f1e3f0b19d3e4d7dd1313df9 to your computer and use it in GitHub Desktop.

Revisions

  1. superblaubeere27 revised this gist Jun 9, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion shader_background.patch
    Original file line number Diff line number Diff line change
    @@ -59,7 +59,7 @@ Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    GlStateManager.enableAlpha();
    - Tessellator tessellator = Tessellator.getInstance();
    - WorldRenderer worldrenderer = tessellator.getWorldRenderer();
    +
    + GlStateManager.disableCull();
    int i = 274;
    int j = this.width / 2 - i / 2;
    int k = 30;
  2. superblaubeere27 created this gist Jun 7, 2020.
    87 changes: 87 additions & 0 deletions shader_background.patch
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,87 @@
    Index: src/minecraft/net/minecraft/client/gui/GuiMainMenu.java
    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    ===================================================================
    --- src/minecraft/net/minecraft/client/gui/GuiMainMenu.java (date 1591536256953)
    +++ src/minecraft/net/minecraft/client/gui/GuiMainMenu.java (date 1591536256953)
    @@ -25,10 +25,12 @@
    import net.minecraft.world.demo.DemoWorldServer;
    import net.minecraft.world.storage.ISaveFormat;
    import net.minecraft.world.storage.WorldInfo;
    +import net.superblaubeere27.glslsandboxrenderer.GLSLSandboxShader;
    import org.apache.commons.io.Charsets;
    import org.apache.logging.log4j.LogManager;
    import org.apache.logging.log4j.Logger;
    import org.lwjgl.opengl.GL11;
    +import org.lwjgl.opengl.GL20;
    import org.lwjgl.opengl.GLContext;
    import org.lwjgl.util.glu.Project;

    @@ -84,6 +86,9 @@
    /** Minecraft Realms button. */
    private GuiButton realmsButton;

    + private GLSLSandboxShader backgroundShader;
    + private long initTime = System.currentTimeMillis(); // Initialize as a failsafe
    +
    public GuiMainMenu()
    {
    this.openGLWarning2 = field_96138_a;
    @@ -147,6 +152,12 @@
    this.openGLWarning2 = I18n.format("title.oldgl2", new Object[0]);
    this.openGLWarningLink = "https://help.mojang.com/customer/portal/articles/325948?ref=game";
    }
    +
    + try {
    + this.backgroundShader = new GLSLSandboxShader("/noise.fsh");
    + } catch (IOException e) {
    + throw new IllegalStateException("Failed to load backgound shader", e);
    + }
    }

    /**
    @@ -225,6 +236,8 @@
    }

    this.mc.func_181537_a(false);
    +
    + initTime = System.currentTimeMillis();
    }

    /**
    @@ -503,16 +516,28 @@
    */
    public void drawScreen(int mouseX, int mouseY, float partialTicks)
    {
    - GlStateManager.disableAlpha();
    - this.renderSkybox(mouseX, mouseY, partialTicks);
    GlStateManager.enableAlpha();
    - Tessellator tessellator = Tessellator.getInstance();
    - WorldRenderer worldrenderer = tessellator.getWorldRenderer();
    +
    int i = 274;
    int j = this.width / 2 - i / 2;
    int k = 30;
    - this.drawGradientRect(0, 0, this.width, this.height, -2130706433, 16777215);
    - this.drawGradientRect(0, 0, this.width, this.height, 0, Integer.MIN_VALUE);
    +
    + this.backgroundShader.useShader(this.width, this.height, mouseX, mouseY, (System.currentTimeMillis() - initTime) / 1000f);
    +
    + GL11.glBegin(GL11.GL_QUADS);
    +
    + GL11.glVertex2f(-1f, -1f);
    + GL11.glVertex2f(-1f, 1f);
    + GL11.glVertex2f(1f, 1f);
    + GL11.glVertex2f(1f, -1f);
    +
    + GL11.glEnd();
    +
    + // Unbind shader
    + GL20.glUseProgram(0);
    +
    + // Stuff enabled done by the skybox rendering
    +
    this.mc.getTextureManager().bindTexture(minecraftTitleTextures);
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);