AVSim/simulation-package
Simulation runtime: the third-party half of the AVSim data generation package This repository holds the third-party runtime of the Simulation data generation package, version 3: the pieces the pipeline needs that were not written by the authors. It contains no code and no data of the authors. It is not usable on its own: the private half of the package, AVSim/simulation, downloads this repository into the same directory at a pinned revision with its fetch_runtime.sh script and… See the full description on the dataset page: https://huggingface.co/datasets/AVSim/simulation-package.
03.7k
1/*****************************************************************************
2* Copyright 1986-2020 NVIDIA Corporation. All rights reserved.
3******************************************************************************
4
5 MDL MATERIALS ARE PROVIDED PURSUANT TO AN END USER LICENSE AGREEMENT,
6 WHICH WAS ACCEPTED IN ORDER TO GAIN ACCESS TO THIS FILE. IN PARTICULAR,
7 THE MDL MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
8 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
9 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
10 COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL NVIDIA
11 CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
12 ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
13 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
14 THE USE OR INABILITY TO USE THE MDL MATERIALS OR FROM OTHER DEALINGS IN
15 THE MDL MATERIALS.
16*/
17
18mdl 1.4;
19
20import ::df::*;
21import ::state::*;
22import ::math::*;
23import ::base::*;
24import ::tex::*;
25import ::anno::*;
26
27import ::nvidia::core_definitions::file_texture;
28import ::nvidia::core_definitions::normalmap_texture;
29
30float4 raw_file_texture(
31 uniform texture_2d texture
32 [[ anno::description("The input texture") ]],
33 base::texture_coordinate_info uvw = base::texture_coordinate_info()
34 [[ anno::description("Custom value for texture coordinate") ]],
35 uniform float2 crop_u = float2(0.0, 1.0)
36 [[ anno::description("Restricts the texture access to sub-domain of the texture in the u direction") ]],
37 uniform float2 crop_v = float2(0.0, 1.0)
38 [[ anno::description("Restricts the texture access to sub-domain of the texture in the v direction") ]],
39 uniform tex::wrap_mode wrap_u = tex::wrap_repeat
40 [[ anno::description("Wrapping mode in the u direction") ]],
41 uniform tex::wrap_mode wrap_v = tex::wrap_repeat
42 [[ anno::description("Wrapping mode in the v direction") ]]
43)
44[[
45 anno::description("General texturing function for 2D bitmap texture stored in a file"),
46 anno::noinline()
47]]
48{
49 return tex::lookup_float4(texture, float2(uvw.position.x, uvw.position.y), wrap_u, wrap_v, crop_u, crop_v);
50}
51
52base::texture_return multiply_colors(
53 color color_1 = color(1.0, 1.0, 1.0),
54 color color_2 = color(.5, .5, .5),
55 float weight = 1.0
56) [[
57 anno::hidden()
58]]
59{
60 return base::blend_color_layers(
61 layers: base::color_layer[](
62 base::color_layer(
63 layer_color: color_2,
64 weight: weight,
65 mode: base::color_layer_multiply
66 )),
67 base: color_1
68 );
69}
70
71base::texture_return add_colors(
72 color color_1 = color(.5, .5, .5),
73 color color_2 = color(.5, .5, .5),
74 float weight = 1.0
75) [[
76 anno::hidden(),
77 anno::unused()
78]]
79{
80 return base::blend_color_layers(
81 layers: base::color_layer[](
82 base::color_layer(
83 layer_color: color_2,
84 weight: weight,
85 mode: base::color_layer_add
86 )),
87 base: color_1
88 );
89}
90
91base::texture_return blend_colors(
92 color color_1 = color(1.0, 1.0, 1.0),
93 color color_2 = color(.5, .5, .5),
94 float weight = 1.0
95) [[
96 anno::hidden(),
97 anno::unused()
98]]
99{
100 return base::blend_color_layers(
101 layers: base::color_layer[](
102 base::color_layer(
103 layer_color: color_2,
104 weight: weight,
105 mode: base::color_layer_blend
106 )),
107 base: color_1
108 );
109}
110
111export material SimPBR_Opacity(
112 // -------------------- DIFFUSE REFLECTION ----------------------
113 uniform color diffuse_color_constant = color(0.2f)
114 [[
115 anno::display_name("Albedo Base Color"),
116 anno::description("The base albedo color to use if no texture is specified"),
117 anno::in_group("Diffuse")
118 ]],
119 uniform texture_2d diffuse_texture = texture_2d()
120 [[
121 anno::display_name("Albedo Map"),
122 anno::description("The texture specifying the albedo value to use"),
123 anno::in_group("Diffuse")
124 ]],
125 uniform color diffuse_tint = color(1.0f)
126 [[
127 anno::display_name("Albedo Tint"),
128 anno::description("This tints the albedo color or texture contant"),
129 anno::in_group("Diffuse")
130 ]],
131
132 // -------------------- SPECULAR REFLECTION ----------------------
133 uniform float reflection_roughness_constant = 0.5f
134 [[
135 anno::display_name("Roughness Amount"),
136 anno::hard_range(0.0,1.),
137 anno::description("Higher roughness values lead to more blurry reflections"),
138 anno::in_group("Specular")
139 ]],
140 uniform float reflection_roughness_texture_influence = 0.0f
141 [[
142 anno::display_name("Roughness Map Influence"),
143 anno::hard_range(0.0, 1.),
144 anno::description("Blends between the constant value and the lookup of the roughness texture"),
145 anno::in_group("Specular")
146 ]],
147 uniform texture_2d reflectionroughness_texture = texture_2d()
148 [[
149 anno::display_name("Roughness Map"),
150 anno::in_group("Specular")
151 ]],
152
153 uniform float anisotropy_constant = 0.0f
154 [[
155 anno::display_name("Anisotropy Amount"),
156 anno::hard_range(-1.,1.),
157 anno::description("0 for isotropic, extents of -1 to 1 for anisotropy"),
158 anno::in_group("Specular")
159 ]],
160 uniform float anisotropy_texture_influence = 0.0f
161 [[
162 anno::display_name("Anisotropy Map Influence"),
163 anno::hard_range(0.0, 1.),
164 anno::description("Blends between the constant value and the lookup of the anisotropy texture"),
165 anno::in_group("Specular")
166 ]],
167 uniform texture_2d anisotropy_texture = texture_2d()
168 [[
169 anno::display_name("Anisotropy Map"),
170 anno::in_group("Specular")
171 ]],
172
173 uniform float metallic_constant = 0.f
174 [[
175 anno::display_name("Metallic Amount"),
176 anno::hard_range(0.0,1.),
177 anno::description("Metallic Material"),
178 anno::in_group("Specular")
179 ]],
180 uniform float metallic_texture_influence = 0.0f
181 [[
182 anno::display_name("Metallic Map Influence"),
183 anno::hard_range(0.0, 1.),
184 anno::description("Blends between the constant value and the lookup of the metallic texture"),
185 anno::in_group("Specular")
186 ]],
187 uniform texture_2d metallic_texture = texture_2d()
188 [[
189 anno::display_name("Metallic Map"),
190 anno::in_group("Specular")
191 ]],
192
193 // -------------------- ORM ----------------------
194 uniform bool enable_ORM_texture = true
195 [[
196 anno::display_name("Enable ORM Texture"),
197 anno::description("When True the ORM texture will be used to extract the Occlusion, Roughness and Metallic Map"),
198 anno::in_group("Reflectivity")
199 ]],
200 uniform texture_2d ORM_texture = texture_2d()
201 [[
202 anno::display_name("ORM Map"),
203 anno::description("Texture that hae Occlusion, Roughness and Metallic map stored in the respective r, g and b channels"),
204 anno::in_group("Reflectivity")
205 ]],
206
207 // -------------------- Clearcoat ----------------------
208 uniform bool enable_clearcoat = false
209 [[
210 anno::display_name("Enable Clearcoat Layer"),
211 anno::description("Adds a clearcoat layer on top of the material when enabled"),
212 anno::in_group("Clearcoat")
213 ]],
214 color clearcoat_tint = color(1.0f)
215 [[
216 anno::display_name("Clearcoat Tint"),
217 anno::description("Clearcoat is tinted and affects the underlying material"),
218 anno::in_group("Clearcoat")
219 ]],
220 float clearcoat_transparency = 1.0f
221 [[
222 anno::display_name("Clearcoat Transparency"),
223 anno::description("Adjusts the transparency of the clearcoat. Can be turned into a fully opaque clearcoat "
224 "covering the underlying layer"),
225 anno::in_group("Clearcoat")
226 ]],
227 float clearcoat_reflection_roughness = 0.0f
228 [[
229 anno::display_name("Clearcoat Roughness"),
230 anno::description("Higher roughness values lead to more blurry reflections"),
231 anno::hard_range(0.0f, 1.0f),
232 anno::in_group("Clearcoat")
233 ]],
234 float clearcoat_weight = 1.0f
235 [[
236 anno::display_name("Clearcoat Weight"),
237 anno::description("Sets the weight for clearcoat layer"),
238 anno::hard_range(0.0f, 1.0f),
239 anno::in_group("Clearcoat")
240 ]],
241 float clearcoat_flatten = 1.0f
242 [[
243 anno::display_name("Clearcoat Flatten"),
244 anno::description("Flattens the clearcoat to even out the underlying bump maps"),
245 anno::hard_range(0.0f, 1.0f),
246 anno::in_group("Clearcoat")
247 ]],
248 float clearcoat_ior = 1.56f
249 [[
250 anno::display_name("Clearcoat IOR"),
251 anno::description("Sets the Index of refraction for the clearcoat layer"),
252 anno::soft_range(1.0f, 4.0f),
253 anno::in_group("Clearcoat")
254 ]],
255 uniform float clearcoat_bump_factor = 1.f
256 [[
257 anno::display_name("Clearcoat Normal Map Strength"),
258 anno::description("Strength of normal map."),
259 anno::in_group("Clearcoat")
260 ]],
261 uniform texture_2d clearcoat_normalmap_texture = texture_2d()
262 [[
263 anno::display_name("Clearcoat Normal Map"),
264 anno::description("Enables the usage of the normalmap texture"),
265 anno::in_group("Clearcoat")
266 ]],
267
268 // -------------------- REFLECTIVITY ----------------------
269 uniform bool enable_retroreflection = false
270 [[
271 anno::display_name("Enable Retroreflection"),
272 anno::in_group("Reflectivity")
273 ]],
274 color retroreflection_color = color(.182,.800,.000)
275 [[
276 anno::display_name("Retro-reflection color"),
277 anno::description("The color of the retroreflection"),
278 anno::in_group("Reflectivity")
279 ]],
280 uniform float normal_reflectivity = 0.5
281 [[
282 anno::display_name("Retro-reflection weight facing"),
283 anno::hard_range(0.0,1.),
284 anno::description("Reflectivity control for geometry facing the viewer"),
285 anno::in_group("Reflectivity")
286 ]],
287 uniform float grazing_reflectivity = 1.0
288 [[
289 anno::display_name("Retro-reflection weight edge"),
290 anno::hard_range(0.0,1.),
291 anno::description("Reflectivity control for the reflectivity at geometry edges"),
292 anno::in_group("Reflectivity")
293 ]],
294
295 // -------------------- AMBIENT OCCLUSION ----------------------
296 float ao_to_diffuse = 0.0
297 [[
298 anno::display_name("AO to Diffuse"),
299 anno::description("Controls the amount of ambient occlusion multiplied into the diffuse color channel"),
300 anno::in_group("AO")
301 ]],
302 uniform texture_2d ao_texture = texture_2d()
303 [[
304 anno::display_name("Ambient Occlusion Map"),
305 anno::description("The Ambient Occlusion texture for the material"),
306 anno::in_group("AO")
307 ]],
308
309 // -------------------- EMISSIVE ----------------------
310 uniform bool enable_emission = false
311 [[
312 anno::display_name("Enable Emission"),
313 anno::description("Enables the emission of light from the material"),
314 anno::in_group("Emissive")
315 ]],
316 uniform color emissive_color = color(1.0, 0.1, 0.1)
317 [[
318 anno::enable_if("enable_emission == true"),
319 anno::display_name("Emissive Color"),
320 anno::description("The emission color"),
321 anno::in_group("Emissive")
322 ]],
323 uniform texture_2d emissive_mask_texture = texture_2d()
324 [[
325 anno::enable_if("enable_emission == true"),
326 anno::display_name("Emissive Mask Map"),
327 anno::description("The texture masking the emissive color"),
328 anno::in_group("Emissive")
329 ]],
330 uniform float emissive_intensity = 40.f
331 [[
332 anno::enable_if("enable_emission == true"),
333 anno::display_name("Emissive Intensity"),
334 anno::description("Intensity of the emission"),
335 anno::in_group("Emissive")
336 ]],
337 uniform bool enable_emissive_flipbook = false
338 [[
339 anno::display_name("Enable Flipbook for emission"),
340 anno::description("Allows the use of animated emissive textures (e.g. video screens)"),
341 anno::in_group("Emissive")
342 ]],
343 uniform int2 flipbook_dim = int2(1,1)
344 [[
345 anno::enable_if("enable_emissive_flipbook == true"),
346 anno::display_name("Flipbook Rows/Columns"),
347 anno::description("How many rows and columns are in the flipbook?"),
348 anno::in_group("Emissive")
349 ]],
350 uniform int target_fps = 1
351 [[
352 anno::enable_if("enable_emissive_flipbook == true"),
353 anno::display_name("Flipbook Target FPS"),
354 anno::description("Playback speed in frames per second"),
355 anno::in_group("Emissive")
356 ]],
357
358 // -------------------- ALPHA ----------------------
359 uniform bool enable_alpha = true
360 [[
361 anno::display_name("Enable Alpha"),
362 anno::description("Enables or disables alpha functionality"),
363 anno::in_group("Alpha")
364 ]],
365 uniform float alpha_constant = 1.0
366 [[
367 anno::display_name("Alpha Fallback Constant"),
368 anno::description("The base alpha constant to use if no texture is specified"),
369 anno::in_group("Alpha")
370 ]],
371 uniform texture_2d opacity_texture = texture_2d()
372 [[
373 anno::display_name("Opacity Map"),
374 anno::description("The texture specifying the opacity value to use"),
375 anno::in_group("Alpha")
376 ]],
377 uniform bool enable_alpha_cutout = false
378 [[
379 anno::display_name("Enable Alpha Cutout"),
380 anno::description("Enables or disables alpha cutout functionality"),
381 anno::in_group("Alpha")
382 ]],
383 uniform float alpha_cutout_cutoff = 1.f
384 [[
385 anno::enable_if("enable_alpha_cutout == true"),
386 anno::hard_range(0.0, 1.0),
387 anno::display_name("Alpha Cutout Cutoff"),
388 anno::description("The cutoff value to to render as transparent up to and opaque past"),
389 anno::in_group("Alpha")
390 ]],
391
392 // -------------------- NORMAL ----------------------
393 uniform float bump_factor = 1.f
394 [[
395 anno::display_name("Normal Map Strength"),
396 anno::description("Strength of normal map."),
397 anno::in_group("Normal")
398 ]],
399 uniform texture_2d normalmap_texture = texture_2d()
400 [[
401 anno::display_name("Normal Map"),
402 anno::in_group("Normal")
403 ]],
404
405 // -------------------- UV ADJUSTMENTS ----------------------
406 uniform bool project_uvw = false
407 [[
408 anno::display_name("Enable Project UVW Coordinates"),
409 anno::description("When enabled, UV coordinates will be generated by projecting them from a coordinate system"),
410 anno::in_group("UV")
411 ]],
412 uniform bool world_or_object = false
413 [[
414 anno::enable_if("project_uvw == true"),
415 anno::display_name("Enable World Space"),
416 anno::description("When set to 'true' uses world space for projection, when 'false' object space is used"),
417 anno::in_group("UV")
418 ]],
419 uniform float2 texture_translate = float2(0.0f)
420 [[
421 anno::display_name("Texture Translate"),
422 anno::description("Controls position of texture."),
423 anno::in_group("UV")
424 ]],
425 uniform float2 texture_scale = float2(1.0f)
426 [[
427 anno::display_name("Texture Scale"),
428 anno::description("Larger number increases size of texture."),
429 anno::in_group("UV")
430 ]],
431 uniform float2 texture_speed = float2(0.0f)
432 [[
433 anno::display_name("Texture Speed"),
434 anno::description("Scrolling texture animation speed in UVs per sec."),
435 anno::in_group("UV")
436 ]]
437)
438[[
439 anno::display_name("Sim PBR Opaque Alpha Cutout"),
440 anno::description("Supports the opaque alpha cutout material model of the Sim Renderer"),
441 anno::version( 1, 0, 0),
442 anno::author("NVIDIA CORPORATION"),
443 anno::key_words(string[]("Sim", "PBR", "opaque", "alpha", "cutout", "omniverse", "generic"))
444]]
445 = let {
446
447 base::texture_coordinate_system the_system = world_or_object ? base::texture_coordinate_world : base::texture_coordinate_object;
448
449 base::texture_coordinate_info uvw = project_uvw ?
450 base::coordinate_projection(
451 coordinate_system: the_system,
452 texture_space: 0,
453 projection_type: base::projection_cubic ) :
454 base::coordinate_source(
455 coordinate_system: base::texture_coordinate_uvw,
456 texture_space: 0
457 );
458
459 // Need to use a small value so the compiler doesnt optimize out this var...
460 float t = 0.00000001;//state::animation_time();
461 base::texture_coordinate_info transformed_uvw = base::transform_coordinate(
462 transform: base::rotation_translation_scale(
463 scaling: float3(texture_scale.x, texture_scale.y, 1.0),
464 rotation: float3(0.0, 0.0, 0.0 ),
465 translation: float3(texture_translate.x + t * texture_speed.x, texture_translate.y + t * texture_speed.y, 0.0)),
466 coordinate: uvw );
467
468 // Diffuse Color Lookup and AO
469 float4 base_lookup = tex::texture_isvalid(diffuse_texture) ? raw_file_texture(texture: diffuse_texture, uvw: transformed_uvw) : float4(1, 1, 1, 1);
470
471 float opacityValue = tex::texture_isvalid(opacity_texture) ? raw_file_texture(texture: opacity_texture, uvw: transformed_uvw).x : alpha_constant;
472
473 // Normal calculations
474 float3 normal_lookup = tex::texture_isvalid(normalmap_texture) ?
475 base::tangent_space_normal_texture(
476 texture: normalmap_texture,
477 factor: bump_factor,
478 uvw: transformed_uvw
479 ) : state::normal();
480
481 float3 clearcoat_normal = base::tangent_space_normal_texture(
482 texture: clearcoat_normalmap_texture,
483 factor: clearcoat_bump_factor,
484 uvw: uvw
485 );
486
487 float3 flattened_clearcoat_normal = ::math::lerp(normal_lookup, ::state::normal(), clearcoat_flatten);
488 float3 final_clearcoat_normal = tex::texture_isvalid(clearcoat_normalmap_texture) ? clearcoat_normal : flattened_clearcoat_normal;
489
490 float ao_lookup = tex::texture_isvalid(ao_texture) ?
491 raw_file_texture(texture: ao_texture, uvw: transformed_uvw).x :
492 1.0f
493 [[anno::unused("Currently unused in material, may be utilized in the future")]];
494
495 color diffuse_color = tex::texture_isvalid(diffuse_texture) ? color(base_lookup.x, base_lookup.y, base_lookup.z) : diffuse_color_constant;
496 color base_color = multiply_colors(diffuse_color, diffuse_tint, 1.0).tint;
497
498 float3 ORM_lookup = tex::lookup_float3(
499 tex: ORM_texture,
500 coord: float2(transformed_uvw.position.x, transformed_uvw.position.y)
501 );
502
503 float roughness_lookup = tex::texture_isvalid(reflectionroughness_texture) ?
504 raw_file_texture(texture: reflectionroughness_texture, uvw: transformed_uvw).x :
505 reflection_roughness_constant;
506 float anisotropy_lookup = tex::texture_isvalid(anisotropy_texture) ?
507 (raw_file_texture(texture: anisotropy_texture, uvw: transformed_uvw).x * 2.0f - 1.0f) :
508 anisotropy_constant;
509 float metallic_lookup = tex::texture_isvalid(metallic_texture) ?
510 raw_file_texture(texture: metallic_texture, uvw: transformed_uvw).x :
511 metallic_constant;
512
513 float roughness_selection = enable_ORM_texture ? ORM_lookup.y : roughness_lookup;
514 float metallic_selection = enable_ORM_texture ? ORM_lookup.z : metallic_lookup;
515 color ao_color = enable_ORM_texture ? color(ORM_lookup.x) : color(ao_lookup);
516
517 color ao_weighted_base_color = multiply_colors(base_color, ao_color, ao_to_diffuse).tint;
518
519 float reflection_roughness = math::lerp(reflection_roughness_constant, roughness_selection, reflection_roughness_texture_influence);
520 float anisotropy = math::lerp(anisotropy_constant, anisotropy_lookup, anisotropy_texture_influence);
521 float metallic = math::lerp(metallic_constant, metallic_selection, metallic_texture_influence);
522
523 float squared_roughness = reflection_roughness * reflection_roughness;
524 float roughness_u = squared_roughness * (1 + anisotropy);
525 float roughness_v = squared_roughness * (1 - anisotropy);
526
527 bsdf diffuse_bsdf = df::weighted_layer(
528 weight: 1.0,
529 layer: df::diffuse_reflection_bsdf(
530 tint: ao_weighted_base_color,
531 roughness: 0.f ),
532 base: bsdf(),
533 normal: enable_clearcoat ? normal_lookup : state::normal()
534 );
535
536 bsdf ggx_smith_bsdf = df::microfacet_ggx_smith_bsdf(
537 roughness_u: roughness_u,
538 roughness_v: roughness_v,
539 tint: color(1.0, 1.0, 1.0),
540 mode: df::scatter_reflect
541 );
542
543 bsdf custom_curve_layer_bsdf = df::custom_curve_layer(
544 normal_reflectivity: 0.03,
545 grazing_reflectivity: 1.0,
546 exponent: 5.0,
547 weight: float(1.0),
548 layer: ggx_smith_bsdf,
549 base: diffuse_bsdf,
550 normal: enable_clearcoat ? normal_lookup : state::normal()
551 );
552
553 //
554 // Begin RETROREFLECTION SUPPORT
555 //
556 bsdf backscattering_glossy_bsdf = df::backscattering_glossy_reflection_bsdf(
557 tint: retroreflection_color,
558 roughness_u: reflection_roughness * reflection_roughness
559 );
560
561 bsdf retroreflection_bsdf = df::custom_curve_layer(
562 normal_reflectivity: 1.-normal_reflectivity,
563 grazing_reflectivity: 1.-grazing_reflectivity,
564 base: backscattering_glossy_bsdf,
565 layer: diffuse_bsdf,
566 normal: enable_clearcoat ? normal_lookup : state::normal()
567 );
568
569 //
570 // End RETROREFLECTION SUPPORT
571 //
572
573 bsdf directional_factor_bsdf = df::directional_factor(
574 normal_tint: ao_weighted_base_color,
575 grazing_tint: color(1.0, 1.0, 1.0),
576 exponent: 5.0f,
577 base: ggx_smith_bsdf
578 );
579
580 // CLEARCOAT
581
582 bsdf omni_PBR_bsdf = df::weighted_layer(
583 weight: metallic,
584 layer: directional_factor_bsdf,
585 base: enable_retroreflection ? retroreflection_bsdf : custom_curve_layer_bsdf,
586 normal: enable_clearcoat ? normal_lookup : state::normal()
587 );
588
589 bsdf clearcoat_bsdf = df::microfacet_ggx_smith_bsdf(
590 roughness_u: clearcoat_reflection_roughness * clearcoat_reflection_roughness,
591 roughness_v: clearcoat_reflection_roughness * clearcoat_reflection_roughness,
592 tint: color(1.0f),
593 mode: df::scatter_reflect
594 );
595
596 // bsdf omni_PBR_coated_bsdf = df::custom_curve_layer(
597 // normal_reflectivity: clearcoat_reflectivity * 0.08,
598 // grazing_reflectivity: 1.0,
599 // weight: clearcoat_weight,
600 // layer: clearcoat_bsdf,
601 // base: omni_PBR_bsdf,
602 // normal: final_clearcoat_normal
603 // );
604
605 bsdf opaque_clearcoat = df::weighted_layer(
606 weight: clearcoat_transparency,
607 layer: ::df::tint(
608 tint: clearcoat_tint,
609 base: omni_PBR_bsdf),
610 base: ::df::diffuse_reflection_bsdf(
611 tint: clearcoat_tint)
612 );
613
614 bsdf omni_PBR_coated_bsdf = df::fresnel_layer(
615 ior: clearcoat_ior,
616 weight: clearcoat_weight,
617 layer: clearcoat_bsdf,
618 base: opaque_clearcoat,
619 normal: final_clearcoat_normal
620 );
621
622
623 bsdf final_bsdf = enable_clearcoat ? omni_PBR_coated_bsdf : omni_PBR_bsdf;
624
625 int rows = flipbook_dim.x;
626 int columns = flipbook_dim.y;
627 int numFrames = rows * columns;
628 varying int frameIdx = int(state::animation_time() * target_fps) % numFrames;
629 varying float2 baseUV = float2(transformed_uvw.position.x, transformed_uvw.position.y);
630 varying float2 emissiveUV = enable_emissive_flipbook
631 ? ((baseUV + float2(frameIdx % rows, frameIdx / rows)) / float2(rows, columns))
632 : baseUV;
633
634 color emissive_mask = tex::texture_isvalid(emissive_mask_texture)
635 ? tex::lookup_color(emissive_mask_texture, emissiveUV, tex::wrap_repeat, tex::wrap_repeat)
636 : color(1.0);
637
638} in material(
639 thin_walled: false,
640 surface: material_surface(
641 scattering: final_bsdf,
642 emission: material_emission (
643 df::diffuse_edf(),
644 intensity: enable_emission ? emissive_color * emissive_mask * color(emissive_intensity) : color(0)
645 )
646 ),
647 geometry: material_geometry(
648 normal: enable_clearcoat ? state::normal() : normal_lookup,
649 cutout_opacity: enable_alpha ? (enable_alpha_cutout ? (opacityValue < alpha_cutout_cutoff ? 0.0 : 1.0) : opacityValue) : 1.0
650 )
651);
652 