| #ifdef GL_ES |
| precision mediump float; |
| #endif |
| |
| |
| |
| |
| |
| |
| |
| uniform mat3 outputToWorld; |
| |
| uniform vec4 color; |
| uniform float time; |
| uniform float brightness; |
| |
| |
| float hash( float n ) { return fract(sin(n)*43758.5453); } |
| float rand(vec2 co){ return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); } |
| |
| float noise( in vec2 x ) |
| { |
| vec2 p = floor(x); |
| vec2 f = fract(x); |
| f = f*f*(3.0-2.0*f); |
| float n = p.x + p.y*57.0; |
| float res = mix(mix(hash(n+0.0), hash(n+1.0),f.x), mix(hash(n+57.0), hash(n+58.0),f.x),f.y); |
| return res; |
| } |
| |
| vec3 cloud(vec2 p) { |
| float f = 0.0; |
| f += 0.50000*noise(p*1.0*10.0); |
| f += 0.25000*noise(p*2.0*10.0); |
| f += 0.12500*noise(p*4.0*10.0); |
| f += 0.06250*noise(p*8.0*10.0); |
| f *= f; |
| |
| return color.rgb * color.a * f * .6; |
| } |
| |
| const float SPEED = 0.01; |
| const float DENSITY = 1.5; |
| |
| void main( void ) |
| { |
| vec2 pos = .01 * (outputToWorld * vec3(gl_FragCoord.xy, 1.0)).xy; |
| |
| |
| |
| vec3 color = cloud(pos); |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| float dist = length(pos); |
| vec2 coord = vec2(dist, atan(pos.y, pos.x)); |
| |
| vec2 p = 40.0 * vec2(coord.x, |
| floor(coord.x + 1.0) * coord.y + |
| hash(floor(40.0 * coord.x))); |
| |
| vec2 uv = 2.0 * fract(p) - 1.0; |
| |
| float cellValue = abs(2.0 * fract(rand(floor(p)) + SPEED * time) - 1.0); |
| float cellBrightness = clamp((cellValue - 0.9) * brightness * 10.0, 0.0, 1.0); |
| |
| color += clamp( |
| (1.0 - 2.0 * length(uv)) * |
| cellBrightness, 0.0, 1.0); |
| |
| |
| gl_FragColor = vec4(color, 1.0); |
| } |