diff --git a/core/assets/bloomshaders/alpha_bloom.frag b/core/assets/bloomshaders/alpha_bloom.frag index 00444c1dca..ce16d33162 100644 --- a/core/assets/bloomshaders/alpha_bloom.frag +++ b/core/assets/bloomshaders/alpha_bloom.frag @@ -13,9 +13,7 @@ uniform float OriginalIntensity; varying MED vec2 v_texCoords; -void main() -{ - +void main(){ vec4 original = texture2D(u_texture0, v_texCoords) * OriginalIntensity; vec4 bloom = texture2D(u_texture1, v_texCoords) * BloomIntensity; original = original * (vec4(1.0) - bloom); diff --git a/core/assets/bloomshaders/alpha_gaussian.frag b/core/assets/bloomshaders/alpha_gaussian.frag index e060efc278..1e502bc60d 100644 --- a/core/assets/bloomshaders/alpha_gaussian.frag +++ b/core/assets/bloomshaders/alpha_gaussian.frag @@ -16,8 +16,7 @@ varying MED vec2 v_texCoords4; const float center = 0.2270270270; const float close = 0.3162162162; const float far = 0.0702702703; -void main() -{ +void main(){ gl_FragColor = far * texture2D(u_texture, v_texCoords0) + close * texture2D(u_texture, v_texCoords1) + center * texture2D(u_texture, v_texCoords2) diff --git a/core/assets/bloomshaders/alpha_threshold.frag b/core/assets/bloomshaders/alpha_threshold.frag index d85c0b1170..a99a9e2efc 100644 --- a/core/assets/bloomshaders/alpha_threshold.frag +++ b/core/assets/bloomshaders/alpha_threshold.frag @@ -9,8 +9,7 @@ precision lowp float; uniform sampler2D u_texture0; uniform vec2 threshold; varying MED vec2 v_texCoords; -void main() -{ +void main(){ vec4 color = texture2D(u_texture0, v_texCoords); if(color.r + color.g + color.b > 0.5 * 3.0){ gl_FragColor = color; diff --git a/core/assets/bloomshaders/bloom.frag b/core/assets/bloomshaders/bloom.frag index 93bbfe3737..1196120cc3 100644 --- a/core/assets/bloomshaders/bloom.frag +++ b/core/assets/bloomshaders/bloom.frag @@ -13,8 +13,7 @@ uniform float OriginalIntensity; varying MED vec2 v_texCoords; -void main() -{ +void main(){ vec3 original = texture2D(u_texture0, v_texCoords).rgb; vec3 bloom = texture2D(u_texture1, v_texCoords).rgb * BloomIntensity; diff --git a/core/assets/bloomshaders/blurspace.vert b/core/assets/bloomshaders/blurspace.vert index 1d7135d9ab..6c73f70f52 100644 --- a/core/assets/bloomshaders/blurspace.vert +++ b/core/assets/bloomshaders/blurspace.vert @@ -15,8 +15,8 @@ varying MED vec2 v_texCoords3; varying MED vec2 v_texCoords4; const vec2 futher = vec2(3.2307692308, 3.2307692308); const vec2 closer = vec2(1.3846153846, 1.3846153846); -void main() -{ + +void main(){ vec2 sizeAndDir = dir / size; vec2 f = futher*sizeAndDir; vec2 c = closer*sizeAndDir; diff --git a/core/assets/bloomshaders/gaussian.frag b/core/assets/bloomshaders/gaussian.frag index 5373349f85..b09606648d 100644 --- a/core/assets/bloomshaders/gaussian.frag +++ b/core/assets/bloomshaders/gaussian.frag @@ -16,8 +16,7 @@ varying MED vec2 v_texCoords4; const float center = 0.2270270270; const float close = 0.3162162162; const float far = 0.0702702703; -void main() -{ +void main(){ gl_FragColor.rgb = far * texture2D(u_texture, v_texCoords0).rgb + close * texture2D(u_texture, v_texCoords1).rgb + center * texture2D(u_texture, v_texCoords2).rgb diff --git a/core/assets/bloomshaders/maskedtreshold.frag b/core/assets/bloomshaders/maskedtreshold.frag index a65064e380..f02fb1d132 100644 --- a/core/assets/bloomshaders/maskedtreshold.frag +++ b/core/assets/bloomshaders/maskedtreshold.frag @@ -9,8 +9,8 @@ precision lowp float; uniform sampler2D u_texture0; uniform vec2 threshold; varying MED vec2 v_texCoords; -void main() -{ + +void main(){ vec4 tex = texture2D(u_texture0, v_texCoords); vec3 colors = (tex.rgb - threshold.r) * threshold.g * tex.a; gl_FragColor = vec4(colors, tex.a); diff --git a/core/assets/bloomshaders/screenspace.vert b/core/assets/bloomshaders/screenspace.vert index 8e521c9a75..7fdb2ec21f 100644 --- a/core/assets/bloomshaders/screenspace.vert +++ b/core/assets/bloomshaders/screenspace.vert @@ -6,8 +6,8 @@ attribute vec4 a_position; attribute vec2 a_texCoord0; varying MED vec2 v_texCoords; -void main() -{ + +void main(){ v_texCoords = a_texCoord0; gl_Position = a_position; } \ No newline at end of file diff --git a/core/assets/bloomshaders/threshold.frag b/core/assets/bloomshaders/threshold.frag index 52de3f18ed..3747e91fe8 100644 --- a/core/assets/bloomshaders/threshold.frag +++ b/core/assets/bloomshaders/threshold.frag @@ -9,7 +9,7 @@ precision lowp float; uniform sampler2D u_texture0; uniform vec2 threshold; varying MED vec2 v_texCoords; -void main() -{ + +void main(){ gl_FragColor.rgb = (texture2D(u_texture0, v_texCoords).rgb - vec3(threshold.x)) * threshold.y; } \ No newline at end of file diff --git a/core/assets/shaders/default.vert b/core/assets/shaders/default.vert index 546333fe24..681aba4818 100644 --- a/core/assets/shaders/default.vert +++ b/core/assets/shaders/default.vert @@ -9,7 +9,7 @@ varying vec2 v_texCoord; uniform vec2 u_viewportInverse; -void main() { +void main(){ gl_Position = u_projTrans * a_position; v_texCoord = a_texCoord0; v_color = a_color; diff --git a/core/assets/shaders/light.frag b/core/assets/shaders/light.frag index c1a831668a..ba35623dab 100644 --- a/core/assets/shaders/light.frag +++ b/core/assets/shaders/light.frag @@ -13,6 +13,5 @@ varying vec2 v_texCoord; void main(){ vec4 color = texture2D(u_texture, v_texCoord.xy); - //color.a = clamp(color.a, 0.0, 0.8); gl_FragColor = clamp(vec4(mix(u_ambient.rgb, color.rgb, color.a), u_ambient.a - color.a), 0.0, 1.0); } diff --git a/core/assets/shaders/menu.frag b/core/assets/shaders/menu.frag deleted file mode 100644 index 1d793559ca..0000000000 --- a/core/assets/shaders/menu.frag +++ /dev/null @@ -1,44 +0,0 @@ -#ifdef GL_ES -precision mediump float; -precision mediump int; -#endif - -#define p1 vec3(255.0,211.0,127.0)/255.0 -#define p2 vec3(234.0,182.0,120.0)/255.0 -#define p3 vec3(212.0,129.0,107.0)/255.0 -#define p4 vec3(142.0,77.0,72.0)/255.0 -#define roundm 0.2 - -uniform sampler2D u_texture; -uniform vec2 u_resolution; -uniform int u_time; -uniform vec2 u_uv; -uniform vec2 u_uv2; -uniform float u_scl; - -varying vec4 v_color; -varying vec2 v_texCoord; - -void main() { - ivec2 coords = ivec2((gl_FragCoord.xy - u_resolution/2.0)/u_scl); - - //int roundx = 8; - //int roundy = roundx; - - //coords.x = (coords.x / roundx) * roundx; - //coords.y = (coords.y / roundy) * roundy; - - float d = (abs(float(coords.x)) - abs(float(coords.y))); - - float m = abs(sin(-float(u_time)/50.0 + d/120.0)); - - if(m > 0.95) gl_FragColor.rgb = p1; - else if(m > 0.75) gl_FragColor.rgb = p2; - else if(m > 0.55) gl_FragColor.rgb = p3; - else if(m > 0.35) gl_FragColor.rgb = p4; - else gl_FragColor.rgb = vec3(0.0); - - gl_FragColor.rgb *= 0.5; - - gl_FragColor.a = mod(abs(float(coords.x)) + abs(float(coords.y)), 110.0) < 35.0 ? 1.0 : 0.0; -} \ No newline at end of file diff --git a/core/assets/shaders/shadow.frag b/core/assets/shaders/shadow.frag deleted file mode 100644 index 7346d78142..0000000000 --- a/core/assets/shaders/shadow.frag +++ /dev/null @@ -1,44 +0,0 @@ -#ifdef GL_ES -precision mediump float; -precision mediump int; -#endif - -#define SPACE 2.0 - -uniform sampler2D u_texture; - -uniform vec4 u_color; -uniform vec2 u_texsize; -uniform float u_scl; - -varying vec4 v_color; -varying vec2 v_texCoord; - -void main() { - vec2 v = vec2(1.0/u_texsize.x, 1.0/u_texsize.y); - - vec4 c = texture2D(u_texture, v_texCoord.xy); - float spacing = SPACE * u_scl; - - gl_FragColor = mix(vec4(0.0, 0.0, 0.0, min(c.a, u_color.a)), u_color, - (1.0-step(0.001, texture2D(u_texture, v_texCoord.xy).a)) * - step(0.001, - //cardinals - texture2D(u_texture, v_texCoord.xy + vec2(0, spacing) * v).a + - texture2D(u_texture, v_texCoord.xy + vec2(0, -spacing) * v).a + - texture2D(u_texture, v_texCoord.xy + vec2(spacing, 0) * v).a + - texture2D(u_texture, v_texCoord.xy + vec2(-spacing, 0) * v).a + - - //cardinal edges - texture2D(u_texture, v_texCoord.xy + vec2(spacing, spacing) * v).a + - texture2D(u_texture, v_texCoord.xy + vec2(spacing, -spacing) * v).a + - texture2D(u_texture, v_texCoord.xy + vec2(-spacing, spacing) * v).a + - texture2D(u_texture, v_texCoord.xy + vec2(-spacing, -spacing) * v).a + - - //cardinals * 2 - texture2D(u_texture, v_texCoord.xy + vec2(0, spacing) * v*2.0).a + - texture2D(u_texture, v_texCoord.xy + vec2(0, -spacing) * v*2.0).a + - texture2D(u_texture, v_texCoord.xy + vec2(spacing, 0) * v*2.0).a + - texture2D(u_texture, v_texCoord.xy + vec2(-spacing, 0) * v*2.0).a - )); -} \ No newline at end of file diff --git a/core/assets/shaders/shield.frag b/core/assets/shaders/shield.frag index 86fb8f161b..ae3831e5fb 100644 --- a/core/assets/shaders/shield.frag +++ b/core/assets/shaders/shield.frag @@ -18,8 +18,7 @@ uniform vec2 u_offset; varying vec4 v_color; varying vec2 v_texCoord; -void main() { - +void main(){ vec2 T = v_texCoord.xy; vec2 coords = (T * u_texsize) + u_offset; diff --git a/core/assets/shaders/snow.frag b/core/assets/shaders/snow.frag deleted file mode 100644 index b17cc756e0..0000000000 --- a/core/assets/shaders/snow.frag +++ /dev/null @@ -1,45 +0,0 @@ -#define LIGHT - -#ifdef LIGHT - #define LAYERS 30. - #define DEPTH .5 - #define WIDTH .3 - #define SPEED .6 - #define SIZE 0.2 -#else - #define LAYERS 200. - #define DEPTH .1 - #define WIDTH .8 - #define SPEED 1.5 - #define SIZE 1.0 -#endif - -varying vec2 v_texCoords; - -uniform vec2 u_pos; -uniform vec2 u_resolution; -uniform float u_time; -uniform sampler2D u_texture0; - -void main(){ - gl_FragColor = texture2D(u_texture0, v_texCoords); - - vec2 uv = (v_texCoords * u_resolution + u_pos) / 1000.0; - const mat3 p = mat3( - 13.3231, 23.5112, 21.7112, - 21.1212, 28.7312, 11.9312, - 21.8112, 14.7212, 61.3934 - ); - float dof = 5.*sin(u_time*.1); - - //TODO this is very slow - for(float i=0.0; i{ +public abstract class Content implements Comparable, Disposable{ public final short id; /** Info on which mod this content was loaded from. */ public @NonNull ModContentInfo minfo = new ModContentInfo(); @@ -40,6 +40,11 @@ public abstract class Content implements Comparable{ return minfo.error != null; } + @Override + public void dispose(){ + //does nothing by default + } + @Override public int compareTo(Content c){ return Integer.compare(id, c.id); diff --git a/core/src/mindustry/graphics/Shaders.java b/core/src/mindustry/graphics/Shaders.java index 6012792469..8e99d156a7 100644 --- a/core/src/mindustry/graphics/Shaders.java +++ b/core/src/mindustry/graphics/Shaders.java @@ -15,12 +15,10 @@ import mindustry.type.*; import static mindustry.Vars.renderer; public class Shaders{ - public static Shadow shadow; public static BlockBuild blockbuild; public static @Nullable Shield shield; public static UnitBuild build; public static FogShader fog; - public static MenuShader menu; public static LightShader light; public static SurfaceShader water, tar, slag; public static PlanetShader planet; @@ -30,7 +28,6 @@ public class Shaders{ public static Shader unlit; public static void init(){ - shadow = new Shadow(); blockbuild = new BlockBuild(); try{ shield = new Shield(); @@ -41,7 +38,6 @@ public class Shaders{ } build = new UnitBuild(); fog = new FogShader(); - menu = new MenuShader(); light = new LightShader(); water = new SurfaceShader("water"); tar = new SurfaceShader("tar"); @@ -131,25 +127,6 @@ public class Shaders{ } - public static class MenuShader extends LoadShader{ - float time = 0f; - - public MenuShader(){ - super("menu", "default"); - } - - @Override - public void apply(){ - time = time % 158; - - setUniformf("u_resolution", Core.graphics.getWidth(), Core.graphics.getHeight()); - setUniformi("u_time", (int)(time += Core.graphics.getDeltaTime() * 60f)); - setUniformf("u_uv", Core.atlas.white().getU(), Core.atlas.white().getV()); - setUniformf("u_scl", Scl.scl(1f)); - setUniformf("u_uv2", Core.atlas.white().getU2(), Core.atlas.white().getV2()); - } - } - public static class FogShader extends LoadShader{ public FogShader(){ super("fog", "default"); @@ -176,23 +153,6 @@ public class Shaders{ } } - public static class Shadow extends LoadShader{ - public Color color = new Color(); - public TextureRegion region = new TextureRegion(); - public float scl; - - public Shadow(){ - super("shadow", "default"); - } - - @Override - public void apply(){ - setUniformf("u_color", color); - setUniformf("u_scl", scl); - setUniformf("u_texsize", region.getTexture().getWidth(), region.getTexture().getHeight()); - } - } - public static class BlockBuild extends LoadShader{ public Color color = new Color(); public float progress; diff --git a/core/src/mindustry/graphics/SnowFilter.java b/core/src/mindustry/graphics/SnowFilter.java deleted file mode 100644 index 3aa72b815e..0000000000 --- a/core/src/mindustry/graphics/SnowFilter.java +++ /dev/null @@ -1,19 +0,0 @@ -package mindustry.graphics; - -import arc.*; -import arc.fx.*; - -public class SnowFilter extends FxFilter{ - - public SnowFilter(){ - super(compileShader(Core.files.internal("shaders/screenspace.vert"), Core.files.internal("shaders/snow.frag"))); - autobind = true; - } - - @Override - public void setParams(){ - shader.setUniformf("u_time", time / 60f); - shader.setUniformf("u_pos", Core.camera.position.x - Core.camera.width / 2, Core.camera.position.y - Core.camera.height / 2); - shader.setUniformf("u_resolution", Core.camera.width, Core.camera.height); - } -} diff --git a/core/src/mindustry/type/Category.java b/core/src/mindustry/type/Category.java index 97f5c9d7a6..537f4120d8 100644 --- a/core/src/mindustry/type/Category.java +++ b/core/src/mindustry/type/Category.java @@ -25,10 +25,10 @@ public enum Category{ public static final Category[] all = values(); public Category prev(){ - return all[(this.ordinal() - 1 + all.length) % all.length]; + return all[(ordinal() - 1 + all.length) % all.length]; } public Category next(){ - return all[(this.ordinal() + 1) % all.length]; + return all[(ordinal() + 1) % all.length]; } } diff --git a/core/src/mindustry/type/Liquid.java b/core/src/mindustry/type/Liquid.java index 8485d0857d..0baa416634 100644 --- a/core/src/mindustry/type/Liquid.java +++ b/core/src/mindustry/type/Liquid.java @@ -9,8 +9,8 @@ import mindustry.ctype.ContentType; import mindustry.ui.*; public class Liquid extends UnlockableContent{ + /** Color used in pipes and on the ground. */ public final @NonNull Color color; - /** Color used in bars. */ public @Nullable Color barColor; /** Color used to draw lights. Note that the alpha channel is used to dictate brightness. */ diff --git a/core/src/mindustry/type/Planet.java b/core/src/mindustry/type/Planet.java index cfee9eeddc..8ac17109ef 100644 --- a/core/src/mindustry/type/Planet.java +++ b/core/src/mindustry/type/Planet.java @@ -186,6 +186,14 @@ public class Planet extends UnlockableContent{ mesh = meshLoader.get(); } + @Override + public void dispose(){ + if(mesh != null){ + mesh.dispose(); + mesh = null; + } + } + /** Gets a sector a tile position. */ public Sector getSector(Ptile tile){ return sectors.get(tile.id);