/*{ "CATEGORIES": [ "Wipe", "Retro" ], "CREDIT": "Automatically converted from https://www.github.com/gl-transitions/gl-transitions/tree/master/swap.glsl", "DESCRIPTION": "", "INPUTS": [ { "NAME": "startImage", "TYPE": "image" }, { "NAME": "endImage", "TYPE": "image" }, { "DEFAULT": 0, "MAX": 1, "MIN": 0, "NAME": "progress", "TYPE": "float" }, { "DEFAULT": 0.2, "MAX": 1, "MIN": 0, "NAME": "perspective", "TYPE": "float" }, { "DEFAULT": 3, "MAX": 10, "MIN": 0, "NAME": "depth", "TYPE": "float" }, { "DEFAULT": 0.4, "MAX": 1, "MIN": 0, "NAME": "reflection", "TYPE": "float" } ], "ISFVSN": "2" } */ vec4 getFromColor(vec2 inUV) { return IMG_NORM_PIXEL(startImage, inUV); } vec4 getToColor(vec2 inUV) { return IMG_NORM_PIXEL(endImage, inUV); } // Author: gre // License: MIT // General parameters 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)); } vec2 project (vec2 p) { return p * vec2(1.0, -1.2) + vec2(0.0, -0.02); } vec4 bgColor (vec2 p, vec2 pfr, vec2 pto) { vec4 c = black; pfr = project(pfr); if (inBounds(pfr)) { c += mix(black, getFromColor(pfr), reflection * mix(1.0, 0.0, pfr.y)); } pto = project(pto); if (inBounds(pto)) { c += mix(black, getToColor(pto), reflection * mix(1.0, 0.0, pto.y)); } return c; } vec4 transition(vec2 p) { vec2 pfr, pto = vec2(-1.); float size = mix(1.0, depth, progress); float persp = perspective * progress; pfr = (p + vec2(-0.0, -0.5)) * vec2(size/(1.0-perspective*progress), size/(1.0-size*persp*p.x)) + vec2(0.0, 0.5); size = mix(1.0, depth, 1.-progress); persp = perspective * (1.-progress); pto = (p + vec2(-1.0, -0.5)) * vec2(size/(1.0-perspective*(1.0-progress)), size/(1.0-size*persp*(0.5-p.x))) + vec2(1.0, 0.5); if (progress < 0.5) { if (inBounds(pfr)) { return getFromColor(pfr); } if (inBounds(pto)) { return getToColor(pto); } } if (inBounds(pto)) { return getToColor(pto); } if (inBounds(pfr)) { return getFromColor(pfr); } return bgColor(p, pfr, pto); } void main() { gl_FragColor = transition(isf_FragNormCoord.xy); }