Back to shaders
Shader test bench
LeftRight
runnable transition
GLSL transition function. Stronghold supplies two demo textures and progress/time uniforms.
Code
// Author: zhmy
// License: MIT
const vec4 black = vec4(0.0, 0.0, 0.0, 1.0);
const vec2 boundMin = vec2(0.0, 0.0);
const vec2 boundMax = vec2(1.0, 1.0);
bool inBounds (vec2 p) {
return all(lessThan(boundMin, p)) && all(lessThan(p, boundMax));
}
vec4 transition (vec2 uv) {
vec2 spfr,spto = vec2(-1.);
float size = mix(1.0, 3.0, progress*0.2);
spto = (uv + vec2(-0.5,-0.5))*vec2(size,size)+vec2(0.5,0.5);
spfr = (uv - vec2(1.-progress, 0.0));
if(inBounds(spfr)){
return getToColor(spfr);
}else if(inBounds(spto)){
return getFromColor(spto) * (1.0 - progress);
} else{
return black;
}
}