Back to shaders
Shader test bench
Mosaic Transition
runnable transition
GLSL transition function. Stronghold supplies two demo textures and progress/time uniforms.
Code
// Author: YueDev
// License: MIT
uniform float mosaicNum;// = 10.0
vec2 getMosaicUV(vec2 uv) {
float mosaicWidth = 2.0 / mosaicNum * min(progress, 1.0 - progress);
float mX = floor(uv.x / mosaicWidth) + 0.5;
float mY = floor(uv.y / mosaicWidth) + 0.5;
return vec2(mX * mosaicWidth, mY * mosaicWidth);
}
vec4 transition (vec2 uv) {
vec2 mosaicUV = min(progress, 1.0 - progress) == 0.0 ? uv : getMosaicUV(uv);
return mix(getFromColor(mosaicUV), getToColor(mosaicUV), progress * progress);
}