summaryrefslogtreecommitdiff
path: root/assets/shader/snow.fs
diff options
context:
space:
mode:
authorRitabrata Das <[email protected]>2026-09-09 21:07:21 +0530
committerRitabrata Das <[email protected]>2026-09-09 21:07:21 +0530
commitffd968a26826108ca9fb23d46ed5789260852eb7 (patch)
tree3861d08dae1c28f547952dbcc16e04ae7b5286b5 /assets/shader/snow.fs
intial commit
Diffstat (limited to 'assets/shader/snow.fs')
-rw-r--r--assets/shader/snow.fs49
1 files changed, 49 insertions, 0 deletions
diff --git a/assets/shader/snow.fs b/assets/shader/snow.fs
new file mode 100644
index 0000000..acb4a59
--- /dev/null
+++ b/assets/shader/snow.fs
@@ -0,0 +1,49 @@
+// Copyright (c) 2013 Andrew Baldwin (twitter: baldand, www: http://thndl.com)
+// License = Attribution-NonCommercial-ShareAlike (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_US)
+
+// "Just snow"
+// Simple (but not cheap) snow made from multiple parallax layers with randomly positioned
+// flakes and directions. Also includes a DoF effect. Pan around with mouse.
+
+#define LIGHT_SNOW // Comment this out for a blizzard
+
+#ifdef LIGHT_SNOW
+ #define LAYERS 50
+ #define DEPTH .5
+ #define WIDTH .3
+ #define SPEED .6
+#else // BLIZZARD
+ #define LAYERS 200
+ #define DEPTH .1
+ #define WIDTH .8
+ #define SPEED 1.5
+#endif
+
+precision mediump float;
+
+uniform float iTime;
+uniform vec2 iResolution;
+uniform vec2 iMouse;
+
+void main()
+{
+ const mat3 p = mat3(13.323122,23.5112,21.71123,21.1212,28.7312,11.9312,21.8112,14.7212,61.3934);
+ vec2 uv = iMouse.xy/iResolution.xy + vec2(1.,iResolution.y/iResolution.x)*gl_FragCoord.xy / iResolution.xy;
+ vec3 acc = vec3(0.0);
+ float dof = 5.*sin(iTime*.1);
+ for (int i=0;i<LAYERS;i++) {
+ float fi = float(i);
+ vec2 q = uv*(1.+fi*DEPTH);
+ q += vec2(q.y*(WIDTH*mod(fi*7.238917,1.)-WIDTH*.5),SPEED*iTime/(1.+fi*DEPTH*.03));
+ vec3 n = vec3(floor(q),31.189+fi);
+ vec3 m = floor(n)*.00001 + fract(n);
+ vec3 mp = (31415.9+m)/fract(p*m);
+ vec3 r = fract(mp);
+ vec2 s = abs(mod(q,1.)-.5+.9*r.xy-.45);
+ s += .01*abs(2.*fract(10.*q.yx)-1.);
+ float d = .6*max(s.x-s.y,s.x+s.y)+max(s.x,s.y)-.01;
+ float edge = .005+.05*min(.5*abs(fi-5.-dof),1.);
+ acc += vec3(smoothstep(edge,-edge,d)*(r.x/(1.+.02*fi*DEPTH)));
+ }
+ gl_FragColor = vec4(vec3(acc),1.0);
+}