From a41817217a2d90ad0b389b35845e0f4d1a639137 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Sat, 21 Sep 2013 17:14:47 -0700 Subject: [PATCH] Blend specular color with reflected color --- src/scene.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/scene.cc b/src/scene.cc index ecbae32..721bc25 100644 --- a/src/scene.cc +++ b/src/scene.cc @@ -268,6 +268,7 @@ Scene::trace_ray(const Ray &ray, */ float specular_level = shape_material.get_specular_level(); + const Color &specular_color = shape_material.get_specular_color(); /* * Compute the reflection ray. Computing the direction of the reflection ray is done by the following formula: @@ -280,10 +281,10 @@ Scene::trace_ray(const Ray &ray, * The origin of the reflection ray is the point on the surface where the incoming ray intersected with it. */ Ray reflection_ray = Ray(intersection, ray.direction - 2.0 * normal * ray.direction.dot(normal)); - Color specular_color = trace_ray(reflection_ray, depth + 1, weight * specular_level); + Color reflection_color = trace_ray(reflection_ray, depth + 1, weight * specular_level); // TODO: Mix in specular_color of material. - out_color += specular_level * specular_color; + out_color += specular_level * specular_color * reflection_color; return out_color; }