aboutsummaryrefslogtreecommitdiff
path: root/material.go
diff options
context:
space:
mode:
authorMartin Lehoux <martin@lehoux.net>2020-04-04 19:41:57 -0700
committerMartin Lehoux <martin@lehoux.net>2020-04-04 19:41:57 -0700
commit13be7ded788fe88d5ac8d6759273516652bf1a80 (patch)
tree57d7eabb022e500e8b06089fb935c4a17c7cfbb3 /material.go
parentd233910be5eb6bdf9bb9deb6ffa0fa79f659e902 (diff)
feat - Add Lambertian material
Diffstat (limited to 'material.go')
-rw-r--r--material.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/material.go b/material.go
new file mode 100644
index 0000000..db1e4d6
--- /dev/null
+++ b/material.go
@@ -0,0 +1,16 @@
+package main
+
+type Material interface {
+ Scatter(ray Ray, hit HitRecord) (Ray, Color)
+}
+
+type Lambertian struct {
+ albedo Color
+}
+
+func (lambertian Lambertian) Scatter(ray Ray, hit HitRecord) (Ray, Color) {
+ // TODO: Use the correct distribution
+ direction := AddVec3D(hit.normal, RandomInUnitSphere())
+ scattered := Ray{hit.point, direction}
+ return scattered, lambertian.albedo
+}