New placement system without limits, queue block placements
This commit is contained in:
63
core/assets/shaders/blockbuild.fragment
Normal file
63
core/assets/shaders/blockbuild.fragment
Normal file
@@ -0,0 +1,63 @@
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
uniform sampler2D u_texture;
|
||||
|
||||
uniform vec4 u_color;
|
||||
uniform vec2 u_texsize;
|
||||
uniform vec2 u_uv;
|
||||
uniform vec2 u_uv2;
|
||||
uniform float u_progress;
|
||||
uniform float u_time;
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoord;
|
||||
|
||||
|
||||
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){
|
||||
float step = 1.0;
|
||||
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));
|
||||
}
|
||||
|
||||
float rand(vec2 co){
|
||||
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
||||
vec2 t = v_texCoord.xy;
|
||||
|
||||
vec2 v = vec2(1.0/u_texsize.x, 1.0/u_texsize.y);
|
||||
vec2 coords = (v_texCoord-u_uv) / v;
|
||||
float value = coords.x + coords.y;
|
||||
|
||||
vec4 color = texture2D(u_texture, t);
|
||||
|
||||
vec2 center = ((u_uv + u_uv2)/2.0 - u_uv) /v;
|
||||
float dst = (abs(center.x - coords.x) + abs(center.y - coords.y))/2.0;
|
||||
float chance = 1.0;
|
||||
|
||||
if(u_progress > 0.8){
|
||||
chance = 1.0-(u_progress-0.8)*5.0;
|
||||
}
|
||||
|
||||
if((mod(u_time / 1.5 + value, 20.0) < 5.0 && cont(t, v)) && rand(coords) < chance){
|
||||
gl_FragColor = u_color;
|
||||
}else if(dst > (1.0-u_progress) * (center.x)){
|
||||
gl_FragColor = color;
|
||||
}else if((dst + 1.0 > (1.0-u_progress) * (center.x)) && color.a > 0.1 && rand(coords) < chance){
|
||||
gl_FragColor = u_color;
|
||||
}else{
|
||||
gl_FragColor = vec4(0.0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user