Improved antialiasing / Improved outlines
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
@@ -3,7 +3,8 @@ precision mediump float;
|
|||||||
precision mediump int;
|
precision mediump int;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SPACE 2.0
|
#define SPACE 1.0
|
||||||
|
#define RADIUS 3.0
|
||||||
|
|
||||||
uniform sampler2D u_texture;
|
uniform sampler2D u_texture;
|
||||||
|
|
||||||
@@ -20,25 +21,16 @@ void main() {
|
|||||||
vec4 c = texture2D(u_texture, v_texCoord.xy);
|
vec4 c = texture2D(u_texture, v_texCoord.xy);
|
||||||
float spacing = SPACE * u_scl;
|
float spacing = SPACE * u_scl;
|
||||||
|
|
||||||
gl_FragColor = mix(c * v_color, u_color,
|
if(c.a >= 0.001){
|
||||||
(1.0-step(0.001, texture2D(u_texture, v_texCoord.xy).a)) *
|
gl_FragColor = c * v_color;
|
||||||
step(0.001,
|
}else{
|
||||||
//cardinals
|
for(float cx = -RADIUS; cx <= RADIUS; cx ++){
|
||||||
texture2D(u_texture, v_texCoord.xy + vec2(0, spacing) * v).a +
|
for(float cy = -RADIUS; cy <= RADIUS; cy ++){
|
||||||
texture2D(u_texture, v_texCoord.xy + vec2(0, -spacing) * v).a +
|
if(texture2D(u_texture, v_texCoord.xy + vec2(cx, cy) * v * spacing).a >= 0.001){
|
||||||
texture2D(u_texture, v_texCoord.xy + vec2(spacing, 0) * v).a +
|
gl_FragColor = u_color;
|
||||||
texture2D(u_texture, v_texCoord.xy + vec2(-spacing, 0) * v).a +
|
return;
|
||||||
|
}
|
||||||
//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
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ precision mediump float;
|
|||||||
precision mediump int;
|
precision mediump int;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SPACE 2.0
|
#define SPACE 0.75
|
||||||
|
#define RADIUS 5.0
|
||||||
|
|
||||||
uniform sampler2D u_texture;
|
uniform sampler2D u_texture;
|
||||||
|
|
||||||
@@ -20,25 +21,16 @@ void main() {
|
|||||||
vec4 c = texture2D(u_texture, v_texCoord.xy);
|
vec4 c = texture2D(u_texture, v_texCoord.xy);
|
||||||
float spacing = SPACE * u_scl;
|
float spacing = SPACE * u_scl;
|
||||||
|
|
||||||
gl_FragColor = mix(vec4(0.0, 0.0, 0.0, min(c.a, u_color.a)), u_color,
|
if(c.a >= 0.001){
|
||||||
(1.0-step(0.001, texture2D(u_texture, v_texCoord.xy).a)) *
|
gl_FragColor = c * v_color;
|
||||||
step(0.001,
|
}else{
|
||||||
//cardinals
|
for(float cx = -RADIUS; cx <= RADIUS; cx ++){
|
||||||
texture2D(u_texture, v_texCoord.xy + vec2(0, spacing) * v).a +
|
for(float cy = -RADIUS; cy <= RADIUS; cy ++){
|
||||||
texture2D(u_texture, v_texCoord.xy + vec2(0, -spacing) * v).a +
|
if(cx*cx + cy*cy <= RADIUS * RADIUS && texture2D(u_texture, v_texCoord.xy + vec2(cx, cy) * v * spacing).a >= 0.001){
|
||||||
texture2D(u_texture, v_texCoord.xy + vec2(spacing, 0) * v).a +
|
gl_FragColor = u_color;
|
||||||
texture2D(u_texture, v_texCoord.xy + vec2(-spacing, 0) * v).a +
|
return;
|
||||||
|
}
|
||||||
//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
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 509 B After Width: | Height: | Size: 510 B |
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.2 MiB |
@@ -256,16 +256,13 @@ public class Renderer implements ApplicationListener{
|
|||||||
drawAndInterpolate(unitGroups[team.ordinal()], u -> u.isFlying() == flying && !u.isDead(), Unit::drawUnder);
|
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);
|
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);
|
Shaders.mix.color.set(Color.WHITE);
|
||||||
|
|
||||||
//Graphics.beginShaders(Shaders.outline);
|
|
||||||
Draw.shader(Shaders.mix, true);
|
Draw.shader(Shaders.mix, true);
|
||||||
drawAndInterpolate(unitGroups[team.ordinal()], u -> u.isFlying() == flying && !u.isDead(), Unit::drawAll);
|
drawAndInterpolate(unitGroups[team.ordinal()], u -> u.isFlying() == flying && !u.isDead(), Unit::drawAll);
|
||||||
drawAndInterpolate(playerGroup, p -> p.isFlying() == flying && p.getTeam() == team, Unit::drawAll);
|
drawAndInterpolate(playerGroup, p -> p.isFlying() == flying && p.getTeam() == team, Unit::drawAll);
|
||||||
Draw.shader();
|
Draw.shader();
|
||||||
blocks.drawTeamBlocks(Layer.turret, team);
|
blocks.drawTeamBlocks(Layer.turret, team);
|
||||||
//Graphics.endShaders();
|
|
||||||
|
|
||||||
drawAndInterpolate(unitGroups[team.ordinal()], u -> u.isFlying() == flying && !u.isDead(), Unit::drawOver);
|
drawAndInterpolate(unitGroups[team.ordinal()], u -> u.isFlying() == flying && !u.isDead(), Unit::drawOver);
|
||||||
drawAndInterpolate(playerGroup, p -> p.isFlying() == flying && p.getTeam() == team, Unit::drawOver);
|
drawAndInterpolate(playerGroup, p -> p.isFlying() == flying && p.getTeam() == team, Unit::drawOver);
|
||||||
|
|||||||
@@ -29,8 +29,6 @@ public class OverlayRenderer{
|
|||||||
|
|
||||||
if(!input.isDrawing() || player.isDead()) continue;
|
if(!input.isDrawing() || player.isDead()) continue;
|
||||||
|
|
||||||
Shaders.outline.color.set(Pal.accent);
|
|
||||||
|
|
||||||
input.drawOutlined();
|
input.drawOutlined();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import io.anuke.arc.scene.ui.layout.Unit;
|
|||||||
import io.anuke.arc.util.Time;
|
import io.anuke.arc.util.Time;
|
||||||
|
|
||||||
public class Shaders{
|
public class Shaders{
|
||||||
public static Outline outline;
|
|
||||||
public static Shadow shadow;
|
public static Shadow shadow;
|
||||||
public static BlockBuild blockbuild;
|
public static BlockBuild blockbuild;
|
||||||
public static BlockPreview blockpreview;
|
public static BlockPreview blockpreview;
|
||||||
@@ -20,7 +19,6 @@ public class Shaders{
|
|||||||
public static MenuShader menu;
|
public static MenuShader menu;
|
||||||
|
|
||||||
public static void init(){
|
public static void init(){
|
||||||
outline = new Outline();
|
|
||||||
shadow = new Shadow();
|
shadow = new Shadow();
|
||||||
blockbuild = new BlockBuild();
|
blockbuild = new BlockBuild();
|
||||||
blockpreview = new BlockPreview();
|
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 static class Shadow extends LoadShader{
|
||||||
public Color color = new Color();
|
public Color color = new Color();
|
||||||
public TextureRegion region = new TextureRegion();
|
public TextureRegion region = new TextureRegion();
|
||||||
|
|||||||
@@ -24,7 +24,9 @@ def antialias = {File file ->
|
|||||||
}
|
}
|
||||||
|
|
||||||
def color = new Color()
|
def color = new Color()
|
||||||
|
def color2 = new Color()
|
||||||
def sum = new Color()
|
def sum = new Color()
|
||||||
|
def suma = new Color()
|
||||||
|
|
||||||
for (int x = 0; x < image.getWidth(); x++){
|
for (int x = 0; x < image.getWidth(); x++){
|
||||||
for(int y = 0; y < image.getHeight(); y++){
|
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 && E!=G) || (H==D && H!=F && D!=B && E!=I)) p8=H
|
||||||
if (F==H && F!=B && H!=D) p9=F
|
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 ->
|
[p1, p2, p3, p4, p5, p6, p7, p8, p9].each{ val ->
|
||||||
Color.argb8888ToColor(color, 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){
|
suma.mul(suma.a <= 0.001f ? 0f : (float)(1f / suma.a))
|
||||||
sum.r += color.r
|
|
||||||
sum.g += color.g
|
float total = 0
|
||||||
sum.b += color.b
|
sum.set(0)
|
||||||
sum.a += color.a
|
|
||||||
total++
|
[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))
|
sum.mul((float)(1f / total))
|
||||||
@@ -73,7 +87,6 @@ def antialias = {File file ->
|
|||||||
|
|
||||||
ImageIO.write(out, "png", file)
|
ImageIO.write(out, "png", file)
|
||||||
}
|
}
|
||||||
|
|
||||||
task swapColors(){
|
task swapColors(){
|
||||||
doLast{
|
doLast{
|
||||||
if (project.hasProperty("colors")) {
|
if (project.hasProperty("colors")) {
|
||||||
|
|||||||
Reference in New Issue
Block a user