diff options
| author | Martin Lehoux <martin@lehoux.net> | 2020-04-04 16:46:06 -0700 |
|---|---|---|
| committer | Martin Lehoux <martin@lehoux.net> | 2020-04-04 16:46:06 -0700 |
| commit | 1e77295876e20702d5ccb477b2f01df980723f04 (patch) | |
| tree | 0483f7485f48f38baa49a2b3b33efa12a364ed71 /color.go | |
| parent | 1008f463687a373f5c5d4024d25a09125b6c49ec (diff) | |
feat - sphere colors
Diffstat (limited to 'color.go')
| -rw-r--r-- | color.go | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -18,8 +18,9 @@ func LinearBlend(color1 Color, color2 Color, param float64) Color { func RayColor(ray Ray, hitable Hitable) Color { hit := hitable.Hit(ray) - if hit.time > 0 { - return Color{1.0, 0.0, 0.0} + if hit.time > 0.0 { + vec := AddVec3D(hit.normal, Vec3D{1.0, 1.0, 1.0}) + return LinearBlend(Color{vec.x, vec.y, vec.z}, Color{0.0, 0.0, 0.0}, 0.5) } 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) |
