Shader tests

This commit is contained in:
Anuken
2019-02-26 15:13:05 -05:00
parent 61f75d7331
commit 4eba89603e
4 changed files with 26 additions and 19 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@@ -3,8 +3,7 @@ precision mediump float;
precision mediump int; precision mediump int;
#endif #endif
#define SPACE 0.75 #define SPACE 2.0
#define RADIUS 5.0
uniform sampler2D u_texture; uniform sampler2D u_texture;
@@ -21,15 +20,25 @@ 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;
if(c.a >= 0.001){ gl_FragColor = mix(vec4(0.0, 0.0, 0.0, min(c.a, u_color.a)), u_color,
gl_FragColor = c * v_color; (1.0-step(0.001, texture2D(u_texture, v_texCoord.xy).a)) *
}else{ step(0.001,
for(float cx = -RADIUS; cx <= RADIUS; cx ++){ //cardinals
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(0, -spacing) * v).a +
gl_FragColor = u_color; 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
));
} }

View File

@@ -3,8 +3,6 @@ precision mediump float;
precision mediump int; precision mediump int;
#endif #endif
#define step 3.0
uniform sampler2D u_texture; uniform sampler2D u_texture;
uniform float u_time; uniform float u_time;
@@ -17,8 +15,8 @@ uniform vec2 u_texsize;
varying vec4 v_color; varying vec4 v_color;
varying vec2 v_texCoord; varying vec2 v_texCoord;
#define SPACE 0.75 #define SPACE 1.3
#define RADIUS 5.0 #define RADIUS 2.0
bool cont(vec2 t, vec2 v){ bool cont(vec2 t, vec2 v){

View File

@@ -140,7 +140,7 @@ public class HudFragment extends Fragment{
infolabel.marginLeft(10f); infolabel.marginLeft(10f);
IntFormat fps = new IntFormat("fps"); IntFormat fps = new IntFormat("fps");
IntFormat ping = new IntFormat("ping"); IntFormat ping = new IntFormat("ping");
infolabel.label(() -> fps.get(Core.graphics.getFramesPerSecond())).padRight(10); infolabel.label(() -> fps.get(Core.graphics.getFramesPerSecond())).padLeft(10).growX();
infolabel.row(); infolabel.row();
if(Net.hasClient()){ if(Net.hasClient()){
infolabel.label(() -> ping.get(Net.getPing())).visible(Net::client).colspan(2); infolabel.label(() -> ping.get(Net.getPing())).visible(Net::client).colspan(2);