Code: Select all
/*{
"CREDIT": "www.colour-burst.com",
"DESCRIPTION": "",
"CATEGORIES": [ "generator" ],
"INPUTS": [
{
"TYPE": "image",
"NAME": "image0"
},
{
"TYPE": "float",
"NAME": "scaleX"
},
{
"TYPE": "float",
"NAME": "scaleY"
},
{
"TYPE": "float",
"NAME": "shiftX"
},
{
"TYPE": "float",
"NAME": "shiftY"
}
]
}*/
/*
ISF Reference
=========================
1) Valid inputs:
- "event"
- "bool"
- "long"
- "float"
- "point2D"
- "color"
- "image"
- "audio"
- "audioFFT"
2) Functions:
- IMG_NORM_PIXEL() -> get a pixel from input with normalized coordinates
- IMG_PIXEL() -> get a pixel from input with screen space coordinates
3) Predefined variables:
- RENDERSIZE (resolution of the shader)
- TIME (run time)
- gl_FragCoord.xy (screen space coordinates of current fragment)
- isf_FragNormCoord.xy (normalized coordinates)
To learn more see:
https://github.com/mrRay/ISF_Spec/
*/
float mirror (float x){
float peak = 1;
x = mod(x,2);
int en = int(x<peak);
x = (x*en) + ( (1-en)*( min(x,peak) + peak-x ) );
return x;
}
vec2 mirror (vec2 cd){
float peak = 1;
cd = mod(cd,2);
int enx = int(cd.x<peak);
int eny = int(cd.y<peak);
cd.x = (cd.x*enx) + ( (1-enx)*( min(cd.x,peak) + peak-cd.x ) );
cd.y = (cd.y*eny) + ( (1-eny)*( min(cd.y,peak) + peak-cd.y ) );
return cd;
}
void main() {
vec2 uv = ((isf_FragNormCoord.xy-.5)*vec2(scaleX,scaleY) )+0.5 +vec2(shiftX,shiftY); //scale from centre
uv = mirror(uv); // mirror repeat coords vec2(shift,0)
vec4 col = IMG_NORM_PIXEL(image0,uv);
gl_FragColor = col;
}