Skip to main content

COLOR_PHASE

Constant COLOR_PHASE 

Source
pub const COLOR_PHASE: &str = "// Port of gl-transitions/transitions/colorphase.glsl\n// Author: gre\n// License: MIT\nfn gl_transition(uv: vec2f) -> vec4f {\n    let amount = builtin_smoothstep4(params.from_step, params.to_step, progress());\n    let source = gl_from_color(uv);\n    let destination = gl_to_color(uv);\n    // Each channel has its own coverage during the color phase. Recover its color\n    // before associating it with the common output alpha.\n    let coverage = mix(vec3f(source.a), vec3f(destination.a), amount.rgb);\n    let associated = mix(source.rgb, destination.rgb, amount.rgb);\n    let rgb = select(vec3f(0.0), associated / max(coverage, vec3f(0.000001)), coverage > vec3f(0.000001));\n    let alpha = mix(source.a, destination.a, amount.a);\n    return vec4f(rgb * alpha, alpha);\n}\n";
Expand description

Per-channel phased color transition body.