Skip to content

Commit

Permalink
Better framework for shaders
Browse files Browse the repository at this point in the history
  • Loading branch information
MEEPofFaith committed Feb 9, 2024
1 parent 221a6c9 commit 9892e9f
Showing 1 changed file with 30 additions and 23 deletions.
53 changes: 30 additions & 23 deletions src/drunkustry/graphics/DrunkShaders.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static void init(){
distortion = new DistortionShader();
}

public static class HallucinationShader extends DrunkShader{
public static class HallucinationShader extends DrunkScreenShader{
public HallucinationShader(){
super("colorHallucination");
}
Expand All @@ -38,7 +38,7 @@ public float timeScale(){
}
}

public static class AberrationShader extends DrunkShader{
public static class AberrationShader extends DrunkScreenShader{
public AberrationShader(){
super("chromaticAberration");
}
Expand All @@ -54,7 +54,7 @@ public float timeScale(){
}
}

public static class DistortionShader extends DrunkShader{
public static class DistortionShader extends DrunkScreenShader{
public DistortionShader(){
super("distortion");
}
Expand All @@ -71,17 +71,11 @@ public float timeScale(){
}

/** Copy of {@link SurfaceShader} that's able to get my shader. */
public static class DrunkShader extends Shader{
Texture noiseTex;
FrameBuffer buffer = new FrameBuffer();
public static class DrunkScreenShader extends DrunkShader{
protected Texture noiseTex;

public DrunkShader(String frag){
super(getShaderFi("screenspace.vert"), getShaderFi(frag + ".frag"));
loadNoise();
}

public DrunkShader(String vertRaw, String fragRaw){
super(vertRaw, fragRaw);
public DrunkScreenShader(String frag){
super(frag);
loadNoise();
}

Expand All @@ -95,16 +89,6 @@ 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);
}

public void applyOther(){
}
Expand Down Expand Up @@ -132,6 +116,29 @@ public void apply(){
}
}

public static class DrunkShader extends Shader{
protected FrameBuffer buffer = new FrameBuffer();

public DrunkShader(String frag){
super(getShaderFi("screenspace.vert"), getShaderFi(frag + ".frag"));
}

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(){
buffer.getTexture().bind(0);
}
}

public static Fi getInternalShaderFi(String file){
return files.internal("shaders/" + file);
}
Expand Down

0 comments on commit 9892e9f

Please sign in to comment.