This repository has been archived on 2024-04-19. You can view files and clone it, but cannot push or open issues or pull requests.
Jessist/Shaders/glow.shader

38 lines
1.1 KiB
Text
Raw Permalink Normal View History

2022-06-18 13:05:48 +02:00
shader_type canvas_item;
render_mode blend_premul_alpha;
uniform float radius = 5.0;
uniform float amount = 0.25;
void fragment() {
float r = radius;
vec2 ps = TEXTURE_PIXEL_SIZE;
vec4 col = texture(TEXTURE, UV);
vec4 glow = col;
glow += texture(TEXTURE, UV + vec2(-r, -r) * ps);
glow += texture(TEXTURE, UV + vec2(-r, 0.0) * ps);
glow += texture(TEXTURE, UV + vec2(-r, r) * ps);
glow += texture(TEXTURE, UV + vec2(0.0, -r) * ps);
glow += texture(TEXTURE, UV + vec2(0.0, r) * ps);
glow += texture(TEXTURE, UV + vec2(r, -r) * ps);
glow += texture(TEXTURE, UV + vec2(r, 0.0) * ps);
glow += texture(TEXTURE, UV + vec2(r, r) * ps);
r *= 2.0;
glow += texture(TEXTURE, UV + vec2(-r, -r) * ps);
glow += texture(TEXTURE, UV + vec2(-r, 0.0) * ps);
glow += texture(TEXTURE, UV + vec2(-r, r) * ps);
glow += texture(TEXTURE, UV + vec2(0.0, -r) * ps);
glow += texture(TEXTURE, UV + vec2(0.0, r) * ps);
glow += texture(TEXTURE, UV + vec2(r, -r) * ps);
glow += texture(TEXTURE, UV + vec2(r, 0.0) * ps);
glow += texture(TEXTURE, UV + vec2(r, r) * ps);
glow /= 17.0;
glow *= amount;
col.rgb *= col.a;
COLOR = glow + col;
}