gl-transitions
Version:
The open collection of GL Transitions
81 lines (70 loc) • 2.15 kB
text/wgsl
// luma — WGSL, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/luma.glsl
// Author: gre
// License: MIT
// Description: A wipe that follows the brightness of a grayscale mask (the luma texture)
// Bindings and uniform layout: see the gl-transitions package README
struct Uniforms {
progress: f32,
ratio: f32,
}
var _from: texture_2d<f32>;
var _sampler: sampler;
var _to: texture_2d<f32>;
var luma: texture_2d<f32>;
var<uniform> uniforms: Uniforms;
var<private> _fragColor: vec4<f32>;
var<private> _uv_1: vec2<f32>;
fn _texture_luma(uv: ptr<function, vec2<f32>>) -> vec4<f32> {
let _e14 = (*uv)[0u];
let _e16 = (*uv)[1u];
let _e19 = textureSampleLevel(luma, _sampler, vec2<f32>(_e14, (1f - _e16)), 0f);
return _e19;
}
fn getFromColor(uv_1: ptr<function, vec2<f32>>) -> vec4<f32> {
let _e14 = (*uv_1)[0u];
let _e16 = (*uv_1)[1u];
let _e19 = textureSampleLevel(_from, _sampler, vec2<f32>(_e14, (1f - _e16)), 0f);
return _e19;
}
fn getToColor(uv_2: ptr<function, vec2<f32>>) -> vec4<f32> {
let _e14 = (*uv_2)[0u];
let _e16 = (*uv_2)[1u];
let _e19 = textureSampleLevel(_to, _sampler, vec2<f32>(_e14, (1f - _e16)), 0f);
return _e19;
}
fn transition(uv_3: ptr<function, vec2<f32>>) -> vec4<f32> {
var param: vec2<f32>;
var param_1: vec2<f32>;
var param_2: vec2<f32>;
let _e16 = (*uv_3);
param = _e16;
let _e17 = getToColor((¶m));
let _e18 = (*uv_3);
param_1 = _e18;
let _e19 = getFromColor((¶m_1));
let _e21 = uniforms.progress;
let _e22 = (*uv_3);
param_2 = _e22;
let _e23 = _texture_luma((¶m_2));
return mix(_e17, _e19, vec4(step(_e21, _e23.x)));
}
fn main_1() {
var param_3: vec2<f32>;
let _e13 = _uv_1;
param_3 = _e13;
let _e14 = transition((¶m_3));
_fragColor = _e14;
return;
}
fn main( _uv: vec2<f32>) -> vec4<f32> {
_uv_1 = _uv;
main_1();
let _e3 = _fragColor;
return _e3;
}