Return Black if max depth exceeded

This commit is contained in:
Eryn Wells 2013-09-21 15:42:11 -07:00
parent 4eafa294ed
commit 90530b74ef

View file

@ -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;
}