Skip to main content

LEVELS

Constant LEVELS 

Source
pub const LEVELS: &str = "// Input range to 0..1, a gamma, then the output range, on the encoded color of all\n// channels or one.\nfn effect(_uv: vec2f, src: vec4f) -> vec4f {\n    let rgb = builtin_straight(src);\n    let range = max(params.input_white - params.input_black, 0.0001);\n    let x = clamp((rgb - vec3f(params.input_black)) / range, vec3f(0.0), vec3f(1.0));\n    let y = pow(max(x, vec3f(1.0e-10)), vec3f(1.0 / params.gamma));\n    let leveled = mix(vec3f(params.output_black), vec3f(params.output_white), y);\n    var mask = vec3f(1.0);\n    if params.channel == 1u { mask = vec3f(1.0, 0.0, 0.0); }\n    if params.channel == 2u { mask = vec3f(0.0, 1.0, 0.0); }\n    if params.channel == 3u { mask = vec3f(0.0, 0.0, 1.0); }\n    return builtin_output(mix(rgb, leveled, mask), src.a);\n}\n";
Expand description

Built-in levels body.