From 90530b74ef7c3bd5076f5879fd3dbcc80f6311e4 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Sat, 21 Sep 2013 15:42:11 -0700 Subject: [PATCH] Return Black if max depth exceeded --- src/scene.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/scene.cc b/src/scene.cc index 3037a46..1d82d99 100644 --- a/src/scene.cc +++ b/src/scene.cc @@ -179,6 +179,10 @@ Scene::add_light(PointLight *light) Color Scene::trace_ray(const Ray &ray, const int depth) { + if (depth >= max_depth) { + return Color::Black; + } + Color out_color = Color::Black; Shape *intersected_shape = NULL; float *t = NULL; @@ -207,6 +211,10 @@ Scene::trace_ray(const Ray &ray, const int depth) return out_color; } + /* + * Diffuse lighting. (Shading, etc.) + */ + Material shape_material = intersected_shape->get_material(); Color shape_color = shape_material.get_diffuse_color(); @@ -245,5 +253,9 @@ Scene::trace_ray(const Ray &ray, const int depth) + diffuse_level * ldotn); } + /* + * Specular lighting. (Reflections, etc.) + */ + return out_color; }