diff --git a/basic/spinner.glsl b/basic/spinner.glsl new file mode 100644 index 0000000..38e7b49 --- /dev/null +++ b/basic/spinner.glsl @@ -0,0 +1,31 @@ +#ifdef GL_ES +precision mediump float; +#endif + +#define TWO_PI 6.28318530718 + +uniform vec2 u_resolution; +uniform float u_time; + +vec3 hsb2rgb( in vec3 c ){ + vec3 rgb = clamp(abs(mod(c.x*6.0+vec3(0.0,4.0,2.0), + 6.0)-3.0)-1.0, + 0.0, + 1.0 ); + rgb = rgb*rgb*(3.0-2.0*rgb); + return c.z * mix( vec3(1.0), rgb, c.y); +} + +void main(){ + vec2 st = gl_FragCoord.xy/u_resolution; + vec3 color = vec3(0.0); + + + vec2 toCenter = vec2(0.5)-st; + float angle = atan(toCenter.y,toCenter.x); + float radius = length(toCenter)*2.0; + + color = hsb2rgb(vec3((angle/TWO_PI)+0.5*u_time*0.35,radius,1.0/radius)); + + gl_FragColor = vec4(color,1.0); +} diff --git a/utilities/inigo.glsl b/utilities/inigo.glsl new file mode 100644 index 0000000..2502ef1 --- /dev/null +++ b/utilities/inigo.glsl @@ -0,0 +1,27 @@ +// Translation (from C) of utility functions Inigo Quilez +// explains in http://www.iquilezles.org/www/articles/functions/functions.htm +float almostIdentity(float x, float m, float n) { + if(x > m) return x; + + float a = 2.*n - m; + float b = 2.0*m - 3.0*n; + float t = x/m; + + return (a*t + b)*t*t + n; +} + +float impulse(float k, float x) { + float h = k * x; + return h*exp(1.0-h); +} + +float cubic_pulse(float c, float w, float x) { + x = abs(x - c); + if(x > w) return .0; + x /= w; + return 1.0 - x*x*(3.0-2.0*x); +} + +float parabola(float x, float k) { + return pow(4.0*x*(1.0-x), k); +} diff --git a/weird/psychedelic_stars.glsl b/weird/psychedelic_stars.glsl new file mode 100644 index 0000000..2cc2de5 --- /dev/null +++ b/weird/psychedelic_stars.glsl @@ -0,0 +1,30 @@ +#ifdef GL_ES +precision mediump float; +#endif + +#define TAU 6.28318530718 + +uniform vec2 u_resolution; +uniform float u_time; + +vec3 hsb2rgb( in vec3 c ){ + vec3 rgb = clamp(abs(mod(c.x*6.0+vec3(0.0,4.0,2.0), + 6.0)-3.0)-1.0, + 0.0, + 1.0 ); + rgb = rgb*rgb*(3.0-2.0*rgb); + return c.z * mix( vec3(1.0), rgb, c.y); +} + +void main(){ + vec2 st = gl_FragCoord.xy/u_resolution; + vec3 color = vec3(0.0); + + vec2 toCenter = (vec2(sin(u_time*0.5), cos(u_time*0.5))-st); + float angle = atan(toCenter.y,toCenter.x)*u_time*3.0; + float radius = length(toCenter)*2.0; + + color = hsb2rgb(vec3((angle/TAU)+0.5,radius,1.0)); + + gl_FragColor = vec4(color,1.0); +}