From c36cf8faf00ad9c46d7142189f842169d62aed29 Mon Sep 17 00:00:00 2001 From: Julian T Date: Thu, 7 May 2020 12:00:52 +0200 Subject: Better antialias --- ray.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ray.c b/ray.c index 83708f6..be66ba8 100644 --- a/ray.c +++ b/ray.c @@ -418,6 +418,7 @@ int ray_trace_recur(space_t *s, color_t *dest, ray_t *ray, unsigned hop, COORD_T // Check if emissive if (o->m->emissive > ZERO_APROX) { color_set(&c, o->m->emissive, o->m->emissive, o->m->emissive); + goto exit; } // Check if we should calculate light @@ -470,11 +471,12 @@ void ray_trace(space_t *s, unsigned int x, unsigned int y, color_t *c, void *see for (int i = 0; i < s->gfx->antialias_samples; i++) { color_t ctmp; color_set(&ctmp, 0, 0, 0); - //memset(&ctmp, 0, sizeof(color_t)); + + // Calculate random direction + COORD_T r1 = ray_rand(seed); + COORD_T r2 = ray_rand(seed); - // Multiple samples inside same pixel - COORD_T tmp = (COORD_T) i/ (COORD_T) s->gfx->antialias_samples; - viewpoint_ray(&s->view, r.direction, x + tmp, y + tmp); + viewpoint_ray(&s->view, r.direction, x + r1, y + r2); // Run the recursive ray trace if (ray_trace_recur(s, &ctmp, &r, 0, 1, seed)) { -- cgit v1.2.3