URL: http://glslsandbox.com/e#22893.1
| 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 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | // Majestic Eye // By: Brandon Fogerty // bfogerty at gmail dot com // xdpixel.com #ifdef GL_ES precision mediump float; #endif uniform float time; uniform vec2 mouse; uniform vec2 resolution; #define HorizontalAmplitude         0.30 #define VerticleAmplitude           0.20 #define HorizontalSpeed             0.90 #define VerticleSpeed               1.50 #define ParticleMinSize             1.76 #define ParticleMaxSize             1.61 #define ParticleBreathingSpeed      0.30 #define ParticleColorChangeSpeed    0.70 #define ParticleCount               2.0 #define ParticleColor1              vec3(9.0, 5.0, 3.0) #define ParticleColor2              vec3(1.0, 3.0, 9.0) float hash( float x ) {     return fract( sin( x ) * 43758.5453 ); } float noise( vec2 uv )  // Thanks Inigo Quilez {     vec3 x = vec3( uv.xy, 0.0 );     vec3 p = floor( x );     vec3 f = fract( x );     f = f*f*(3.0 - 2.0*f);     float offset = 57.0;     float n = dot( p, vec3(1.0, offset, offset*2.0) );     return mix( mix(    mix( hash( n + 0.0 ),       hash( n + 1.0 ), f.x ),                         mix( hash( n + offset),     hash( n + offset+1.0), f.x ), f.y ),                 mix(    mix( hash( n + offset*2.0), hash( n + offset*2.0+1.0), f.x),                         mix( hash( n + offset*3.0), hash( n + offset*3.0+1.0), f.x), f.y), f.z); } float snoise( vec2 uv ) {     return noise( uv ) * 2.0 - 1.0; } float perlinNoise( vec2 uv ) {        float n =   noise( uv * 1.0 )   * 128.0 +                 noise( uv * 2.0 )   * 64.0 +                 noise( uv * 4.0 )   * 32.0 +                 noise( uv * 8.0 )   * 16.0 +                 noise( uv * 16.0 )  * 8.0 +                 noise( uv * 32.0 )  * 4.0 +                 noise( uv * 64.0 )  * 2.0 +                 noise( uv * 128.0 ) * 1.0;     float noiseVal = n / ( 1.0 + 2.0 + 4.0 + 8.0 + 16.0 + 32.0 + 64.0 + 128.0 );     noiseVal = abs(noiseVal * 2.0 - 1.0);     return  noiseVal; } float fBm( vec2 uv, float lacunarity, float gain ) {     float sum = 0.0;     float amp = 7.0;     for( int i = 0; i < 2; ++i )     {         sum += ( perlinNoise( uv ) ) * amp;         amp *= gain;         uv *= lacunarity;     }     return sum; } vec3 particles( vec2 pos ) {     vec3 c = vec3( 0, 0, 0 );     float noiseFactor = fBm( pos, 0.01, 0.1);     for( float i = 1.0; i < ParticleCount+1.0; ++i )     {         float cs = cos( time * HorizontalSpeed * (i/ParticleCount) + noiseFactor ) * HorizontalAmplitude;         float ss = sin( time * VerticleSpeed   * (i/ParticleCount) + noiseFactor ) * VerticleAmplitude;         vec2 origin = vec2( cs , ss );         float t = sin( time * ParticleBreathingSpeed * i ) * 0.5 + 0.5;         float particleSize = mix( ParticleMinSize, ParticleMaxSize, t );         float d = clamp( sin( length( pos - origin )  + particleSize ), 0.0, particleSize);         float t2 = sin( time * ParticleColorChangeSpeed * i ) * 0.5 + 0.5;         vec3 color = mix( ParticleColor1, ParticleColor2, t2 );         c += color * pow( d, 10.0 );     }     return c; } void main( void )  {     vec2 uv = ( gl_FragCoord.xy / resolution.xy ) * 2.0 - 1.0;     uv.x *= ( resolution.x / resolution.y );     vec3 finalColor = particles( sin( abs(uv) ) ) * length(uv);     gl_FragColor = vec4( finalColor, 1.0 ); } |