-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdroste.fs
76 lines (69 loc) · 1.83 KB
/
droste.fs
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*{
"DESCRIPTION": "droste",
"CREDIT": "kaleidope.de",
"CATEGORIES": [
"mind expansion"
],
"INPUTS": [
{
"NAME": "iChannel0",
"TYPE": "image"
},
{
"NAME": "spiralfactor",
"TYPE": "float",
"MIN": 0.0,
"MAX": 2.0,
"DEFAULT": 1.0
},
{
"NAME": "innerradius",
"TYPE": "float",
"MIN": 0.0,
"MAX": 4.0,
"DEFAULT": 0.1
},
{
"NAME": "outerradius",
"TYPE": "float",
"MIN": 0.1,
"MAX": 2.0,
"DEFAULT": 0.5
},
{
"NAME": "offset",
"TYPE": "float",
"MIN": 0.1,
"MAX": 2.0,
"DEFAULT": 0.5
},
],
}*/
vec3 iResolution = vec3(RENDERSIZE, 1.);
float iTime = TIME;
float inv_webcam_aspect = 480.0/640.0,
two_pi = 6.28318530718,
inner_radius = innerradius,
outer_radius = outerradius,
spiral_factor = spiralfactor;
vec2 wrap(vec2 pos, float r1, float r2) {
float theta = pos.x * two_pi,
r = pos.y * (r2-r1) + r1;
return vec2(offset + inv_webcam_aspect * r * cos(theta), 0.5 + r * sin(theta));
}
vec2 unwrap(vec2 pos, float factor) {
vec2 centred = pos - vec2(0.5, 0.5);
float theta = atan(centred.y, centred.x),
phi = theta / two_pi,
r2 = dot(centred, centred),
logr = 0.5 * log(r2) * factor,
y = logr - phi;
return vec2(phi, y - floor(y));
}
void mainImage( out vec4 fragColor, in vec2 fragCoord ) {
vec2 uv = (fragCoord.xy - 0.5 * iResolution.xy) / iResolution.y + vec2(0.5, 0.5);
fragColor = texture(iChannel0, wrap(unwrap(uv, spiral_factor), inner_radius, outer_radius));
}
void main(void) {
mainImage(gl_FragColor, gl_FragCoord.xy);
}