|
1
|
|
|
# Cook-Torance for diffuseType and Blinn-Phong |
|
2
|
|
|
# Figure out specular and frensel stuff |
|
3
|
|
|
# Emission? |
|
4
|
|
|
# Need to setup so it can send outputs to a shader |
|
5
|
|
|
# Inputs need to be defined a lot better |
|
6
|
|
|
from ed2d import texture |
|
7
|
|
|
from ed2d import files |
|
8
|
|
|
|
|
9
|
|
|
class Material(object): |
|
10
|
|
|
def __init__(self, program): |
|
11
|
|
|
self.diffuse = None |
|
12
|
|
|
self.idiffuse = 0 # Intensity parameter |
|
13
|
|
|
|
|
14
|
|
|
self.ambient = None |
|
15
|
|
|
self.iambient = 0 # Intensity parameter |
|
16
|
|
|
|
|
17
|
|
|
self.specular = None |
|
18
|
|
|
self.roughness = None |
|
19
|
|
|
|
|
20
|
|
|
# This is the diffuse texture |
|
21
|
|
|
self.albedo = None |
|
22
|
|
|
|
|
23
|
|
|
self.diffuseType = None |
|
24
|
|
|
self.specularType = None |
|
25
|
|
|
|
|
26
|
|
|
self.normalMap = None |
|
27
|
|
|
self.specularMap = None |
|
28
|
|
|
self.displacementMap = None |
|
29
|
|
|
|
|
30
|
|
|
# Assign the shader that will render the Material |
|
31
|
|
|
self.program = program |
|
32
|
|
|
|
|
33
|
|
|
def setDiffuseColor(self, r, g, b, intensity): |
|
34
|
|
|
''' Sets the diffuse color of a material. ''' |
|
35
|
|
|
self.diffuse = [r, g, b] |
|
36
|
|
|
self.idiffuse = intensity |
|
37
|
|
|
|
|
38
|
|
|
def setAmbientColor(self, r, g, b, intensity): |
|
39
|
|
|
''' Sets the ambient color of a material. ''' |
|
40
|
|
|
self.ambient = [r, g, b] |
|
41
|
|
|
self.iambient = intensity |
|
42
|
|
|
|
|
43
|
|
|
def setSpecularColor(self, r, g, b, roughness): |
|
44
|
|
|
''' Sets the specular color and roughness of a material. ''' |
|
45
|
|
|
self.specular = [r, g, b] |
|
46
|
|
|
self.roughness = roughness |
|
47
|
|
|
|
|
48
|
|
|
def diffuseType(self, shader): |
|
49
|
|
|
pass |
|
50
|
|
|
|
|
51
|
|
|
def specularType(self, shader): |
|
52
|
|
|
pass |
|
53
|
|
|
|
|
54
|
|
|
def addTextures(self, textureDict): |
|
55
|
|
|
# This will replace the crap underneath this function |
|
56
|
|
|
pass |
|
57
|
|
|
|
|
58
|
|
|
# This will replace the texture assignment via Mesh class |
|
59
|
|
|
def addTexture(self, textureFileName): |
|
60
|
|
|
''' This sets the diffuse albeo/texture of the material. ''' |
|
61
|
|
|
imagePath = files.resolve_path('data', 'images', textureFileName) |
|
62
|
|
|
self.albedo = texture.Texture(imagePath, self.program) |
|
63
|
|
|
|
|
64
|
|
|
def addNormalMap(self, textureFileName): |
|
65
|
|
|
imagePath = files.resolve_path('data', 'images', textureFileName) |
|
66
|
|
|
self.normalMap = texture.Texture(imagePath, self.program) |
|
67
|
|
|
|
|
68
|
|
|
def addSpecularMap(self, textureFileName): |
|
69
|
|
|
imagePath = files.resolve_path('data', 'images', textureFileName) |
|
70
|
|
|
self.specularMap = texture.Texture(imagePath, self.program) |
|
71
|
|
|
|
|
72
|
|
|
def addDisplacementMap(self, textureFileName): |
|
73
|
|
|
imagePath = files.resolve_path('data', 'images', textureFileName) |
|
74
|
|
|
self.displacementMap = texture.Texture(imagePath, self.program) |
|
75
|
|
|
|