Skip to main content

BOUNCE

Constant BOUNCE 

Source
pub const BOUNCE: &str = "// Port of gl-transitions/transitions/Bounce.glsl\n// Author: Adrian Purser\n// License: MIT\n// alpha2: the shadow is composited over the incoming picture, so it darkens it without making\n// it translucent, and the drop edge is antialiased.\nconst BOUNCE_PI = 3.14159265358;\n\nfn gl_transition(uv: vec2f) -> vec4f {\n    let eased = sin(progress() * BOUNCE_PI / 2.0);\n    let phase = progress() * BOUNCE_PI * params.bounces;\n    let y = abs(cos(phase)) * (1.0 - eased);\n    let d = uv.y - y;\n    let dropped = builtin_aa_step(d, 0.0);\n    let shadow_alpha = params.shadow_color.a;\n    let fade = mix(\n        (d / params.shadow_height) * shadow_alpha + (1.0 - shadow_alpha),\n        1.0,\n        builtin_smoothstep(0.95, 1.0, progress()),\n    );\n    let shadow = clamp(step(d, params.shadow_height) * (1.0 - fade), 0.0, 1.0);\n    let shaded = builtin_over(vec4f(params.shadow_color.rgb, 1.0) * shadow, gl_to_color(uv));\n    return mix(shaded, gl_from_color(vec2f(uv.x, uv.y + (1.0 - y))), dropped);\n}\n";
Expand description

Picture dropping away with bounces and a contact shadow transition body.