URL: http://glslsandbox.com/e#23623.0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
// Digitized Worley Noise // By: Brandon Fogerty // bfogerty@gmail.com // xdpixel.com #ifdef GL_ES precision mediump float; #endif uniform float time; uniform vec2 mouse; uniform vec2 resolution; float random( vec2 p ) { return fract( sin( fract( sin( p.x ) ) + p.y) * 42.17563); } float worley( vec2 p, float timeSpeed ) { float d = 10.0; for( int xo = -1; xo <= 1; xo++ ) { for( int yo = -1; yo <= 1; yo++ ) { vec2 test_cell = floor(p) + vec2( xo, yo ); float f1 = random( test_cell ); float f2 = random( test_cell + vec2(1.0,83.0) ); float xp = mix( f1, f2, sin(time*timeSpeed) ); float yp = mix( f1, f2, cos(time*timeSpeed) ); vec2 c = test_cell + vec2(xp,yp); vec2 cTop = p - c; d = min( d, dot(cTop,cTop) ); } } return d; } float worley2( vec2 p ) { float d = 10.0; for( int xo = -1; xo <= 1; xo++ ) { for( int yo = -1; yo <= 1; yo++ ) { vec2 test_cell = floor(p) + vec2( xo, yo ); vec2 c = test_cell; vec2 cTop = p - c; d = min( d, dot(cTop,cTop) ); } } return d; } float pass( vec2 uv, float timeSpeed ) { float t = worley( gl_FragCoord.xy / 15.0, timeSpeed ); t = pow(t, 4.0 ); return t; } void main( void ) { vec2 uv = (gl_FragCoord.xy / resolution.xy) * 2.0 - 1.0; float t = worley2( gl_FragCoord.xy / 0.6 ); vec3 finalColor = vec3( t,0,t) * 1.1; t = pass( uv, 1.0 ); finalColor += vec3( t, t, sqrt(t * 4.0) ); finalColor *= smoothstep(1.0, 0.0, length(uv.y) * 2.5 ); gl_FragColor = vec4( finalColor, 1.0 ); } |