diff options
Diffstat (limited to 'lib/ray.rb')
-rw-r--r-- | lib/ray.rb | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -10,9 +10,12 @@ class Ray @origin + (@direction * time) end - def colour(world) - if rec = world.hit(self, Interval.new(0, Float::INFINITY)) - return (Colour.new(1,1,1) + rec.normal) * 0.5 + def colour(world, depth) + return Colour.new if depth <= 0 + + if rec = world.hit(self, Interval.new(0.0001, Float::INFINITY)) + dir = Vec3.random_unit(rec.normal) + return Ray.new(rec.point, dir).colour(world, depth - 1) * 0.5 end unit_dir = direction.unit |