diff options
| author | Martin Lehoux <martin@lehoux.net> | 2020-04-04 19:41:57 -0700 |
|---|---|---|
| committer | Martin Lehoux <martin@lehoux.net> | 2020-04-04 19:41:57 -0700 |
| commit | 13be7ded788fe88d5ac8d6759273516652bf1a80 (patch) | |
| tree | 57d7eabb022e500e8b06089fb935c4a17c7cfbb3 /color.go | |
| parent | d233910be5eb6bdf9bb9deb6ffa0fa79f659e902 (diff) | |
feat - Add Lambertian material
Diffstat (limited to 'color.go')
| -rw-r--r-- | color.go | 6 |
1 files changed, 2 insertions, 4 deletions
@@ -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) |
