Skip to main content

LUMINANCE_FRAG

Constant LUMINANCE_FRAG 

Source
pub const LUMINANCE_FRAG: &str = r#"
#version 330 core

in  vec2 f_uv;
out vec4 frag_color;

uniform sampler2D u_scene;

void main() {
    vec3 color = texture(u_scene, f_uv).rgb;
    float lum = dot(color, vec3(0.2126, 0.7152, 0.0722));
    // Output log luminance for averaging
    float logLum = log(max(lum, 0.0001));
    frag_color = vec4(logLum, lum, 0.0, 1.0);
}
"#;
Expand description

Luminance computation shader for auto-exposure. Computes log-average luminance of the scene.