-
Notifications
You must be signed in to change notification settings - Fork 15
/
curlesque.sksl
58 lines (49 loc) · 1.15 KB
/
curlesque.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
uniform float iTime;
uniform float2 iResolution;
// curlesque
// Created by klk in 2018-04-11
// https://www.shadertoy.com/view/lsKyWV
// Created by Alex Kluchikov
const float pi = 3.14159265359;
float saw(float x)
{
return abs(fract(x)-0.5)*2.0;
}
float dw(vec2 p, vec2 c, float t)
{
return sin(length(p-c)-t);
}
float dw1(vec2 uv)
{
float v=0.0;
float t=iTime*2.0;
v+=dw(uv,vec2(sin(t*0.07)*30.0,cos(t*0.04)*20.0),t*1.3);
v+=dw(uv,vec2(cos(t*0.13)*30.0,sin(t*0.14)*20.0),t*1.6+1.0);
v+=dw(uv,vec2( 18,-15),t*0.7+2.0);
v+=dw(uv,vec2(-18, 15),t*1.1-1.0);
return v/4.0;
}
float fun(float x, float y)
{
return dw1(vec2(x-0.5,y-0.5)*80.0);
}
vec3 duv(vec2 uv)
{
float x=uv.x;
float y=uv.y;
float v=fun(x,y);
float d=1.0/400.0;
float dx=(v-fun(x+d,y))/d;
float dy=(v-fun(x,y+d))/d;
float a=atan(dx,dy)/pi/2.0;
return vec3(v,0,(v*4.0+a));
}
vec4 main( in vec2 fragCoord )
{
vec2 uv = fragCoord.xy/iResolution.x;
vec3 h=duv(uv);
float sp=saw(h.z+iTime*1.3);
//sp=(sp>0.5)?0.3:1.0;
sp=clamp((sp-0.25)*2.0,0.5,1.0);
return vec4((h.x+0.5)*sp, (0.3+saw(h.x+0.5)*0.6)*sp, (0.6-h.x)*sp, 1.0);
}