diff options
Diffstat (limited to 'ray.go')
-rw-r--r-- | ray.go | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -7,6 +7,7 @@ import ( type Ray struct { Origin Vec3 Direction Vec3 + Valid bool } func (r Ray) At(t float64) Vec3 { @@ -20,8 +21,11 @@ func (r Ray) Colour(world Hittable, md uint) Vec3 { hit := world.Hit(r, Interval{0.001, maths.Inf(1)}) if hit.Valid { - dir := hit.N.Add(RandomVec3OnUnitSphere()); - return Ray{hit.P, dir}.Colour(world, md - 1).Div(SplatVec3(10)); + scat := hit.Mat.Scatter(r, hit); + if scat.Valid { + return scat.Colour(world, md - 1).Mul(hit.Mat.Attenuation()); + } + return SplatVec3(0); } unit_dir := r.Direction.Unit(); |