Add min_weight property to Scene

This commit is contained in:
Eryn Wells 2013-09-21 17:01:11 -07:00
parent 482896cfa1
commit 6c1e8c7ffb
2 changed files with 7 additions and 2 deletions

View file

@ -19,6 +19,7 @@
Scene::Scene() Scene::Scene()
: width(640), height(480), : width(640), height(480),
max_depth(5), max_depth(5),
min_weight(1e-4),
ambient(new AmbientLight()), ambient(new AmbientLight()),
shapes(), shapes(),
lights(), lights(),
@ -181,7 +182,7 @@ Scene::trace_ray(const Ray &ray,
const int depth, const int depth,
const float weight) const float weight)
{ {
if (depth >= max_depth) { if (depth >= max_depth || weight <= min_weight) {
return Color::Black; return Color::Black;
} }

View file

@ -47,8 +47,12 @@ private:
// Pixel dimensions of the image. // Pixel dimensions of the image.
int width, height; int width, height;
// Ray tracing parameters. /*
* Ray tracing parameters. max_depth indicates the maximum depth of the ray tree. min_weight indicates the minimum
* specular weight to apply before giving up.
*/
int max_depth; int max_depth;
float min_weight;
// Scene objects. // Scene objects.
AmbientLight *ambient; AmbientLight *ambient;