KAOS Posted Wednesday at 11:20 PM Author Share Posted Wednesday at 11:20 PM Storm Mode update incoming.... It is impossible to encapsulate all of the features in a single image. 1 Link to comment Share on other sites More sharing options...
KAOS Posted yesterday at 02:27 AM Author Share Posted yesterday at 02:27 AM controller.addWeatherLayer('lightning-strikes', { type: 'symbol', paint: { symbol: { shader: ` #extension GL_OES_standard_derivatives : enable precision mediump float; uniform vec2 resolution; uniform float dpr; uniform float time; varying vec2 vUv; varying vec2 vPosition; varying float vFactor; varying float vRandom; float rand(float x) { return fract(sin(x)*75154.32912); } float rand3d(vec3 x) { return fract(375.10297 * sin(dot(x, vec3(103.0139,227.0595,31.05914)))); } float noise(float x) { float i = floor(x); float a = rand(i), b = rand(i+1.); float f = x - i; return mix(a,b,f); } float perlin(float x) { float r=0.,s=1.,w=1.; for (int i=0; i<6; i++) { s *= 2.0; w *= 0.5; r += w * noise(s*x); } return r; } float noise3d(vec3 x) { vec3 i = floor(x); float i000 = rand3d(i+vec3(0.,0.,0.)), i001 = rand3d(i+vec3(0.,0.,1.)); float i010 = rand3d(i+vec3(0.,1.,0.)), i011 = rand3d(i+vec3(0.,1.,1.)); float i100 = rand3d(i+vec3(1.,0.,0.)), i101 = rand3d(i+vec3(1.,0.,1.)); float i110 = rand3d(i+vec3(1.,1.,0.)), i111 = rand3d(i+vec3(1.,1.,1.)); vec3 f = x - i; return mix(mix(mix(i000,i001,f.z), mix(i010,i011,f.z), f.y), mix(mix(i100,i101,f.z), mix(i110,i111,f.z), f.y), f.x); } float perlin3d(vec3 x) { float r = 0.0; float w = 1.0, s = 1.0; for (int i=0; i<5; i++) { w *= 0.5; s *= 2.0; r += w * noise3d(s * x); } return r; } #define COL1 vec4(0, 0, 0, 0) / 255.0 #define COL2 vec4(235, 241, 245, 255) / 255.0 #define SIZE 100 #define FLASH_POWER .8 #define RADIUS .001 #define SPEED .0018 #define SEED void main() { vec2 pos = vUv; float dist = length(2.0 * pos - 1.0) * 2.0; float x = time + 0.1; float m = 0.2 + 0.2 * vFactor; // max duration of strike float i = floor(x/m); float f = x/m - i; float k = vFactor; // frequency of strikes float n = noise(i); float t = ceil(n-k); // occurrence float d = max(0., n-k) / (1.-k); // duration float o = ceil(t - f - (1. - d)); // occurrence with duration float fx = 4.; if (o == 1.) { fx += 10. * vFactor; } fx = max(4., fx); float g = fx / (dist * (10. + 20.)) * FLASH_POWER; // smooth out edges to avoid fading extending beyond the symbol's bounds float edgeFadeFactor = smoothstep(0.5, 1.0, dist); float invertedEdgeFadeFactor = 1.0 - edgeFadeFactor; vec4 color = mix(COL1, COL2, g); color.a *= min(1.0, 0.5 + vFactor) * invertedEdgeFadeFactor; gl_FragColor = color; gl_FragColor.rgb *= gl_FragColor.a; } `, size: { width: 60, height: 60 }, animated: true, blending: 2, pitchWithMap: true, allowOverlap: true, factor: (data) => { const max = 200; return (200 - data.age) / 200; } } } }); Link to comment Share on other sites More sharing options...
KAOS Posted yesterday at 02:30 AM Author Share Posted yesterday at 02:30 AM One wrong comma and nothing works. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now