const EDGE_GLOW: &str = r#"
float fx_l(vec2 uv) {
return dot(texture(tex, uv).rgb, vec3(0.2126, 0.7152, 0.0722));
}
void main() {
vec2 uv = gl_FragCoord.xy / u_res;
vec4 src = texture(tex, uv);
vec2 o = vec2(max(p1, 0.5) * max(u_scale, 0.05)) / u_res;
float tl = fx_l(uv + vec2(-o.x, -o.y));
float tc = fx_l(uv + vec2(0.0, -o.y));
float tr = fx_l(uv + vec2(o.x, -o.y));
float ml = fx_l(uv + vec2(-o.x, 0.0));
float mr = fx_l(uv + vec2(o.x, 0.0));
float bl = fx_l(uv + vec2(-o.x, o.y));
float bc = fx_l(uv + vec2(0.0, o.y));
float br = fx_l(uv + vec2(o.x, o.y));
float gx = (tr + 2.0 * mr + br) - (tl + 2.0 * ml + bl);
float gy = (bl + 2.0 * bc + br) - (tl + 2.0 * tc + tr);
float e = length(vec2(gx, gy)) * 0.25;
float edge = smoothstep(p0, p0 + 0.15, e);
vec3 glow = vec3(p3, p4, p5) / 255.0 * max(p2, 0.0) * edge;
vec4 res;
if (p6 >= 0.5) {
res = vec4(clamp(src.rgb + glow, 0.0, 1.0), src.a);
} else {
res = vec4(clamp(glow, 0.0, 1.0), edge * src.a);
}
float m = u_has_mask > 0.5 ? texture(u_mask, uv).r : 1.0;
out_color = mix(src, res, m);
}
"#;Expand description
Sobel on luma with the tap spacing set by Width (p1) - a wider kernel is the cheap stand-in for
dilating the edge - then a coloured glow, optionally over the source.