From ecdb3ebb4897a2a750d403a3389a12cb982cd113 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Thu, 1 Jun 2017 15:32:17 -0700 Subject: ray: perform ambient light color scale in prepare Trivially removes a ray_3f_mult_scalar() from the hot path. --- src/modules/ray/ray_scene.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/modules/ray/ray_scene.c') diff --git a/src/modules/ray/ray_scene.c b/src/modules/ray/ray_scene.c index acd65d3..955bab6 100644 --- a/src/modules/ray/ray_scene.c +++ b/src/modules/ray/ray_scene.c @@ -57,8 +57,7 @@ static inline ray_color_t shade_ray(ray_scene_t *scene, ray_ray_t *ray, ray_obje unsigned i; surface = ray_object_surface(object, &intersection); - color = ray_3f_mult_scalar(&scene->ambient_color, scene->ambient_brightness); - color = ray_3f_mult(&surface.color, &color); + color = ray_3f_mult(&surface.color, &scene->_prepared.ambient_light); /* visit lights for shadows and illumination */ for (i = 0; i < scene->n_lights; i++) { @@ -186,6 +185,8 @@ void ray_scene_prepare(ray_scene_t *scene) { unsigned i; + scene->_prepared.ambient_light = ray_3f_mult_scalar(&scene->ambient_color, scene->ambient_brightness); + for (i = 0; i < scene->n_objects; i++) ray_object_prepare(&scene->objects[i]); } -- cgit v1.2.3