aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian T <julian@jtle.dk>2020-05-07 12:00:52 +0200
committerJulian T <julian@jtle.dk>2020-05-07 12:00:52 +0200
commitc36cf8faf00ad9c46d7142189f842169d62aed29 (patch)
tree2af0fa7820116af47b1e908c5abf7fd3f265dfff
parentba99860760eda6ec221b15190547736407723f84 (diff)
Better antialias
-rw-r--r--ray.c10
1 files 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)) {