/*{ "CATEGORIES": [ "Distortion" ], "CREDIT": "Automatically converted from https://www.github.com/gl-transitions/gl-transitions/tree/master/displacement.glsl", "DESCRIPTION": "", "INPUTS": [ { "NAME": "startImage", "TYPE": "image" }, { "NAME": "endImage", "TYPE": "image" }, { "DEFAULT": 0, "MAX": 1, "MIN": 0, "NAME": "progress", "TYPE": "float" }, { "NAME": "displacementMap", "TYPE": "image" }, { "DEFAULT": 0.5, "MAX": 1, "MIN": 0, "NAME": "strength", "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: Travis Fischer // License: MIT // // Adapted from a Codrops article by Robin Delaporte // https://tympanus.net/Development/DistortionHoverEffect vec4 transition (vec2 uv) { float displacement = IMG_NORM_PIXEL(displacementMap, uv).r * strength; vec2 uvFrom = vec2(uv.x + progress * displacement, uv.y); vec2 uvTo = vec2(uv.x - (1.0 - progress) * displacement, uv.y); return mix( getFromColor(uvFrom), getToColor(uvTo), progress ); } void main() { gl_FragColor = transition(isf_FragNormCoord.xy); }