Skip to content

Instantly share code, notes, and snippets.

@AnastasiaDunbar
Forked from glslioadmin/TEMPLATE.glsl
Last active April 4, 2016 05:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AnastasiaDunbar/ae64014bc78e4ed8cf05 to your computer and use it in GitHub Desktop.
Save AnastasiaDunbar/ae64014bc78e4ed8cf05 to your computer and use it in GitHub Desktop.
GLSL.io Transition (v1)
/*paint.glsl
#ifdef GL_ES
precision highp float;
#endif
uniform sampler2D from, to;
uniform float progress;
uniform vec2 resolution;
uniform sampler2D a;
const int waves = 4;
float random (float x) {
return fract(sin(x)*1e4);
}
float paint(vec2 p, float sharp) {
float f = 0.;
for (float i = 0.; i < float(waves); i++) {
f += sin((p.x*mix(1.,7.,random(i))*5.)+random(i+4.2)+(progress*8.)+cos(progress*i*2.))*random(i+.53);
}
f /= float(waves)+4.;
f = clamp((f+((p.y-2.)+(progress*3.)))*sharp,0.,1.);
return f;
}
void main() {
vec2 p = gl_FragCoord.xy / resolution.xy;
//mix(texture2D(from, p), texture2D(to, p), progress)
float esp = 0.01;
float s = (paint(p-esp,20.)-paint(p,15.))*.4;
gl_FragColor = mix(texture2D(from, p), texture2D(to, p), paint(p,50.))+s;
}
*/
#ifdef GL_ES
precision highp float;
#endif
uniform sampler2D from, to;
uniform float progress;
uniform vec2 resolution;
uniform float FPS;
uniform float Seed;
#define progress (floor(progress*FPS)/(FPS+1.))
float sigmoid(float x, float a) {
float b = pow(x*2.,a)/2.;
if (x > .5) {
b = 1.-pow(2.-(x*2.),a)/2.;
}
return b;
}
float rand(float co){
return fract(sin((co*24.9898)+Seed)*43758.5453);
}
float rand(vec2 co){
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
}
float apow(float a,float b) { return pow(abs(a),b)*sign(b); }
vec3 pow3(vec3 a,vec3 b) { return vec3(apow(a.r,b.r),apow(a.g,b.g),apow(a.b,b.b)); }
float smooth_mix(float a,float b,float c) { return mix(a,b,sigmoid(c,2.)); }
float random(vec2 co, float shft){
co += 10.;
return smooth_mix(fract(sin(dot(co.xy ,vec2(12.9898+(floor(shft)*.5),78.233+Seed))) * 43758.5453),fract(sin(dot(co.xy ,vec2(12.9898+(floor(shft+1.)*.5),78.233+Seed))) * 43758.5453),fract(shft));
}
float smooth_random(vec2 co, float shft) {
return smooth_mix(smooth_mix(random(floor(co),shft),random(floor(co+vec2(1.,0.)),shft),fract(co.x)),smooth_mix(random(floor(co+vec2(0.,1.)),shft),random(floor(co+vec2(1.,1.)),shft),fract(co.x)),fract(co.y));
}
vec4 texture(vec2 p) {
return mix(texture2D(from, p), texture2D(to, p), sigmoid(progress,10.));
}
#define pi 3.14159265358979323
#define clamps(x) clamp(x,0.,1.)
void main() {
vec2 p = gl_FragCoord.xy / resolution.xy;
vec3 f = vec3(0.);
for (float i = 0.; i < 13.; i++) {
f += sin(((p.x*rand(i)*6.)+(progress*8.))+rand(i+1.43))*sin(((p.y*rand(i+4.4)*6.)+(progress*6.))+rand(i+2.4));
f += 1.-clamps(length(p-vec2(smooth_random(vec2(progress*1.3),i+1.),smooth_random(vec2(progress*.5),i+6.25)))*mix(20.,70.,rand(i)));
}
f += 4.;
f /= 11.;
f = pow3(f*vec3(1.,0.7,0.6),vec3(1.,2.-sin(progress*pi),1.3));
f *= sin(progress*pi);
p -= .5;
p *= 1.+(smooth_random(vec2(progress*5.),6.3)*sin(progress*pi)*.05);
p += .5;
vec4 blurred_image = vec4(0.);
float bluramount = sin(progress*pi)*.03;
#define repeats 50.
for (float i = 0.; i < repeats; i++) {
vec2 q = vec2(cos(degrees((i/repeats)*360.)),sin(degrees((i/repeats)*360.))) * (rand(vec2(i,p.x+p.y))+bluramount);
vec2 uv2 = p+(q*bluramount);
blurred_image += texture(uv2);
}
blurred_image /= repeats;
gl_FragColor = blurred_image+vec4(f,0.);
}
{"FPS":40,"Seed":2.31}
GLSL.io Transition License (v1):
The MIT License (MIT)
Copyright (C) 2014 contact@glsl.io
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment