added foreground tile outline shader, closes #11
This commit is contained in:
parent
9c9e6292f9
commit
aab5edd1ac
16 changed files with 141 additions and 646 deletions
26
src/foreground_outline.gdshader
Normal file
26
src/foreground_outline.gdshader
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
shader_type canvas_item;
|
||||
|
||||
uniform sampler2D screen_tex : hint_screen_texture, repeat_disable, filter_nearest;
|
||||
uniform vec3 outline_color : source_color = vec3(1.0);
|
||||
|
||||
vec3 inv(vec3 x) {
|
||||
return 1.0 - x;
|
||||
}
|
||||
vec3 screen(vec3 src, vec3 dst) {
|
||||
return inv(inv(dst)*inv(src));
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
vec4 base = textureLod(screen_tex, SCREEN_UV, 0.0);
|
||||
float alpha = base.a;
|
||||
|
||||
float min_alpha = 1.0;
|
||||
min_alpha = min(min_alpha, texture(screen_tex, UV + vec2(1, 0) * SCREEN_PIXEL_SIZE).a);
|
||||
min_alpha = min(min_alpha, texture(screen_tex, UV - vec2(1, 0) * SCREEN_PIXEL_SIZE).a);
|
||||
min_alpha = min(min_alpha, texture(screen_tex, UV + vec2(0, 1) * SCREEN_PIXEL_SIZE).a);
|
||||
min_alpha = min(min_alpha, texture(screen_tex, UV - vec2(0, 1) * SCREEN_PIXEL_SIZE).a);
|
||||
|
||||
float edge = clamp(alpha - min_alpha, 0.0, 1.0);
|
||||
vec3 blended = screen(outline_color.rgb, base.rgb);
|
||||
COLOR = mix(base, vec4(blended, 1.0), edge);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue