-
Notifications
You must be signed in to change notification settings - Fork 0
/
material.go
48 lines (41 loc) · 1.16 KB
/
material.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package gotracer
import (
"github.com/go-gl/mathgl/mgl64"
)
const (
AirIndex = 1.0003
)
// NOTES:
// Reflective
// - determines how much diffuse vs reflected light
// - base for fresnel
// Roughness (gloss/smoothness)
// - be sure to conserve energy. Light will appear dimmer when spread out
// - fresnel less noticable with nore roughness
// MaterialAttribute is an interface for getting a color. Designed with texture
// mapping in mind.
type MaterialAttribute interface {
// ColorAt takes normalized coordinates and return the color at those coordinates.
ColorAt(mgl64.Vec2) Color64
}
type Material struct {
Name string
Emissive MaterialAttribute
Ambient MaterialAttribute
Diffuse MaterialAttribute
Specular MaterialAttribute
Reflective MaterialAttribute
Smoothness MaterialAttribute
Transmissive MaterialAttribute
Index MaterialAttribute
Normal MaterialAttribute
IsLiquid MaterialAttribute
BRDF BRDF
}
// UniformColor represents a MaterialAttribute that is the same at every location.
type UniformColor struct {
Color Color64
}
func (c UniformColor) ColorAt(_ mgl64.Vec2) Color64 {
return c.Color
}