Fixed pad shader/disconnect bugs

This commit is contained in:
Anuken
2019-02-21 14:08:42 -05:00
parent 5b7b50f555
commit 9c240850b8
11 changed files with 30 additions and 15 deletions

View File

@@ -32,7 +32,7 @@ void main() {
vec2 coord = t / v;
vec4 c = texture2D(u_texture, t);
if(cont(t, v) ){
if(cont(t, v)){
gl_FragColor = u_color;
}else{
gl_FragColor = vec4(0.0);

View File

@@ -3,6 +3,8 @@ precision mediump float;
precision mediump int;
#endif
#define step 3.0
uniform sampler2D u_texture;
uniform float u_time;
@@ -15,27 +17,39 @@ uniform vec2 u_texsize;
varying vec4 v_color;
varying vec2 v_texCoord;
float rand(vec2 co){
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
}
bool id(vec4 v){
return v.a > 0.1;
}
bool id(vec2 coords, vec4 base){
vec4 target = texture2D(u_texture, coords);
return target.a < 0.1 || (coords.x < u_uv.x || coords.y < u_uv.y || coords.x > u_uv2.x || coords.y > u_uv2.y);
}
bool cont(vec2 T, vec2 v){
vec4 base = texture2D(u_texture, T);
return base.a > 0.1 &&
(id(T + vec2(0, step) * v, base) || id(T + vec2(0, -step) * v, base) ||
id(T + vec2(step, 0) * v, base) || id(T + vec2(-step, 0) * v, base) ||
id(T + vec2(step, step) * v, base) || id(T + vec2(-step, -step) * v, base) ||
id(T + vec2(step, -step) * v, base) || id(T + vec2(-step, step) * v, base));
}
void main() {
vec2 coords = (v_texCoord.xy - u_uv) / (u_uv2 - u_uv);
vec2 t = v_texCoord.xy;
vec2 v = vec2(1.0/u_texsize.x, 1.0/u_texsize.y);
vec4 c = texture2D(u_texture, v_texCoord.xy);
if(1.0-abs(coords.x - 0.5)*2.0 < 1.0-u_progress){
bool outl = cont(t, v);
if(1.0-abs(coords.x - 0.5)*2.0 < 1.0-u_progress && !outl){
c = vec4(0.0);
}
if(c.a > 0.01){
float f = abs(sin(coords.x*2.0 + u_time));
if(f > 0.9 )
if(f > 0.9 || outl)
f = 1.0;
else
f = 0.0;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB