diff --git a/core/assets-raw/sprites_replacement/blocks/environment/white-tree-dead.png b/core/assets-raw/sprites_replacement/blocks/environment/white-tree-dead.png new file mode 100644 index 0000000000..4831e1879e Binary files /dev/null and b/core/assets-raw/sprites_replacement/blocks/environment/white-tree-dead.png differ diff --git a/core/assets-raw/sprites_replacement/blocks/environment/white-tree.png b/core/assets-raw/sprites_replacement/blocks/environment/white-tree.png new file mode 100644 index 0000000000..af2b61c5ca Binary files /dev/null and b/core/assets-raw/sprites_replacement/blocks/environment/white-tree.png differ diff --git a/core/assets/shaders/outline.fragment b/core/assets/shaders/outline.fragment index 09a9a4e041..94e97b1969 100644 --- a/core/assets/shaders/outline.fragment +++ b/core/assets/shaders/outline.fragment @@ -3,7 +3,8 @@ precision mediump float; precision mediump int; #endif -#define SPACE 2.0 +#define SPACE 1.0 +#define RADIUS 3.0 uniform sampler2D u_texture; @@ -20,25 +21,16 @@ void main() { vec4 c = texture2D(u_texture, v_texCoord.xy); float spacing = SPACE * u_scl; - gl_FragColor = mix(c * v_color, 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 - )); + if(c.a >= 0.001){ + gl_FragColor = c * v_color; + }else{ + for(float cx = -RADIUS; cx <= RADIUS; cx ++){ + for(float cy = -RADIUS; cy <= RADIUS; cy ++){ + if(texture2D(u_texture, v_texCoord.xy + vec2(cx, cy) * v * spacing).a >= 0.001){ + gl_FragColor = u_color; + return; + } + } + } + } } diff --git a/core/assets/shaders/shadow.fragment b/core/assets/shaders/shadow.fragment index b1d73a8b1f..42ccdcee64 100644 --- a/core/assets/shaders/shadow.fragment +++ b/core/assets/shaders/shadow.fragment @@ -3,7 +3,8 @@ precision mediump float; precision mediump int; #endif -#define SPACE 2.0 +#define SPACE 0.75 +#define RADIUS 5.0 uniform sampler2D u_texture; @@ -20,25 +21,16 @@ void main() { 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 - )); + if(c.a >= 0.001){ + gl_FragColor = c * v_color; + }else{ + for(float cx = -RADIUS; cx <= RADIUS; cx ++){ + for(float cy = -RADIUS; cy <= RADIUS; cy ++){ + if(cx*cx + cy*cy <= RADIUS * RADIUS && texture2D(u_texture, v_texCoord.xy + vec2(cx, cy) * v * spacing).a >= 0.001){ + gl_FragColor = u_color; + return; + } + } + } + } } diff --git a/core/assets/sprites/block_colors.png b/core/assets/sprites/block_colors.png index aece7ce51f..7a9bed0f1a 100644 Binary files a/core/assets/sprites/block_colors.png and b/core/assets/sprites/block_colors.png differ diff --git a/core/assets/sprites/sprites.png b/core/assets/sprites/sprites.png index a7e9c67f03..259f2d538a 100644 Binary files a/core/assets/sprites/sprites.png and b/core/assets/sprites/sprites.png differ diff --git a/core/src/io/anuke/mindustry/core/Renderer.java b/core/src/io/anuke/mindustry/core/Renderer.java index 28affd9348..0fd6fb66ad 100644 --- a/core/src/io/anuke/mindustry/core/Renderer.java +++ b/core/src/io/anuke/mindustry/core/Renderer.java @@ -256,16 +256,13 @@ public class Renderer implements ApplicationListener{ drawAndInterpolate(unitGroups[team.ordinal()], u -> u.isFlying() == flying && !u.isDead(), Unit::drawUnder); drawAndInterpolate(playerGroup, p -> p.isFlying() == flying && p.getTeam() == team && !p.isDead(), Unit::drawUnder); - Shaders.outline.color.set(team.color); Shaders.mix.color.set(Color.WHITE); - //Graphics.beginShaders(Shaders.outline); Draw.shader(Shaders.mix, true); drawAndInterpolate(unitGroups[team.ordinal()], u -> u.isFlying() == flying && !u.isDead(), Unit::drawAll); drawAndInterpolate(playerGroup, p -> p.isFlying() == flying && p.getTeam() == team, Unit::drawAll); Draw.shader(); blocks.drawTeamBlocks(Layer.turret, team); - //Graphics.endShaders(); drawAndInterpolate(unitGroups[team.ordinal()], u -> u.isFlying() == flying && !u.isDead(), Unit::drawOver); drawAndInterpolate(playerGroup, p -> p.isFlying() == flying && p.getTeam() == team, Unit::drawOver); diff --git a/core/src/io/anuke/mindustry/graphics/OverlayRenderer.java b/core/src/io/anuke/mindustry/graphics/OverlayRenderer.java index a2cf531e7e..af8ad777c2 100644 --- a/core/src/io/anuke/mindustry/graphics/OverlayRenderer.java +++ b/core/src/io/anuke/mindustry/graphics/OverlayRenderer.java @@ -29,8 +29,6 @@ public class OverlayRenderer{ if(!input.isDrawing() || player.isDead()) continue; - Shaders.outline.color.set(Pal.accent); - input.drawOutlined(); } } diff --git a/core/src/io/anuke/mindustry/graphics/Shaders.java b/core/src/io/anuke/mindustry/graphics/Shaders.java index 2d8219127d..9756cc82f3 100644 --- a/core/src/io/anuke/mindustry/graphics/Shaders.java +++ b/core/src/io/anuke/mindustry/graphics/Shaders.java @@ -8,7 +8,6 @@ import io.anuke.arc.scene.ui.layout.Unit; import io.anuke.arc.util.Time; public class Shaders{ - public static Outline outline; public static Shadow shadow; public static BlockBuild blockbuild; public static BlockPreview blockpreview; @@ -20,7 +19,6 @@ public class Shaders{ public static MenuShader menu; public static void init(){ - outline = new Outline(); shadow = new Shadow(); blockbuild = new BlockBuild(); blockpreview = new BlockPreview(); @@ -91,23 +89,6 @@ public class Shaders{ } } - public static class Outline extends LoadShader{ - public Color color = new Color(); - public TextureRegion region = new TextureRegion(); - public float scl; - - public Outline(){ - super("outline", "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 Shadow extends LoadShader{ public Color color = new Color(); public TextureRegion region = new TextureRegion(); diff --git a/tools/build.gradle b/tools/build.gradle index e032aa15cd..c7dc080848 100644 --- a/tools/build.gradle +++ b/tools/build.gradle @@ -24,7 +24,9 @@ def antialias = {File file -> } def color = new Color() + def color2 = new Color() def sum = new Color() + def suma = new Color() for (int x = 0; x < image.getWidth(); x++){ for(int y = 0; y < image.getHeight(); y++){ @@ -50,18 +52,30 @@ def antialias = {File file -> if ((F==H && F!=B && H!=D && E!=G) || (H==D && H!=F && D!=B && E!=I)) p8=H if (F==H && F!=B && H!=D) p9=F - int total = 0 + suma.set(0) [p1, p2, p3, p4, p5, p6, p7, p8, p9].each{ val -> Color.argb8888ToColor(color, val) + suma.r += color.r*color.a + suma.g += color.g*color.a + suma.b += color.b*color.a + suma.a += color.a + } - if(color.a > 0.05){ - sum.r += color.r - sum.g += color.g - sum.b += color.b - sum.a += color.a - total++ - } + suma.mul(suma.a <= 0.001f ? 0f : (float)(1f / suma.a)) + + float total = 0 + sum.set(0) + + [p1, p2, p3, p4, p5, p6, p7, p8, p9].each{ val -> + Color.argb8888ToColor(color, val) + float a = color.a + color.lerp(suma, (float)(1f - a)) + sum.r += color.r + sum.g += color.g + sum.b += color.b + sum.a += a + total += 1f } sum.mul((float)(1f / total)) @@ -73,7 +87,6 @@ def antialias = {File file -> ImageIO.write(out, "png", file) } - task swapColors(){ doLast{ if (project.hasProperty("colors")) {