Debian Codegraph @

libs/gltfio/materials/transmission.mat.in

raw
1 material {
2 name : transmission_${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 refractionMode: screenspace,
12 refractionType: thin,
13 parameters : [
14
15 // Base Color
16 { type : int, name : baseColorIndex },
17 { type : float4, name : baseColorFactor },
18 { type : sampler2d, name : baseColorMap },
19 { type : mat3, name : baseColorUvMatrix },
20
21 // Metallic-Roughness Map
22 { type : int, name : metallicRoughnessIndex },
23 { type : float, name : metallicFactor },
24 { type : float, name : roughnessFactor },
25 { type : sampler2d, name : metallicRoughnessMap },
26 { type : mat3, name : metallicRoughnessUvMatrix },
27
28 // Normal Map
29 { type : int, name : normalIndex },
30 { type : float, name : normalScale },
31 { type : sampler2d, name : normalMap },
32 { type : mat3, name : normalUvMatrix },
33
34 // Ambient Occlusion
35 { type : int, name : aoIndex },
36 { type : float, name : aoStrength },
37 { type : sampler2d, name : occlusionMap },
38 { type : mat3, name : occlusionUvMatrix },
39
40 // Emissive Map
41 { type : int, name : emissiveIndex },
42 { type : float3, name : emissiveFactor },
43 { type : sampler2d, name : emissiveMap },
44 { type : mat3, name : emissiveUvMatrix },
45
46 // Transmission Map
47 { type : int, name : transmissionIndex },
48 { type : float, name : transmissionFactor },
49 { type : sampler2d, name : transmissionMap },
50 { type : mat3, name : transmissionUvMatrix }
51 ],
52 }
53
54 fragment {
55 void material(inout MaterialInputs material) {
56 highp float2 uvs[2];
57 uvs[0] = getUV0();
58 uvs[1] = getUV1();
59
60 if (materialParams.normalIndex > -1) {
61 highp float2 uv = uvs[materialParams.normalIndex];
62 uv = (vec3(uv, 1.0) * materialParams.normalUvMatrix).xy;
63 material.normal = texture(materialParams_normalMap, uv).xyz * 2.0 - 1.0;
64 material.normal.xy *= materialParams.normalScale;
65 }
66
67 prepareMaterial(material);
68 material.baseColor = materialParams.baseColorFactor;
69
70 if (materialParams.baseColorIndex > -1) {
71 highp float2 uv = uvs[materialParams.baseColorIndex];
72 uv = (vec3(uv, 1.0) * materialParams.baseColorUvMatrix).xy;
73 material.baseColor *= texture(materialParams_baseColorMap, uv);
74 }
75
76 #if defined(BLEND_MODE_TRANSPARENT)
77 material.baseColor.rgb *= material.baseColor.a;
78 #endif
79
80 material.baseColor *= getColor();
81
82 material.roughness = materialParams.roughnessFactor;
83 material.metallic = materialParams.metallicFactor;
84 material.emissive = vec4(materialParams.emissiveFactor.rgb, 0.0);
85 material.transmission = materialParams.transmissionFactor;
86 material.absorption = 1.0 - material.baseColor.rgb;
87
88 if (materialParams.transmissionIndex > -1) {
89 highp float2 uv = uvs[materialParams.transmissionIndex];
90 uv = (vec3(uv, 1.0) * materialParams.transmissionUvMatrix).xy;
91 material.transmission *= texture(materialParams_transmissionMap, uv).r;
92 }
93
94 if (materialParams.metallicRoughnessIndex > -1) {
95 highp float2 uv = uvs[materialParams.metallicRoughnessIndex];
96 uv = (vec3(uv, 1.0) * materialParams.metallicRoughnessUvMatrix).xy;
97 vec4 mr = texture(materialParams_metallicRoughnessMap, uv);
98 material.roughness *= mr.g;
99 material.metallic *= mr.b;
100 }
101
102 if (materialParams.aoIndex > -1) {
103 highp float2 uv = uvs[materialParams.aoIndex];
104 uv = (vec3(uv, 1.0) * materialParams.occlusionUvMatrix).xy;
105 material.ambientOcclusion = texture(materialParams_occlusionMap, uv).r *
106 materialParams.aoStrength;
107 }
108 if (materialParams.emissiveIndex > -1) {
109 highp float2 uv = uvs[materialParams.emissiveIndex];
110 uv = (vec3(uv, 1.0) * materialParams.emissiveUvMatrix).xy;
111 material.emissive.rgb *= texture(materialParams_emissiveMap, uv).rgb;
112 }
113 }
114 }