ISF - Distortion - Ripples
/*{
"CATEGORIES": [
"Distortion Effect"
],
"CREDIT": "carter rosenberg",
"DESCRIPTION": null,
"INPUTS": [
{
"NAME": "inputImage",
"TYPE": "image"
},
{
"DEFAULT": 1,
"MAX": 32,
"MIN": 0.1,
"NAME": "level",
"TYPE": "float"
},
{
"DEFAULT": 0,
"MAX": 1,
"MIN": 0,
"NAME": "offset",
"TYPE": "float"
},
{
"DEFAULT": 0,
"MAX": 1,
"MIN": 0,
"NAME": "x_smear",
"TYPE": "float"
},
{
"DEFAULT": 0,
"MAX": 1,
"MIN": 0.01,
"NAME": "y_smear",
"TYPE": "float"
},
{
"DEFAULT": [
0.5,
0.5
],
"MAX": [
1,
1
],
"MIN": [
0,
0
],
"NAME": "center",
"TYPE": "point2D"
},
{
"DEFAULT": 0,
"LABELS": [
"Single",
"Double"
],
"NAME": "mode",
"TYPE": "long",
"VALUES": [
0,
1
]
},
{
"TYPE":"float",
"NAME":"repeatStyle"
},
{
"TYPE":"float",
"NAME":"radius"
}
],
"ISFVSN": "2",
"VSN": null
}
*/
const float pi = 3.14159265359;
#ifndef GL_ES
float distance (vec2 inCenter, vec2 pt)
{
float tmp = pow(inCenter.x-pt.x,2.0)+pow(inCenter.y-pt.y,2.0);
return pow(tmp,0.5);
}
#endif
float circle(in vec2 center, in float lRadius, in float blur){
float aspect = RENDERSIZE.x / RENDERSIZE.y;
vec2 pixel = isf_FragNormCoord.xy;
vec2 dist = pixel - center;
dist.y /= aspect * 0.5 * 2.0;
return 1.-smoothstep( lRadius - ( lRadius * blur ),
lRadius + ( lRadius * blur ),
dot( dist, dist ) * 4.0 );
}
void main() {
/*
vec2 loc = gl_FragCoord.xy;
vec2 locCenter = feedbackCenter * RENDERSIZE;
float scaledRadius = maskRadius * min(RENDERSIZE.x,RENDERSIZE.y);
float dist = distance(locCenter,loc);
dist>scaledRadius
*/
vec2 uv = isf_FragNormCoord.xy;
vec2 texSize = RENDERSIZE;
vec2 tc = uv * texSize;
vec2 modifiedCenter = center * RENDERSIZE;
float scaledRadius = radius * min(RENDERSIZE.x,RENDERSIZE.y);
float r = distance(modifiedCenter, tc);
float a = atan((tc.y-modifiedCenter.y),(tc.x-modifiedCenter.x));
//float render_length = length(RENDERSIZE);
//float radius_sized = clamp(radius * render_length, 1.0, render_length);
float radius_sized = radius * length(RENDERSIZE);
tc -= modifiedCenter;
gl_FragColor = vec4(0.0);
if (r<scaledRadius) {
float percent = 1.0-(radius_sized - r) / radius_sized;
float adjustedOffset = offset * 2.0 * pi;
tc.x = r*(1.0+sin(percent * level * 2.0 * pi + adjustedOffset))/2.0 * cos(a);
tc.y = r*(1.0+sin(percent * level * 2.0 * pi + adjustedOffset))/2.0 * sin(a);
tc.x = mix(uv.x, tc.x, max(1.0-x_smear,0.001));
tc.y = mix(uv.y, tc.y, max(1.0-y_smear,0.001));
} else {
gl_FragColor = vec4(0.0);
}
tc += modifiedCenter;
vec2 loc = tc / texSize;
gl_FragColor = IMG_NORM_PIXEL(inputImage, loc);
}