233 Float ao_intensity = miss / ao_samples; |
233 Float ao_intensity = miss / ao_samples; |
234 col = col * ao_intensity; |
234 col = col * ao_intensity; |
235 } |
235 } |
236 |
236 |
237 return col; |
237 return col; |
238 } |
|
239 } |
|
240 |
|
241 static inline void samplepixel(Colour &c, Vector3 &dir, RenderrowData* d, const int &oversample) |
|
242 { |
|
243 if (oversample <= 0) |
|
244 { |
|
245 // no oversampling |
|
246 dir.normalize(); |
|
247 Ray ray(d->eye, dir); |
|
248 c = d->rt->raytrace(ray, 0, NULL); |
|
249 } |
|
250 else |
|
251 if (oversample <= 3) |
|
252 { |
|
253 // grid oversampling |
|
254 c = Colour(0,0,0); |
|
255 static const int gridsamples[] = {5,9,16}; |
|
256 static const Float osa5x[] = {0.0, -0.4, +0.4, +0.4, -0.4}; |
|
257 static const Float osa5y[] = {0.0, -0.4, -0.4, +0.4, +0.4}; |
|
258 static const Float osa9x[] = {-0.34, 0.00, +0.34, |
|
259 -0.34, 0.00, +0.34, -0.34, 0.00, +0.34}; |
|
260 static const Float osa9y[] = {-0.34, -0.34, -0.34, |
|
261 0.00, 0.00, 0.00, +0.34, +0.34, +0.34}; |
|
262 static const Float osa16x[] = {-0.375, -0.125, +0.125, +0.375, |
|
263 -0.375, -0.125, +0.125, +0.375, -0.375, -0.125, +0.125, +0.375, |
|
264 -0.375, -0.125, +0.125, +0.375}; |
|
265 static const Float osa16y[] = {-0.375, -0.375, -0.375, -0.375, |
|
266 -0.125, -0.125, -0.125, -0.125, +0.125, +0.125, +0.125, +0.125, |
|
267 +0.375, +0.375, +0.375, +0.375}; |
|
268 static const Float *osaSx[] = {osa5x, osa9x, osa16x}; |
|
269 static const Float *osaSy[] = {osa5y, osa9y, osa16y}; |
|
270 const int samples = gridsamples[oversample-1]; |
|
271 const Float *osax = osaSx[oversample-1]; |
|
272 const Float *osay = osaSy[oversample-1]; |
|
273 for (int i = 0; i < samples; i++) |
|
274 { |
|
275 Vector3 tmpdir = dir + osax[i]*d->dx + osay[i]*d->dy; |
|
276 tmpdir.normalize(); |
|
277 Ray ray(d->eye, tmpdir); |
|
278 c += d->rt->raytrace(ray, 0, NULL); |
|
279 } |
|
280 c = c * (1.0/samples); |
|
281 } |
|
282 else |
|
283 { |
|
284 // stochastic oversampling |
|
285 // ...todo |
|
286 } |
238 } |
287 } |
239 } |
288 |
240 |
289 #if 0 |
241 #if 0 |
290 static void *renderrow(void *data) |
242 static void *renderrow(void *data) |