-
Notifications
You must be signed in to change notification settings - Fork 362
/
Copy pathgltf_pbr.mtlx
269 lines (219 loc) · 12.5 KB
/
gltf_pbr.mtlx
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
<?xml version="1.0"?>
<materialx version="1.38">
<nodedef name="ND_gltf_pbr_surfaceshader" node="gltf_pbr" nodegroup="pbr" doc="glTF PBR" version="0.0.1" isdefaultversion="true">
<input name="base_color" type="color3" value="1, 1, 1" uimin="0, 0, 0" uimax="1, 1, 1" uiname="Base Color" uifolder="Base" />
<input name="metallic" type="float" value="1" uimin="0" uimax="1" uiname="Metallic" uifolder="Base" />
<input name="roughness" type="float" value="1" uimin="0" uimax="1" uiname="Roughness" uifolder="Base" />
<input name="normal" type="vector3" defaultgeomprop="Nworld" uiname="Normal" uifolder="Base" />
<input name="occlusion" type="float" value="1" uimin="0" uimax="1" uiname="Occlusion" uifolder="Base" />
<input name="transmission" type="float" value="0" uimin="0" uimax="1" uiname="Transmission" uifolder="Base" />
<input name="specular" type="float" value="1" uimin="0" uimax="1" uiname="Specular" uifolder="Base" />
<input name="specular_color" type="color3" value="1, 1, 1" uimin="0, 0, 0" uisoftmax="1, 1, 1" uiname="Specular Color" uifolder="Base" />
<input name="ior" uniform="true" type="float" value="1.5" uimin="1" uisoftmax="3" uiname="Index of Refraction" uifolder="Base" />
<input name="alpha" type="float" value="1" uimin="0" uimax="1" uiname="Alpha" uifolder="Alpha" />
<input name="alpha_mode" uniform="true" type="integer" enum="OPAQUE, MASK, BLEND" enumvalues="0, 1, 2" value="0" uiname="Alpha Mode" uifolder="Alpha" />
<input name="alpha_cutoff" uniform="true" type="float" value="0.5" uimin="0" uimax="1" uiname="Alpha Cutoff" uifolder="Alpha" />
<input name="sheen_color" type="color3" value="0, 0, 0" uimin="0, 0, 0" uimax="1, 1, 1" uiname="Sheen Color" uifolder="Sheen" />
<input name="sheen_roughness" type="float" value="0" uimin="0" uimax="1" uiname="Sheen Roughness" uifolder="Sheen" />
<input name="clearcoat" type="float" value="0" uimin="0" uimax="1" uiname="Clearcoat" uifolder="Clearcoat" />
<input name="clearcoat_roughness" type="float" value="0" uimin="0" uimax="1" uiname="Clearcoat Roughness" uifolder="Clearcoat" />
<input name="clearcoat_normal" type="vector3" defaultgeomprop="Nworld" uiname="Clearcoat Normal" uifolder="Clearcoat" />
<input name="emissive" type="color3" value="0, 0, 0" uimin="0, 0, 0" uimax="1, 1, 1" uiname="Emissive" uifolder="Emission" />
<input name="emissive_strength" uniform="true" type="float" value="1" uimin="0" uiname="Emissive Strength" uifolder="Emission" />
<input name="thickness" uniform="false" type="float" value="0" uimin="0" uiname="Thickness" uifolder="Volume" />
<input name="attenuation_distance" uniform="true" type="float" uimin="0" uiname="Attenuation Distance" uifolder="Volume" />
<input name="attenuation_color" uniform="true" type="color3" value="1, 1, 1" uimin="0, 0, 0" uimax="1, 1, 1" uiname="Attenuation Color" uifolder="Volume" />
<output name="out" type="surfaceshader" />
</nodedef>
<nodegraph name="IMPL_gltf_pbr_surfaceshader" nodedef="ND_gltf_pbr_surfaceshader">
<!-- Volume -->
<convert name="attenuation_color_vec" type="vector3">
<input name="in" type="color3" interfacename="attenuation_color" />
</convert>
<ln name="ln_attenuation_color_vec" type="vector3">
<input name="in" type="vector3" nodename="attenuation_color_vec" />
</ln>
<divide name="ln_attenuation_color_vec_over_distance" type="vector3">
<input name="in1" type="vector3" nodename="ln_attenuation_color_vec" />
<input name="in2" type="float" interfacename="attenuation_distance" />
</divide>
<multiply name="attenuation_coeff" type="vector3">
<input name="in1" type="vector3" nodename="ln_attenuation_color_vec_over_distance" />
<input name="in2" type="float" value="-1" />
</multiply>
<anisotropic_vdf name="isotropic_volume" type="VDF">
<!-- No scattering yet, so absorption_coeff == attenuation_coeff -->
<input name="absorption" type="vector3" nodename="attenuation_coeff" />
<input name="scattering" type="vector3" value="0, 0, 0" />
<input name="anisotropy" type="float" value="0" />
</anisotropic_vdf>
<!-- Base layer -->
<!-- Compute F0 and F90 of dielectric component -->
<subtract name="one_minus_ior" type="float">
<input name="in1" type="float" value="1" />
<input name="in2" type="float" interfacename="ior" />
</subtract>
<add name="one_plus_ior" type="float">
<input name="in1" type="float" value="1" />
<input name="in2" type="float" interfacename="ior" />
</add>
<divide name="ior_div" type="float">
<input name="in1" type="float" nodename="one_minus_ior" />
<input name="in2" type="float" nodename="one_plus_ior" />
</divide>
<multiply name="dielectric_f0_from_ior" type="float">
<input name="in1" type="float" nodename="ior_div" />
<input name="in2" type="float" nodename="ior_div" />
</multiply>
<multiply name="dielectric_f0_from_ior_specular_color" type="color3">
<input name="in1" type="color3" interfacename="specular_color" />
<input name="in2" type="float" nodename="dielectric_f0_from_ior" />
</multiply>
<min name="clamped_dielectric_f0_from_ior_specular_color" type="color3">
<input name="in1" type="color3" nodename="dielectric_f0_from_ior_specular_color" />
<input name="in2" type="float" value="1" />
</min>
<multiply name="dielectric_f0" type="color3">
<input name="in1" type="color3" nodename="clamped_dielectric_f0_from_ior_specular_color" />
<input name="in2" type="float" interfacename="specular" />
</multiply>
<multiply name="dielectric_f90" type="color3">
<input name="in1" type="color3" value="1, 1, 1" />
<input name="in2" type="float" interfacename="specular" />
</multiply>
<!-- Roughness -->
<roughness_anisotropy name="roughness_uv" type="vector2">
<input name="roughness" type="float" interfacename="roughness" />
</roughness_anisotropy>
<!-- Dielectric -->
<oren_nayar_diffuse_bsdf name="diffuse_bsdf" type="BSDF">
<input name="color" type="color3" interfacename="base_color" />
<input name="normal" type="vector3" interfacename="normal" />
</oren_nayar_diffuse_bsdf>
<dielectric_bsdf name="transmission_bsdf" type="BSDF">
<input name="weight" type="float" value="1" />
<input name="tint" type="color3" interfacename="base_color" />
<input name="ior" type="float" interfacename="ior" />
<input name="roughness" type="vector2" nodename="roughness_uv" />
<input name="normal" type="vector3" interfacename="normal" />
<input name="scatter_mode" type="string" value="T" />
</dielectric_bsdf>
<generalized_schlick_bsdf name="reflection_bsdf" type="BSDF">
<input name="color0" type="color3" nodename="dielectric_f0" />
<input name="color90" type="color3" nodename="dielectric_f90" />
<input name="roughness" type="vector2" nodename="roughness_uv" />
<input name="normal" type="vector3" interfacename="normal" />
<input name="scatter_mode" type="string" value="R" />
</generalized_schlick_bsdf>
<mix name="transmission_mix" type="BSDF">
<input name="bg" type="BSDF" nodename="diffuse_bsdf" />
<input name="fg" type="BSDF" nodename="transmission_bsdf" />
<input name="mix" type="float" interfacename="transmission" />
</mix>
<layer name="dielectric_bsdf" type="BSDF">
<input name="top" type="BSDF" nodename="reflection_bsdf" />
<input name="base" type="BSDF" nodename="transmission_mix" />
</layer>
<!-- Metal -->
<generalized_schlick_bsdf name="metal_bsdf" type="BSDF">
<input name="color0" type="color3" interfacename="base_color" />
<input name="color90" type="color3" value="1, 1, 1" />
<input name="roughness" type="vector2" nodename="roughness_uv" />
<input name="normal" type="vector3" interfacename="normal" />
</generalized_schlick_bsdf>
<!-- Dielectric/metal mix -->
<mix name="base_mix" type="BSDF">
<input name="bg" type="BSDF" nodename="dielectric_bsdf" />
<input name="fg" type="BSDF" nodename="metal_bsdf" />
<input name="mix" type="float" interfacename="metallic" />
</mix>
<!-- Sheen layer -->
<!-- Compute sheen intensity = max(sheen_color.r, sheen_color.g, sheen_color.b) -->
<extract name="sheen_color_r" type="float">
<input name="in" type="color3" interfacename="sheen_color" />
<input name="index" type="integer" value="0" />
</extract>
<extract name="sheen_color_g" type="float">
<input name="in" type="color3" interfacename="sheen_color" />
<input name="index" type="integer" value="1" />
</extract>
<extract name="sheen_color_b" type="float">
<input name="in" type="color3" interfacename="sheen_color" />
<input name="index" type="integer" value="2" />
</extract>
<max name="sheen_color_max_rg" type="float">
<input name="in1" type="float" nodename="sheen_color_r" />
<input name="in2" type="float" nodename="sheen_color_g" />
</max>
<max name="sheen_intensity" type="float">
<input name="in1" type="float" nodename="sheen_color_max_rg" />
<input name="in2" type="float" nodename="sheen_color_b" />
</max>
<multiply name="sheen_roughness_sq" type="float">
<input name="in1" type="float" interfacename="sheen_roughness" />
<input name="in2" type="float" interfacename="sheen_roughness" />
</multiply>
<divide name="sheen_color_normalized" type="color3">
<input name="in1" type="color3" interfacename="sheen_color" />
<input name="in2" type="float" nodename="sheen_intensity" />
</divide>
<sheen_bsdf name="sheen_bsdf" type="BSDF">
<input name="weight" type="float" nodename="sheen_intensity" />
<input name="color" type="color3" nodename="sheen_color_normalized" />
<input name="roughness" type="float" nodename="sheen_roughness_sq" />
<input name="normal" type="vector3" interfacename="normal" />
</sheen_bsdf>
<layer name="sheen_layer" type="BSDF">
<input name="top" type="BSDF" nodename="sheen_bsdf" />
<input name="base" type="BSDF" nodename="base_mix" />
</layer>
<!-- Clearcoat -->
<roughness_anisotropy name="clearcoat_roughness_uv" type="vector2">
<input name="roughness" type="float" interfacename="clearcoat_roughness" />
</roughness_anisotropy>
<dielectric_bsdf name="clearcoat_bsdf" type="BSDF">
<input name="weight" type="float" interfacename="clearcoat" />
<input name="roughness" type="vector2" nodename="clearcoat_roughness_uv" />
<input name="ior" type="float" value="1.5"/>
<input name="normal" type="vector3" interfacename="clearcoat_normal" />
</dielectric_bsdf>
<layer name="clearcoat_layer" type="BSDF">
<input name="top" type="BSDF" nodename="clearcoat_bsdf" />
<input name="base" type="BSDF" nodename="sheen_layer" />
</layer>
<!-- Emission -->
<multiply name="emission_color" type="color3">
<input name="in1" type="color3" interfacename="emissive" />
<input name="in2" type="float" interfacename="emissive_strength" />
</multiply>
<uniform_edf name="emission" type="EDF">
<input name="color" type="color3" nodename="emission_color" />
</uniform_edf>
<!-- Alpha -->
<ifgreatereq name="opacity_mask_cutoff" type="float">
<input name="value1" type="float" interfacename="alpha" />
<input name="value2" type="float" interfacename="alpha_cutoff" />
<input name="in1" type="float" value="1" />
<input name="in2" type="float" value="0" />
</ifgreatereq>
<ifequal name="opacity_mask" type="float">
<input name="value1" type="integer" interfacename="alpha_mode" />
<input name="value2" type="integer" value="1" />
<input name="in1" type="float" nodename="opacity_mask_cutoff" />
<input name="in2" type="float" interfacename="alpha" />
</ifequal>
<ifequal name="opacity" type="float">
<input name="value1" type="integer" interfacename="alpha_mode" />
<input name="value2" type="integer" value="0" />
<input name="in1" type="float" value="1" />
<input name="in2" type="float" nodename="opacity_mask" />
</ifequal>
<!-- Surface -->
<surface name="shader_constructor" type="surfaceshader">
<input name="bsdf" type="BSDF" nodename="clearcoat_layer" />
<input name="edf" type="EDF" nodename="emission" />
<input name="opacity" type="float" nodename="opacity" />
</surface>
<output name="out" type="surfaceshader" nodename="shader_constructor" />
</nodegraph>
</materialx>