-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbench.gsl
More file actions
executable file
·75 lines (67 loc) · 1.72 KB
/
bench.gsl
File metadata and controls
executable file
·75 lines (67 loc) · 1.72 KB
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
color shader_bench (float u, float v)
{
float i;
float x = 0, y = 0;
float MAXIT = 256;
for (i = 0; i < MAXIT; i += 1) {
float oldx = x, oldy = y;
x = oldx*oldx - oldy*oldy + u;
y = 2*oldx*oldy + v;
/* skip noise since it is renderer-dependent
point noiz = (point) noise (point (10*x, 10*y, 0));
x += 0.07 * noiz[0];
y += 0.07 * noiz[1];
*/
float rsquared = x*x+y*y;
if (rsquared > 10) {
break;
}
}
float c = i/MAXIT;
return (color) spline (pow (1-c, 2),
(color) (0),
(color) (0),
color (1, 0, 0),
color (0, 0, 1),
(color) (1), (color) (1));
}
surface bench (string mode = "simple",
float samples = 16,
float ray_bias = 0.001)
{
normal NN = normalize (N);
if(mode == "raydiff") {
float occ = occlusion ("ALL",
P, NN, M_PI_2,
"bias", ray_bias,
"maxhitdist", 5000,
"samples", samples);
C = opacity * (1 - occ);
} else if(mode == "rayspec") {
float depth = raylevel();
if (depth > 1) {
C =(color) (0);
} else {
float maxsamples, minsamples, coneangle;
if (depth == 0) {
maxsamples = samples;
minsamples = samples/4;
coneangle = radians (2.5);
} else {
maxsamples = 1;
minsamples = 1;
coneangle = 0;
}
vector II = normalize (I);
color hitcolor = 0, total = 0;
// XXX Haven't done statement: Gather
total /= maxsamples;
C = opacity * total;
}
} else if(mode == "shader") {
point oP = transform ("object", P);
C = opacity * shader_bench(oP[0], oP[1]);
} else if(mode == "simple") {
C = opacity * (diffuse(NN) + ambient());
}
}