Skip to content

Commit

Permalink
Truly unbreak the UI
Browse files Browse the repository at this point in the history
  • Loading branch information
MEEPofFaith committed Feb 8, 2024
1 parent cd43544 commit 001fb88
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 23 deletions.
35 changes: 12 additions & 23 deletions src/drunkustry/graphics/DrunkRendering.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,29 @@
import mindustry.graphics.*;

import static arc.Core.*;
import static drunkustry.graphics.DrunkShaders.*;

public class DrunkRendering{
public static FrameBuffer colorBuffer;
public static FrameBuffer aberrationBuffer;
private static FrameBuffer distortionBuffer;
public static final float begin = Layer.min;
public static final float end = Layer.max;

public static void init(){
colorBuffer = new FrameBuffer();
aberrationBuffer = new FrameBuffer();
distortionBuffer = new FrameBuffer();

Events.run(Trigger.drawOver, () -> {
colorBuffer.resize(graphics.getWidth(), graphics.getHeight());
aberrationBuffer.resize(graphics.getWidth(), graphics.getHeight());
distortionBuffer.resize(graphics.getWidth(), graphics.getHeight());

Draw.draw(Layer.min, () -> {
distortionBuffer.begin(Color.clear);
Draw.draw(begin, () -> {
distortion.begin();
});
Draw.draw(Layer.min + 0.01f, () -> {
aberrationBuffer.begin(Color.clear);
Draw.draw(begin + 0.01f, () -> {
chromaticAberration.begin();
});

Draw.draw(Layer.buildBeam + 1.5f, () -> {
aberrationBuffer.end();
aberrationBuffer.blit(DrunkShaders.chromaticAberration);
Draw.draw(end, () -> {
chromaticAberration.end();

colorBuffer.begin(Color.clear);
colorHallucination.begin();
Draw.rect();
colorBuffer.end();
colorBuffer.blit(DrunkShaders.colorHallucination);
colorHallucination.end();

distortionBuffer.end();
distortionBuffer.blit(DrunkShaders.distortion);
distortion.end();
});
});
}
Expand Down
12 changes: 12 additions & 0 deletions src/drunkustry/graphics/DrunkShaders.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public static void init(){
/** Copy of {@link SurfaceShader} that's able to get my shader. */
public static class DrunkShader extends Shader{
Texture noiseTex;
FrameBuffer buffer = new FrameBuffer();

public DrunkShader(String frag){
super(getShaderFi("screenspace.vert"), getShaderFi(frag + ".frag"));
Expand All @@ -46,6 +47,16 @@ public void loadNoise(){
t.setWrap(TextureWrap.repeat);
};
}

public void begin(){
buffer.resize(graphics.getWidth(), graphics.getHeight());
buffer.begin(Color.clear);
}

public void end(){
buffer.end();
buffer.blit(this);
}

@Override
public void apply(){
Expand All @@ -59,6 +70,7 @@ public void apply(){
}

noiseTex.bind(1);
buffer.getTexture().bind(0);
setUniformi("u_noise", 1);
}
}
Expand Down

0 comments on commit 001fb88

Please sign in to comment.