OverviewFilesCommitsIssuesDocsReleasesPeers

ifsrenderer-linux / WpfDisplay / Library / PostEffects / Glow.ifsfx

32 lines · ifsfx ref:
@Name: Glow
@Version: 1.0
@Description: Adds a blurred layer of the brightest parts of the image back onto the original, creating a glow effect.

@Strength: 0.5
@Threshold: 0.6
@Radius: 1.0
@Quality: 1.0

vec2 pixel_step = vec2(1.0) / vec2(float(width), float(height));
float scaled_radius = @Radius * float(width) / 960.0;

float step = 1.0 / max(@Quality, 1.0);
vec3 blur = vec3(0.0);
float wsum = 0.0;
for (float fy = -1.0; fy <= 1.0; fy+=step) {
    for (float fx = -1.0; fx <= 1.0; fx+=step) {
        float d2 = fx * fx + fy * fy;
        float w = exp(-2.0 * d2);
        vec2 offset = pixel_step * scaled_radius * vec2(fx, fy);
        vec3 s = texture(input_tex, uv + offset).rgb;
        float sl = dot(s, vec3(0.299, 0.587, 0.114));
        s *= smoothstep(@Threshold - 0.15, @Threshold + 0.15, sl);
        blur += s * w;
        wsum += w;
    }
}
blur /= wsum;

// Additive blend of blurred highlights back onto the original.
output_color = vec4(input_color.rgb + blur * @Strength, input_color.a);