diff options
| author | Martin Lehoux <martin@lehoux.net> | 2020-04-04 19:55:48 -0700 |
|---|---|---|
| committer | Martin Lehoux <martin@lehoux.net> | 2020-04-04 19:55:48 -0700 |
| commit | 8730659596dbfdb9625c0fc413625b261f7d6d70 (patch) | |
| tree | 85ff11a0c8f5a770b39330ec140965ffcc810ed5 /material.go | |
| parent | 13be7ded788fe88d5ac8d6759273516652bf1a80 (diff) | |
feat - Add Metal material
Diffstat (limited to 'material.go')
| -rw-r--r-- | material.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/material.go b/material.go index db1e4d6..a36fb52 100644 --- a/material.go +++ b/material.go @@ -14,3 +14,14 @@ func (lambertian Lambertian) Scatter(ray Ray, hit HitRecord) (Ray, Color) { scattered := Ray{hit.point, direction} return scattered, lambertian.albedo } + +type Metal struct { + albedo Color + fuzz float64 +} + +func (metal Metal) Scatter(ray Ray, hit HitRecord) (Ray, Color) { + reflected := AddVec3D(ray.direction.Unit().Reflect(hit.normal), ScalarProduct(metal.fuzz, RandomInUnitSphere())) + scattered := Ray{hit.point, reflected} + return scattered, metal.albedo +} |
