Back to shaders
Shader test bench
Crazy Parametric Fun.fs
runnable fragment
Complete GLSL fragment shader. Stronghold runs it directly when the browser can compile it.
Code
uniform sampler2D startImage;
uniform sampler2D endImage;
uniform float progress;
uniform float b;
uniform float smoothness;
uniform float amplitude;
uniform float a;
precision mediump float;
/*{
"CATEGORIES": [
"Distortion"
],
"CREDIT": "Automatically converted from https://www.github.com/gl-transitions/gl-transitions/tree/master/CrazyParametricFun.glsl",
"DESCRIPTION": "",
"INPUTS": [
{
"NAME": "startImage",
"TYPE": "image"
},
{
"NAME": "endImage",
"TYPE": "image"
},
{
"DEFAULT": 0,
"MAX": 1,
"MIN": 0,
"NAME": "progress",
"TYPE": "float"
},
{
"DEFAULT": 1,
"MAX": 10,
"MIN": 0,
"NAME": "b",
"TYPE": "float"
},
{
"NAME": "smoothness",
"TYPE": "float"
},
{
"DEFAULT": 120,
"MAX": 360,
"MIN": 0,
"NAME": "amplitude",
"TYPE": "float"
},
{
"DEFAULT": 4,
"MAX": 10,
"MIN": 0,
"NAME": "a",
"TYPE": "float"
}
],
"ISFVSN": "2"
}
*/
vec4 getFromColor(vec2 inUV) {
return texture2D(startImage, inUV);
}
vec4 getToColor(vec2 inUV) {
return texture2D(endImage, inUV);
}
// Author: mandubian
// License: MIT
vec4 transition(vec2 uv) {
vec2 p = uv.xy / vec2(1.0).xy;
vec2 dir = p - vec2(.5);
float dist = length(dir);
float x = (a - b) * cos(progress) + b * cos(progress * ((a / b) - 1.) );
float y = (a - b) * sin(progress) - b * sin(progress * ((a / b) - 1.));
vec2 offset = dir * vec2(sin(progress * dist * amplitude * x), sin(progress * dist * amplitude * y)) / smoothness;
return mix(getFromColor(p + offset), getToColor(p), smoothstep(0.2, 1.0, progress));
}
void main() {
gl_FragColor = transition((gl_FragCoord.xy / u_resolution.xy).xy);
}