diff options
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 +} |
