wibblin' on the border now
This commit is contained in:
parent
168eb7814e
commit
463b7952b1
1 changed files with 37 additions and 0 deletions
37
shaders/wibble_border.gdshader
Normal file
37
shaders/wibble_border.gdshader
Normal file
|
@ -0,0 +1,37 @@
|
|||
shader_type canvas_item;
|
||||
|
||||
uniform vec2 speed = vec2(0.0, 0.0);
|
||||
uniform vec2 ammount = vec2(0.0, 0.0);
|
||||
uniform vec2 offset = vec2(0.0, 0.0);
|
||||
uniform vec2 delay = vec2(0.0, 0.0);
|
||||
|
||||
uniform vec4 border_color : hint_color = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
uniform bool border_corners = false;
|
||||
|
||||
bool is_border(sampler2D tex, vec2 uv, vec2 pixel_size) {
|
||||
float check = texture(tex, uv + vec2(pixel_size.x, 0.0)).a;
|
||||
check += texture(tex, uv + vec2(-pixel_size.x, 0.0)).a;
|
||||
check += texture(tex, uv + vec2(0.0, pixel_size.y)).a;
|
||||
check += texture(tex, uv + vec2(0.0, -pixel_size.y)).a;
|
||||
|
||||
if (border_corners) {
|
||||
check += texture(tex, uv + pixel_size).a;
|
||||
check += texture(tex, uv - pixel_size).a;
|
||||
check += texture(tex, uv + vec2(pixel_size.x, -pixel_size.y)).a;
|
||||
check += texture(tex, uv + vec2(-pixel_size.x, pixel_size.y)).a;
|
||||
}
|
||||
|
||||
return check > 0.0;
|
||||
}
|
||||
|
||||
void vertex() {
|
||||
VERTEX += sin(speed * (delay + TIME)) * ammount + offset;
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
COLOR = texture(TEXTURE, UV);
|
||||
|
||||
if (COLOR.a == 0.0 && is_border(TEXTURE, UV, TEXTURE_PIXEL_SIZE)) {
|
||||
COLOR = border_color;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue