aboutsummaryrefslogtreecommitdiff
path: root/lib/ray.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ray.rb')
-rw-r--r--lib/ray.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/ray.rb b/lib/ray.rb
index eb6038c..1285158 100644
--- a/lib/ray.rb
+++ b/lib/ray.rb
@@ -14,8 +14,11 @@ class Ray
return Colour.new if depth <= 0
if rec = world.hit(self, Interval.new(0.0001, Float::INFINITY))
- dir = rec.normal + Vec3.random_unit
- return Ray.new(rec.point, dir).colour(world, depth - 1) * 0.5
+ if scat = rec.material.scatter(self, rec)
+ return scat.colour(world, depth - 1) * rec.material.attenuation
+ else
+ return Colour.new(0,0,0)
+ end
end
unit_dir = direction.unit