forked from team-sg/hero-mark-2
first commit
This commit is contained in:
commit
096ebe5aa4
275 changed files with 3937 additions and 0 deletions
32
scripts/recolor_border.shader
Normal file
32
scripts/recolor_border.shader
Normal file
|
@ -0,0 +1,32 @@
|
|||
shader_type canvas_item;
|
||||
|
||||
uniform sampler2D palette : hint_albedo;
|
||||
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 fragment() {
|
||||
vec4 color = texture(TEXTURE, UV);
|
||||
|
||||
if (color.a == 0.0 && is_border(TEXTURE, UV, TEXTURE_PIXEL_SIZE)) {
|
||||
COLOR = border_color;
|
||||
} else {
|
||||
COLOR = texture(palette, color.rg );
|
||||
COLOR.a = color.a;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue