1 uniform float tsec, phase;
4 float fbm(vec2 p, int octaves);
8 const vec3 color = vec3(0.2, 0.4, 1.0);
10 float tm = tsec + phase;
12 vec2 uv = gl_TexCoord[0].st;
13 vec2 pt = uv * vec2(2.0) - vec2(1.0);
15 float pulse = fbm(vec2(uv.y * 50.0 - tm * 0.5, 0.0), 2);
17 float d_horiz = abs(pt.x);
18 float d_vert = max(abs(pt.y), 0.0);
20 float beam_sharpness = 80.0 * clamp(pow(uv.y, 0.5), 0.0, 1.0) * (pulse * 0.5 + 1.0);
21 float beam_intensity = 6.0 * min(0.01 / (uv.y * uv.y) - 0.0004, 1.0);
23 float glow_u = pow(1.0 - smoothstep(0.0, 1.0, d_horiz), beam_sharpness) * beam_intensity;
24 float glow_v = 1.0 - smoothstep(0.98, 1.0, d_vert);
26 float glow = glow_u * glow_v;
28 gl_FragColor.rgb = color * glow;// + vec3(0.0, 1.0, 0.0) * step(0.99, max(abs(pt.x), abs(pt.y)));
32 float fbm(vec2 p, int octaves)
38 for(int i=0; i<octaves; i++) {
39 res += cnoise(p * freq) * scale;
47 // GLSL textureless classic 2D noise "cnoise",
48 // with an RSL-style periodic variant "pnoise".
49 // Author: Stefan Gustavson (stefan.gustavson@liu.se)
50 // Version: 2011-08-22
52 // Many thanks to Ian McEwan of Ashima Arts for the
53 // ideas for permutation and gradient selection.
55 // Copyright (c) 2011 Stefan Gustavson. All rights reserved.
56 // Distributed under the MIT license. See LICENSE file.
57 // https://github.com/stegu/webgl-noise
62 return x - floor(x * (1.0 / 289.0)) * 289.0;
67 return mod289(((x*34.0)+1.0)*x);
70 vec4 taylor_inv_sqrt(vec4 r)
72 return 1.79284291400159 - 0.85373472095314 * r;
76 return t*t*t*(t*(t*6.0-15.0)+10.0);
79 // Classic perlin noise
82 vec4 pi = floor(p.xyxy) + vec4(0.0, 0.0, 1.0, 1.0);
83 vec4 pf = fract(p.xyxy) - vec4(0.0, 0.0, 1.0, 1.0);
84 pi = mod289(pi); // To avoid truncation effects in permutation
90 vec4 i = permute(permute(ix) + iy);
92 vec4 gx = fract(i * (1.0 / 41.0)) * 2.0 - 1.0 ;
93 vec4 gy = abs(gx) - 0.5 ;
94 vec4 tx = floor(gx + 0.5);
97 vec2 g00 = vec2(gx.x,gy.x);
98 vec2 g10 = vec2(gx.y,gy.y);
99 vec2 g01 = vec2(gx.z,gy.z);
100 vec2 g11 = vec2(gx.w,gy.w);
102 vec4 norm = taylor_inv_sqrt(vec4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11)));
108 float n00 = dot(g00, vec2(fx.x, fy.x));
109 float n10 = dot(g10, vec2(fx.y, fy.y));
110 float n01 = dot(g01, vec2(fx.z, fy.z));
111 float n11 = dot(g11, vec2(fx.w, fy.w));
113 vec2 fade_xy = fade(pf.xy);
114 vec2 n_x = mix(vec2(n00, n01), vec2(n10, n11), fade_xy.x);
115 float n_xy = mix(n_x.x, n_x.y, fade_xy.y);