From 13be7ded788fe88d5ac8d6759273516652bf1a80 Mon Sep 17 00:00:00 2001 From: Martin Lehoux Date: Sat, 4 Apr 2020 19:41:57 -0700 Subject: feat - Add Lambertian material --- color.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'color.go') diff --git a/color.go b/color.go index 857bc41..bb7318a 100644 --- a/color.go +++ b/color.go @@ -32,10 +32,8 @@ func RayColor(ray Ray, hitable_list HitableList, depth int) Color { } hit := hitable_list.Hit(ray, T_MIN, T_MAX) if hit.time > 0.0 { - // TODO: Use the correct distribution - direction := AddVec3D(hit.normal, RandomInUnitSphere()) - scattered := Ray{hit.point, direction} - return AttenuateColor(Color{0.5, 0.5, 0.5}, RayColor(scattered, hitable_list, depth+1)) + scattered, attenuation := hit.material.Scatter(ray, hit) + return AttenuateColor(attenuation, RayColor(scattered, hitable_list, depth+1)) } param := 0.5 * (ray.direction.Unit().y + 1) return LinearBlend(Color{0.5, 0.7, 1.0}, Color{1.0, 1.0, 1.0}, param) -- cgit v1.3