You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
945 B

// from https://github.com/godotengine/godot-demo-projects/blob/master/2d/sprite_shaders/sprite_shaders.tscn
shader_type canvas_item;
render_mode blend_premul_alpha;
// This shader only works properly with premultiplied alpha blend mode.
uniform float aura_width = 2.0;
uniform vec4 aura_color : source_color;
void fragment() {
vec4 col = texture(TEXTURE, UV);
vec2 ps = TEXTURE_PIXEL_SIZE;
float a;
float maxa = col.a;
float mina = col.a;
a = texture(TEXTURE, UV + vec2(0.0, -aura_width) * ps).a;
maxa = max(a, maxa);
mina = min(a, mina);
a = texture(TEXTURE, UV + vec2(0.0, aura_width) * ps).a;
maxa = max(a, maxa);
mina = min(a, mina);
a = texture(TEXTURE, UV + vec2(-aura_width, 0.0) * ps).a;
maxa = max(a, maxa);
mina = min(a, mina);
a = texture(TEXTURE, UV + vec2(aura_width, 0.0) * ps).a;
maxa = max(a, maxa);
mina = min(a, mina);
col.rgb *= col.a;
COLOR = col;
COLOR.rgb += aura_color.rgb * (maxa - mina);
}