|
|
@ -98,63 +98,6 @@ float trace(vec3 from, vec3 direction) {
|
|
98
|
98
|
return 1.0-float(stepsDone)/float(MaximumRaySteps);
|
|
99
|
99
|
}
|
|
100
|
100
|
|
|
101
|
|
/*uniform int MaxIterations; //#slider[1,50,200]
|
|
102
|
|
const float bailout = 4.0;
|
|
103
|
|
const float power = 8.0;
|
|
104
|
|
const float phaseX = 0.0;
|
|
105
|
|
const float phaseY = 0.0;
|
|
106
|
|
|
|
107
|
|
float DistanceEstimator(vec3 z0) {
|
|
108
|
|
vec3 c = z0;
|
|
109
|
|
vec3 z = z0;
|
|
110
|
|
float pd = power - 1.0; // power for derivative
|
|
111
|
|
|
|
112
|
|
// Convert z to polar coordinates
|
|
113
|
|
float r = length(z);
|
|
114
|
|
float th = atan(z.y, z.x);
|
|
115
|
|
float ph = asin(z.z / r);
|
|
116
|
|
|
|
117
|
|
vec3 dz;
|
|
118
|
|
float ph_dz = 0.0;
|
|
119
|
|
float th_dz = 0.0;
|
|
120
|
|
float r_dz = 1.0;
|
|
121
|
|
float powR, powRsin;
|
|
122
|
|
|
|
123
|
|
// Iterate to compute the distance estimator.
|
|
124
|
|
for (int n = 0; n < MaxIterations; n++) {
|
|
125
|
|
// Calculate derivative of
|
|
126
|
|
powR = power * pow(r, pd);
|
|
127
|
|
powRsin = powR * r_dz * sin(ph_dz + pd*ph);
|
|
128
|
|
dz.x = powRsin * cos(th_dz + pd*th) + 1.0;
|
|
129
|
|
dz.y = powRsin * sin(th_dz + pd*th);
|
|
130
|
|
dz.z = powR * r_dz * cos(ph_dz + pd*ph);
|
|
131
|
|
|
|
132
|
|
// polar coordinates of derivative dz
|
|
133
|
|
r_dz = length(dz);
|
|
134
|
|
th_dz = atan(dz.y, dz.x);
|
|
135
|
|
ph_dz = acos(dz.z / r_dz);
|
|
136
|
|
|
|
137
|
|
// z iteration
|
|
138
|
|
powR = pow(r, power);
|
|
139
|
|
powRsin = sin(power*ph);
|
|
140
|
|
z.x = powR * powRsin * cos(power*th);
|
|
141
|
|
z.y = powR * powRsin * sin(power*th);
|
|
142
|
|
z.z = powR * cos(power*ph);
|
|
143
|
|
z += c;
|
|
144
|
|
|
|
145
|
|
r = length(z);
|
|
146
|
|
if (r > bailout) break;
|
|
147
|
|
|
|
148
|
|
th = atan(z.y, z.x) + phaseX;
|
|
149
|
|
ph = acos(z.z / r) + phaseY;
|
|
150
|
|
|
|
151
|
|
}
|
|
152
|
|
|
|
153
|
|
// Return the distance estimation value which determines the next raytracing
|
|
154
|
|
// step size, or if whether we are within the threshold of the surface.
|
|
155
|
|
return 0.5 * r * log(r)/r_dz;
|
|
156
|
|
}*/
|
|
157
|
|
|
|
158
|
101
|
float sphere(vec3 pos) {
|
|
159
|
102
|
return length(pos) - 1.0;
|
|
160
|
103
|
}
|