Debian Codegraph @

libs/gltfio/materials/sheen.mat.in

raw
1 material {
2 name : sheen_${SHADINGMODEL}_${BLENDING},
3 requires : [ uv0, uv1, color ],
4 shadingModel : ${SHADINGMODEL},
5 blending : fade,
6 depthWrite : true,
7 doubleSided : ${DOUBLESIDED},
8 flipUV : false,
9 specularAmbientOcclusion : simple,
10 specularAntiAliasing : true,
11 parameters : [
12
13 // Base Color
14 { type : int, name : baseColorIndex },
15 { type : float4, name : baseColorFactor },
16 { type : sampler2d, name : baseColorMap },
17 { type : mat3, name : baseColorUvMatrix },
18
19 // Metallic-Roughness Map
20 { type : int, name : metallicRoughnessIndex },
21 { type : float, name : metallicFactor },
22 { type : float, name : roughnessFactor },
23 { type : sampler2d, name : metallicRoughnessMap },
24 { type : mat3, name : metallicRoughnessUvMatrix },
25
26 // Normal Map
27 { type : int, name : normalIndex },
28 { type : float, name : normalScale },
29 { type : sampler2d, name : normalMap },
30 { type : mat3, name : normalUvMatrix },
31
32 // Ambient Occlusion
33 { type : int, name : aoIndex },
34 { type : float, name : aoStrength },
35 { type : sampler2d, name : occlusionMap },
36 { type : mat3, name : occlusionUvMatrix },
37
38 // Emissive Map
39 { type : int, name : emissiveIndex },
40 { type : float3, name : emissiveFactor },
41 { type : sampler2d, name : emissiveMap },
42 { type : mat3, name : emissiveUvMatrix },
43
44 // Sheen Map
45 { type : int, name : sheenColorIndex },
46 { type : float3, name : sheenColorFactor },
47 { type : sampler2d, name : sheenColorMap },
48 { type : mat3, name : sheenColorUvMatrix },
49 { type : int, name : sheenRoughnessIndex },
50 { type : float, name : sheenRoughnessFactor },
51 { type : sampler2d, name : sheenRoughnessMap },
52 { type : mat3, name : sheenRoughnessUvMatrix }
53 ],
54 }
55
56 fragment {
57 void material(inout MaterialInputs material) {
58 highp float2 uvs[2];
59 uvs[0] = getUV0();
60 uvs[1] = getUV1();
61
62 if (materialParams.normalIndex > -1) {
63 highp float2 uv = uvs[materialParams.normalIndex];
64 uv = (vec3(uv, 1.0) * materialParams.normalUvMatrix).xy;
65 material.normal = texture(materialParams_normalMap, uv).xyz * 2.0 - 1.0;
66 material.normal.xy *= materialParams.normalScale;
67 }
68
69 prepareMaterial(material);
70 material.baseColor = materialParams.baseColorFactor;
71
72 if (materialParams.baseColorIndex > -1) {
73 highp float2 uv = uvs[materialParams.baseColorIndex];
74 uv = (vec3(uv, 1.0) * materialParams.baseColorUvMatrix).xy;
75 material.baseColor *= texture(materialParams_baseColorMap, uv);
76 }
77
78 #if defined(BLEND_MODE_TRANSPARENT)
79 material.baseColor.rgb *= material.baseColor.a;
80 #endif
81
82 material.baseColor *= getColor();
83
84 material.roughness = materialParams.roughnessFactor;
85 material.metallic = materialParams.metallicFactor;
86 material.emissive = vec4(materialParams.emissiveFactor.rgb, 0.0);
87 material.sheenColor = materialParams.sheenColorFactor;
88 material.sheenRoughness = materialParams.sheenRoughnessFactor;
89
90 if (materialParams.sheenColorIndex > -1) {
91 highp float2 uv = uvs[materialParams.sheenColorIndex];
92 uv = (vec3(uv, 1.0) * materialParams.sheenColorUvMatrix).xy;
93 material.sheenColor *= texture(materialParams_sheenColorMap, uv).rgb;
94 }
95
96 if (materialParams.sheenRoughnessIndex > -1) {
97 highp float2 uv = uvs[materialParams.sheenRoughnessIndex];
98 uv = (vec3(uv, 1.0) * materialParams.sheenRoughnessUvMatrix).xy;
99 material.sheenRoughness *= texture(materialParams_sheenRoughnessMap, uv).a;
100 }
101
102 if (materialParams.metallicRoughnessIndex > -1) {
103 highp float2 uv = uvs[materialParams.metallicRoughnessIndex];
104 uv = (vec3(uv, 1.0) * materialParams.metallicRoughnessUvMatrix).xy;
105 vec4 mr = texture(materialParams_metallicRoughnessMap, uv);
106 material.roughness *= mr.g;
107 material.metallic *= mr.b;
108 }
109
110 if (materialParams.aoIndex > -1) {
111 highp float2 uv = uvs[materialParams.aoIndex];
112 uv = (vec3(uv, 1.0) * materialParams.occlusionUvMatrix).xy;
113 material.ambientOcclusion = texture(materialParams_occlusionMap, uv).r *
114 materialParams.aoStrength;
115 }
116 if (materialParams.emissiveIndex > -1) {
117 highp float2 uv = uvs[materialParams.emissiveIndex];
118 uv = (vec3(uv, 1.0) * materialParams.emissiveUvMatrix).xy;
119 material.emissive.rgb *= texture(materialParams_emissiveMap, uv).rgb;
120 }
121 }
122 }