Back to shaders
Shader test bench
DirectionalScaled
runnable transition
GLSL transition function. Stronghold supplies two demo textures and progress/time uniforms.
Code
// Author: Thibaut Foussard
// based on Directional transition by Gaëtan Renaudeau
// https://gl-transitions.com/editor/Directional
// License: MIT
#define PI acos(-1.0)
uniform vec2 direction; // = vec2(0.0, 1.0)
uniform float scale; // = .7
float parabola(float x) {
float y = pow(sin(x * PI), 1.);
return y;
}
vec4 transition (vec2 uv) {
float easedProgress = pow(sin(progress * PI / 2.), 3.);
vec2 p = uv + easedProgress * sign(direction);
vec2 f = fract(p);
float s = 1. - (1. - (1. / scale)) * parabola(progress);
f = (f - 0.5) * s + 0.5;
float mixer = step(0.0, p.y) * step(p.y, 1.0) * step(0.0, p.x) * step(p.x, 1.0);
vec4 col = mix(getToColor(f), getFromColor(f), mixer);
float border = step(0., f.x) * step(0., (1. - f.x)) * step(0., f.y) * step(0., 1. - f.y);
col *= border;
return col;
}