| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| mdl 1.6; |
|
|
| import ::df::*; |
| import ::state::*; |
| import ::math::*; |
| import ::base::*; |
| import ::tex::*; |
| import ::anno::*; |
|
|
| import ::nvidia::core_definitions::file_texture; |
| import ::nvidia::core_definitions::normalmap_texture; |
|
|
| export material SimPBR_Translucent( |
| |
| uniform float ior_constant = 1.1f |
| [[ |
| anno::display_name("Index of Refraction"), |
| anno::hard_range(0.0,5.), |
| anno::description("Index of Refraction of the material"), |
| anno::in_group("Specular") |
| ]], |
| uniform float reflection_roughness_constant = 0.5f |
| [[ |
| anno::display_name("Roughness Amount"), |
| anno::hard_range(0.0,1.), |
| anno::description("Higher roughness values lead to more blurry reflections"), |
| anno::in_group("Specular") |
| ]], |
| uniform float reflection_roughness_texture_influence = 0.0f |
| [[ |
| anno::display_name("Roughness Map Influence"), |
| anno::hard_range(0.0, 1.), |
| anno::description("Blends between the constant value and the lookup of the roughness texture"), |
| anno::in_group("Specular") |
| ]], |
| uniform texture_2d reflectionroughness_texture = texture_2d() |
| [[ |
| anno::display_name("Roughness Map"), |
| anno::in_group("Specular") |
| ]], |
|
|
| |
| color transmittance_color = color(1.0, 1.0f, 1.0f) |
| [[ |
| anno::display_name("Transmittance Color"), |
| anno::description("Expected transmittance after the specified transmittance distance through the volume."), |
| anno::in_group("Volume") |
| ]], |
| float transmittance_measurement_distance = 1.0f |
| [[ |
| anno::display_name("Transmittance Measurement Distance"), |
| anno::description("Distance to match the transmittance through the volume at."), |
| anno::in_group("Volume") |
| ]], |
|
|
| |
| uniform bool enable_thin_walled = false |
| [[ |
| anno::display_name("Enable Thin Walled"), |
| anno::description("Enables thin walled logic"), |
| anno::in_group("Geometry") |
| ]], |
|
|
| |
| uniform bool enable_emission = false |
| [[ |
| anno::display_name("Enable Emission"), |
| anno::description("Enables the emission of light from the material"), |
| anno::in_group("Emissive") |
| ]], |
| color emissive_color = color(1.0, 0.1, 0.1) |
| [[ |
| anno::enable_if("enable_emission == true"), |
| anno::display_name("Emissive Color"), |
| anno::description("The emission color"), |
| anno::in_group("Emissive") |
| ]], |
| uniform texture_2d emissive_mask_texture = texture_2d() |
| [[ |
| anno::enable_if("enable_emission == true"), |
| anno::display_name("Emissive Mask Map"), |
| anno::description("The texture masking the emissive color"), |
| anno::in_group("Emissive") |
| ]], |
| uniform float emissive_intensity = 40.f |
| [[ |
| anno::enable_if("enable_emission == true"), |
| anno::display_name("Emissive Intensity"), |
| anno::description("Intensity of the emission"), |
| anno::in_group("Emissive") |
| ]], |
| uniform bool enable_emissive_flipbook = false |
| [[ |
| anno::display_name("Enable Flipbook for emission"), |
| anno::description("Allows the use of animated emissive textures (e.g. video screens)"), |
| anno::in_group("Emissive") |
| ]], |
| uniform int2 flipbook_dim = int2(1,1) |
| [[ |
| anno::enable_if("enable_emissive_flipbook == true"), |
| anno::display_name("Flipbook Rows/Columns"), |
| anno::description("How many rows and columns are in the flipbook?"), |
| anno::in_group("Emissive") |
| ]], |
| uniform int target_fps = 1 |
| [[ |
| anno::enable_if("enable_emissive_flipbook == true"), |
| anno::display_name("Flipbook Target FPS"), |
| anno::description("Playback speed in frames per second"), |
| anno::in_group("Emissive") |
| ]], |
|
|
| |
| uniform float bump_factor = 1.f |
| [[ |
| anno::display_name("Normal Map Strength"), |
| anno::description("Strength of normal map."), |
| anno::in_group("Normal") |
| ]], |
| uniform texture_2d normalmap_texture = texture_2d() |
| [[ |
| anno::display_name("Normal Map"), |
| anno::in_group("Normal") |
| ]], |
| uniform bool flip_tangent_u = false |
| [[ |
| anno::display_name("Normal Map Flip U Tangent"), |
| anno::in_group("Normal") |
| ]], |
| uniform bool flip_tangent_v = true |
| [[ |
| anno::display_name("Normal Map Flip V Tangent"), |
| anno::in_group("Normal") |
| ]], |
|
|
| |
| uniform bool project_uvw = false |
| [[ |
| anno::display_name("Enable Project UVW Coordinates"), |
| anno::description("When enabled, UV coordinates will be generated by projecting them from a coordinate system"), |
| anno::in_group("UV") |
| ]], |
| uniform bool world_or_object = false |
| [[ |
| anno::enable_if("project_uvw == true"), |
| anno::display_name("Enable World Space"), |
| anno::description("When set to 'true' uses world space for projection, when 'false' object space is used"), |
| anno::in_group("UV") |
| ]], |
| uniform float2 texture_translate = float2(0.0f) |
| [[ |
| anno::display_name("Texture Translate"), |
| anno::description("Controls position of texture."), |
| anno::in_group("UV") |
| ]], |
| uniform float2 texture_scale = float2(1.0f) |
| [[ |
| anno::display_name("Texture Tiling"), |
| anno::description("Controls the repetition of the texture."), |
| anno::in_group("UV") |
| ]], |
| uniform float2 texture_speed = float2(0.0f) |
| [[ |
| anno::display_name("Texture Speed"), |
| anno::description("Scrolling texture animation speed in UVs per sec."), |
| anno::in_group("UV") |
| ]] |
| ) |
| [[ anno::display_name("Sim PBR Translucent"), anno::description("Supports the translucent material model of the Sim Renderer"), anno::in_group("SimReady"), anno::version( 1, 0, 0), anno::author("NVIDIA CORPORATION"), anno::key_words(string[]("Sim", "PBR", "translucent", "omniverse", "generic")) |
| ]] |
| = let { |
| base::texture_coordinate_system the_system = world_or_object ? base::texture_coordinate_world : base::texture_coordinate_object; |
|
|
| base::texture_coordinate_info uvw = project_uvw ? |
| base::coordinate_projection( |
| coordinate_system: the_system, |
| texture_space: 0, |
| projection_type: base::projection_cubic |
| ) : base::coordinate_source( |
| coordinate_system: base::texture_coordinate_uvw, |
| texture_space: 0 |
| ); |
|
|
| |
| float t = 0.00000001; |
| base::texture_coordinate_info transformed_uvw = base::transform_coordinate( |
| transform: base::rotation_translation_scale( |
| scaling: float3(texture_scale.x, texture_scale.y, 1.0), |
| rotation: float3(0.0, 0.0, 0.0 ), |
| translation: float3(texture_translate.x + t * texture_speed.x, texture_translate.y + t * texture_speed.y, 0.0)), |
| coordinate: uvw |
| ); |
| float2 uv = float2(transformed_uvw.position.x, transformed_uvw.position.y); |
|
|
| color volume_absorption_coefficient = -math::log(transmittance_color) / (transmittance_measurement_distance*0.01); |
|
|
| float roughness_lookup = tex::texture_isvalid(reflectionroughness_texture) ? |
| tex::lookup_float4(tex: reflectionroughness_texture, coord: uv).x : reflection_roughness_constant; |
| float reflection_roughness = math::lerp(reflection_roughness_constant, roughness_lookup, reflection_roughness_texture_influence); |
|
|
| float roughness_squared = reflection_roughness * reflection_roughness; |
| bsdf final_bsdf(enable_thin_walled ? |
| ::df::fresnel_layer( |
| ior_constant, |
| 1.f, |
| ::df::microfacet_ggx_smith_bsdf( |
| roughness_squared, |
| roughness_squared, |
| color(1.f, 1.f, 1.f), |
| color(0.f, 0.f, 0.f), |
| ::state::texture_tangent_u(0), |
| ::df::scatter_reflect, |
| "" |
| ), |
| ::df::specular_bsdf( |
| transmittance_color, |
| ::df::scatter_transmit, |
| "" |
| ), ::state::normal()) |
| : ::df::microfacet_ggx_smith_bsdf( |
| roughness_squared, |
| roughness_squared, |
| color(1.f, 1.f, 1.f), |
| color(0.f, 0.f, 0.f), |
| ::state::texture_tangent_u(0), |
| ::df::scatter_reflect_transmit, |
| "" |
| )); |
|
|
| int rows = flipbook_dim.x; |
| int columns = flipbook_dim.y; |
| int numFrames = rows * columns; |
| varying int frameIdx = int(state::animation_time() * target_fps) % numFrames; |
| varying float2 baseUV = float2(transformed_uvw.position.x, transformed_uvw.position.y); |
| varying float2 emissiveUV = enable_emissive_flipbook ? |
| ((baseUV + float2(frameIdx % rows, frameIdx / rows)) / float2(rows, columns)) : baseUV; |
|
|
| color emissive_mask = tex::texture_isvalid(emissive_mask_texture) ? |
| tex::lookup_color(emissive_mask_texture, emissiveUV, tex::wrap_repeat, tex::wrap_repeat) : color(1.0); |
|
|
| |
| float3 normal_lookup = tex::texture_isvalid(normalmap_texture) ? |
| base::tangent_space_normal_texture( |
| texture: normalmap_texture, |
| factor: bump_factor, |
| uvw: transformed_uvw, |
| flip_tangent_u: flip_tangent_u, |
| flip_tangent_v: flip_tangent_v |
| ) : state::normal(); |
| } in material( |
| thin_walled: enable_thin_walled, |
| surface: material_surface( |
| scattering: final_bsdf, |
| emission: material_emission ( |
| df::diffuse_edf(), |
| intensity: enable_emission ? emissive_color * emissive_mask * color(emissive_intensity) : color(0) |
| ) |
| ), |
| ior: color(ior_constant), |
| volume: material_volume( |
| scattering: df::anisotropic_vdf(), |
| absorption_coefficient: volume_absorption_coefficient, |
| scattering_coefficient: color(0.0f, 0.0f, 0.0f) |
| ), |
| geometry: material_geometry( |
| normal: normal_lookup |
| ) |
| ); |
|
|