-
Notifications
You must be signed in to change notification settings - Fork 15
/
storm.sksl
33 lines (30 loc) · 1.1 KB
/
storm.sksl
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
uniform float3 iResolution; // Viewport resolution (pixels)
uniform float iTime; // Shader playback time (s)
uniform float4 iMouse; // Mouse drag pos=.xy Click pos=.zw (pixels)
uniform float3 iImage1Resolution; // iImage1 resolution (pixels)
uniform shader iImage1; // An input image.
// Source: @zozuar https://twitter.com/zozuar/status/1492217553103503363
vec3 hsv(float h, float s, float v){
vec4 t = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(vec3(h) + t.xyz) * 6.0 - vec3(t.w));
return v * mix(vec3(t.x), clamp(p - vec3(t.x), 0.0, 1.0), s);
}
vec4 main(vec2 FC) {
float e=0,R=0,t=iTime,s;
vec2 r = iResolution.xy;
vec3 q=vec3(0,0,-1), p, d=vec3((FC.xy-.5*r)/r.y,.7);
vec4 o=vec4(0);
for(float i=0;i<100;++i) {
o.rgb+=hsv(.1,e*.4,e/1e2)+.005;
p=q+=d*max(e,.02)*R*.3;
float py = (p.x == 0 && p.y == 0) ? 1 : p.y;
p=vec3(log(R=length(p))-t,e=asin(-p.z/R)-1.,atan(p.x,py)+t/3.);
s=1;
for(int z=1; z<=9; ++z) {
e+=cos(dot(sin(p*s),cos(p.zxy*s)))/s;
s+=s;
}
i>50.?d/=-d:d;
}
return vec4(o.rgb, 1);
}