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;
|
||||
#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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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(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);
|
||||
|
||||
@@ -29,8 +29,6 @@ public class OverlayRenderer{
|
||||
|
||||
if(!input.isDrawing() || player.isDead()) continue;
|
||||
|
||||
Shaders.outline.color.set(Pal.accent);
|
||||
|
||||
input.drawOutlined();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user