diff --git a/voronoi.glsl b/voronoi.glsl new file mode 100644 index 0000000..ad59e84 --- /dev/null +++ b/voronoi.glsl @@ -0,0 +1,49 @@ +//Modified from: https://www.shadertoy.com/view/MslGD8 + +// Created by inigo quilez - iq/2013 +// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. + +#ifdef GL_ES +precision mediump float; +#extension GL_OES_standard_derivatives : enable +#endif + +uniform float time; +uniform vec2 mouse; +uniform vec2 resolution; + +vec2 hash( vec2 p ) { p=vec2(dot(p,vec2(127.1,311.7)),dot(p,vec2(269.5,183.3))); return fract(sin(p)*18.5453); } + +// return distance, and cell id +vec2 voronoi( in vec2 x ) +{ + vec2 n = floor( x ); + vec2 f = fract( x ); + + vec3 m = vec3( 8.0 ); + for( int j=-1; j<=1; j++ ) + for( int i=-1; i<=1; i++ ) + { + vec2 g = vec2( float(i), float(j) ); + vec2 o = hash( n + g ); + vec2 r = g - f + (0.5+0.5*tan(time+6.2831-o)); + float d = dot( r, r ); + if( d