Skip to main content

WIND

Constant WIND 

Source
pub const WIND: &str = "// Port of gl-transitions/transitions/wind.glsl\n// Author: gre\n// License: MIT\n\n// One random value in [0, 1) per output row from a PCG hash (Jarzynski and Olano, 2020), which\n// is identical on every GPU unlike `fract(sin(x) * ...)`.\nfn wind_random(uv_y: f32) -> f32 {\n    let row = u32(max(floor(uv_y * resolution().y), 0.0));\n    let state = row * 747796405u + 2891336453u;\n    let word = ((state >> ((state >> 28u) + 4u)) ^ state) * 277803737u;\n    // The top 24 bits convert to f32 exactly.\n    return f32(((word >> 22u) ^ word) >> 8u) / 16777216.0;\n}\n\nfn gl_transition(uv: vec2f) -> vec4f {\n    let x = select(uv.x, 1.0 - uv.x, params.reversed != 0u);\n    let random = wind_random(uv.y);\n    // A descending ramp (size > 0): MSL, GLSL and SPIR-V `smoothstep` leave edge0 > edge1\n    // undefined, so the helper defines it with WGSL\'s own arithmetic.\n    let mask = builtin_smoothstep(\n        0.0,\n        -params.size,\n        x * (1.0 - params.size) + params.size * random - progress() * (1.0 + params.size),\n    );\n    return mix(gl_from_color(uv), gl_to_color(uv), mask);\n}\n";
Expand description

Noisy wind wipe transition body.