-
Notifications
You must be signed in to change notification settings - Fork 2
/
material.py
57 lines (51 loc) · 1.88 KB
/
material.py
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
49
50
51
52
53
54
55
56
57
import numpy as np
TYPE_DIFFUSE = "diffuse"
TYPE_TEXTURED = "textured"
# Color values are not in uint8 so just make sure to clip everything to uint8
# when rendering the final image
COLOR_DARK_GRAY = np.array([64, 64, 64])
COLOR_GRAY = np.array([135, 135, 135])
COLOR_LIGHT_GRAY = np.array([211, 211, 211])
COLOR_GREEN = np.array([65, 230, 65])
COLOR_RED = np.array([230, 80, 80])
COLOR_BLUE = np.array([70, 70, 230])
COLOR_WHITE = np.array([245, 245, 245])
class Material:
"""
This class represents the material that an object will have.
Attributes:
diffuse(numpy.array): RGB color for the diffuse component
material_type(str): the type of material like diffuse, textured, etc
specular(float): parameter for how specular is this material (use
values between 0 and 1)
border(float): parameter for how thick the border is in this material
(use values between 0 and 1)
kr(float): parameter for how much the surface reflects (between 0 - 1)
ior(float): parameter for index of refraction (between 0 - 1)
roughness(float): parameter for how smooth is the surface of reflection
illumination_map(IlluminationTexture): an illumination map object for
backwards raytracing
"""
def __init__(
self,
diffuse=COLOR_GRAY,
material_type=TYPE_DIFFUSE,
specular=1.0,
border=1.0,
kr=0.0,
ior=1.0,
roughness=0.0
):
self.diffuse = diffuse
self.material_type = material_type
self.specular = specular
self.border = border
self.kr = kr
self.ior = ior
self.texture = None
self.roughness = roughness
self.illumination_map = None
def add_texture(self, texture):
self.texture = texture
def add_illumination_map(self, texture):
self.illumination_map = texture