aboutsummaryrefslogtreecommitdiff
path: root/color.go
diff options
context:
space:
mode:
authorMartin Lehoux <martin@lehoux.net>2020-04-04 16:46:06 -0700
committerMartin Lehoux <martin@lehoux.net>2020-04-04 16:46:06 -0700
commit1e77295876e20702d5ccb477b2f01df980723f04 (patch)
tree0483f7485f48f38baa49a2b3b33efa12a364ed71 /color.go
parent1008f463687a373f5c5d4024d25a09125b6c49ec (diff)
feat - sphere colors
Diffstat (limited to 'color.go')
-rw-r--r--color.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/color.go b/color.go
index dbcb47a..1ac8141 100644
--- a/color.go
+++ b/color.go
@@ -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)