-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsuperquad-toroids-2.irmf
42 lines (39 loc) · 1.22 KB
/
superquad-toroids-2.irmf
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
/*{
"author": "Glenn M. Lewis",
"copyright": "Apache-2.0",
"date": "2020-04-13",
"irmf": "1.0",
"materials": ["Red","Green"],
"max": [5,5,5],
"min": [-5,-5,-5],
"notes": "Figure 10 from: https://authors.library.caltech.edu/9756.",
"options": {
"resolution": 2048,
"color1": [255,0,0,1],
"color2": [0,255,0,1]
},
"title": "Superquadric toroids",
"units": "mm",
"version": "1.0"
}*/
vec2 superquad2(in float slices, in float e1, in float e2, in float a4, in vec3 xyz) {
xyz.xyz *= 2.5;
vec2 result = (mod(abs(xyz.z) * 6.0, 1.0) <= 0.5) ? vec2(1, 0) : vec2(0, 1);
float angle = -1.3;
float c = cos(angle);
float s = sin(angle);
xyz.yz = mat2(c, - s, s, c) * xyz.yz;
xyz = abs(xyz); // Due to GLSL 'pow' definition.
float f = pow(pow(pow(xyz.x, 2.0 / e2) + pow(xyz.y, 2.0 / e2), e2 / 2.0) - a4, 2.0 / e1) + pow(xyz.z, 2.0 / e1);
return f <= 1.0 ? result : vec2(0);
}
void mainModel4(out vec4 materials, in vec3 xyz) {
materials.xy = vec2(0);
vec4 e = vec4(0.1, 0.3, 1.0, 3.0);
vec4 o = vec4(-3.4, - 1.2, 1.2, 3.4);
for(int i = 0; i < 4; i ++ ) {
for(int j = 0; j < 4; j ++ ) {
materials.xy += superquad2(6.0, e[i], e[j], 1.5, xyz - vec3(o[j], 0, o[3 - i]));
}
}
}