-
Notifications
You must be signed in to change notification settings - Fork 0
/
lit.mat
62 lines (58 loc) · 1.58 KB
/
lit.mat
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
58
59
60
61
62
material {
name : lit,
shadingModel : lit,
parameters : [
{
type : float3,
name : baseColor
},
{
type : samplerExternal,
name : frontTexture
},
{
type : samplerExternal,
name : backTexture
},
{
type : samplerExternal,
name : frontNormalTexture
},
{
type : samplerExternal,
name : backNormalTexture
},
{
type : mat4,
name : textureTransform
}
],
variables : [
uv
],
}
vertex {
void materialVertex(inout MaterialVertexInputs material) {
material.uv = 0.5 * (getPosition() + vec4(1));
}
}
fragment {
void material(inout MaterialInputs material) {
vec2 uv = (materialParams.textureTransform * variable_uv).xy;
if (variable_uv.x >= 0.51) {
material.normal = texture(materialParams_frontNormalTexture, uv).xyz * 2.0 - 1.0;
} else if (variable_uv.x <= 0.49) {
material.normal = texture(materialParams_backNormalTexture, uv).xyz * 2.0 - 1.0;
}
prepareMaterial(material);
material.metallic = 1.0;
material.clearCoat = 1.0;
if (variable_uv.x >= 0.51) {
material.baseColor = texture(materialParams_frontTexture, uv);
} else if (variable_uv.x <= 0.49) {
material.baseColor = texture(materialParams_backTexture, uv);
} else {
material.baseColor.rgb = materialParams.baseColor.rgb;
}
}
}