URL: http://glslsandbox.com/e#20583.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 | // Energy Sphere // By: Brandon Fogerty // bfogerty at gmail dot com // Special Thanks to  ElusivePete // xdpixel.com #ifdef GL_ES precision mediump float; #endif uniform float time; uniform vec2 resolution; vec2 getNewUV( vec2 uv, vec2 pos, float radius, float strength, out float dist) {     vec2 fromUVToPoint = pos - uv;     dist = length( fromUVToPoint );     float mag = (1.0 - (dist / radius)) * strength;     mag *= step( dist, radius );     return uv + (mag * fromUVToPoint); } vec4 proceduralTexture2D( vec2 uv, vec2 resolution ) {     vec2 fragCoord = (uv  * resolution.x );     vec3 brightColor = vec3( 1.0, 1.0, 1.0 );     vec3 darkColor = vec3( 0.0, 0.0, 0.0 );     vec2 p = floor( (fragCoord.xy / resolution.x) * 10.0 );     float t = mod(p.x + p.y, 2.0) * 10.0;     vec3 color = mix( darkColor, brightColor, t);     return vec4( color, 1.0 );   } void main( void )  {     vec2 uv = (gl_FragCoord.xy / resolution.xy) * 2.0 - 1.0;     uv.x *= resolution.x / resolution.y;     float radius = 0.50;     float ct = cos( time / 3.0 );     float st0 = sin( time / 3.0 );     float st1 = sin( time );     vec2 origin = vec2( 0.0, 0.0 );     float x = origin.x + ( ct * st0) * 2.70;     float y = origin.y + ( st1 ) * 0.50;     vec2 pos = vec2(x,y);     float dist = 0.0;     vec2 newUV = getNewUV( uv, pos, radius, 0.5, dist);     float start = 0.42;     float glowT = sin(time)*0.5 + 0.5;     float outlineRadius = radius +  (1.0-glowT)*0.01 + (glowT * 0.08);     vec4 highlight = vec4( 0.00, 0.00, 0.00, 1.0 );     float t = (outlineRadius - start) / max( (dist - start), 0.01);     highlight = mix( vec4( 0.00, 0.00, 0.00, 1.0 ), vec4( 0.00, 0.50, 0.80, 1.0 ), t);     vec4 color = proceduralTexture2D( newUV, resolution.xy ) + highlight;     color.a = 1.0;     gl_FragColor = color; } |