aboutsummaryrefslogtreecommitdiff
path: root/material.go
blob: db1e4d66d710dcf897e80cb944e5b05b16c7d41e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
}