Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- assets/objects/dojo/blocks/blue_block.usdcAdded
- assets/objects/dojo/blocks/green_block.usdcAdded
- assets/objects/dojo/blocks/red_block.usdcAdded
- assets/objects/dojo/blocks/sources.jsonAdded+109
- assets/objects/dojo/bowl/sources.jsonAdded+16
- assets/objects/dojo/pickup/book.usdcAdded
- assets/objects/dojo/pickup/book_book (3).jpgAdded
- assets/objects/dojo/pickup/book_texturs a (2).jpgAdded
- assets/objects/dojo/pickup/eraser.usdcAdded
- assets/objects/dojo/pickup/eraser_scan.jpgAdded
- assets/objects/fruits_veggies/materials/SimPBR.mdlAdded+562
- assets/objects/fruits_veggies/materials/SimPBR_Model.mdlAdded+212
- assets/objects/fruits_veggies/materials/baking_annotations.mdlAdded+38
- assets/objects/fruits_veggies/textures/lemon_01/materials/OmniPBR_Opacity.mdlAdded+426
- assets/objects/fruits_veggies/textures/lemon_02/materials/OmniPBR_Opacity.mdlAdded+426
- assets/objects/vomp/antiquelvasesmall/materials/SimPBR.mdlAdded+562
- assets/objects/vomp/antiquelvasesmall/materials/SimPBR_Model.mdlAdded+212
- assets/objects/vomp/antiquelvasesmall/materials/SimPBR_Opacity.mdlAdded+651
- assets/objects/vomp/antiquelvasesmall/materials/SimPBR_Translucent.mdlAdded+290
- assets/objects/vomp/anza_large/materials/SimPBR.mdlAdded+562
- assets/objects/vomp/anza_large/materials/SimPBR_Model.mdlAdded+212
- assets/objects/vomp/anza_large/materials/SimPBR_Opacity.mdlAdded+651
- assets/objects/vomp/anza_large/materials/SimPBR_Translucent.mdlAdded+290
- assets/objects/vomp/anza_medium/materials/SimPBR.mdlAdded+562
- assets/objects/vomp/anza_medium/materials/SimPBR_Model.mdlAdded+212
- assets/objects/vomp/anza_medium/materials/SimPBR_Opacity.mdlAdded+651
- assets/objects/vomp/anza_medium/materials/SimPBR_Translucent.mdlAdded+290
- assets/objects/vomp/bin_a01/materials/Plastic_B.mdlAdded+52
- assets/objects/vomp/bin_a03/materials/Plastic_B.mdlAdded+52
- assets/objects/vomp/bin_a05/materials/Plastic_B.mdlAdded+52
- assets/objects/vomp/bin_b01/materials/Plastic_B.mdlAdded+52
- assets/objects/vomp/bin_b04/materials/Plastic_B.mdlAdded+52
- assets/objects/vomp/bin_b06/materials/Plastic_B.mdlAdded+52
- assets/objects/vomp/bin_b07/materials/Plastic_B.mdlAdded+52
- assets/objects/vomp/blackandbrassbowl_large/materials/SimPBR.mdlAdded+562
- assets/objects/vomp/blackandbrassbowl_large/materials/SimPBR_Model.mdlAdded+212
- assets/objects/vomp/blackandbrassbowl_large/materials/SimPBR_Opacity.mdlAdded+651
- assets/objects/vomp/blackandbrassbowl_large/materials/SimPBR_Translucent.mdlAdded+290
- assets/objects/vomp/blackandbrassbowl_small/materials/SimPBR.mdlAdded+562
- assets/objects/vomp/blackandbrassbowl_small/materials/SimPBR_Model.mdlAdded+212
- assets/objects/vomp/blackandbrassbowl_small/materials/SimPBR_Opacity.mdlAdded+651
- assets/objects/vomp/blackandbrassbowl_small/materials/SimPBR_Translucent.mdlAdded+290
- assets/objects/vomp/box_a01/materials/Plastic_B.mdlAdded+52
- assets/objects/vomp/box_a01/materials/Plastic_Black_A.mdlAdded+52
- assets/objects/vomp/box_a03/materials/Plastic_B.mdlAdded+52
- assets/objects/vomp/box_a03/materials/Plastic_Black_A.mdlAdded+52
- assets/objects/vomp/box_a06/materials/Plastic_B.mdlAdded+52
- assets/objects/vomp/box_a06/materials/Plastic_Black_A.mdlAdded+52
- assets/objects/vomp/box_a07/materials/Plastic_B.mdlAdded+52
- assets/objects/vomp/box_a07/materials/Plastic_Black_A.mdlAdded+52
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109{ "source_visuals": { "texture_6": { "source_url": "https://huggingface.co/datasets/RoboDojo-Benchmark/RoboDojo/resolve/1127bda94f172d757386945af3eb3a6754d1a4e6/Assets/Object/RoboDojo/Rigid/block/00006/object.usdz", "source_sha256": "4ef81752cbaaf830dfd0e0d547f2e1f088c41adbee5833c28bf774f159675d00", "visual_prim": "/World/visual", "extent_m": [ 0.035, 0.035, 0.035 ], "visual_vertices": 2253, "diffuse_rgb": [ 1.0, 1.0, 1.0 ], "albedo_sha256": "5595f8e35632965d3d7b68c0d88e950fa5913e5f3a3d81b169b250d28ed90c23" }, "texture_9": { "source_url": "https://huggingface.co/datasets/RoboDojo-Benchmark/RoboDojo/resolve/1127bda94f172d757386945af3eb3a6754d1a4e6/Assets/Object/RoboDojo/Rigid/block/00009/object.usdz", "source_sha256": "edce904abea5428dbcc91972d3a26ac9bf6482511d962c9485d9c96ed7d1f46e", "visual_prim": "/World/visual", "extent_m": [ 0.035, 0.035, 0.035 ], "visual_vertices": 2257, "diffuse_rgb": [ 1.0, 1.0, 1.0 ], "albedo_sha256": "5e251710d634109b46e4b91a7f1d87ce9571f1f161a2e79b120a1d4e11688bb6" }, "texture_12": { "source_url": "https://huggingface.co/datasets/RoboDojo-Benchmark/RoboDojo/resolve/1127bda94f172d757386945af3eb3a6754d1a4e6/Assets/Object/RoboDojo/Rigid/block/00012/object.usdz", "source_sha256": "de1de2a3912a3a3cba5cc4d07c41205272eb958e50c4882d0fe28ea690730c6e", "visual_prim": "/World/visual", "extent_m": [ 0.035, 0.035, 0.035 ], "visual_vertices": 2244, "diffuse_rgb": [ 1.0, 1.0, 1.0 ], "albedo_sha256": "a1da35b7de8acca4fa70ae24ad373e830f0f88881f5c48f5ce2ce91f72d414f7" }, "blue_block": { "source_url": "https://huggingface.co/datasets/RoboDojo-Benchmark/RoboDojo/resolve/1127bda94f172d757386945af3eb3a6754d1a4e6/Assets/Object/RoboDojo/Rigid/cube/00001/object.usdz", "source_sha256": "95a555a472401952403660e99faa3b0791d523b71e28c3e923c6fc6aaf89bba4", "visual_prim": "/World/visual/model", "extent_m": [ 0.035, 0.035, 0.035 ], "visual_vertices": 36, "diffuse_rgb": [ 0.0, 0.0, 1.0 ], "albedo_sha256": null }, "green_block": { "source_url": "https://huggingface.co/datasets/RoboDojo-Benchmark/RoboDojo/resolve/1127bda94f172d757386945af3eb3a6754d1a4e6/Assets/Object/RoboDojo/Rigid/cube/00002/object.usdz", "source_sha256": "d2e6b6b0a40d599b30a4dbcf84fa5081a71cbe55ae5b3c90bbe35f03d9c510b1", "visual_prim": "/World/visual/model", "extent_m": [ 0.035, 0.035, 0.035 ], "visual_vertices": 36, "diffuse_rgb": [ 0.0, 1.0, 0.0 ], "albedo_sha256": null }, "red_block": { "source_url": "https://huggingface.co/datasets/RoboDojo-Benchmark/RoboDojo/resolve/1127bda94f172d757386945af3eb3a6754d1a4e6/Assets/Object/RoboDojo/Rigid/cube/00003/object.usdz", "source_sha256": "66eb66bdd05680c118dc0c8996a392625c712f244735a487f323038e7ccf4640", "visual_prim": "/World/visual/model", "extent_m": [ 0.035, 0.035, 0.035 ], "visual_vertices": 36, "diffuse_rgb": [ 1.0, 0.0, 0.0 ], "albedo_sha256": null } }, "host_physics": "RubiksCubeTask cuboid proxy: local mass 0.20 kg, cube material 2.0/2.0/0.1. Source mass, friction and colliders excluded.", "host_fixture": "rubiks_cube_bowl.usda", "render_finish": "Official mesh, UV, solid color or exact original base-color JPG; local neutral PBR finish."}12345678910111213141516{ "visual_source": { "path": "Assets/Object/RoboDojo/Rigid/bowl/00009/object.usdz", "sha256": "b31ce3031f173faf9810e43fa5c7e3e2daae61823914a46a88cc51d33290c21f", "bytes": 5136768, "url": "https://huggingface.co/datasets/RoboDojo-Benchmark/RoboDojo/resolve/1127bda94f172d757386945af3eb3a6754d1a4e6/Assets/Object/RoboDojo/Rigid/bowl/00009/object.usdz" }, "visual_prim": "/root/visual/model", "texture": "SubUSDs/textures/shaded.png", "host_dynamics_reference": "assets/objects/ycb/bowl.usd", "mass_kg": 0.5, "static_friction": 2, "dynamic_friction": 2, "restitution": 0.1, "converter": "tools/dojo/build_bowl.py"}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562/*****************************************************************************
* Copyright 1986-2020 NVIDIA Corporation. All rights reserved.
******************************************************************************
MDL MATERIALS ARE PROVIDED PURSUANT TO AN END USER LICENSE AGREEMENT,
WHICH WAS ACCEPTED IN ORDER TO GAIN ACCESS TO THIS FILE. IN PARTICULAR,
THE MDL MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL NVIDIA
CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
THE USE OR INABILITY TO USE THE MDL MATERIALS OR FROM OTHER DEALINGS IN
THE MDL MATERIALS.
*/
mdl 1.4;
import ::df::*;
import ::state::*;
import ::math::*;
import ::base::*;
import ::tex::*;
import ::anno::*;
using SimPBR_Model import *;
using baking_annotations import *;
export material SimPBR(
// -------------------- DIFFUSE REFLECTION ----------------------
uniform color diffuse_color_constant = color(0.2f)
[[
anno::display_name("Albedo Base Color"),
anno::description("The base albedo color to use if no texture is specified"),
anno::in_group("Diffuse")
]],
uniform texture_2d diffuse_texture = texture_2d()
[[
anno::display_name("Albedo Map"),
anno::description("The texture specifying the albedo value to use"),
anno::in_group("Diffuse")
]],
uniform color diffuse_tint = color(1.0f)
[[
anno::display_name("Albedo Tint"),
anno::description("This tints the albedo color or texture contant"),
anno::in_group("Diffuse")
]],
uniform bool enable_transmission = false
[[
anno::display_name("Enable Diffuse Transmission"),
anno::description("Enables the diffuse transmission of light through thin diffuse scattering layer"),
anno::in_group("Diffuse")
]],
uniform float opacity_ratio = 1.f
[[
anno::enable_if("enable_transmission == true"),
anno::display_name("Opacity Ratio"),
anno::description("Amount of opacity"),
anno::in_group("Diffuse")
]],
uniform color opacity_tint = color(1.0f)
[[
anno::enable_if("enable_transmission == true"),
anno::display_name("Diffuse transmission tint"),
anno::description("Base diffuse transmission color"),
anno::in_group("Diffuse")
]],
uniform float opacity_multiplier = 1.f
[[
anno::enable_if("enable_transmission == true"),
anno::display_name("Diffuse transmission multiplier"),
anno::description("Base diffuse transmission multiplier"),
anno::in_group("Diffuse")
]],
// -------------------- SPECULAR REFLECTION ----------------------
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")
]],
float anisotropy_constant = 0.0f
[[
anno::display_name("Anisotropy Amount"),
anno::hard_range(-1.,1.),
anno::description("0 for isotropic, extents of -1 to 1 for anisotropy"),
anno::in_group("Specular")
]],
uniform float anisotropy_texture_influence = 0.0f
[[
anno::display_name("Anisotropy Map Influence"),
anno::hard_range(0.0, 1.),
anno::description("Blends between the constant value and the lookup of the anisotropy texture"),
anno::in_group("Specular")
]],
uniform texture_2d anisotropy_texture = texture_2d()
[[
anno::display_name("Anisotropy Map"),
anno::in_group("Specular")
]],
float metallic_constant = 0.f
[[
anno::display_name("Metallic Amount"),
anno::hard_range(0.0,1.),
anno::description("Metallic Material"),
anno::in_group("Specular")
]],
uniform float metallic_texture_influence = 0.0f
[[
anno::display_name("Metallic Map Influence"),
anno::hard_range(0.0, 1.),
anno::description("Blends between the constant value and the lookup of the metallic texture"),
anno::in_group("Specular")
]],
uniform texture_2d metallic_texture = texture_2d()
[[
anno::display_name("Metallic Map"),
anno::in_group("Specular")
]],
float specular_constant = 1.f
[[
anno::display_name("Specular amount"),
anno::hard_range(0.0, 1.0),
anno::description("Scale of the specular component"),
anno::in_group("Specular")
]],
uniform texture_2d specular_texture = texture_2d()
[[
anno::display_name("Specular Map"),
anno::in_group("Specular")
]],
// -------------------- ORM ----------------------
uniform bool enable_ORM_texture = true
[[
anno::display_name("Enable ORM Texture"),
anno::description("When True the ORM texture will be used to extract the Occlusion, Roughness and Metallic Map"),
anno::in_group("Reflectivity")
]],
uniform texture_2d ORM_texture = texture_2d()
[[
anno::display_name("ORM Map"),
anno::description("Texture that hae Occlusion, Roughness and Metallic map stored in the respective r, g and b channels"),
anno::in_group("Reflectivity")
]],
// -------------------- Clearcoat ----------------------
uniform bool enable_clearcoat = false
[[
anno::display_name("Enable Clearcoat Layer"),
anno::description("Adds a clearcoat layer on top of the material when enabled"),
anno::in_group("Clearcoat")
]],
color clearcoat_tint = color(1.0f)
[[
anno::display_name("Clearcoat Tint"),
anno::description("Clearcoat is tinted and affects the underlying material"),
anno::in_group("Clearcoat")
]],
float clearcoat_transparency = 1.0f
[[
anno::display_name("Clearcoat Transparency"),
anno::description("Adjusts the transparency of the clearcoat. Can be turned into a fully opaque clearcoat "
"covering the underlying layer"),
anno::in_group("Clearcoat")
]],
float clearcoat_reflection_roughness = 0.0f
[[
anno::display_name("Clearcoat Roughness"),
anno::description("Higher roughness values lead to more blurry reflections"),
anno::hard_range(0.0f, 1.0f),
anno::in_group("Clearcoat")
]],
float clearcoat_weight = 1.0f
[[
anno::display_name("Clearcoat Weight"),
anno::description("Sets the weight for clearcoat layer"),
anno::hard_range(0.0f, 1.0f),
anno::in_group("Clearcoat")
]],
float clearcoat_flatten = 1.0f
[[
anno::display_name("Clearcoat Flatten"),
anno::description("Flattens the clearcoat to even out the underlying bump maps"),
anno::hard_range(0.0f, 1.0f),
anno::in_group("Clearcoat")
]],
float clearcoat_ior = 1.56f
[[
anno::display_name("Clearcoat IOR"),
anno::description("Sets the Index of refraction for the clearcoat layer"),
anno::soft_range(1.0f, 4.0f),
anno::in_group("Clearcoat")
]],
uniform float clearcoat_bump_factor = 1.f
[[
anno::display_name("Clearcoat Normal Map Strength"),
anno::description("Strength of normal map."),
anno::in_group("Clearcoat")
]],
float3 clearcoat_normal_input = float3(0.0, 0.0, 0.0),
uniform texture_2d clearcoat_normalmap_texture = texture_2d()
[[
anno::display_name("Clearcoat Normal Map"),
anno::description("Enables the usage of the normalmap texture"),
anno::in_group("Clearcoat")
]],
uniform bool clearcoat_flip_tangent_u = false
[[
anno::display_name("Clearcoat Normal Map Flip U Tangent"),
anno::in_group("Clearcoat")
]],
uniform bool clearcoat_flip_tangent_v = true
[[
anno::display_name("Clearcoat Normal Map Flip V Tangent"),
anno::in_group("Clearcoat")
]],
// -------------------- REFLECTIVITY ----------------------
uniform bool enable_retroreflection = false
[[
anno::display_name("Enable Retroreflection"),
anno::in_group("Reflectivity")
]],
color retroreflection_tint = color(.182,.800,.000)
[[
anno::display_name("Retro-reflection tint"),
anno::description("The tint of the retroreflection"),
anno::in_group("Reflectivity")
]],
uniform float normal_reflectivity = 0.5
[[
anno::display_name("Retro-reflection weight facing"),
anno::hard_range(0.0,1.),
anno::description("Reflectivity control for geometry facing the viewer"),
anno::in_group("Reflectivity")
]],
uniform float grazing_reflectivity = 1.0
[[
anno::display_name("Retro-reflection weight edge"),
anno::hard_range(0.0,1.),
anno::description("Reflectivity control for the reflectivity at geometry edges"),
anno::in_group("Reflectivity")
]],
// -------------------- AMBIENT OCCLUSION ----------------------
float ao_to_diffuse = 0.0
[[
anno::display_name("AO to Diffuse"),
anno::description("Controls the amount of ambient occlusion multiplied into the diffuse color channel"),
anno::in_group("AO")
]],
float ao_input = float(1.0),
uniform texture_2d ao_texture = texture_2d()
[[
anno::display_name("Ambient Occlusion Map"),
anno::description("The Ambient Occlusion texture for the material"),
anno::in_group("AO")
]],
// -------------------- EMISSIVE ----------------------
uniform bool enable_emission = false
[[
anno::display_name("Enable Emission"),
anno::description("Enables the emission of light from the material"),
anno::in_group("Emissive")
]],
uniform 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")
]],
color emissive_mask_input = color(1.0),
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")
]],
// -------------------- ALPHA ----------------------
uniform bool enable_opacity = false
[[
anno::display_name("Enable Opacity"),
anno::description("Enables or disables alpha functionality"),
anno::in_group("Alpha")
]],
float alpha_constant = 1.0
[[
anno::enable_if("enable_opacity == true"),
anno::display_name("Opacity Fallback Constant"),
anno::hard_range(0.0, 1.0),
anno::description("The base alpha constant to use if no texture is specified"),
anno::in_group("Alpha")
]],
uniform texture_2d opacity_texture = texture_2d()
[[
anno::enable_if("enable_opacity == true"),
anno::display_name("Opacity Map"),
anno::description("The texture specifying the opacity value to use"),
anno::in_group("Alpha")
]],
uniform bool enable_opacity_cutout = false
[[
anno::enable_if("enable_opacity == true"),
anno::display_name("Enable Alpha Cutout"),
anno::description("Enables or disables alpha cutout functionality"),
anno::in_group("Alpha")
]],
uniform float alpha_cutout_cutoff = 1.f
[[
anno::enable_if("enable_opacity == true"),
anno::enable_if("enable_opacity_cutout == true"),
anno::hard_range(0.0, 1.0),
anno::display_name("Alpha Cutout Cutoff"),
anno::description("The cutoff value to to render as transparent up to and opaque past"),
anno::in_group("Alpha")
]],
// -------------------- NORMAL ----------------------
uniform float bump_factor = 1.f
[[
anno::display_name("Normal Map Strength"),
anno::description("Strength of normal map."),
anno::in_group("Normal")
]],
float3 normal_input = state::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::description("Flips the U Tangent vector."),
anno::in_group("Normal")
]],
uniform bool flip_tangent_v = true
[[
anno::display_name("Normal Map Flip V Tangent"),
anno::description("Flips the V Tangent vector. By Default, SimPBR materials setup for DirectX normal maps. Set Normal Map Flip V = false for OpenGL."),
anno::in_group("Normal")
]],
// -------------------- UV ADJUSTMENTS ----------------------
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 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"),
anno::description("Supports the opaque alpha cutout 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", "opaque", "alpha", "cutout", "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
);
// Need to use a small value so the compiler doesnt optimize out this var...
float t = 0.00000001;//state::animation_time();
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);
// Diffuse Color Lookup and AO
float4 base_lookup = tex::texture_isvalid(diffuse_texture) ? tex::lookup_float4(tex: diffuse_texture, coord: uv) : float4(1, 1, 1, 1);
float opacityValue = tex::texture_isvalid(opacity_texture) ? tex::lookup_float4(tex: opacity_texture, coord: uv).w : alpha_constant;
// Normal calculations
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
) : normal_input;
float3 clearcoat_normal = tex::texture_isvalid(clearcoat_normalmap_texture) ?
base::tangent_space_normal_texture(
texture: clearcoat_normalmap_texture,
factor: clearcoat_bump_factor,
uvw: uvw,
flip_tangent_u: clearcoat_flip_tangent_u,
flip_tangent_v: clearcoat_flip_tangent_v
) : clearcoat_normal_input;
float3 flattened_clearcoat_normal = ::math::lerp(normal_lookup, ::state::normal(), clearcoat_flatten);
float3 final_clearcoat_normal = tex::texture_isvalid(clearcoat_normalmap_texture) ? clearcoat_normal : flattened_clearcoat_normal;
float ao_lookup = tex::texture_isvalid(ao_texture) ? tex::lookup_float4(tex: ao_texture, coord: uv).x : ao_input;
color diffuse_color = tex::texture_isvalid(diffuse_texture) ? color(base_lookup.x, base_lookup.y, base_lookup.z) : diffuse_color_constant;
float3 ORM_lookup = tex::lookup_float3(
tex: ORM_texture,
coord: float2(transformed_uvw.position.x, transformed_uvw.position.y)
);
float roughness_lookup = tex::texture_isvalid(reflectionroughness_texture) ?
tex::lookup_float4(tex: reflectionroughness_texture, coord: uv).x : reflection_roughness_constant;
float anisotropy_lookup = tex::texture_isvalid(anisotropy_texture) ?
(tex::lookup_float4(tex: anisotropy_texture, coord: uv).x * 2.0f - 1.0f) : anisotropy_constant;
float metallic_lookup = tex::texture_isvalid(metallic_texture) ?
tex::lookup_float4(tex: metallic_texture, coord: uv).x : metallic_constant;
float specular_lookup = tex::texture_isvalid(specular_texture) ?
tex::lookup_float4(tex: specular_texture, coord: uv).x : specular_constant;
float roughness_selection = enable_ORM_texture ? ORM_lookup.y : roughness_lookup;
float metallic_selection = enable_ORM_texture ? ORM_lookup.z : metallic_lookup;
float ao = enable_ORM_texture ? ORM_lookup.x : ao_lookup;
float reflection_roughness = math::lerp(reflection_roughness_constant, roughness_selection, reflection_roughness_texture_influence);
float anisotropy = math::lerp(anisotropy_constant, anisotropy_lookup, anisotropy_texture_influence);
float metallic = math::lerp(metallic_constant, metallic_selection, metallic_texture_influence);
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) : emissive_mask_input;
} in SimPBR_Model(
diffuse_color: diffuse_color,
diffuse_tint: diffuse_tint,
roughness: reflection_roughness,
anisotropy: anisotropy,
metallic: metallic,
specular: specular_lookup,
normal: normal_lookup,
enable_clearcoat: enable_clearcoat,
clearcoat_tint: clearcoat_tint,
clearcoat_transparency: clearcoat_transparency,
clearcoat_reflection_roughness: clearcoat_reflection_roughness,
clearcoat_weight: clearcoat_weight,
clearcoat_ior: clearcoat_ior,
clearcoat_normal: final_clearcoat_normal,
enable_retroreflection: enable_retroreflection,
retroreflection_tint: retroreflection_tint,
normal_reflectivity: normal_reflectivity,
grazing_reflectivity: grazing_reflectivity,
ao_to_diffuse: ao_to_diffuse,
ao: ao,
enable_emission: enable_emission,
emissive_color: emissive_color,
emissive_mask: emissive_mask,
emissive_intensity: emissive_intensity,
enable_opacity: enable_opacity,
alpha: opacityValue,
enable_opacity_cutout: enable_opacity_cutout,
alpha_cutout_cutoff: alpha_cutout_cutoff,
opacity_ratio: enable_transmission ? opacity_ratio : 1.0,
opacity_tint : opacity_tint,
opacity_multiplier : opacity_multiplier
);123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212/*****************************************************************************
* Copyright 1986-2020 NVIDIA Corporation. All rights reserved.
******************************************************************************
MDL MATERIALS ARE PROVIDED PURSUANT TO AN END USER LICENSE AGREEMENT,
WHICH WAS ACCEPTED IN ORDER TO GAIN ACCESS TO THIS FILE. IN PARTICULAR,
THE MDL MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL NVIDIA
CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
THE USE OR INABILITY TO USE THE MDL MATERIALS OR FROM OTHER DEALINGS IN
THE MDL MATERIALS.
*/
mdl 1.4;
import ::df::*;
import ::state::*;
import ::math::*;
import ::base::*;
import ::tex::*;
import ::anno::*;
using baking_annotations import *;
base::texture_return multiply_colors(
color color_1 = color(1.0, 1.0, 1.0),
color color_2 = color(.5, .5, .5),
float weight = 1.0
)
[[
anno::hidden()
]]
{
return base::blend_color_layers(
layers: base::color_layer[](
base::color_layer(
layer_color: color_2,
weight: weight,
mode: base::color_layer_multiply
)
), base: color_1
);
}
export material SimPBR_Model(
color diffuse_color = color(0.2f) [[ target_baked_argument("diffuse_texture", "diffuse_color_constant", "RGBA8_UNORM") ]],
uniform color diffuse_tint = color(1.0f),
float roughness = 0.5f [[ target_baked_argument("reflectionroughness_texture", "reflection_roughness_constant", "R8_UNORM") ]],
float anisotropy = 0.0f [[ target_baked_argument("anisotropy_texture", "anisotropy_constant", "R8_SNORM") ]],
float metallic = 0.f [[ target_baked_argument("metallic_texture", "metallic_constant", "R8_UNORM") ]],
float specular = 1.f [[ target_baked_argument("specular_texture", "specular_constant", "R8_UNORM") ]],
float3 normal = float3(0.0, 0.0, 0.0) [[ target_baked_argument("normalmap_texture", "normal_input", "RGBA8_SNORM", baking_annotations::TRANSFORM_UNORM_VECTOR) ]],
uniform bool enable_clearcoat = false,
color clearcoat_tint = color(1.0f),
float clearcoat_transparency = 1.0f,
float clearcoat_reflection_roughness = 0.0f,
float clearcoat_weight = 1.0f,
float clearcoat_ior = 1.56f,
float3 clearcoat_normal = float3(0.0, 0.0, 0.0) [[ target_baked_argument("clearcoat_normalmap_texture", "clearcoat_normal_input", "RGBA8_SNORM", baking_annotations::TRANSFORM_UNORM_VECTOR) ]],
uniform bool enable_retroreflection = false,
color retroreflection_tint = color(.182,.800,.000),
uniform float normal_reflectivity = 0.5,
uniform float grazing_reflectivity = 1.0,
float ao_to_diffuse = 0.0,
float ao = 1.0f [[ target_baked_argument("ao_texture", "ao_input", "R8_UNORM") ]],
uniform bool enable_emission = false,
uniform color emissive_color = color(1.0, 0.1, 0.1),
color emissive_mask = color(1.0, 0.1, 0.1) [[ target_baked_argument("emissive_mask_texture", "emissive_mask_input", "R8_UNORM") ]],
uniform float emissive_intensity = 40.f,
uniform bool enable_opacity = false,
float alpha = 1.0,
uniform bool enable_opacity_cutout = false,
uniform float alpha_cutout_cutoff = 1.f,
uniform float opacity_ratio = 1.f,
uniform color opacity_tint = color(1.0f),
uniform float opacity_multiplier = 1.f
)
[[
target_material_model(),
target_material_rendering("..::SimPBR::SimPBR")
]]
= let {
color base_color = multiply_colors(diffuse_color, diffuse_tint, 1.0).tint;
color ao_weighted_base_color = multiply_colors(base_color, color(ao), ao_to_diffuse).tint;
float squared_roughness = roughness * roughness;
float roughness_u = squared_roughness * (1 + anisotropy);
float roughness_v = squared_roughness * (1 - anisotropy);
color diffuse_transmission_color = base_color * opacity_tint * opacity_multiplier;
bsdf diffuse_bsdf = df::weighted_layer(
weight: opacity_ratio,
layer: df::diffuse_reflection_bsdf(
tint: ao_weighted_base_color,
roughness: 0.0f
),
base: df::diffuse_transmission_bsdf(tint: diffuse_transmission_color),
normal: enable_clearcoat ? normal : state::normal()
);
bsdf ggx_smith_bsdf = df::microfacet_ggx_smith_bsdf(
roughness_u: roughness_u,
roughness_v: roughness_v,
tint: color(1.0, 1.0, 1.0),
mode: df::scatter_reflect
);
bsdf custom_curve_layer_bsdf = df::custom_curve_layer(
normal_reflectivity: 0.03,
grazing_reflectivity: 1.0,
exponent: 5.0,
weight: specular,
layer: ggx_smith_bsdf,
base: diffuse_bsdf,
normal: enable_clearcoat ? normal : state::normal()
);
//
// Begin RETROREFLECTION SUPPORT
//
color final_retroreflection_color = multiply_colors(retroreflection_tint, base_color, 1.0).tint;
bsdf backscattering_glossy_bsdf = df::backscattering_glossy_reflection_bsdf(
tint: final_retroreflection_color,
roughness_u: squared_roughness
);
/*bsdf retroreflection_bsdf = df::custom_curve_layer(
normal_reflectivity: 1.-normal_reflectivity,
grazing_reflectivity: 1.-grazing_reflectivity,
base: backscattering_glossy_bsdf,
layer: custom_curve_layer_bsdf,
normal: enable_clearcoat ? normal_lookup : state::normal()
);*/
// if normal_reflectivity and grazing_reflectivity are 1 and weight is 1, just the layer is used
bsdf opt_retroreflection_bsdf = df::custom_curve_layer(
normal_reflectivity: enable_retroreflection ? 1.-normal_reflectivity : 1,
grazing_reflectivity: enable_retroreflection ? 1.-grazing_reflectivity : 1,
base: backscattering_glossy_bsdf,
layer: custom_curve_layer_bsdf,
normal: enable_clearcoat ? normal : state::normal()
);
//
// End RETROREFLECTION SUPPORT
//
bsdf directional_factor_bsdf = df::directional_factor(
normal_tint: ao_weighted_base_color,
grazing_tint: color(1.0, 1.0, 1.0),
exponent: 5.0f,
base: ggx_smith_bsdf
);
// CLEARCOAT
bsdf omni_PBR_bsdf = df::weighted_layer(
weight: metallic,
layer: directional_factor_bsdf,
base: opt_retroreflection_bsdf, //enable_retroreflection ? retroreflection_bsdf : custom_curve_layer_bsdf,
normal: enable_clearcoat ? normal : state::normal()
);
bsdf clearcoat_bsdf = df::microfacet_ggx_smith_bsdf(
roughness_u: clearcoat_reflection_roughness * clearcoat_reflection_roughness,
roughness_v: clearcoat_reflection_roughness * clearcoat_reflection_roughness,
tint: color(1.0f),
mode: df::scatter_reflect
);
// bsdf omni_PBR_coated_bsdf = df::custom_curve_layer(
// normal_reflectivity: clearcoat_reflectivity * 0.08,
// grazing_reflectivity: 1.0,
// weight: clearcoat_weight,
// layer: clearcoat_bsdf,
// base: omni_PBR_bsdf,
// normal: final_clearcoat_normal
// );
bsdf opt_opaque_clearcoat = df::weighted_layer(
weight: enable_clearcoat ? clearcoat_transparency : 1,
layer: ::df::tint(tint: enable_clearcoat ? clearcoat_tint : color(1), base: omni_PBR_bsdf),
base: ::df::diffuse_reflection_bsdf(tint: clearcoat_tint)
);
bsdf opt_omni_PBR_coated_bsdf = df::fresnel_layer(
ior: clearcoat_ior,
weight: enable_clearcoat ? clearcoat_weight : 0,
layer: clearcoat_bsdf,
base: opt_opaque_clearcoat,
normal: clearcoat_normal
);
bsdf final_bsdf = opt_omni_PBR_coated_bsdf;
} in material(
thin_walled: false,
surface: material_surface(
scattering: final_bsdf,
emission: material_emission(
df::diffuse_edf(),
intensity: enable_emission ? emissive_color * emissive_mask * color(emissive_intensity) : color(0)
)
),
geometry: material_geometry(
normal: enable_clearcoat ? state::normal() : normal,
cutout_opacity: enable_opacity ? (enable_opacity_cutout ? (alpha < alpha_cutout_cutoff ? 0.0 : 1.0) : alpha) : 1.0
)
);1234567891011121314151617181920212223242526272829303132333435363738mdl 1.4;
import ::anno::*;
export const string TRANSFORM_NONE = "NONE";
export const string TRANSFORM_UNORM_VECTOR = "UNORM_VECTOR";
export const string FORMAT_RGBA8_UNORM = "RGBA8_UNORM";
export const string FORMAT_R8_UNORM = "R8_UNORM";
export const string FORMAT_RGBA16_SFLOAT = "RGBA16_SFLOAT";
export const string BLEND_MODE_OPACITY = "opacity_blend";
export const string BLEND_MODE_REPLACE = "replace";
// This annotation is used to mark a material as target material for baking.
// It is that is detected by the MDL SDK and neuray.
export annotation target_material_model();
export annotation target_material_rendering(
string rendering_material_override = "" // if set, the baked material will be rendering using this material,
// otherwise the target itself is used
);
export annotation target_baked_argument(
// the name of the baked texture parameter in the rendering material
string baked_name,
// the name of the constant parameter in the rendering material in case baking was not necessary
string constant_name = "",
// texture format to bake to
string format = "",
// transformations, like encoding normals into [0,1] range
string transform = TRANSFORM_NONE,
// blending, e.g., based on alpha or replace
string blend_mode = BLEND_MODE_OPACITY
);123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426/***************************************************************************************************
* Copyright 2020 NVIDIA Corporation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of NVIDIA CORPORATION nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**************************************************************************************************/
mdl 1.4;
import ::base::*;
import ::anno::*;
using OmniPBR_ClearCoat_Opacity import OmniPBR_ClearCoat_Opacity;
export material OmniPBR_Opacity(
color diffuse_color_constant = color(0.2f)
[[
anno::display_name("Base Color"),
anno::description("This is the base color"),
anno::in_group("Albedo")
]],
uniform texture_2d diffuse_texture = texture_2d()
[[
anno::display_name("Albedo Map"),
anno::in_group("Albedo")
]],
float albedo_desaturation = float(0.0)
[[
anno::display_name("Albedo Desaturation"),
anno::soft_range(float(0.0f), float(1.0f)),
anno::description("Desaturates the diffuse color"),
anno::in_group("Albedo")
]],
float albedo_add = float(0.0)
[[
anno::display_name("Albedo Add"),
anno::soft_range(float(-1.0f), float(1.0f)),
anno::description("Adds a constant value to the diffuse color "),
anno::in_group("Albedo")
]],
float albedo_brightness = float(1.0)
[[
anno::display_name("Albedo Brightness"),
anno::soft_range(float(0.0f), float(1.0f)),
anno::description("Multiplier for the diffuse color "),
anno::in_group("Albedo")
]],
color diffuse_tint = color(1.0f)
[[
anno::display_name("Color Tint"),
anno::description("When enabled, this color value is multiplied over the final albedo color"),
anno::in_group("Albedo")
]],
// -------------------- REFLECTIVITY ----------------------
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("Reflectivity")
]],
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("Reflectivity")
]],
uniform texture_2d reflectionroughness_texture = texture_2d()
[[
anno::display_name("Roughness Map"),
anno::in_group("Reflectivity")
]],
float metallic_constant = 0.f
[[
anno::display_name("Metallic Amount"),
anno::hard_range(0.0,1.),
anno::description("Metallic Material"),
anno::in_group("Reflectivity")
]],
float metallic_texture_influence = 0.0f
[[
anno::display_name("Metallic Map Influence"),
anno::hard_range(0.0, 1.),
anno::description("Blends between the constant value and the lookup of the metallic texture"),
anno::in_group("Reflectivity")
]],
uniform texture_2d metallic_texture = texture_2d()
[[
anno::display_name("Metallic Map"),
anno::in_group("Reflectivity")
]],
float specular_level = float(0.5)
[[
anno::display_name("Specular"),
anno::soft_range(float(0.0f), float(1.0f)),
anno::description("The specular level (intensity) of the material"),
anno::in_group("Reflectivity")
]],
// -------------------- ORM ----------------------
uniform bool enable_ORM_texture = false
[[
anno::display_name("Enable ORM Texture"),
anno::description("When True the ORM texture will be used to extract the Occlusion, Roughness and Metallic Map"),
anno::in_group("Reflectivity")
]],
uniform texture_2d ORM_texture = texture_2d()
[[
anno::display_name("ORM Map"),
anno::description("Texture that hae Occlusion, Roughness and Metallic map stored in the respective r, g and b channels"),
anno::in_group("Reflectivity")
]],
// -------------------- AO Group ----------------------
float ao_to_diffuse = 0.0
[[
anno::display_name("AO to Diffuse"),
anno::description("Controls the amount of ambient occlusion multiplied into the diffuse color channel"),
anno::in_group("AO"),
anno::hard_range(0.0f, 1.0f)
]],
uniform texture_2d ao_texture = texture_2d()
[[
anno::display_name("Ambient Occlusion Map"),
anno::description("The Ambient Occlusion texture for the material"),
anno::in_group("AO")
]],
// -------------------- EMISSIVE ----------------------
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_color_texture = texture_2d()
[[
anno::enable_if("enable_emission == true"),
anno::display_name("Emissive Color map"),
anno::in_group("Emissive"),
anno::description("The emissive color texture")
]],
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")
]],
// Cutout Opacity
uniform bool enable_opacity = true
[[
anno::display_name("Enable Opacity"),
anno::description("Enables the use of cutout opacity"),
anno::in_group("Opacity")
]],
uniform bool enable_opacity_texture = false
[[
anno::display_name("Enable Opacity Texture"),
anno::description("Enables or disables the usage of the opacity texture map"),
anno::in_group("Opacity")
]],
uniform float opacity_constant = 1.f
[[
anno::hard_range(0.0, 1.0),
anno::display_name("Opacity Amount"),
anno::description("Opacity value between 0 and 1, when Opacity Map is not valid"),
anno::in_group("Opacity")
]],
uniform texture_2d opacity_texture = texture_2d()
[[
anno::display_name("Opacity Map"),
anno::in_group("Opacity")
]],
uniform base::mono_mode opacity_mode = base::mono_average
[[
anno::display_name("Opacity Mono Source"),
anno::in_group("Opacity"),
anno::description("Determines how to lookup opacity from the supplied texture. mono_alpha, mono_average, mono_luminance, mono_maximum")
]],
uniform float opacity_threshold = 0.f
[[
anno::hard_range(0.0, 1.0),
anno::display_name("Opacity Threshold"),
anno::description("If negative, disable cutout_opacity; if 0, use fractional opacity values 'as is'; if > 0, remap opacity values to 1 when >= threshold and to 0 otherwise"),
anno::in_group("Opacity")
]],
// -------------------- Normal ----------------------
/*
uniform bool enable_normalmap_texture = false
[[
anno::display_name("Enable Normal Texture"),
anno::description("Enables the usage of the normalmap texture"),
anno::in_group("Features")
]],
*/
uniform float bump_factor = 1.f
[[
anno::display_name("Normal Map Strength"),
anno::description("Strength of normal map."),
anno::in_group("Normal"),
anno::soft_range(0.0f, 1.0f)
]],
uniform texture_2d normalmap_texture = texture_2d()
[[
anno::display_name("Normal Map"),
anno::description("Enables the usage of the normalmap texture"),
anno::in_group("Normal")
]],
/* uniform bool enable_detail_normalmap_texture = false
[[
anno::display_name("Enable Detail Normal Texture"),
anno::in_group("Features"),
anno::description("Enables the usage of the detail normalmap texture")
]],
*/
uniform float detail_bump_factor = .3f
[[
anno::display_name("Detail Normal Strength"),
anno::in_group("Normal"),
anno::soft_range(0.0f, 1.0f),
anno::description("Strength of the detail normal")
]],
uniform texture_2d detail_normalmap_texture = texture_2d()
[[
anno::display_name("Detail Normal Map"),
anno::in_group("Normal")
]],
// UV Projection Group
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 int uv_space_index = 0
[[
anno::enable_if("project_uvw == true"),
anno::display_name("UV Space Index"),
anno::description("UV Space Index."),
anno::in_group("UV"),
anno::hard_range(0, 3)
]],
// Adjustments Group
uniform float2 texture_translate = float2(0.0f)
[[
anno::enable_if("project_uvw == true"),
anno::display_name("Texture Translate"),
anno::description("Controls position of texture."),
anno::in_group("UV")
]],
uniform float texture_rotate = 0.f
[[
anno::enable_if("project_uvw == true"),
anno::display_name("Texture Rotate"),
anno::description("Rotates angle of texture in degrees."),
anno::in_group("UV")
]],
uniform float2 texture_scale = float2(1.0f)
[[
anno::enable_if("project_uvw == true"),
anno::display_name("Texture Scale"),
anno::description("Larger number increases size of texture."),
anno::in_group("UV")
]],
uniform float2 detail_texture_translate = float2(0.0f)
[[
anno::enable_if("project_uvw == true"),
anno::display_name("Detail Texture Translate"),
anno::description("Controls the position of the detail texture."),
anno::in_group("UV")
]],
uniform float detail_texture_rotate = 0.f
[[
anno::enable_if("project_uvw == true"),
anno::display_name("Detail Texture Rotate"),
anno::description("Rotates angle of the detail texture in degrees."),
anno::in_group("UV")
]],
uniform float2 detail_texture_scale = float2(1.0f)
[[
anno::enable_if("project_uvw == true"),
anno::display_name("Detail Texture Scale"),
anno::description("Larger numbers increase the size of the detail texture"),
anno::in_group("UV")
]]
)
[[
anno::display_name("OmniPBR Opacity"),
anno::description("OmniPBR supports opacity and ORM textures"),
anno::in_group("Base"),
anno::version( 2, 1, 0),
anno::author("NVIDIA CORPORATION"),
anno::key_words(string[]("omni", "PBR", "opacity", "omniverse", "generic"))
]]
= OmniPBR_ClearCoat_Opacity(
diffuse_texture: diffuse_texture,
albedo_desaturation: albedo_desaturation,
albedo_add: albedo_add,
albedo_brightness: albedo_brightness,
diffuse_color_constant: diffuse_color_constant,
diffuse_tint: diffuse_tint,
//ao
ao_texture: ao_texture,
ao_to_diffuse: ao_to_diffuse,
//ORM
ORM_texture: ORM_texture,
enable_ORM_texture: enable_ORM_texture,
//reflectivity
reflection_roughness_constant: reflection_roughness_constant,
reflectionroughness_texture: reflectionroughness_texture,
reflection_roughness_texture_influence: reflection_roughness_texture_influence,
metallic_constant: metallic_constant,
metallic_texture: metallic_texture,
metallic_texture_influence: metallic_texture_influence,
specular_level: specular_level,
//opacity
enable_opacity: enable_opacity,
enable_opacity_texture: enable_opacity_texture,
opacity_texture: opacity_texture,
opacity_constant: opacity_constant,
opacity_mode: opacity_mode,
opacity_threshold: opacity_threshold,
//emissive
enable_emission: enable_emission,
emissive_color: emissive_color,
emissive_color_texture: emissive_color_texture,
emissive_mask_texture: emissive_mask_texture,
emissive_intensity: emissive_intensity,
//clearcoat
enable_clearcoat: false,
clearcoat_tint: color(1.0f),
clearcoat_transparency: 1.0f,
clearcoat_reflection_roughness: 0.0f,
clearcoat_weight: 1.0f,
clearcoat_flatten: 1.0f,
clearcoat_ior: 1.56f,
clearcoat_bump_factor: 1.f,
clearcoat_normalmap_texture: texture_2d(),
//normal
normalmap_texture: normalmap_texture,
bump_factor: bump_factor,
detail_normalmap_texture: detail_normalmap_texture,
detail_bump_factor: detail_bump_factor,
project_uvw: project_uvw,
world_or_object: world_or_object,
uv_space_index: uv_space_index,
texture_translate: texture_translate,
texture_rotate: texture_rotate,
texture_scale: texture_scale,
detail_texture_translate: detail_texture_translate,
detail_texture_rotate: detail_texture_rotate,
detail_texture_scale: detail_texture_scale,
clearcoat_texture_translate: float2(0.0f),
clearcoat_texture_rotate: 0.0f,
clearcoat_texture_scale: float2(1.0f)
);123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426/***************************************************************************************************
* Copyright 2020 NVIDIA Corporation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of NVIDIA CORPORATION nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**************************************************************************************************/
mdl 1.4;
import ::base::*;
import ::anno::*;
using OmniPBR_ClearCoat_Opacity import OmniPBR_ClearCoat_Opacity;
export material OmniPBR_Opacity(
color diffuse_color_constant = color(0.2f)
[[
anno::display_name("Base Color"),
anno::description("This is the base color"),
anno::in_group("Albedo")
]],
uniform texture_2d diffuse_texture = texture_2d()
[[
anno::display_name("Albedo Map"),
anno::in_group("Albedo")
]],
float albedo_desaturation = float(0.0)
[[
anno::display_name("Albedo Desaturation"),
anno::soft_range(float(0.0f), float(1.0f)),
anno::description("Desaturates the diffuse color"),
anno::in_group("Albedo")
]],
float albedo_add = float(0.0)
[[
anno::display_name("Albedo Add"),
anno::soft_range(float(-1.0f), float(1.0f)),
anno::description("Adds a constant value to the diffuse color "),
anno::in_group("Albedo")
]],
float albedo_brightness = float(1.0)
[[
anno::display_name("Albedo Brightness"),
anno::soft_range(float(0.0f), float(1.0f)),
anno::description("Multiplier for the diffuse color "),
anno::in_group("Albedo")
]],
color diffuse_tint = color(1.0f)
[[
anno::display_name("Color Tint"),
anno::description("When enabled, this color value is multiplied over the final albedo color"),
anno::in_group("Albedo")
]],
// -------------------- REFLECTIVITY ----------------------
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("Reflectivity")
]],
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("Reflectivity")
]],
uniform texture_2d reflectionroughness_texture = texture_2d()
[[
anno::display_name("Roughness Map"),
anno::in_group("Reflectivity")
]],
float metallic_constant = 0.f
[[
anno::display_name("Metallic Amount"),
anno::hard_range(0.0,1.),
anno::description("Metallic Material"),
anno::in_group("Reflectivity")
]],
float metallic_texture_influence = 0.0f
[[
anno::display_name("Metallic Map Influence"),
anno::hard_range(0.0, 1.),
anno::description("Blends between the constant value and the lookup of the metallic texture"),
anno::in_group("Reflectivity")
]],
uniform texture_2d metallic_texture = texture_2d()
[[
anno::display_name("Metallic Map"),
anno::in_group("Reflectivity")
]],
float specular_level = float(0.5)
[[
anno::display_name("Specular"),
anno::soft_range(float(0.0f), float(1.0f)),
anno::description("The specular level (intensity) of the material"),
anno::in_group("Reflectivity")
]],
// -------------------- ORM ----------------------
uniform bool enable_ORM_texture = false
[[
anno::display_name("Enable ORM Texture"),
anno::description("When True the ORM texture will be used to extract the Occlusion, Roughness and Metallic Map"),
anno::in_group("Reflectivity")
]],
uniform texture_2d ORM_texture = texture_2d()
[[
anno::display_name("ORM Map"),
anno::description("Texture that hae Occlusion, Roughness and Metallic map stored in the respective r, g and b channels"),
anno::in_group("Reflectivity")
]],
// -------------------- AO Group ----------------------
float ao_to_diffuse = 0.0
[[
anno::display_name("AO to Diffuse"),
anno::description("Controls the amount of ambient occlusion multiplied into the diffuse color channel"),
anno::in_group("AO"),
anno::hard_range(0.0f, 1.0f)
]],
uniform texture_2d ao_texture = texture_2d()
[[
anno::display_name("Ambient Occlusion Map"),
anno::description("The Ambient Occlusion texture for the material"),
anno::in_group("AO")
]],
// -------------------- EMISSIVE ----------------------
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_color_texture = texture_2d()
[[
anno::enable_if("enable_emission == true"),
anno::display_name("Emissive Color map"),
anno::in_group("Emissive"),
anno::description("The emissive color texture")
]],
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")
]],
// Cutout Opacity
uniform bool enable_opacity = true
[[
anno::display_name("Enable Opacity"),
anno::description("Enables the use of cutout opacity"),
anno::in_group("Opacity")
]],
uniform bool enable_opacity_texture = false
[[
anno::display_name("Enable Opacity Texture"),
anno::description("Enables or disables the usage of the opacity texture map"),
anno::in_group("Opacity")
]],
uniform float opacity_constant = 1.f
[[
anno::hard_range(0.0, 1.0),
anno::display_name("Opacity Amount"),
anno::description("Opacity value between 0 and 1, when Opacity Map is not valid"),
anno::in_group("Opacity")
]],
uniform texture_2d opacity_texture = texture_2d()
[[
anno::display_name("Opacity Map"),
anno::in_group("Opacity")
]],
uniform base::mono_mode opacity_mode = base::mono_average
[[
anno::display_name("Opacity Mono Source"),
anno::in_group("Opacity"),
anno::description("Determines how to lookup opacity from the supplied texture. mono_alpha, mono_average, mono_luminance, mono_maximum")
]],
uniform float opacity_threshold = 0.f
[[
anno::hard_range(0.0, 1.0),
anno::display_name("Opacity Threshold"),
anno::description("If negative, disable cutout_opacity; if 0, use fractional opacity values 'as is'; if > 0, remap opacity values to 1 when >= threshold and to 0 otherwise"),
anno::in_group("Opacity")
]],
// -------------------- Normal ----------------------
/*
uniform bool enable_normalmap_texture = false
[[
anno::display_name("Enable Normal Texture"),
anno::description("Enables the usage of the normalmap texture"),
anno::in_group("Features")
]],
*/
uniform float bump_factor = 1.f
[[
anno::display_name("Normal Map Strength"),
anno::description("Strength of normal map."),
anno::in_group("Normal"),
anno::soft_range(0.0f, 1.0f)
]],
uniform texture_2d normalmap_texture = texture_2d()
[[
anno::display_name("Normal Map"),
anno::description("Enables the usage of the normalmap texture"),
anno::in_group("Normal")
]],
/* uniform bool enable_detail_normalmap_texture = false
[[
anno::display_name("Enable Detail Normal Texture"),
anno::in_group("Features"),
anno::description("Enables the usage of the detail normalmap texture")
]],
*/
uniform float detail_bump_factor = .3f
[[
anno::display_name("Detail Normal Strength"),
anno::in_group("Normal"),
anno::soft_range(0.0f, 1.0f),
anno::description("Strength of the detail normal")
]],
uniform texture_2d detail_normalmap_texture = texture_2d()
[[
anno::display_name("Detail Normal Map"),
anno::in_group("Normal")
]],
// UV Projection Group
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 int uv_space_index = 0
[[
anno::enable_if("project_uvw == true"),
anno::display_name("UV Space Index"),
anno::description("UV Space Index."),
anno::in_group("UV"),
anno::hard_range(0, 3)
]],
// Adjustments Group
uniform float2 texture_translate = float2(0.0f)
[[
anno::enable_if("project_uvw == true"),
anno::display_name("Texture Translate"),
anno::description("Controls position of texture."),
anno::in_group("UV")
]],
uniform float texture_rotate = 0.f
[[
anno::enable_if("project_uvw == true"),
anno::display_name("Texture Rotate"),
anno::description("Rotates angle of texture in degrees."),
anno::in_group("UV")
]],
uniform float2 texture_scale = float2(1.0f)
[[
anno::enable_if("project_uvw == true"),
anno::display_name("Texture Scale"),
anno::description("Larger number increases size of texture."),
anno::in_group("UV")
]],
uniform float2 detail_texture_translate = float2(0.0f)
[[
anno::enable_if("project_uvw == true"),
anno::display_name("Detail Texture Translate"),
anno::description("Controls the position of the detail texture."),
anno::in_group("UV")
]],
uniform float detail_texture_rotate = 0.f
[[
anno::enable_if("project_uvw == true"),
anno::display_name("Detail Texture Rotate"),
anno::description("Rotates angle of the detail texture in degrees."),
anno::in_group("UV")
]],
uniform float2 detail_texture_scale = float2(1.0f)
[[
anno::enable_if("project_uvw == true"),
anno::display_name("Detail Texture Scale"),
anno::description("Larger numbers increase the size of the detail texture"),
anno::in_group("UV")
]]
)
[[
anno::display_name("OmniPBR Opacity"),
anno::description("OmniPBR supports opacity and ORM textures"),
anno::in_group("Base"),
anno::version( 2, 1, 0),
anno::author("NVIDIA CORPORATION"),
anno::key_words(string[]("omni", "PBR", "opacity", "omniverse", "generic"))
]]
= OmniPBR_ClearCoat_Opacity(
diffuse_texture: diffuse_texture,
albedo_desaturation: albedo_desaturation,
albedo_add: albedo_add,
albedo_brightness: albedo_brightness,
diffuse_color_constant: diffuse_color_constant,
diffuse_tint: diffuse_tint,
//ao
ao_texture: ao_texture,
ao_to_diffuse: ao_to_diffuse,
//ORM
ORM_texture: ORM_texture,
enable_ORM_texture: enable_ORM_texture,
//reflectivity
reflection_roughness_constant: reflection_roughness_constant,
reflectionroughness_texture: reflectionroughness_texture,
reflection_roughness_texture_influence: reflection_roughness_texture_influence,
metallic_constant: metallic_constant,
metallic_texture: metallic_texture,
metallic_texture_influence: metallic_texture_influence,
specular_level: specular_level,
//opacity
enable_opacity: enable_opacity,
enable_opacity_texture: enable_opacity_texture,
opacity_texture: opacity_texture,
opacity_constant: opacity_constant,
opacity_mode: opacity_mode,
opacity_threshold: opacity_threshold,
//emissive
enable_emission: enable_emission,
emissive_color: emissive_color,
emissive_color_texture: emissive_color_texture,
emissive_mask_texture: emissive_mask_texture,
emissive_intensity: emissive_intensity,
//clearcoat
enable_clearcoat: false,
clearcoat_tint: color(1.0f),
clearcoat_transparency: 1.0f,
clearcoat_reflection_roughness: 0.0f,
clearcoat_weight: 1.0f,
clearcoat_flatten: 1.0f,
clearcoat_ior: 1.56f,
clearcoat_bump_factor: 1.f,
clearcoat_normalmap_texture: texture_2d(),
//normal
normalmap_texture: normalmap_texture,
bump_factor: bump_factor,
detail_normalmap_texture: detail_normalmap_texture,
detail_bump_factor: detail_bump_factor,
project_uvw: project_uvw,
world_or_object: world_or_object,
uv_space_index: uv_space_index,
texture_translate: texture_translate,
texture_rotate: texture_rotate,
texture_scale: texture_scale,
detail_texture_translate: detail_texture_translate,
detail_texture_rotate: detail_texture_rotate,
detail_texture_scale: detail_texture_scale,
clearcoat_texture_translate: float2(0.0f),
clearcoat_texture_rotate: 0.0f,
clearcoat_texture_scale: float2(1.0f)
);123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562/*****************************************************************************
* Copyright 1986-2020 NVIDIA Corporation. All rights reserved.
******************************************************************************
MDL MATERIALS ARE PROVIDED PURSUANT TO AN END USER LICENSE AGREEMENT,
WHICH WAS ACCEPTED IN ORDER TO GAIN ACCESS TO THIS FILE. IN PARTICULAR,
THE MDL MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL NVIDIA
CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
THE USE OR INABILITY TO USE THE MDL MATERIALS OR FROM OTHER DEALINGS IN
THE MDL MATERIALS.
*/
mdl 1.4;
import ::df::*;
import ::state::*;
import ::math::*;
import ::base::*;
import ::tex::*;
import ::anno::*;
using .::SimPBR_Model import *;
using .::baking_annotations import *;
export material SimPBR(
// -------------------- DIFFUSE REFLECTION ----------------------
uniform color diffuse_color_constant = color(0.2f)
[[
anno::display_name("Albedo Base Color"),
anno::description("The base albedo color to use if no texture is specified"),
anno::in_group("Diffuse")
]],
uniform texture_2d diffuse_texture = texture_2d()
[[
anno::display_name("Albedo Map"),
anno::description("The texture specifying the albedo value to use"),
anno::in_group("Diffuse")
]],
uniform color diffuse_tint = color(1.0f)
[[
anno::display_name("Albedo Tint"),
anno::description("This tints the albedo color or texture contant"),
anno::in_group("Diffuse")
]],
uniform bool enable_transmission = false
[[
anno::display_name("Enable Diffuse Transmission"),
anno::description("Enables the diffuse transmission of light through thin diffuse scattering layer"),
anno::in_group("Diffuse")
]],
uniform float opacity_ratio = 1.f
[[
anno::enable_if("enable_transmission == true"),
anno::display_name("Opacity Ratio"),
anno::description("Amount of opacity"),
anno::in_group("Diffuse")
]],
uniform color opacity_tint = color(1.0f)
[[
anno::enable_if("enable_transmission == true"),
anno::display_name("Diffuse transmission tint"),
anno::description("Base diffuse transmission color"),
anno::in_group("Diffuse")
]],
uniform float opacity_multiplier = 1.f
[[
anno::enable_if("enable_transmission == true"),
anno::display_name("Diffuse transmission multiplier"),
anno::description("Base diffuse transmission multiplier"),
anno::in_group("Diffuse")
]],
// -------------------- SPECULAR REFLECTION ----------------------
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")
]],
float anisotropy_constant = 0.0f
[[
anno::display_name("Anisotropy Amount"),
anno::hard_range(-1.,1.),
anno::description("0 for isotropic, extents of -1 to 1 for anisotropy"),
anno::in_group("Specular")
]],
uniform float anisotropy_texture_influence = 0.0f
[[
anno::display_name("Anisotropy Map Influence"),
anno::hard_range(0.0, 1.),
anno::description("Blends between the constant value and the lookup of the anisotropy texture"),
anno::in_group("Specular")
]],
uniform texture_2d anisotropy_texture = texture_2d()
[[
anno::display_name("Anisotropy Map"),
anno::in_group("Specular")
]],
float metallic_constant = 0.f
[[
anno::display_name("Metallic Amount"),
anno::hard_range(0.0,1.),
anno::description("Metallic Material"),
anno::in_group("Specular")
]],
uniform float metallic_texture_influence = 0.0f
[[
anno::display_name("Metallic Map Influence"),
anno::hard_range(0.0, 1.),
anno::description("Blends between the constant value and the lookup of the metallic texture"),
anno::in_group("Specular")
]],
uniform texture_2d metallic_texture = texture_2d()
[[
anno::display_name("Metallic Map"),
anno::in_group("Specular")
]],
float specular_constant = 1.f
[[
anno::display_name("Specular amount"),
anno::hard_range(0.0, 1.0),
anno::description("Scale of the specular component"),
anno::in_group("Specular")
]],
uniform texture_2d specular_texture = texture_2d()
[[
anno::display_name("Specular Map"),
anno::in_group("Specular")
]],
// -------------------- ORM ----------------------
uniform bool enable_ORM_texture = true
[[
anno::display_name("Enable ORM Texture"),
anno::description("When True the ORM texture will be used to extract the Occlusion, Roughness and Metallic Map"),
anno::in_group("Reflectivity")
]],
uniform texture_2d ORM_texture = texture_2d()
[[
anno::display_name("ORM Map"),
anno::description("Texture that hae Occlusion, Roughness and Metallic map stored in the respective r, g and b channels"),
anno::in_group("Reflectivity")
]],
// -------------------- Clearcoat ----------------------
uniform bool enable_clearcoat = false
[[
anno::display_name("Enable Clearcoat Layer"),
anno::description("Adds a clearcoat layer on top of the material when enabled"),
anno::in_group("Clearcoat")
]],
color clearcoat_tint = color(1.0f)
[[
anno::display_name("Clearcoat Tint"),
anno::description("Clearcoat is tinted and affects the underlying material"),
anno::in_group("Clearcoat")
]],
float clearcoat_transparency = 1.0f
[[
anno::display_name("Clearcoat Transparency"),
anno::description("Adjusts the transparency of the clearcoat. Can be turned into a fully opaque clearcoat "
"covering the underlying layer"),
anno::in_group("Clearcoat")
]],
float clearcoat_reflection_roughness = 0.0f
[[
anno::display_name("Clearcoat Roughness"),
anno::description("Higher roughness values lead to more blurry reflections"),
anno::hard_range(0.0f, 1.0f),
anno::in_group("Clearcoat")
]],
float clearcoat_weight = 1.0f
[[
anno::display_name("Clearcoat Weight"),
anno::description("Sets the weight for clearcoat layer"),
anno::hard_range(0.0f, 1.0f),
anno::in_group("Clearcoat")
]],
float clearcoat_flatten = 1.0f
[[
anno::display_name("Clearcoat Flatten"),
anno::description("Flattens the clearcoat to even out the underlying bump maps"),
anno::hard_range(0.0f, 1.0f),
anno::in_group("Clearcoat")
]],
float clearcoat_ior = 1.56f
[[
anno::display_name("Clearcoat IOR"),
anno::description("Sets the Index of refraction for the clearcoat layer"),
anno::soft_range(1.0f, 4.0f),
anno::in_group("Clearcoat")
]],
uniform float clearcoat_bump_factor = 1.f
[[
anno::display_name("Clearcoat Normal Map Strength"),
anno::description("Strength of normal map."),
anno::in_group("Clearcoat")
]],
float3 clearcoat_normal_input = float3(0.0, 0.0, 0.0),
uniform texture_2d clearcoat_normalmap_texture = texture_2d()
[[
anno::display_name("Clearcoat Normal Map"),
anno::description("Enables the usage of the normalmap texture"),
anno::in_group("Clearcoat")
]],
uniform bool clearcoat_flip_tangent_u = false
[[
anno::display_name("Clearcoat Normal Map Flip U Tangent"),
anno::in_group("Clearcoat")
]],
uniform bool clearcoat_flip_tangent_v = true
[[
anno::display_name("Clearcoat Normal Map Flip V Tangent"),
anno::in_group("Clearcoat")
]],
// -------------------- REFLECTIVITY ----------------------
uniform bool enable_retroreflection = false
[[
anno::display_name("Enable Retroreflection"),
anno::in_group("Reflectivity")
]],
color retroreflection_tint = color(.182,.800,.000)
[[
anno::display_name("Retro-reflection tint"),
anno::description("The tint of the retroreflection"),
anno::in_group("Reflectivity")
]],
uniform float normal_reflectivity = 0.5
[[
anno::display_name("Retro-reflection weight facing"),
anno::hard_range(0.0,1.),
anno::description("Reflectivity control for geometry facing the viewer"),
anno::in_group("Reflectivity")
]],
uniform float grazing_reflectivity = 1.0
[[
anno::display_name("Retro-reflection weight edge"),
anno::hard_range(0.0,1.),
anno::description("Reflectivity control for the reflectivity at geometry edges"),
anno::in_group("Reflectivity")
]],
// -------------------- AMBIENT OCCLUSION ----------------------
float ao_to_diffuse = 0.0
[[
anno::display_name("AO to Diffuse"),
anno::description("Controls the amount of ambient occlusion multiplied into the diffuse color channel"),
anno::in_group("AO")
]],
float ao_input = float(1.0),
uniform texture_2d ao_texture = texture_2d()
[[
anno::display_name("Ambient Occlusion Map"),
anno::description("The Ambient Occlusion texture for the material"),
anno::in_group("AO")
]],
// -------------------- EMISSIVE ----------------------
uniform bool enable_emission = false
[[
anno::display_name("Enable Emission"),
anno::description("Enables the emission of light from the material"),
anno::in_group("Emissive")
]],
uniform 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")
]],
color emissive_mask_input = color(1.0),
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")
]],
// -------------------- ALPHA ----------------------
uniform bool enable_opacity = false
[[
anno::display_name("Enable Opacity"),
anno::description("Enables or disables alpha functionality"),
anno::in_group("Alpha")
]],
float alpha_constant = 1.0
[[
anno::enable_if("enable_opacity == true"),
anno::display_name("Opacity Fallback Constant"),
anno::hard_range(0.0, 1.0),
anno::description("The base alpha constant to use if no texture is specified"),
anno::in_group("Alpha")
]],
uniform texture_2d opacity_texture = texture_2d()
[[
anno::enable_if("enable_opacity == true"),
anno::display_name("Opacity Map"),
anno::description("The texture specifying the opacity value to use"),
anno::in_group("Alpha")
]],
uniform bool enable_opacity_cutout = false
[[
anno::enable_if("enable_opacity == true"),
anno::display_name("Enable Alpha Cutout"),
anno::description("Enables or disables alpha cutout functionality"),
anno::in_group("Alpha")
]],
uniform float alpha_cutout_cutoff = 1.f
[[
anno::enable_if("enable_opacity == true"),
anno::enable_if("enable_opacity_cutout == true"),
anno::hard_range(0.0, 1.0),
anno::display_name("Alpha Cutout Cutoff"),
anno::description("The cutoff value to to render as transparent up to and opaque past"),
anno::in_group("Alpha")
]],
// -------------------- NORMAL ----------------------
uniform float bump_factor = 1.f
[[
anno::display_name("Normal Map Strength"),
anno::description("Strength of normal map."),
anno::in_group("Normal")
]],
float3 normal_input = state::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::description("Flips the U Tangent vector."),
anno::in_group("Normal")
]],
uniform bool flip_tangent_v = true
[[
anno::display_name("Normal Map Flip V Tangent"),
anno::description("Flips the V Tangent vector. By Default, SimPBR materials setup for DirectX normal maps. Set Normal Map Flip V = false for OpenGL."),
anno::in_group("Normal")
]],
// -------------------- UV ADJUSTMENTS ----------------------
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 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"),
anno::description("Supports the opaque alpha cutout 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", "opaque", "alpha", "cutout", "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
);
// Need to use a small value so the compiler doesnt optimize out this var...
float t = 0.00000001;//state::animation_time();
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);
// Diffuse Color Lookup and AO
float4 base_lookup = tex::texture_isvalid(diffuse_texture) ? tex::lookup_float4(tex: diffuse_texture, coord: uv) : float4(1, 1, 1, 1);
float opacityValue = tex::texture_isvalid(opacity_texture) ? tex::lookup_float4(tex: opacity_texture, coord: uv).w : alpha_constant;
// Normal calculations
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
) : normal_input;
float3 clearcoat_normal = tex::texture_isvalid(clearcoat_normalmap_texture) ?
base::tangent_space_normal_texture(
texture: clearcoat_normalmap_texture,
factor: clearcoat_bump_factor,
uvw: uvw,
flip_tangent_u: clearcoat_flip_tangent_u,
flip_tangent_v: clearcoat_flip_tangent_v
) : clearcoat_normal_input;
float3 flattened_clearcoat_normal = ::math::lerp(normal_lookup, ::state::normal(), clearcoat_flatten);
float3 final_clearcoat_normal = tex::texture_isvalid(clearcoat_normalmap_texture) ? clearcoat_normal : flattened_clearcoat_normal;
float ao_lookup = tex::texture_isvalid(ao_texture) ? tex::lookup_float4(tex: ao_texture, coord: uv).x : ao_input;
color diffuse_color = tex::texture_isvalid(diffuse_texture) ? color(base_lookup.x, base_lookup.y, base_lookup.z) : diffuse_color_constant;
float3 ORM_lookup = tex::lookup_float3(
tex: ORM_texture,
coord: float2(transformed_uvw.position.x, transformed_uvw.position.y)
);
float roughness_lookup = tex::texture_isvalid(reflectionroughness_texture) ?
tex::lookup_float4(tex: reflectionroughness_texture, coord: uv).x : reflection_roughness_constant;
float anisotropy_lookup = tex::texture_isvalid(anisotropy_texture) ?
(tex::lookup_float4(tex: anisotropy_texture, coord: uv).x * 2.0f - 1.0f) : anisotropy_constant;
float metallic_lookup = tex::texture_isvalid(metallic_texture) ?
tex::lookup_float4(tex: metallic_texture, coord: uv).x : metallic_constant;
float specular_lookup = tex::texture_isvalid(specular_texture) ?
tex::lookup_float4(tex: specular_texture, coord: uv).x : specular_constant;
float roughness_selection = enable_ORM_texture ? ORM_lookup.y : roughness_lookup;
float metallic_selection = enable_ORM_texture ? ORM_lookup.z : metallic_lookup;
float ao = enable_ORM_texture ? ORM_lookup.x : ao_lookup;
float reflection_roughness = math::lerp(reflection_roughness_constant, roughness_selection, reflection_roughness_texture_influence);
float anisotropy = math::lerp(anisotropy_constant, anisotropy_lookup, anisotropy_texture_influence);
float metallic = math::lerp(metallic_constant, metallic_selection, metallic_texture_influence);
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) : emissive_mask_input;
} in SimPBR_Model(
diffuse_color: diffuse_color,
diffuse_tint: diffuse_tint,
roughness: reflection_roughness,
anisotropy: anisotropy,
metallic: metallic,
specular: specular_lookup,
normal: normal_lookup,
enable_clearcoat: enable_clearcoat,
clearcoat_tint: clearcoat_tint,
clearcoat_transparency: clearcoat_transparency,
clearcoat_reflection_roughness: clearcoat_reflection_roughness,
clearcoat_weight: clearcoat_weight,
clearcoat_ior: clearcoat_ior,
clearcoat_normal: final_clearcoat_normal,
enable_retroreflection: enable_retroreflection,
retroreflection_tint: retroreflection_tint,
normal_reflectivity: normal_reflectivity,
grazing_reflectivity: grazing_reflectivity,
ao_to_diffuse: ao_to_diffuse,
ao: ao,
enable_emission: enable_emission,
emissive_color: emissive_color,
emissive_mask: emissive_mask,
emissive_intensity: emissive_intensity,
enable_opacity: enable_opacity,
alpha: opacityValue,
enable_opacity_cutout: enable_opacity_cutout,
alpha_cutout_cutoff: alpha_cutout_cutoff,
opacity_ratio: enable_transmission ? opacity_ratio : 1.0,
opacity_tint : opacity_tint,
opacity_multiplier : opacity_multiplier
);123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212/*****************************************************************************
* Copyright 1986-2020 NVIDIA Corporation. All rights reserved.
******************************************************************************
MDL MATERIALS ARE PROVIDED PURSUANT TO AN END USER LICENSE AGREEMENT,
WHICH WAS ACCEPTED IN ORDER TO GAIN ACCESS TO THIS FILE. IN PARTICULAR,
THE MDL MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL NVIDIA
CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
THE USE OR INABILITY TO USE THE MDL MATERIALS OR FROM OTHER DEALINGS IN
THE MDL MATERIALS.
*/
mdl 1.4;
import ::df::*;
import ::state::*;
import ::math::*;
import ::base::*;
import ::tex::*;
import ::anno::*;
using .::baking_annotations import *;
base::texture_return multiply_colors(
color color_1 = color(1.0, 1.0, 1.0),
color color_2 = color(.5, .5, .5),
float weight = 1.0
)
[[
anno::hidden()
]]
{
return base::blend_color_layers(
layers: base::color_layer[](
base::color_layer(
layer_color: color_2,
weight: weight,
mode: base::color_layer_multiply
)
), base: color_1
);
}
export material SimPBR_Model(
color diffuse_color = color(0.2f) [[ target_baked_argument("diffuse_texture", "diffuse_color_constant", "RGBA8_UNORM") ]],
uniform color diffuse_tint = color(1.0f),
float roughness = 0.5f [[ target_baked_argument("reflectionroughness_texture", "reflection_roughness_constant", "R8_UNORM") ]],
float anisotropy = 0.0f [[ target_baked_argument("anisotropy_texture", "anisotropy_constant", "R8_SNORM") ]],
float metallic = 0.f [[ target_baked_argument("metallic_texture", "metallic_constant", "R8_UNORM") ]],
float specular = 1.f [[ target_baked_argument("specular_texture", "specular_constant", "R8_UNORM") ]],
float3 normal = float3(0.0, 0.0, 0.0) [[ target_baked_argument("normalmap_texture", "normal_input", "RGBA8_SNORM", baking_annotations::TRANSFORM_UNORM_VECTOR) ]],
uniform bool enable_clearcoat = false,
color clearcoat_tint = color(1.0f),
float clearcoat_transparency = 1.0f,
float clearcoat_reflection_roughness = 0.0f,
float clearcoat_weight = 1.0f,
float clearcoat_ior = 1.56f,
float3 clearcoat_normal = float3(0.0, 0.0, 0.0) [[ target_baked_argument("clearcoat_normalmap_texture", "clearcoat_normal_input", "RGBA8_SNORM", baking_annotations::TRANSFORM_UNORM_VECTOR) ]],
uniform bool enable_retroreflection = false,
color retroreflection_tint = color(.182,.800,.000),
uniform float normal_reflectivity = 0.5,
uniform float grazing_reflectivity = 1.0,
float ao_to_diffuse = 0.0,
float ao = 1.0f [[ target_baked_argument("ao_texture", "ao_input", "R8_UNORM") ]],
uniform bool enable_emission = false,
uniform color emissive_color = color(1.0, 0.1, 0.1),
color emissive_mask = color(1.0, 0.1, 0.1) [[ target_baked_argument("emissive_mask_texture", "emissive_mask_input", "R8_UNORM") ]],
uniform float emissive_intensity = 40.f,
uniform bool enable_opacity = false,
float alpha = 1.0,
uniform bool enable_opacity_cutout = false,
uniform float alpha_cutout_cutoff = 1.f,
uniform float opacity_ratio = 1.f,
uniform color opacity_tint = color(1.0f),
uniform float opacity_multiplier = 1.f
)
[[
target_material_model(),
target_material_rendering("..::SimPBR::SimPBR")
]]
= let {
color base_color = multiply_colors(diffuse_color, diffuse_tint, 1.0).tint;
color ao_weighted_base_color = multiply_colors(base_color, color(ao), ao_to_diffuse).tint;
float squared_roughness = roughness * roughness;
float roughness_u = squared_roughness * (1 + anisotropy);
float roughness_v = squared_roughness * (1 - anisotropy);
color diffuse_transmission_color = base_color * opacity_tint * opacity_multiplier;
bsdf diffuse_bsdf = df::weighted_layer(
weight: opacity_ratio,
layer: df::diffuse_reflection_bsdf(
tint: ao_weighted_base_color,
roughness: 0.0f
),
base: df::diffuse_transmission_bsdf(tint: diffuse_transmission_color),
normal: enable_clearcoat ? normal : state::normal()
);
bsdf ggx_smith_bsdf = df::microfacet_ggx_smith_bsdf(
roughness_u: roughness_u,
roughness_v: roughness_v,
tint: color(1.0, 1.0, 1.0),
mode: df::scatter_reflect
);
bsdf custom_curve_layer_bsdf = df::custom_curve_layer(
normal_reflectivity: 0.03,
grazing_reflectivity: 1.0,
exponent: 5.0,
weight: specular,
layer: ggx_smith_bsdf,
base: diffuse_bsdf,
normal: enable_clearcoat ? normal : state::normal()
);
//
// Begin RETROREFLECTION SUPPORT
//
color final_retroreflection_color = multiply_colors(retroreflection_tint, base_color, 1.0).tint;
bsdf backscattering_glossy_bsdf = df::backscattering_glossy_reflection_bsdf(
tint: final_retroreflection_color,
roughness_u: squared_roughness
);
/*bsdf retroreflection_bsdf = df::custom_curve_layer(
normal_reflectivity: 1.-normal_reflectivity,
grazing_reflectivity: 1.-grazing_reflectivity,
base: backscattering_glossy_bsdf,
layer: custom_curve_layer_bsdf,
normal: enable_clearcoat ? normal_lookup : state::normal()
);*/
// if normal_reflectivity and grazing_reflectivity are 1 and weight is 1, just the layer is used
bsdf opt_retroreflection_bsdf = df::custom_curve_layer(
normal_reflectivity: enable_retroreflection ? 1.-normal_reflectivity : 1,
grazing_reflectivity: enable_retroreflection ? 1.-grazing_reflectivity : 1,
base: backscattering_glossy_bsdf,
layer: custom_curve_layer_bsdf,
normal: enable_clearcoat ? normal : state::normal()
);
//
// End RETROREFLECTION SUPPORT
//
bsdf directional_factor_bsdf = df::directional_factor(
normal_tint: ao_weighted_base_color,
grazing_tint: color(1.0, 1.0, 1.0),
exponent: 5.0f,
base: ggx_smith_bsdf
);
// CLEARCOAT
bsdf omni_PBR_bsdf = df::weighted_layer(
weight: metallic,
layer: directional_factor_bsdf,
base: opt_retroreflection_bsdf, //enable_retroreflection ? retroreflection_bsdf : custom_curve_layer_bsdf,
normal: enable_clearcoat ? normal : state::normal()
);
bsdf clearcoat_bsdf = df::microfacet_ggx_smith_bsdf(
roughness_u: clearcoat_reflection_roughness * clearcoat_reflection_roughness,
roughness_v: clearcoat_reflection_roughness * clearcoat_reflection_roughness,
tint: color(1.0f),
mode: df::scatter_reflect
);
// bsdf omni_PBR_coated_bsdf = df::custom_curve_layer(
// normal_reflectivity: clearcoat_reflectivity * 0.08,
// grazing_reflectivity: 1.0,
// weight: clearcoat_weight,
// layer: clearcoat_bsdf,
// base: omni_PBR_bsdf,
// normal: final_clearcoat_normal
// );
bsdf opt_opaque_clearcoat = df::weighted_layer(
weight: enable_clearcoat ? clearcoat_transparency : 1,
layer: ::df::tint(tint: enable_clearcoat ? clearcoat_tint : color(1), base: omni_PBR_bsdf),
base: ::df::diffuse_reflection_bsdf(tint: clearcoat_tint)
);
bsdf opt_omni_PBR_coated_bsdf = df::fresnel_layer(
ior: clearcoat_ior,
weight: enable_clearcoat ? clearcoat_weight : 0,
layer: clearcoat_bsdf,
base: opt_opaque_clearcoat,
normal: clearcoat_normal
);
bsdf final_bsdf = opt_omni_PBR_coated_bsdf;
} in material(
thin_walled: false,
surface: material_surface(
scattering: final_bsdf,
emission: material_emission(
df::diffuse_edf(),
intensity: enable_emission ? emissive_color * emissive_mask * color(emissive_intensity) : color(0)
)
),
geometry: material_geometry(
normal: enable_clearcoat ? state::normal() : normal,
cutout_opacity: enable_opacity ? (enable_opacity_cutout ? (alpha < alpha_cutout_cutoff ? 0.0 : 1.0) : alpha) : 1.0
)
);123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651/*****************************************************************************
* Copyright 1986-2020 NVIDIA Corporation. All rights reserved.
******************************************************************************
MDL MATERIALS ARE PROVIDED PURSUANT TO AN END USER LICENSE AGREEMENT,
WHICH WAS ACCEPTED IN ORDER TO GAIN ACCESS TO THIS FILE. IN PARTICULAR,
THE MDL MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL NVIDIA
CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
THE USE OR INABILITY TO USE THE MDL MATERIALS OR FROM OTHER DEALINGS IN
THE MDL MATERIALS.
*/
mdl 1.4;
import ::df::*;
import ::state::*;
import ::math::*;
import ::base::*;
import ::tex::*;
import ::anno::*;
import ::nvidia::core_definitions::file_texture;
import ::nvidia::core_definitions::normalmap_texture;
float4 raw_file_texture(
uniform texture_2d texture
[[ anno::description("The input texture") ]],
base::texture_coordinate_info uvw = base::texture_coordinate_info()
[[ anno::description("Custom value for texture coordinate") ]],
uniform float2 crop_u = float2(0.0, 1.0)
[[ anno::description("Restricts the texture access to sub-domain of the texture in the u direction") ]],
uniform float2 crop_v = float2(0.0, 1.0)
[[ anno::description("Restricts the texture access to sub-domain of the texture in the v direction") ]],
uniform tex::wrap_mode wrap_u = tex::wrap_repeat
[[ anno::description("Wrapping mode in the u direction") ]],
uniform tex::wrap_mode wrap_v = tex::wrap_repeat
[[ anno::description("Wrapping mode in the v direction") ]]
)
[[
anno::description("General texturing function for 2D bitmap texture stored in a file"),
anno::noinline()
]]
{
return tex::lookup_float4(texture, float2(uvw.position.x, uvw.position.y), wrap_u, wrap_v, crop_u, crop_v);
}
base::texture_return multiply_colors(
color color_1 = color(1.0, 1.0, 1.0),
color color_2 = color(.5, .5, .5),
float weight = 1.0
) [[
anno::hidden()
]]
{
return base::blend_color_layers(
layers: base::color_layer[](
base::color_layer(
layer_color: color_2,
weight: weight,
mode: base::color_layer_multiply
)),
base: color_1
);
}
base::texture_return add_colors(
color color_1 = color(.5, .5, .5),
color color_2 = color(.5, .5, .5),
float weight = 1.0
) [[
anno::hidden(),
anno::unused()
]]
{
return base::blend_color_layers(
layers: base::color_layer[](
base::color_layer(
layer_color: color_2,
weight: weight,
mode: base::color_layer_add
)),
base: color_1
);
}
base::texture_return blend_colors(
color color_1 = color(1.0, 1.0, 1.0),
color color_2 = color(.5, .5, .5),
float weight = 1.0
) [[
anno::hidden(),
anno::unused()
]]
{
return base::blend_color_layers(
layers: base::color_layer[](
base::color_layer(
layer_color: color_2,
weight: weight,
mode: base::color_layer_blend
)),
base: color_1
);
}
export material SimPBR_Opacity(
// -------------------- DIFFUSE REFLECTION ----------------------
uniform color diffuse_color_constant = color(0.2f)
[[
anno::display_name("Albedo Base Color"),
anno::description("The base albedo color to use if no texture is specified"),
anno::in_group("Diffuse")
]],
uniform texture_2d diffuse_texture = texture_2d()
[[
anno::display_name("Albedo Map"),
anno::description("The texture specifying the albedo value to use"),
anno::in_group("Diffuse")
]],
uniform color diffuse_tint = color(1.0f)
[[
anno::display_name("Albedo Tint"),
anno::description("This tints the albedo color or texture contant"),
anno::in_group("Diffuse")
]],
// -------------------- SPECULAR REFLECTION ----------------------
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")
]],
uniform float anisotropy_constant = 0.0f
[[
anno::display_name("Anisotropy Amount"),
anno::hard_range(-1.,1.),
anno::description("0 for isotropic, extents of -1 to 1 for anisotropy"),
anno::in_group("Specular")
]],
uniform float anisotropy_texture_influence = 0.0f
[[
anno::display_name("Anisotropy Map Influence"),
anno::hard_range(0.0, 1.),
anno::description("Blends between the constant value and the lookup of the anisotropy texture"),
anno::in_group("Specular")
]],
uniform texture_2d anisotropy_texture = texture_2d()
[[
anno::display_name("Anisotropy Map"),
anno::in_group("Specular")
]],
uniform float metallic_constant = 0.f
[[
anno::display_name("Metallic Amount"),
anno::hard_range(0.0,1.),
anno::description("Metallic Material"),
anno::in_group("Specular")
]],
uniform float metallic_texture_influence = 0.0f
[[
anno::display_name("Metallic Map Influence"),
anno::hard_range(0.0, 1.),
anno::description("Blends between the constant value and the lookup of the metallic texture"),
anno::in_group("Specular")
]],
uniform texture_2d metallic_texture = texture_2d()
[[
anno::display_name("Metallic Map"),
anno::in_group("Specular")
]],
// -------------------- ORM ----------------------
uniform bool enable_ORM_texture = true
[[
anno::display_name("Enable ORM Texture"),
anno::description("When True the ORM texture will be used to extract the Occlusion, Roughness and Metallic Map"),
anno::in_group("Reflectivity")
]],
uniform texture_2d ORM_texture = texture_2d()
[[
anno::display_name("ORM Map"),
anno::description("Texture that hae Occlusion, Roughness and Metallic map stored in the respective r, g and b channels"),
anno::in_group("Reflectivity")
]],
// -------------------- Clearcoat ----------------------
uniform bool enable_clearcoat = false
[[
anno::display_name("Enable Clearcoat Layer"),
anno::description("Adds a clearcoat layer on top of the material when enabled"),
anno::in_group("Clearcoat")
]],
color clearcoat_tint = color(1.0f)
[[
anno::display_name("Clearcoat Tint"),
anno::description("Clearcoat is tinted and affects the underlying material"),
anno::in_group("Clearcoat")
]],
float clearcoat_transparency = 1.0f
[[
anno::display_name("Clearcoat Transparency"),
anno::description("Adjusts the transparency of the clearcoat. Can be turned into a fully opaque clearcoat "
"covering the underlying layer"),
anno::in_group("Clearcoat")
]],
float clearcoat_reflection_roughness = 0.0f
[[
anno::display_name("Clearcoat Roughness"),
anno::description("Higher roughness values lead to more blurry reflections"),
anno::hard_range(0.0f, 1.0f),
anno::in_group("Clearcoat")
]],
float clearcoat_weight = 1.0f
[[
anno::display_name("Clearcoat Weight"),
anno::description("Sets the weight for clearcoat layer"),
anno::hard_range(0.0f, 1.0f),
anno::in_group("Clearcoat")
]],
float clearcoat_flatten = 1.0f
[[
anno::display_name("Clearcoat Flatten"),
anno::description("Flattens the clearcoat to even out the underlying bump maps"),
anno::hard_range(0.0f, 1.0f),
anno::in_group("Clearcoat")
]],
float clearcoat_ior = 1.56f
[[
anno::display_name("Clearcoat IOR"),
anno::description("Sets the Index of refraction for the clearcoat layer"),
anno::soft_range(1.0f, 4.0f),
anno::in_group("Clearcoat")
]],
uniform float clearcoat_bump_factor = 1.f
[[
anno::display_name("Clearcoat Normal Map Strength"),
anno::description("Strength of normal map."),
anno::in_group("Clearcoat")
]],
uniform texture_2d clearcoat_normalmap_texture = texture_2d()
[[
anno::display_name("Clearcoat Normal Map"),
anno::description("Enables the usage of the normalmap texture"),
anno::in_group("Clearcoat")
]],
// -------------------- REFLECTIVITY ----------------------
uniform bool enable_retroreflection = false
[[
anno::display_name("Enable Retroreflection"),
anno::in_group("Reflectivity")
]],
color retroreflection_color = color(.182,.800,.000)
[[
anno::display_name("Retro-reflection color"),
anno::description("The color of the retroreflection"),
anno::in_group("Reflectivity")
]],
uniform float normal_reflectivity = 0.5
[[
anno::display_name("Retro-reflection weight facing"),
anno::hard_range(0.0,1.),
anno::description("Reflectivity control for geometry facing the viewer"),
anno::in_group("Reflectivity")
]],
uniform float grazing_reflectivity = 1.0
[[
anno::display_name("Retro-reflection weight edge"),
anno::hard_range(0.0,1.),
anno::description("Reflectivity control for the reflectivity at geometry edges"),
anno::in_group("Reflectivity")
]],
// -------------------- AMBIENT OCCLUSION ----------------------
float ao_to_diffuse = 0.0
[[
anno::display_name("AO to Diffuse"),
anno::description("Controls the amount of ambient occlusion multiplied into the diffuse color channel"),
anno::in_group("AO")
]],
uniform texture_2d ao_texture = texture_2d()
[[
anno::display_name("Ambient Occlusion Map"),
anno::description("The Ambient Occlusion texture for the material"),
anno::in_group("AO")
]],
// -------------------- EMISSIVE ----------------------
uniform bool enable_emission = false
[[
anno::display_name("Enable Emission"),
anno::description("Enables the emission of light from the material"),
anno::in_group("Emissive")
]],
uniform 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")
]],
// -------------------- ALPHA ----------------------
uniform bool enable_alpha = true
[[
anno::display_name("Enable Alpha"),
anno::description("Enables or disables alpha functionality"),
anno::in_group("Alpha")
]],
uniform float alpha_constant = 1.0
[[
anno::display_name("Alpha Fallback Constant"),
anno::description("The base alpha constant to use if no texture is specified"),
anno::in_group("Alpha")
]],
uniform texture_2d opacity_texture = texture_2d()
[[
anno::display_name("Opacity Map"),
anno::description("The texture specifying the opacity value to use"),
anno::in_group("Alpha")
]],
uniform bool enable_alpha_cutout = false
[[
anno::display_name("Enable Alpha Cutout"),
anno::description("Enables or disables alpha cutout functionality"),
anno::in_group("Alpha")
]],
uniform float alpha_cutout_cutoff = 1.f
[[
anno::enable_if("enable_alpha_cutout == true"),
anno::hard_range(0.0, 1.0),
anno::display_name("Alpha Cutout Cutoff"),
anno::description("The cutoff value to to render as transparent up to and opaque past"),
anno::in_group("Alpha")
]],
// -------------------- NORMAL ----------------------
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")
]],
// -------------------- UV ADJUSTMENTS ----------------------
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 Scale"),
anno::description("Larger number increases size of 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 Opaque Alpha Cutout"),
anno::description("Supports the opaque alpha cutout material model of the Sim Renderer"),
anno::version( 1, 0, 0),
anno::author("NVIDIA CORPORATION"),
anno::key_words(string[]("Sim", "PBR", "opaque", "alpha", "cutout", "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
);
// Need to use a small value so the compiler doesnt optimize out this var...
float t = 0.00000001;//state::animation_time();
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 );
// Diffuse Color Lookup and AO
float4 base_lookup = tex::texture_isvalid(diffuse_texture) ? raw_file_texture(texture: diffuse_texture, uvw: transformed_uvw) : float4(1, 1, 1, 1);
float opacityValue = tex::texture_isvalid(opacity_texture) ? raw_file_texture(texture: opacity_texture, uvw: transformed_uvw).x : alpha_constant;
// Normal calculations
float3 normal_lookup = tex::texture_isvalid(normalmap_texture) ?
base::tangent_space_normal_texture(
texture: normalmap_texture,
factor: bump_factor,
uvw: transformed_uvw
) : state::normal();
float3 clearcoat_normal = base::tangent_space_normal_texture(
texture: clearcoat_normalmap_texture,
factor: clearcoat_bump_factor,
uvw: uvw
);
float3 flattened_clearcoat_normal = ::math::lerp(normal_lookup, ::state::normal(), clearcoat_flatten);
float3 final_clearcoat_normal = tex::texture_isvalid(clearcoat_normalmap_texture) ? clearcoat_normal : flattened_clearcoat_normal;
float ao_lookup = tex::texture_isvalid(ao_texture) ?
raw_file_texture(texture: ao_texture, uvw: transformed_uvw).x :
1.0f
[[anno::unused("Currently unused in material, may be utilized in the future")]];
color diffuse_color = tex::texture_isvalid(diffuse_texture) ? color(base_lookup.x, base_lookup.y, base_lookup.z) : diffuse_color_constant;
color base_color = multiply_colors(diffuse_color, diffuse_tint, 1.0).tint;
float3 ORM_lookup = tex::lookup_float3(
tex: ORM_texture,
coord: float2(transformed_uvw.position.x, transformed_uvw.position.y)
);
float roughness_lookup = tex::texture_isvalid(reflectionroughness_texture) ?
raw_file_texture(texture: reflectionroughness_texture, uvw: transformed_uvw).x :
reflection_roughness_constant;
float anisotropy_lookup = tex::texture_isvalid(anisotropy_texture) ?
(raw_file_texture(texture: anisotropy_texture, uvw: transformed_uvw).x * 2.0f - 1.0f) :
anisotropy_constant;
float metallic_lookup = tex::texture_isvalid(metallic_texture) ?
raw_file_texture(texture: metallic_texture, uvw: transformed_uvw).x :
metallic_constant;
float roughness_selection = enable_ORM_texture ? ORM_lookup.y : roughness_lookup;
float metallic_selection = enable_ORM_texture ? ORM_lookup.z : metallic_lookup;
color ao_color = enable_ORM_texture ? color(ORM_lookup.x) : color(ao_lookup);
color ao_weighted_base_color = multiply_colors(base_color, ao_color, ao_to_diffuse).tint;
float reflection_roughness = math::lerp(reflection_roughness_constant, roughness_selection, reflection_roughness_texture_influence);
float anisotropy = math::lerp(anisotropy_constant, anisotropy_lookup, anisotropy_texture_influence);
float metallic = math::lerp(metallic_constant, metallic_selection, metallic_texture_influence);
float squared_roughness = reflection_roughness * reflection_roughness;
float roughness_u = squared_roughness * (1 + anisotropy);
float roughness_v = squared_roughness * (1 - anisotropy);
bsdf diffuse_bsdf = df::weighted_layer(
weight: 1.0,
layer: df::diffuse_reflection_bsdf(
tint: ao_weighted_base_color,
roughness: 0.f ),
base: bsdf(),
normal: enable_clearcoat ? normal_lookup : state::normal()
);
bsdf ggx_smith_bsdf = df::microfacet_ggx_smith_bsdf(
roughness_u: roughness_u,
roughness_v: roughness_v,
tint: color(1.0, 1.0, 1.0),
mode: df::scatter_reflect
);
bsdf custom_curve_layer_bsdf = df::custom_curve_layer(
normal_reflectivity: 0.03,
grazing_reflectivity: 1.0,
exponent: 5.0,
weight: float(1.0),
layer: ggx_smith_bsdf,
base: diffuse_bsdf,
normal: enable_clearcoat ? normal_lookup : state::normal()
);
//
// Begin RETROREFLECTION SUPPORT
//
bsdf backscattering_glossy_bsdf = df::backscattering_glossy_reflection_bsdf(
tint: retroreflection_color,
roughness_u: reflection_roughness * reflection_roughness
);
bsdf retroreflection_bsdf = df::custom_curve_layer(
normal_reflectivity: 1.-normal_reflectivity,
grazing_reflectivity: 1.-grazing_reflectivity,
base: backscattering_glossy_bsdf,
layer: diffuse_bsdf,
normal: enable_clearcoat ? normal_lookup : state::normal()
);
//
// End RETROREFLECTION SUPPORT
//
bsdf directional_factor_bsdf = df::directional_factor(
normal_tint: ao_weighted_base_color,
grazing_tint: color(1.0, 1.0, 1.0),
exponent: 5.0f,
base: ggx_smith_bsdf
);
// CLEARCOAT
bsdf omni_PBR_bsdf = df::weighted_layer(
weight: metallic,
layer: directional_factor_bsdf,
base: enable_retroreflection ? retroreflection_bsdf : custom_curve_layer_bsdf,
normal: enable_clearcoat ? normal_lookup : state::normal()
);
bsdf clearcoat_bsdf = df::microfacet_ggx_smith_bsdf(
roughness_u: clearcoat_reflection_roughness * clearcoat_reflection_roughness,
roughness_v: clearcoat_reflection_roughness * clearcoat_reflection_roughness,
tint: color(1.0f),
mode: df::scatter_reflect
);
// bsdf omni_PBR_coated_bsdf = df::custom_curve_layer(
// normal_reflectivity: clearcoat_reflectivity * 0.08,
// grazing_reflectivity: 1.0,
// weight: clearcoat_weight,
// layer: clearcoat_bsdf,
// base: omni_PBR_bsdf,
// normal: final_clearcoat_normal
// );
bsdf opaque_clearcoat = df::weighted_layer(
weight: clearcoat_transparency,
layer: ::df::tint(
tint: clearcoat_tint,
base: omni_PBR_bsdf),
base: ::df::diffuse_reflection_bsdf(
tint: clearcoat_tint)
);
bsdf omni_PBR_coated_bsdf = df::fresnel_layer(
ior: clearcoat_ior,
weight: clearcoat_weight,
layer: clearcoat_bsdf,
base: opaque_clearcoat,
normal: final_clearcoat_normal
);
bsdf final_bsdf = enable_clearcoat ? omni_PBR_coated_bsdf : omni_PBR_bsdf;
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);
} in material(
thin_walled: false,
surface: material_surface(
scattering: final_bsdf,
emission: material_emission (
df::diffuse_edf(),
intensity: enable_emission ? emissive_color * emissive_mask * color(emissive_intensity) : color(0)
)
),
geometry: material_geometry(
normal: enable_clearcoat ? state::normal() : normal_lookup,
cutout_opacity: enable_alpha ? (enable_alpha_cutout ? (opacityValue < alpha_cutout_cutoff ? 0.0 : 1.0) : opacityValue) : 1.0
)
);123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290/*****************************************************************************
* Copyright 1986-2020 NVIDIA Corporation. All rights reserved.
******************************************************************************
MDL MATERIALS ARE PROVIDED PURSUANT TO AN END USER LICENSE AGREEMENT,
WHICH WAS ACCEPTED IN ORDER TO GAIN ACCESS TO THIS FILE. IN PARTICULAR,
THE MDL MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL NVIDIA
CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
THE USE OR INABILITY TO USE THE MDL MATERIALS OR FROM OTHER DEALINGS IN
THE MDL MATERIALS.
*/
mdl 1.4;
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(
// -------------------- SPECULAR REFLECTION/TRANSMISSION ----------------------
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")
]],
// -------------------- VOLUME ----------------------
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")
]],
// -------------------- EMISSIVE ----------------------
uniform bool enable_thin_walled = false
[[
anno::display_name("Enable Thin Walled"),
anno::description("Enables thin walled logic"),
anno::in_group("Geometry")
]],
// -------------------- EMISSIVE ----------------------
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")
]],
// -------------------- NORMAL ----------------------
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")
]],
// -------------------- UV ADJUSTMENTS ----------------------
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
);
// Need to use a small value so the compiler doesnt optimize out this var...
float t = 0.00000001;//state::animation_time();
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),
::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),
::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);
// Normal calculations
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
)
);123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562/*****************************************************************************
* Copyright 1986-2020 NVIDIA Corporation. All rights reserved.
******************************************************************************
MDL MATERIALS ARE PROVIDED PURSUANT TO AN END USER LICENSE AGREEMENT,
WHICH WAS ACCEPTED IN ORDER TO GAIN ACCESS TO THIS FILE. IN PARTICULAR,
THE MDL MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL NVIDIA
CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
THE USE OR INABILITY TO USE THE MDL MATERIALS OR FROM OTHER DEALINGS IN
THE MDL MATERIALS.
*/
mdl 1.4;
import ::df::*;
import ::state::*;
import ::math::*;
import ::base::*;
import ::tex::*;
import ::anno::*;
using .::SimPBR_Model import *;
using .::baking_annotations import *;
export material SimPBR(
// -------------------- DIFFUSE REFLECTION ----------------------
uniform color diffuse_color_constant = color(0.2f)
[[
anno::display_name("Albedo Base Color"),
anno::description("The base albedo color to use if no texture is specified"),
anno::in_group("Diffuse")
]],
uniform texture_2d diffuse_texture = texture_2d()
[[
anno::display_name("Albedo Map"),
anno::description("The texture specifying the albedo value to use"),
anno::in_group("Diffuse")
]],
uniform color diffuse_tint = color(1.0f)
[[
anno::display_name("Albedo Tint"),
anno::description("This tints the albedo color or texture contant"),
anno::in_group("Diffuse")
]],
uniform bool enable_transmission = false
[[
anno::display_name("Enable Diffuse Transmission"),
anno::description("Enables the diffuse transmission of light through thin diffuse scattering layer"),
anno::in_group("Diffuse")
]],
uniform float opacity_ratio = 1.f
[[
anno::enable_if("enable_transmission == true"),
anno::display_name("Opacity Ratio"),
anno::description("Amount of opacity"),
anno::in_group("Diffuse")
]],
uniform color opacity_tint = color(1.0f)
[[
anno::enable_if("enable_transmission == true"),
anno::display_name("Diffuse transmission tint"),
anno::description("Base diffuse transmission color"),
anno::in_group("Diffuse")
]],
uniform float opacity_multiplier = 1.f
[[
anno::enable_if("enable_transmission == true"),
anno::display_name("Diffuse transmission multiplier"),
anno::description("Base diffuse transmission multiplier"),
anno::in_group("Diffuse")
]],
// -------------------- SPECULAR REFLECTION ----------------------
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")
]],
float anisotropy_constant = 0.0f
[[
anno::display_name("Anisotropy Amount"),
anno::hard_range(-1.,1.),
anno::description("0 for isotropic, extents of -1 to 1 for anisotropy"),
anno::in_group("Specular")
]],
uniform float anisotropy_texture_influence = 0.0f
[[
anno::display_name("Anisotropy Map Influence"),
anno::hard_range(0.0, 1.),
anno::description("Blends between the constant value and the lookup of the anisotropy texture"),
anno::in_group("Specular")
]],
uniform texture_2d anisotropy_texture = texture_2d()
[[
anno::display_name("Anisotropy Map"),
anno::in_group("Specular")
]],
float metallic_constant = 0.f
[[
anno::display_name("Metallic Amount"),
anno::hard_range(0.0,1.),
anno::description("Metallic Material"),
anno::in_group("Specular")
]],
uniform float metallic_texture_influence = 0.0f
[[
anno::display_name("Metallic Map Influence"),
anno::hard_range(0.0, 1.),
anno::description("Blends between the constant value and the lookup of the metallic texture"),
anno::in_group("Specular")
]],
uniform texture_2d metallic_texture = texture_2d()
[[
anno::display_name("Metallic Map"),
anno::in_group("Specular")
]],
float specular_constant = 1.f
[[
anno::display_name("Specular amount"),
anno::hard_range(0.0, 1.0),
anno::description("Scale of the specular component"),
anno::in_group("Specular")
]],
uniform texture_2d specular_texture = texture_2d()
[[
anno::display_name("Specular Map"),
anno::in_group("Specular")
]],
// -------------------- ORM ----------------------
uniform bool enable_ORM_texture = true
[[
anno::display_name("Enable ORM Texture"),
anno::description("When True the ORM texture will be used to extract the Occlusion, Roughness and Metallic Map"),
anno::in_group("Reflectivity")
]],
uniform texture_2d ORM_texture = texture_2d()
[[
anno::display_name("ORM Map"),
anno::description("Texture that hae Occlusion, Roughness and Metallic map stored in the respective r, g and b channels"),
anno::in_group("Reflectivity")
]],
// -------------------- Clearcoat ----------------------
uniform bool enable_clearcoat = false
[[
anno::display_name("Enable Clearcoat Layer"),
anno::description("Adds a clearcoat layer on top of the material when enabled"),
anno::in_group("Clearcoat")
]],
color clearcoat_tint = color(1.0f)
[[
anno::display_name("Clearcoat Tint"),
anno::description("Clearcoat is tinted and affects the underlying material"),
anno::in_group("Clearcoat")
]],
float clearcoat_transparency = 1.0f
[[
anno::display_name("Clearcoat Transparency"),
anno::description("Adjusts the transparency of the clearcoat. Can be turned into a fully opaque clearcoat "
"covering the underlying layer"),
anno::in_group("Clearcoat")
]],
float clearcoat_reflection_roughness = 0.0f
[[
anno::display_name("Clearcoat Roughness"),
anno::description("Higher roughness values lead to more blurry reflections"),
anno::hard_range(0.0f, 1.0f),
anno::in_group("Clearcoat")
]],
float clearcoat_weight = 1.0f
[[
anno::display_name("Clearcoat Weight"),
anno::description("Sets the weight for clearcoat layer"),
anno::hard_range(0.0f, 1.0f),
anno::in_group("Clearcoat")
]],
float clearcoat_flatten = 1.0f
[[
anno::display_name("Clearcoat Flatten"),
anno::description("Flattens the clearcoat to even out the underlying bump maps"),
anno::hard_range(0.0f, 1.0f),
anno::in_group("Clearcoat")
]],
float clearcoat_ior = 1.56f
[[
anno::display_name("Clearcoat IOR"),
anno::description("Sets the Index of refraction for the clearcoat layer"),
anno::soft_range(1.0f, 4.0f),
anno::in_group("Clearcoat")
]],
uniform float clearcoat_bump_factor = 1.f
[[
anno::display_name("Clearcoat Normal Map Strength"),
anno::description("Strength of normal map."),
anno::in_group("Clearcoat")
]],
float3 clearcoat_normal_input = float3(0.0, 0.0, 0.0),
uniform texture_2d clearcoat_normalmap_texture = texture_2d()
[[
anno::display_name("Clearcoat Normal Map"),
anno::description("Enables the usage of the normalmap texture"),
anno::in_group("Clearcoat")
]],
uniform bool clearcoat_flip_tangent_u = false
[[
anno::display_name("Clearcoat Normal Map Flip U Tangent"),
anno::in_group("Clearcoat")
]],
uniform bool clearcoat_flip_tangent_v = true
[[
anno::display_name("Clearcoat Normal Map Flip V Tangent"),
anno::in_group("Clearcoat")
]],
// -------------------- REFLECTIVITY ----------------------
uniform bool enable_retroreflection = false
[[
anno::display_name("Enable Retroreflection"),
anno::in_group("Reflectivity")
]],
color retroreflection_tint = color(.182,.800,.000)
[[
anno::display_name("Retro-reflection tint"),
anno::description("The tint of the retroreflection"),
anno::in_group("Reflectivity")
]],
uniform float normal_reflectivity = 0.5
[[
anno::display_name("Retro-reflection weight facing"),
anno::hard_range(0.0,1.),
anno::description("Reflectivity control for geometry facing the viewer"),
anno::in_group("Reflectivity")
]],
uniform float grazing_reflectivity = 1.0
[[
anno::display_name("Retro-reflection weight edge"),
anno::hard_range(0.0,1.),
anno::description("Reflectivity control for the reflectivity at geometry edges"),
anno::in_group("Reflectivity")
]],
// -------------------- AMBIENT OCCLUSION ----------------------
float ao_to_diffuse = 0.0
[[
anno::display_name("AO to Diffuse"),
anno::description("Controls the amount of ambient occlusion multiplied into the diffuse color channel"),
anno::in_group("AO")
]],
float ao_input = float(1.0),
uniform texture_2d ao_texture = texture_2d()
[[
anno::display_name("Ambient Occlusion Map"),
anno::description("The Ambient Occlusion texture for the material"),
anno::in_group("AO")
]],
// -------------------- EMISSIVE ----------------------
uniform bool enable_emission = false
[[
anno::display_name("Enable Emission"),
anno::description("Enables the emission of light from the material"),
anno::in_group("Emissive")
]],
uniform 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")
]],
color emissive_mask_input = color(1.0),
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")
]],
// -------------------- ALPHA ----------------------
uniform bool enable_opacity = false
[[
anno::display_name("Enable Opacity"),
anno::description("Enables or disables alpha functionality"),
anno::in_group("Alpha")
]],
float alpha_constant = 1.0
[[
anno::enable_if("enable_opacity == true"),
anno::display_name("Opacity Fallback Constant"),
anno::hard_range(0.0, 1.0),
anno::description("The base alpha constant to use if no texture is specified"),
anno::in_group("Alpha")
]],
uniform texture_2d opacity_texture = texture_2d()
[[
anno::enable_if("enable_opacity == true"),
anno::display_name("Opacity Map"),
anno::description("The texture specifying the opacity value to use"),
anno::in_group("Alpha")
]],
uniform bool enable_opacity_cutout = false
[[
anno::enable_if("enable_opacity == true"),
anno::display_name("Enable Alpha Cutout"),
anno::description("Enables or disables alpha cutout functionality"),
anno::in_group("Alpha")
]],
uniform float alpha_cutout_cutoff = 1.f
[[
anno::enable_if("enable_opacity == true"),
anno::enable_if("enable_opacity_cutout == true"),
anno::hard_range(0.0, 1.0),
anno::display_name("Alpha Cutout Cutoff"),
anno::description("The cutoff value to to render as transparent up to and opaque past"),
anno::in_group("Alpha")
]],
// -------------------- NORMAL ----------------------
uniform float bump_factor = 1.f
[[
anno::display_name("Normal Map Strength"),
anno::description("Strength of normal map."),
anno::in_group("Normal")
]],
float3 normal_input = state::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::description("Flips the U Tangent vector."),
anno::in_group("Normal")
]],
uniform bool flip_tangent_v = true
[[
anno::display_name("Normal Map Flip V Tangent"),
anno::description("Flips the V Tangent vector. By Default, SimPBR materials setup for DirectX normal maps. Set Normal Map Flip V = false for OpenGL."),
anno::in_group("Normal")
]],
// -------------------- UV ADJUSTMENTS ----------------------
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 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"),
anno::description("Supports the opaque alpha cutout 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", "opaque", "alpha", "cutout", "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
);
// Need to use a small value so the compiler doesnt optimize out this var...
float t = 0.00000001;//state::animation_time();
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);
// Diffuse Color Lookup and AO
float4 base_lookup = tex::texture_isvalid(diffuse_texture) ? tex::lookup_float4(tex: diffuse_texture, coord: uv) : float4(1, 1, 1, 1);
float opacityValue = tex::texture_isvalid(opacity_texture) ? tex::lookup_float4(tex: opacity_texture, coord: uv).w : alpha_constant;
// Normal calculations
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
) : normal_input;
float3 clearcoat_normal = tex::texture_isvalid(clearcoat_normalmap_texture) ?
base::tangent_space_normal_texture(
texture: clearcoat_normalmap_texture,
factor: clearcoat_bump_factor,
uvw: uvw,
flip_tangent_u: clearcoat_flip_tangent_u,
flip_tangent_v: clearcoat_flip_tangent_v
) : clearcoat_normal_input;
float3 flattened_clearcoat_normal = ::math::lerp(normal_lookup, ::state::normal(), clearcoat_flatten);
float3 final_clearcoat_normal = tex::texture_isvalid(clearcoat_normalmap_texture) ? clearcoat_normal : flattened_clearcoat_normal;
float ao_lookup = tex::texture_isvalid(ao_texture) ? tex::lookup_float4(tex: ao_texture, coord: uv).x : ao_input;
color diffuse_color = tex::texture_isvalid(diffuse_texture) ? color(base_lookup.x, base_lookup.y, base_lookup.z) : diffuse_color_constant;
float3 ORM_lookup = tex::lookup_float3(
tex: ORM_texture,
coord: float2(transformed_uvw.position.x, transformed_uvw.position.y)
);
float roughness_lookup = tex::texture_isvalid(reflectionroughness_texture) ?
tex::lookup_float4(tex: reflectionroughness_texture, coord: uv).x : reflection_roughness_constant;
float anisotropy_lookup = tex::texture_isvalid(anisotropy_texture) ?
(tex::lookup_float4(tex: anisotropy_texture, coord: uv).x * 2.0f - 1.0f) : anisotropy_constant;
float metallic_lookup = tex::texture_isvalid(metallic_texture) ?
tex::lookup_float4(tex: metallic_texture, coord: uv).x : metallic_constant;
float specular_lookup = tex::texture_isvalid(specular_texture) ?
tex::lookup_float4(tex: specular_texture, coord: uv).x : specular_constant;
float roughness_selection = enable_ORM_texture ? ORM_lookup.y : roughness_lookup;
float metallic_selection = enable_ORM_texture ? ORM_lookup.z : metallic_lookup;
float ao = enable_ORM_texture ? ORM_lookup.x : ao_lookup;
float reflection_roughness = math::lerp(reflection_roughness_constant, roughness_selection, reflection_roughness_texture_influence);
float anisotropy = math::lerp(anisotropy_constant, anisotropy_lookup, anisotropy_texture_influence);
float metallic = math::lerp(metallic_constant, metallic_selection, metallic_texture_influence);
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) : emissive_mask_input;
} in SimPBR_Model(
diffuse_color: diffuse_color,
diffuse_tint: diffuse_tint,
roughness: reflection_roughness,
anisotropy: anisotropy,
metallic: metallic,
specular: specular_lookup,
normal: normal_lookup,
enable_clearcoat: enable_clearcoat,
clearcoat_tint: clearcoat_tint,
clearcoat_transparency: clearcoat_transparency,
clearcoat_reflection_roughness: clearcoat_reflection_roughness,
clearcoat_weight: clearcoat_weight,
clearcoat_ior: clearcoat_ior,
clearcoat_normal: final_clearcoat_normal,
enable_retroreflection: enable_retroreflection,
retroreflection_tint: retroreflection_tint,
normal_reflectivity: normal_reflectivity,
grazing_reflectivity: grazing_reflectivity,
ao_to_diffuse: ao_to_diffuse,
ao: ao,
enable_emission: enable_emission,
emissive_color: emissive_color,
emissive_mask: emissive_mask,
emissive_intensity: emissive_intensity,
enable_opacity: enable_opacity,
alpha: opacityValue,
enable_opacity_cutout: enable_opacity_cutout,
alpha_cutout_cutoff: alpha_cutout_cutoff,
opacity_ratio: enable_transmission ? opacity_ratio : 1.0,
opacity_tint : opacity_tint,
opacity_multiplier : opacity_multiplier
);123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212/*****************************************************************************
* Copyright 1986-2020 NVIDIA Corporation. All rights reserved.
******************************************************************************
MDL MATERIALS ARE PROVIDED PURSUANT TO AN END USER LICENSE AGREEMENT,
WHICH WAS ACCEPTED IN ORDER TO GAIN ACCESS TO THIS FILE. IN PARTICULAR,
THE MDL MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL NVIDIA
CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
THE USE OR INABILITY TO USE THE MDL MATERIALS OR FROM OTHER DEALINGS IN
THE MDL MATERIALS.
*/
mdl 1.4;
import ::df::*;
import ::state::*;
import ::math::*;
import ::base::*;
import ::tex::*;
import ::anno::*;
using .::baking_annotations import *;
base::texture_return multiply_colors(
color color_1 = color(1.0, 1.0, 1.0),
color color_2 = color(.5, .5, .5),
float weight = 1.0
)
[[
anno::hidden()
]]
{
return base::blend_color_layers(
layers: base::color_layer[](
base::color_layer(
layer_color: color_2,
weight: weight,
mode: base::color_layer_multiply
)
), base: color_1
);
}
export material SimPBR_Model(
color diffuse_color = color(0.2f) [[ target_baked_argument("diffuse_texture", "diffuse_color_constant", "RGBA8_UNORM") ]],
uniform color diffuse_tint = color(1.0f),
float roughness = 0.5f [[ target_baked_argument("reflectionroughness_texture", "reflection_roughness_constant", "R8_UNORM") ]],
float anisotropy = 0.0f [[ target_baked_argument("anisotropy_texture", "anisotropy_constant", "R8_SNORM") ]],
float metallic = 0.f [[ target_baked_argument("metallic_texture", "metallic_constant", "R8_UNORM") ]],
float specular = 1.f [[ target_baked_argument("specular_texture", "specular_constant", "R8_UNORM") ]],
float3 normal = float3(0.0, 0.0, 0.0) [[ target_baked_argument("normalmap_texture", "normal_input", "RGBA8_SNORM", baking_annotations::TRANSFORM_UNORM_VECTOR) ]],
uniform bool enable_clearcoat = false,
color clearcoat_tint = color(1.0f),
float clearcoat_transparency = 1.0f,
float clearcoat_reflection_roughness = 0.0f,
float clearcoat_weight = 1.0f,
float clearcoat_ior = 1.56f,
float3 clearcoat_normal = float3(0.0, 0.0, 0.0) [[ target_baked_argument("clearcoat_normalmap_texture", "clearcoat_normal_input", "RGBA8_SNORM", baking_annotations::TRANSFORM_UNORM_VECTOR) ]],
uniform bool enable_retroreflection = false,
color retroreflection_tint = color(.182,.800,.000),
uniform float normal_reflectivity = 0.5,
uniform float grazing_reflectivity = 1.0,
float ao_to_diffuse = 0.0,
float ao = 1.0f [[ target_baked_argument("ao_texture", "ao_input", "R8_UNORM") ]],
uniform bool enable_emission = false,
uniform color emissive_color = color(1.0, 0.1, 0.1),
color emissive_mask = color(1.0, 0.1, 0.1) [[ target_baked_argument("emissive_mask_texture", "emissive_mask_input", "R8_UNORM") ]],
uniform float emissive_intensity = 40.f,
uniform bool enable_opacity = false,
float alpha = 1.0,
uniform bool enable_opacity_cutout = false,
uniform float alpha_cutout_cutoff = 1.f,
uniform float opacity_ratio = 1.f,
uniform color opacity_tint = color(1.0f),
uniform float opacity_multiplier = 1.f
)
[[
target_material_model(),
target_material_rendering("..::SimPBR::SimPBR")
]]
= let {
color base_color = multiply_colors(diffuse_color, diffuse_tint, 1.0).tint;
color ao_weighted_base_color = multiply_colors(base_color, color(ao), ao_to_diffuse).tint;
float squared_roughness = roughness * roughness;
float roughness_u = squared_roughness * (1 + anisotropy);
float roughness_v = squared_roughness * (1 - anisotropy);
color diffuse_transmission_color = base_color * opacity_tint * opacity_multiplier;
bsdf diffuse_bsdf = df::weighted_layer(
weight: opacity_ratio,
layer: df::diffuse_reflection_bsdf(
tint: ao_weighted_base_color,
roughness: 0.0f
),
base: df::diffuse_transmission_bsdf(tint: diffuse_transmission_color),
normal: enable_clearcoat ? normal : state::normal()
);
bsdf ggx_smith_bsdf = df::microfacet_ggx_smith_bsdf(
roughness_u: roughness_u,
roughness_v: roughness_v,
tint: color(1.0, 1.0, 1.0),
mode: df::scatter_reflect
);
bsdf custom_curve_layer_bsdf = df::custom_curve_layer(
normal_reflectivity: 0.03,
grazing_reflectivity: 1.0,
exponent: 5.0,
weight: specular,
layer: ggx_smith_bsdf,
base: diffuse_bsdf,
normal: enable_clearcoat ? normal : state::normal()
);
//
// Begin RETROREFLECTION SUPPORT
//
color final_retroreflection_color = multiply_colors(retroreflection_tint, base_color, 1.0).tint;
bsdf backscattering_glossy_bsdf = df::backscattering_glossy_reflection_bsdf(
tint: final_retroreflection_color,
roughness_u: squared_roughness
);
/*bsdf retroreflection_bsdf = df::custom_curve_layer(
normal_reflectivity: 1.-normal_reflectivity,
grazing_reflectivity: 1.-grazing_reflectivity,
base: backscattering_glossy_bsdf,
layer: custom_curve_layer_bsdf,
normal: enable_clearcoat ? normal_lookup : state::normal()
);*/
// if normal_reflectivity and grazing_reflectivity are 1 and weight is 1, just the layer is used
bsdf opt_retroreflection_bsdf = df::custom_curve_layer(
normal_reflectivity: enable_retroreflection ? 1.-normal_reflectivity : 1,
grazing_reflectivity: enable_retroreflection ? 1.-grazing_reflectivity : 1,
base: backscattering_glossy_bsdf,
layer: custom_curve_layer_bsdf,
normal: enable_clearcoat ? normal : state::normal()
);
//
// End RETROREFLECTION SUPPORT
//
bsdf directional_factor_bsdf = df::directional_factor(
normal_tint: ao_weighted_base_color,
grazing_tint: color(1.0, 1.0, 1.0),
exponent: 5.0f,
base: ggx_smith_bsdf
);
// CLEARCOAT
bsdf omni_PBR_bsdf = df::weighted_layer(
weight: metallic,
layer: directional_factor_bsdf,
base: opt_retroreflection_bsdf, //enable_retroreflection ? retroreflection_bsdf : custom_curve_layer_bsdf,
normal: enable_clearcoat ? normal : state::normal()
);
bsdf clearcoat_bsdf = df::microfacet_ggx_smith_bsdf(
roughness_u: clearcoat_reflection_roughness * clearcoat_reflection_roughness,
roughness_v: clearcoat_reflection_roughness * clearcoat_reflection_roughness,
tint: color(1.0f),
mode: df::scatter_reflect
);
// bsdf omni_PBR_coated_bsdf = df::custom_curve_layer(
// normal_reflectivity: clearcoat_reflectivity * 0.08,
// grazing_reflectivity: 1.0,
// weight: clearcoat_weight,
// layer: clearcoat_bsdf,
// base: omni_PBR_bsdf,
// normal: final_clearcoat_normal
// );
bsdf opt_opaque_clearcoat = df::weighted_layer(
weight: enable_clearcoat ? clearcoat_transparency : 1,
layer: ::df::tint(tint: enable_clearcoat ? clearcoat_tint : color(1), base: omni_PBR_bsdf),
base: ::df::diffuse_reflection_bsdf(tint: clearcoat_tint)
);
bsdf opt_omni_PBR_coated_bsdf = df::fresnel_layer(
ior: clearcoat_ior,
weight: enable_clearcoat ? clearcoat_weight : 0,
layer: clearcoat_bsdf,
base: opt_opaque_clearcoat,
normal: clearcoat_normal
);
bsdf final_bsdf = opt_omni_PBR_coated_bsdf;
} in material(
thin_walled: false,
surface: material_surface(
scattering: final_bsdf,
emission: material_emission(
df::diffuse_edf(),
intensity: enable_emission ? emissive_color * emissive_mask * color(emissive_intensity) : color(0)
)
),
geometry: material_geometry(
normal: enable_clearcoat ? state::normal() : normal,
cutout_opacity: enable_opacity ? (enable_opacity_cutout ? (alpha < alpha_cutout_cutoff ? 0.0 : 1.0) : alpha) : 1.0
)
);123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651/*****************************************************************************
* Copyright 1986-2020 NVIDIA Corporation. All rights reserved.
******************************************************************************
MDL MATERIALS ARE PROVIDED PURSUANT TO AN END USER LICENSE AGREEMENT,
WHICH WAS ACCEPTED IN ORDER TO GAIN ACCESS TO THIS FILE. IN PARTICULAR,
THE MDL MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL NVIDIA
CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
THE USE OR INABILITY TO USE THE MDL MATERIALS OR FROM OTHER DEALINGS IN
THE MDL MATERIALS.
*/
mdl 1.4;
import ::df::*;
import ::state::*;
import ::math::*;
import ::base::*;
import ::tex::*;
import ::anno::*;
import ::nvidia::core_definitions::file_texture;
import ::nvidia::core_definitions::normalmap_texture;
float4 raw_file_texture(
uniform texture_2d texture
[[ anno::description("The input texture") ]],
base::texture_coordinate_info uvw = base::texture_coordinate_info()
[[ anno::description("Custom value for texture coordinate") ]],
uniform float2 crop_u = float2(0.0, 1.0)
[[ anno::description("Restricts the texture access to sub-domain of the texture in the u direction") ]],
uniform float2 crop_v = float2(0.0, 1.0)
[[ anno::description("Restricts the texture access to sub-domain of the texture in the v direction") ]],
uniform tex::wrap_mode wrap_u = tex::wrap_repeat
[[ anno::description("Wrapping mode in the u direction") ]],
uniform tex::wrap_mode wrap_v = tex::wrap_repeat
[[ anno::description("Wrapping mode in the v direction") ]]
)
[[
anno::description("General texturing function for 2D bitmap texture stored in a file"),
anno::noinline()
]]
{
return tex::lookup_float4(texture, float2(uvw.position.x, uvw.position.y), wrap_u, wrap_v, crop_u, crop_v);
}
base::texture_return multiply_colors(
color color_1 = color(1.0, 1.0, 1.0),
color color_2 = color(.5, .5, .5),
float weight = 1.0
) [[
anno::hidden()
]]
{
return base::blend_color_layers(
layers: base::color_layer[](
base::color_layer(
layer_color: color_2,
weight: weight,
mode: base::color_layer_multiply
)),
base: color_1
);
}
base::texture_return add_colors(
color color_1 = color(.5, .5, .5),
color color_2 = color(.5, .5, .5),
float weight = 1.0
) [[
anno::hidden(),
anno::unused()
]]
{
return base::blend_color_layers(
layers: base::color_layer[](
base::color_layer(
layer_color: color_2,
weight: weight,
mode: base::color_layer_add
)),
base: color_1
);
}
base::texture_return blend_colors(
color color_1 = color(1.0, 1.0, 1.0),
color color_2 = color(.5, .5, .5),
float weight = 1.0
) [[
anno::hidden(),
anno::unused()
]]
{
return base::blend_color_layers(
layers: base::color_layer[](
base::color_layer(
layer_color: color_2,
weight: weight,
mode: base::color_layer_blend
)),
base: color_1
);
}
export material SimPBR_Opacity(
// -------------------- DIFFUSE REFLECTION ----------------------
uniform color diffuse_color_constant = color(0.2f)
[[
anno::display_name("Albedo Base Color"),
anno::description("The base albedo color to use if no texture is specified"),
anno::in_group("Diffuse")
]],
uniform texture_2d diffuse_texture = texture_2d()
[[
anno::display_name("Albedo Map"),
anno::description("The texture specifying the albedo value to use"),
anno::in_group("Diffuse")
]],
uniform color diffuse_tint = color(1.0f)
[[
anno::display_name("Albedo Tint"),
anno::description("This tints the albedo color or texture contant"),
anno::in_group("Diffuse")
]],
// -------------------- SPECULAR REFLECTION ----------------------
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")
]],
uniform float anisotropy_constant = 0.0f
[[
anno::display_name("Anisotropy Amount"),
anno::hard_range(-1.,1.),
anno::description("0 for isotropic, extents of -1 to 1 for anisotropy"),
anno::in_group("Specular")
]],
uniform float anisotropy_texture_influence = 0.0f
[[
anno::display_name("Anisotropy Map Influence"),
anno::hard_range(0.0, 1.),
anno::description("Blends between the constant value and the lookup of the anisotropy texture"),
anno::in_group("Specular")
]],
uniform texture_2d anisotropy_texture = texture_2d()
[[
anno::display_name("Anisotropy Map"),
anno::in_group("Specular")
]],
uniform float metallic_constant = 0.f
[[
anno::display_name("Metallic Amount"),
anno::hard_range(0.0,1.),
anno::description("Metallic Material"),
anno::in_group("Specular")
]],
uniform float metallic_texture_influence = 0.0f
[[
anno::display_name("Metallic Map Influence"),
anno::hard_range(0.0, 1.),
anno::description("Blends between the constant value and the lookup of the metallic texture"),
anno::in_group("Specular")
]],
uniform texture_2d metallic_texture = texture_2d()
[[
anno::display_name("Metallic Map"),
anno::in_group("Specular")
]],
// -------------------- ORM ----------------------
uniform bool enable_ORM_texture = true
[[
anno::display_name("Enable ORM Texture"),
anno::description("When True the ORM texture will be used to extract the Occlusion, Roughness and Metallic Map"),
anno::in_group("Reflectivity")
]],
uniform texture_2d ORM_texture = texture_2d()
[[
anno::display_name("ORM Map"),
anno::description("Texture that hae Occlusion, Roughness and Metallic map stored in the respective r, g and b channels"),
anno::in_group("Reflectivity")
]],
// -------------------- Clearcoat ----------------------
uniform bool enable_clearcoat = false
[[
anno::display_name("Enable Clearcoat Layer"),
anno::description("Adds a clearcoat layer on top of the material when enabled"),
anno::in_group("Clearcoat")
]],
color clearcoat_tint = color(1.0f)
[[
anno::display_name("Clearcoat Tint"),
anno::description("Clearcoat is tinted and affects the underlying material"),
anno::in_group("Clearcoat")
]],
float clearcoat_transparency = 1.0f
[[
anno::display_name("Clearcoat Transparency"),
anno::description("Adjusts the transparency of the clearcoat. Can be turned into a fully opaque clearcoat "
"covering the underlying layer"),
anno::in_group("Clearcoat")
]],
float clearcoat_reflection_roughness = 0.0f
[[
anno::display_name("Clearcoat Roughness"),
anno::description("Higher roughness values lead to more blurry reflections"),
anno::hard_range(0.0f, 1.0f),
anno::in_group("Clearcoat")
]],
float clearcoat_weight = 1.0f
[[
anno::display_name("Clearcoat Weight"),
anno::description("Sets the weight for clearcoat layer"),
anno::hard_range(0.0f, 1.0f),
anno::in_group("Clearcoat")
]],
float clearcoat_flatten = 1.0f
[[
anno::display_name("Clearcoat Flatten"),
anno::description("Flattens the clearcoat to even out the underlying bump maps"),
anno::hard_range(0.0f, 1.0f),
anno::in_group("Clearcoat")
]],
float clearcoat_ior = 1.56f
[[
anno::display_name("Clearcoat IOR"),
anno::description("Sets the Index of refraction for the clearcoat layer"),
anno::soft_range(1.0f, 4.0f),
anno::in_group("Clearcoat")
]],
uniform float clearcoat_bump_factor = 1.f
[[
anno::display_name("Clearcoat Normal Map Strength"),
anno::description("Strength of normal map."),
anno::in_group("Clearcoat")
]],
uniform texture_2d clearcoat_normalmap_texture = texture_2d()
[[
anno::display_name("Clearcoat Normal Map"),
anno::description("Enables the usage of the normalmap texture"),
anno::in_group("Clearcoat")
]],
// -------------------- REFLECTIVITY ----------------------
uniform bool enable_retroreflection = false
[[
anno::display_name("Enable Retroreflection"),
anno::in_group("Reflectivity")
]],
color retroreflection_color = color(.182,.800,.000)
[[
anno::display_name("Retro-reflection color"),
anno::description("The color of the retroreflection"),
anno::in_group("Reflectivity")
]],
uniform float normal_reflectivity = 0.5
[[
anno::display_name("Retro-reflection weight facing"),
anno::hard_range(0.0,1.),
anno::description("Reflectivity control for geometry facing the viewer"),
anno::in_group("Reflectivity")
]],
uniform float grazing_reflectivity = 1.0
[[
anno::display_name("Retro-reflection weight edge"),
anno::hard_range(0.0,1.),
anno::description("Reflectivity control for the reflectivity at geometry edges"),
anno::in_group("Reflectivity")
]],
// -------------------- AMBIENT OCCLUSION ----------------------
float ao_to_diffuse = 0.0
[[
anno::display_name("AO to Diffuse"),
anno::description("Controls the amount of ambient occlusion multiplied into the diffuse color channel"),
anno::in_group("AO")
]],
uniform texture_2d ao_texture = texture_2d()
[[
anno::display_name("Ambient Occlusion Map"),
anno::description("The Ambient Occlusion texture for the material"),
anno::in_group("AO")
]],
// -------------------- EMISSIVE ----------------------
uniform bool enable_emission = false
[[
anno::display_name("Enable Emission"),
anno::description("Enables the emission of light from the material"),
anno::in_group("Emissive")
]],
uniform 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")
]],
// -------------------- ALPHA ----------------------
uniform bool enable_alpha = true
[[
anno::display_name("Enable Alpha"),
anno::description("Enables or disables alpha functionality"),
anno::in_group("Alpha")
]],
uniform float alpha_constant = 1.0
[[
anno::display_name("Alpha Fallback Constant"),
anno::description("The base alpha constant to use if no texture is specified"),
anno::in_group("Alpha")
]],
uniform texture_2d opacity_texture = texture_2d()
[[
anno::display_name("Opacity Map"),
anno::description("The texture specifying the opacity value to use"),
anno::in_group("Alpha")
]],
uniform bool enable_alpha_cutout = false
[[
anno::display_name("Enable Alpha Cutout"),
anno::description("Enables or disables alpha cutout functionality"),
anno::in_group("Alpha")
]],
uniform float alpha_cutout_cutoff = 1.f
[[
anno::enable_if("enable_alpha_cutout == true"),
anno::hard_range(0.0, 1.0),
anno::display_name("Alpha Cutout Cutoff"),
anno::description("The cutoff value to to render as transparent up to and opaque past"),
anno::in_group("Alpha")
]],
// -------------------- NORMAL ----------------------
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")
]],
// -------------------- UV ADJUSTMENTS ----------------------
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 Scale"),
anno::description("Larger number increases size of 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 Opaque Alpha Cutout"),
anno::description("Supports the opaque alpha cutout material model of the Sim Renderer"),
anno::version( 1, 0, 0),
anno::author("NVIDIA CORPORATION"),
anno::key_words(string[]("Sim", "PBR", "opaque", "alpha", "cutout", "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
);
// Need to use a small value so the compiler doesnt optimize out this var...
float t = 0.00000001;//state::animation_time();
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 );
// Diffuse Color Lookup and AO
float4 base_lookup = tex::texture_isvalid(diffuse_texture) ? raw_file_texture(texture: diffuse_texture, uvw: transformed_uvw) : float4(1, 1, 1, 1);
float opacityValue = tex::texture_isvalid(opacity_texture) ? raw_file_texture(texture: opacity_texture, uvw: transformed_uvw).x : alpha_constant;
// Normal calculations
float3 normal_lookup = tex::texture_isvalid(normalmap_texture) ?
base::tangent_space_normal_texture(
texture: normalmap_texture,
factor: bump_factor,
uvw: transformed_uvw
) : state::normal();
float3 clearcoat_normal = base::tangent_space_normal_texture(
texture: clearcoat_normalmap_texture,
factor: clearcoat_bump_factor,
uvw: uvw
);
float3 flattened_clearcoat_normal = ::math::lerp(normal_lookup, ::state::normal(), clearcoat_flatten);
float3 final_clearcoat_normal = tex::texture_isvalid(clearcoat_normalmap_texture) ? clearcoat_normal : flattened_clearcoat_normal;
float ao_lookup = tex::texture_isvalid(ao_texture) ?
raw_file_texture(texture: ao_texture, uvw: transformed_uvw).x :
1.0f
[[anno::unused("Currently unused in material, may be utilized in the future")]];
color diffuse_color = tex::texture_isvalid(diffuse_texture) ? color(base_lookup.x, base_lookup.y, base_lookup.z) : diffuse_color_constant;
color base_color = multiply_colors(diffuse_color, diffuse_tint, 1.0).tint;
float3 ORM_lookup = tex::lookup_float3(
tex: ORM_texture,
coord: float2(transformed_uvw.position.x, transformed_uvw.position.y)
);
float roughness_lookup = tex::texture_isvalid(reflectionroughness_texture) ?
raw_file_texture(texture: reflectionroughness_texture, uvw: transformed_uvw).x :
reflection_roughness_constant;
float anisotropy_lookup = tex::texture_isvalid(anisotropy_texture) ?
(raw_file_texture(texture: anisotropy_texture, uvw: transformed_uvw).x * 2.0f - 1.0f) :
anisotropy_constant;
float metallic_lookup = tex::texture_isvalid(metallic_texture) ?
raw_file_texture(texture: metallic_texture, uvw: transformed_uvw).x :
metallic_constant;
float roughness_selection = enable_ORM_texture ? ORM_lookup.y : roughness_lookup;
float metallic_selection = enable_ORM_texture ? ORM_lookup.z : metallic_lookup;
color ao_color = enable_ORM_texture ? color(ORM_lookup.x) : color(ao_lookup);
color ao_weighted_base_color = multiply_colors(base_color, ao_color, ao_to_diffuse).tint;
float reflection_roughness = math::lerp(reflection_roughness_constant, roughness_selection, reflection_roughness_texture_influence);
float anisotropy = math::lerp(anisotropy_constant, anisotropy_lookup, anisotropy_texture_influence);
float metallic = math::lerp(metallic_constant, metallic_selection, metallic_texture_influence);
float squared_roughness = reflection_roughness * reflection_roughness;
float roughness_u = squared_roughness * (1 + anisotropy);
float roughness_v = squared_roughness * (1 - anisotropy);
bsdf diffuse_bsdf = df::weighted_layer(
weight: 1.0,
layer: df::diffuse_reflection_bsdf(
tint: ao_weighted_base_color,
roughness: 0.f ),
base: bsdf(),
normal: enable_clearcoat ? normal_lookup : state::normal()
);
bsdf ggx_smith_bsdf = df::microfacet_ggx_smith_bsdf(
roughness_u: roughness_u,
roughness_v: roughness_v,
tint: color(1.0, 1.0, 1.0),
mode: df::scatter_reflect
);
bsdf custom_curve_layer_bsdf = df::custom_curve_layer(
normal_reflectivity: 0.03,
grazing_reflectivity: 1.0,
exponent: 5.0,
weight: float(1.0),
layer: ggx_smith_bsdf,
base: diffuse_bsdf,
normal: enable_clearcoat ? normal_lookup : state::normal()
);
//
// Begin RETROREFLECTION SUPPORT
//
bsdf backscattering_glossy_bsdf = df::backscattering_glossy_reflection_bsdf(
tint: retroreflection_color,
roughness_u: reflection_roughness * reflection_roughness
);
bsdf retroreflection_bsdf = df::custom_curve_layer(
normal_reflectivity: 1.-normal_reflectivity,
grazing_reflectivity: 1.-grazing_reflectivity,
base: backscattering_glossy_bsdf,
layer: diffuse_bsdf,
normal: enable_clearcoat ? normal_lookup : state::normal()
);
//
// End RETROREFLECTION SUPPORT
//
bsdf directional_factor_bsdf = df::directional_factor(
normal_tint: ao_weighted_base_color,
grazing_tint: color(1.0, 1.0, 1.0),
exponent: 5.0f,
base: ggx_smith_bsdf
);
// CLEARCOAT
bsdf omni_PBR_bsdf = df::weighted_layer(
weight: metallic,
layer: directional_factor_bsdf,
base: enable_retroreflection ? retroreflection_bsdf : custom_curve_layer_bsdf,
normal: enable_clearcoat ? normal_lookup : state::normal()
);
bsdf clearcoat_bsdf = df::microfacet_ggx_smith_bsdf(
roughness_u: clearcoat_reflection_roughness * clearcoat_reflection_roughness,
roughness_v: clearcoat_reflection_roughness * clearcoat_reflection_roughness,
tint: color(1.0f),
mode: df::scatter_reflect
);
// bsdf omni_PBR_coated_bsdf = df::custom_curve_layer(
// normal_reflectivity: clearcoat_reflectivity * 0.08,
// grazing_reflectivity: 1.0,
// weight: clearcoat_weight,
// layer: clearcoat_bsdf,
// base: omni_PBR_bsdf,
// normal: final_clearcoat_normal
// );
bsdf opaque_clearcoat = df::weighted_layer(
weight: clearcoat_transparency,
layer: ::df::tint(
tint: clearcoat_tint,
base: omni_PBR_bsdf),
base: ::df::diffuse_reflection_bsdf(
tint: clearcoat_tint)
);
bsdf omni_PBR_coated_bsdf = df::fresnel_layer(
ior: clearcoat_ior,
weight: clearcoat_weight,
layer: clearcoat_bsdf,
base: opaque_clearcoat,
normal: final_clearcoat_normal
);
bsdf final_bsdf = enable_clearcoat ? omni_PBR_coated_bsdf : omni_PBR_bsdf;
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);
} in material(
thin_walled: false,
surface: material_surface(
scattering: final_bsdf,
emission: material_emission (
df::diffuse_edf(),
intensity: enable_emission ? emissive_color * emissive_mask * color(emissive_intensity) : color(0)
)
),
geometry: material_geometry(
normal: enable_clearcoat ? state::normal() : normal_lookup,
cutout_opacity: enable_alpha ? (enable_alpha_cutout ? (opacityValue < alpha_cutout_cutoff ? 0.0 : 1.0) : opacityValue) : 1.0
)
);123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290/*****************************************************************************
* Copyright 1986-2020 NVIDIA Corporation. All rights reserved.
******************************************************************************
MDL MATERIALS ARE PROVIDED PURSUANT TO AN END USER LICENSE AGREEMENT,
WHICH WAS ACCEPTED IN ORDER TO GAIN ACCESS TO THIS FILE. IN PARTICULAR,
THE MDL MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL NVIDIA
CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
THE USE OR INABILITY TO USE THE MDL MATERIALS OR FROM OTHER DEALINGS IN
THE MDL MATERIALS.
*/
mdl 1.4;
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(
// -------------------- SPECULAR REFLECTION/TRANSMISSION ----------------------
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")
]],
// -------------------- VOLUME ----------------------
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")
]],
// -------------------- EMISSIVE ----------------------
uniform bool enable_thin_walled = false
[[
anno::display_name("Enable Thin Walled"),
anno::description("Enables thin walled logic"),
anno::in_group("Geometry")
]],
// -------------------- EMISSIVE ----------------------
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")
]],
// -------------------- NORMAL ----------------------
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")
]],
// -------------------- UV ADJUSTMENTS ----------------------
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
);
// Need to use a small value so the compiler doesnt optimize out this var...
float t = 0.00000001;//state::animation_time();
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),
::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),
::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);
// Normal calculations
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
)
);123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562/*****************************************************************************
* Copyright 1986-2020 NVIDIA Corporation. All rights reserved.
******************************************************************************
MDL MATERIALS ARE PROVIDED PURSUANT TO AN END USER LICENSE AGREEMENT,
WHICH WAS ACCEPTED IN ORDER TO GAIN ACCESS TO THIS FILE. IN PARTICULAR,
THE MDL MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL NVIDIA
CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
THE USE OR INABILITY TO USE THE MDL MATERIALS OR FROM OTHER DEALINGS IN
THE MDL MATERIALS.
*/
mdl 1.4;
import ::df::*;
import ::state::*;
import ::math::*;
import ::base::*;
import ::tex::*;
import ::anno::*;
using .::SimPBR_Model import *;
using .::baking_annotations import *;
export material SimPBR(
// -------------------- DIFFUSE REFLECTION ----------------------
uniform color diffuse_color_constant = color(0.2f)
[[
anno::display_name("Albedo Base Color"),
anno::description("The base albedo color to use if no texture is specified"),
anno::in_group("Diffuse")
]],
uniform texture_2d diffuse_texture = texture_2d()
[[
anno::display_name("Albedo Map"),
anno::description("The texture specifying the albedo value to use"),
anno::in_group("Diffuse")
]],
uniform color diffuse_tint = color(1.0f)
[[
anno::display_name("Albedo Tint"),
anno::description("This tints the albedo color or texture contant"),
anno::in_group("Diffuse")
]],
uniform bool enable_transmission = false
[[
anno::display_name("Enable Diffuse Transmission"),
anno::description("Enables the diffuse transmission of light through thin diffuse scattering layer"),
anno::in_group("Diffuse")
]],
uniform float opacity_ratio = 1.f
[[
anno::enable_if("enable_transmission == true"),
anno::display_name("Opacity Ratio"),
anno::description("Amount of opacity"),
anno::in_group("Diffuse")
]],
uniform color opacity_tint = color(1.0f)
[[
anno::enable_if("enable_transmission == true"),
anno::display_name("Diffuse transmission tint"),
anno::description("Base diffuse transmission color"),
anno::in_group("Diffuse")
]],
uniform float opacity_multiplier = 1.f
[[
anno::enable_if("enable_transmission == true"),
anno::display_name("Diffuse transmission multiplier"),
anno::description("Base diffuse transmission multiplier"),
anno::in_group("Diffuse")
]],
// -------------------- SPECULAR REFLECTION ----------------------
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")
]],
float anisotropy_constant = 0.0f
[[
anno::display_name("Anisotropy Amount"),
anno::hard_range(-1.,1.),
anno::description("0 for isotropic, extents of -1 to 1 for anisotropy"),
anno::in_group("Specular")
]],
uniform float anisotropy_texture_influence = 0.0f
[[
anno::display_name("Anisotropy Map Influence"),
anno::hard_range(0.0, 1.),
anno::description("Blends between the constant value and the lookup of the anisotropy texture"),
anno::in_group("Specular")
]],
uniform texture_2d anisotropy_texture = texture_2d()
[[
anno::display_name("Anisotropy Map"),
anno::in_group("Specular")
]],
float metallic_constant = 0.f
[[
anno::display_name("Metallic Amount"),
anno::hard_range(0.0,1.),
anno::description("Metallic Material"),
anno::in_group("Specular")
]],
uniform float metallic_texture_influence = 0.0f
[[
anno::display_name("Metallic Map Influence"),
anno::hard_range(0.0, 1.),
anno::description("Blends between the constant value and the lookup of the metallic texture"),
anno::in_group("Specular")
]],
uniform texture_2d metallic_texture = texture_2d()
[[
anno::display_name("Metallic Map"),
anno::in_group("Specular")
]],
float specular_constant = 1.f
[[
anno::display_name("Specular amount"),
anno::hard_range(0.0, 1.0),
anno::description("Scale of the specular component"),
anno::in_group("Specular")
]],
uniform texture_2d specular_texture = texture_2d()
[[
anno::display_name("Specular Map"),
anno::in_group("Specular")
]],
// -------------------- ORM ----------------------
uniform bool enable_ORM_texture = true
[[
anno::display_name("Enable ORM Texture"),
anno::description("When True the ORM texture will be used to extract the Occlusion, Roughness and Metallic Map"),
anno::in_group("Reflectivity")
]],
uniform texture_2d ORM_texture = texture_2d()
[[
anno::display_name("ORM Map"),
anno::description("Texture that hae Occlusion, Roughness and Metallic map stored in the respective r, g and b channels"),
anno::in_group("Reflectivity")
]],
// -------------------- Clearcoat ----------------------
uniform bool enable_clearcoat = false
[[
anno::display_name("Enable Clearcoat Layer"),
anno::description("Adds a clearcoat layer on top of the material when enabled"),
anno::in_group("Clearcoat")
]],
color clearcoat_tint = color(1.0f)
[[
anno::display_name("Clearcoat Tint"),
anno::description("Clearcoat is tinted and affects the underlying material"),
anno::in_group("Clearcoat")
]],
float clearcoat_transparency = 1.0f
[[
anno::display_name("Clearcoat Transparency"),
anno::description("Adjusts the transparency of the clearcoat. Can be turned into a fully opaque clearcoat "
"covering the underlying layer"),
anno::in_group("Clearcoat")
]],
float clearcoat_reflection_roughness = 0.0f
[[
anno::display_name("Clearcoat Roughness"),
anno::description("Higher roughness values lead to more blurry reflections"),
anno::hard_range(0.0f, 1.0f),
anno::in_group("Clearcoat")
]],
float clearcoat_weight = 1.0f
[[
anno::display_name("Clearcoat Weight"),
anno::description("Sets the weight for clearcoat layer"),
anno::hard_range(0.0f, 1.0f),
anno::in_group("Clearcoat")
]],
float clearcoat_flatten = 1.0f
[[
anno::display_name("Clearcoat Flatten"),
anno::description("Flattens the clearcoat to even out the underlying bump maps"),
anno::hard_range(0.0f, 1.0f),
anno::in_group("Clearcoat")
]],
float clearcoat_ior = 1.56f
[[
anno::display_name("Clearcoat IOR"),
anno::description("Sets the Index of refraction for the clearcoat layer"),
anno::soft_range(1.0f, 4.0f),
anno::in_group("Clearcoat")
]],
uniform float clearcoat_bump_factor = 1.f
[[
anno::display_name("Clearcoat Normal Map Strength"),
anno::description("Strength of normal map."),
anno::in_group("Clearcoat")
]],
float3 clearcoat_normal_input = float3(0.0, 0.0, 0.0),
uniform texture_2d clearcoat_normalmap_texture = texture_2d()
[[
anno::display_name("Clearcoat Normal Map"),
anno::description("Enables the usage of the normalmap texture"),
anno::in_group("Clearcoat")
]],
uniform bool clearcoat_flip_tangent_u = false
[[
anno::display_name("Clearcoat Normal Map Flip U Tangent"),
anno::in_group("Clearcoat")
]],
uniform bool clearcoat_flip_tangent_v = true
[[
anno::display_name("Clearcoat Normal Map Flip V Tangent"),
anno::in_group("Clearcoat")
]],
// -------------------- REFLECTIVITY ----------------------
uniform bool enable_retroreflection = false
[[
anno::display_name("Enable Retroreflection"),
anno::in_group("Reflectivity")
]],
color retroreflection_tint = color(.182,.800,.000)
[[
anno::display_name("Retro-reflection tint"),
anno::description("The tint of the retroreflection"),
anno::in_group("Reflectivity")
]],
uniform float normal_reflectivity = 0.5
[[
anno::display_name("Retro-reflection weight facing"),
anno::hard_range(0.0,1.),
anno::description("Reflectivity control for geometry facing the viewer"),
anno::in_group("Reflectivity")
]],
uniform float grazing_reflectivity = 1.0
[[
anno::display_name("Retro-reflection weight edge"),
anno::hard_range(0.0,1.),
anno::description("Reflectivity control for the reflectivity at geometry edges"),
anno::in_group("Reflectivity")
]],
// -------------------- AMBIENT OCCLUSION ----------------------
float ao_to_diffuse = 0.0
[[
anno::display_name("AO to Diffuse"),
anno::description("Controls the amount of ambient occlusion multiplied into the diffuse color channel"),
anno::in_group("AO")
]],
float ao_input = float(1.0),
uniform texture_2d ao_texture = texture_2d()
[[
anno::display_name("Ambient Occlusion Map"),
anno::description("The Ambient Occlusion texture for the material"),
anno::in_group("AO")
]],
// -------------------- EMISSIVE ----------------------
uniform bool enable_emission = false
[[
anno::display_name("Enable Emission"),
anno::description("Enables the emission of light from the material"),
anno::in_group("Emissive")
]],
uniform 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")
]],
color emissive_mask_input = color(1.0),
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")
]],
// -------------------- ALPHA ----------------------
uniform bool enable_opacity = false
[[
anno::display_name("Enable Opacity"),
anno::description("Enables or disables alpha functionality"),
anno::in_group("Alpha")
]],
float alpha_constant = 1.0
[[
anno::enable_if("enable_opacity == true"),
anno::display_name("Opacity Fallback Constant"),
anno::hard_range(0.0, 1.0),
anno::description("The base alpha constant to use if no texture is specified"),
anno::in_group("Alpha")
]],
uniform texture_2d opacity_texture = texture_2d()
[[
anno::enable_if("enable_opacity == true"),
anno::display_name("Opacity Map"),
anno::description("The texture specifying the opacity value to use"),
anno::in_group("Alpha")
]],
uniform bool enable_opacity_cutout = false
[[
anno::enable_if("enable_opacity == true"),
anno::display_name("Enable Alpha Cutout"),
anno::description("Enables or disables alpha cutout functionality"),
anno::in_group("Alpha")
]],
uniform float alpha_cutout_cutoff = 1.f
[[
anno::enable_if("enable_opacity == true"),
anno::enable_if("enable_opacity_cutout == true"),
anno::hard_range(0.0, 1.0),
anno::display_name("Alpha Cutout Cutoff"),
anno::description("The cutoff value to to render as transparent up to and opaque past"),
anno::in_group("Alpha")
]],
// -------------------- NORMAL ----------------------
uniform float bump_factor = 1.f
[[
anno::display_name("Normal Map Strength"),
anno::description("Strength of normal map."),
anno::in_group("Normal")
]],
float3 normal_input = state::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::description("Flips the U Tangent vector."),
anno::in_group("Normal")
]],
uniform bool flip_tangent_v = true
[[
anno::display_name("Normal Map Flip V Tangent"),
anno::description("Flips the V Tangent vector. By Default, SimPBR materials setup for DirectX normal maps. Set Normal Map Flip V = false for OpenGL."),
anno::in_group("Normal")
]],
// -------------------- UV ADJUSTMENTS ----------------------
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 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"),
anno::description("Supports the opaque alpha cutout 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", "opaque", "alpha", "cutout", "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
);
// Need to use a small value so the compiler doesnt optimize out this var...
float t = 0.00000001;//state::animation_time();
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);
// Diffuse Color Lookup and AO
float4 base_lookup = tex::texture_isvalid(diffuse_texture) ? tex::lookup_float4(tex: diffuse_texture, coord: uv) : float4(1, 1, 1, 1);
float opacityValue = tex::texture_isvalid(opacity_texture) ? tex::lookup_float4(tex: opacity_texture, coord: uv).w : alpha_constant;
// Normal calculations
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
) : normal_input;
float3 clearcoat_normal = tex::texture_isvalid(clearcoat_normalmap_texture) ?
base::tangent_space_normal_texture(
texture: clearcoat_normalmap_texture,
factor: clearcoat_bump_factor,
uvw: uvw,
flip_tangent_u: clearcoat_flip_tangent_u,
flip_tangent_v: clearcoat_flip_tangent_v
) : clearcoat_normal_input;
float3 flattened_clearcoat_normal = ::math::lerp(normal_lookup, ::state::normal(), clearcoat_flatten);
float3 final_clearcoat_normal = tex::texture_isvalid(clearcoat_normalmap_texture) ? clearcoat_normal : flattened_clearcoat_normal;
float ao_lookup = tex::texture_isvalid(ao_texture) ? tex::lookup_float4(tex: ao_texture, coord: uv).x : ao_input;
color diffuse_color = tex::texture_isvalid(diffuse_texture) ? color(base_lookup.x, base_lookup.y, base_lookup.z) : diffuse_color_constant;
float3 ORM_lookup = tex::lookup_float3(
tex: ORM_texture,
coord: float2(transformed_uvw.position.x, transformed_uvw.position.y)
);
float roughness_lookup = tex::texture_isvalid(reflectionroughness_texture) ?
tex::lookup_float4(tex: reflectionroughness_texture, coord: uv).x : reflection_roughness_constant;
float anisotropy_lookup = tex::texture_isvalid(anisotropy_texture) ?
(tex::lookup_float4(tex: anisotropy_texture, coord: uv).x * 2.0f - 1.0f) : anisotropy_constant;
float metallic_lookup = tex::texture_isvalid(metallic_texture) ?
tex::lookup_float4(tex: metallic_texture, coord: uv).x : metallic_constant;
float specular_lookup = tex::texture_isvalid(specular_texture) ?
tex::lookup_float4(tex: specular_texture, coord: uv).x : specular_constant;
float roughness_selection = enable_ORM_texture ? ORM_lookup.y : roughness_lookup;
float metallic_selection = enable_ORM_texture ? ORM_lookup.z : metallic_lookup;
float ao = enable_ORM_texture ? ORM_lookup.x : ao_lookup;
float reflection_roughness = math::lerp(reflection_roughness_constant, roughness_selection, reflection_roughness_texture_influence);
float anisotropy = math::lerp(anisotropy_constant, anisotropy_lookup, anisotropy_texture_influence);
float metallic = math::lerp(metallic_constant, metallic_selection, metallic_texture_influence);
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) : emissive_mask_input;
} in SimPBR_Model(
diffuse_color: diffuse_color,
diffuse_tint: diffuse_tint,
roughness: reflection_roughness,
anisotropy: anisotropy,
metallic: metallic,
specular: specular_lookup,
normal: normal_lookup,
enable_clearcoat: enable_clearcoat,
clearcoat_tint: clearcoat_tint,
clearcoat_transparency: clearcoat_transparency,
clearcoat_reflection_roughness: clearcoat_reflection_roughness,
clearcoat_weight: clearcoat_weight,
clearcoat_ior: clearcoat_ior,
clearcoat_normal: final_clearcoat_normal,
enable_retroreflection: enable_retroreflection,
retroreflection_tint: retroreflection_tint,
normal_reflectivity: normal_reflectivity,
grazing_reflectivity: grazing_reflectivity,
ao_to_diffuse: ao_to_diffuse,
ao: ao,
enable_emission: enable_emission,
emissive_color: emissive_color,
emissive_mask: emissive_mask,
emissive_intensity: emissive_intensity,
enable_opacity: enable_opacity,
alpha: opacityValue,
enable_opacity_cutout: enable_opacity_cutout,
alpha_cutout_cutoff: alpha_cutout_cutoff,
opacity_ratio: enable_transmission ? opacity_ratio : 1.0,
opacity_tint : opacity_tint,
opacity_multiplier : opacity_multiplier
);123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212/*****************************************************************************
* Copyright 1986-2020 NVIDIA Corporation. All rights reserved.
******************************************************************************
MDL MATERIALS ARE PROVIDED PURSUANT TO AN END USER LICENSE AGREEMENT,
WHICH WAS ACCEPTED IN ORDER TO GAIN ACCESS TO THIS FILE. IN PARTICULAR,
THE MDL MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL NVIDIA
CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
THE USE OR INABILITY TO USE THE MDL MATERIALS OR FROM OTHER DEALINGS IN
THE MDL MATERIALS.
*/
mdl 1.4;
import ::df::*;
import ::state::*;
import ::math::*;
import ::base::*;
import ::tex::*;
import ::anno::*;
using .::baking_annotations import *;
base::texture_return multiply_colors(
color color_1 = color(1.0, 1.0, 1.0),
color color_2 = color(.5, .5, .5),
float weight = 1.0
)
[[
anno::hidden()
]]
{
return base::blend_color_layers(
layers: base::color_layer[](
base::color_layer(
layer_color: color_2,
weight: weight,
mode: base::color_layer_multiply
)
), base: color_1
);
}
export material SimPBR_Model(
color diffuse_color = color(0.2f) [[ target_baked_argument("diffuse_texture", "diffuse_color_constant", "RGBA8_UNORM") ]],
uniform color diffuse_tint = color(1.0f),
float roughness = 0.5f [[ target_baked_argument("reflectionroughness_texture", "reflection_roughness_constant", "R8_UNORM") ]],
float anisotropy = 0.0f [[ target_baked_argument("anisotropy_texture", "anisotropy_constant", "R8_SNORM") ]],
float metallic = 0.f [[ target_baked_argument("metallic_texture", "metallic_constant", "R8_UNORM") ]],
float specular = 1.f [[ target_baked_argument("specular_texture", "specular_constant", "R8_UNORM") ]],
float3 normal = float3(0.0, 0.0, 0.0) [[ target_baked_argument("normalmap_texture", "normal_input", "RGBA8_SNORM", baking_annotations::TRANSFORM_UNORM_VECTOR) ]],
uniform bool enable_clearcoat = false,
color clearcoat_tint = color(1.0f),
float clearcoat_transparency = 1.0f,
float clearcoat_reflection_roughness = 0.0f,
float clearcoat_weight = 1.0f,
float clearcoat_ior = 1.56f,
float3 clearcoat_normal = float3(0.0, 0.0, 0.0) [[ target_baked_argument("clearcoat_normalmap_texture", "clearcoat_normal_input", "RGBA8_SNORM", baking_annotations::TRANSFORM_UNORM_VECTOR) ]],
uniform bool enable_retroreflection = false,
color retroreflection_tint = color(.182,.800,.000),
uniform float normal_reflectivity = 0.5,
uniform float grazing_reflectivity = 1.0,
float ao_to_diffuse = 0.0,
float ao = 1.0f [[ target_baked_argument("ao_texture", "ao_input", "R8_UNORM") ]],
uniform bool enable_emission = false,
uniform color emissive_color = color(1.0, 0.1, 0.1),
color emissive_mask = color(1.0, 0.1, 0.1) [[ target_baked_argument("emissive_mask_texture", "emissive_mask_input", "R8_UNORM") ]],
uniform float emissive_intensity = 40.f,
uniform bool enable_opacity = false,
float alpha = 1.0,
uniform bool enable_opacity_cutout = false,
uniform float alpha_cutout_cutoff = 1.f,
uniform float opacity_ratio = 1.f,
uniform color opacity_tint = color(1.0f),
uniform float opacity_multiplier = 1.f
)
[[
target_material_model(),
target_material_rendering("..::SimPBR::SimPBR")
]]
= let {
color base_color = multiply_colors(diffuse_color, diffuse_tint, 1.0).tint;
color ao_weighted_base_color = multiply_colors(base_color, color(ao), ao_to_diffuse).tint;
float squared_roughness = roughness * roughness;
float roughness_u = squared_roughness * (1 + anisotropy);
float roughness_v = squared_roughness * (1 - anisotropy);
color diffuse_transmission_color = base_color * opacity_tint * opacity_multiplier;
bsdf diffuse_bsdf = df::weighted_layer(
weight: opacity_ratio,
layer: df::diffuse_reflection_bsdf(
tint: ao_weighted_base_color,
roughness: 0.0f
),
base: df::diffuse_transmission_bsdf(tint: diffuse_transmission_color),
normal: enable_clearcoat ? normal : state::normal()
);
bsdf ggx_smith_bsdf = df::microfacet_ggx_smith_bsdf(
roughness_u: roughness_u,
roughness_v: roughness_v,
tint: color(1.0, 1.0, 1.0),
mode: df::scatter_reflect
);
bsdf custom_curve_layer_bsdf = df::custom_curve_layer(
normal_reflectivity: 0.03,
grazing_reflectivity: 1.0,
exponent: 5.0,
weight: specular,
layer: ggx_smith_bsdf,
base: diffuse_bsdf,
normal: enable_clearcoat ? normal : state::normal()
);
//
// Begin RETROREFLECTION SUPPORT
//
color final_retroreflection_color = multiply_colors(retroreflection_tint, base_color, 1.0).tint;
bsdf backscattering_glossy_bsdf = df::backscattering_glossy_reflection_bsdf(
tint: final_retroreflection_color,
roughness_u: squared_roughness
);
/*bsdf retroreflection_bsdf = df::custom_curve_layer(
normal_reflectivity: 1.-normal_reflectivity,
grazing_reflectivity: 1.-grazing_reflectivity,
base: backscattering_glossy_bsdf,
layer: custom_curve_layer_bsdf,
normal: enable_clearcoat ? normal_lookup : state::normal()
);*/
// if normal_reflectivity and grazing_reflectivity are 1 and weight is 1, just the layer is used
bsdf opt_retroreflection_bsdf = df::custom_curve_layer(
normal_reflectivity: enable_retroreflection ? 1.-normal_reflectivity : 1,
grazing_reflectivity: enable_retroreflection ? 1.-grazing_reflectivity : 1,
base: backscattering_glossy_bsdf,
layer: custom_curve_layer_bsdf,
normal: enable_clearcoat ? normal : state::normal()
);
//
// End RETROREFLECTION SUPPORT
//
bsdf directional_factor_bsdf = df::directional_factor(
normal_tint: ao_weighted_base_color,
grazing_tint: color(1.0, 1.0, 1.0),
exponent: 5.0f,
base: ggx_smith_bsdf
);
// CLEARCOAT
bsdf omni_PBR_bsdf = df::weighted_layer(
weight: metallic,
layer: directional_factor_bsdf,
base: opt_retroreflection_bsdf, //enable_retroreflection ? retroreflection_bsdf : custom_curve_layer_bsdf,
normal: enable_clearcoat ? normal : state::normal()
);
bsdf clearcoat_bsdf = df::microfacet_ggx_smith_bsdf(
roughness_u: clearcoat_reflection_roughness * clearcoat_reflection_roughness,
roughness_v: clearcoat_reflection_roughness * clearcoat_reflection_roughness,
tint: color(1.0f),
mode: df::scatter_reflect
);
// bsdf omni_PBR_coated_bsdf = df::custom_curve_layer(
// normal_reflectivity: clearcoat_reflectivity * 0.08,
// grazing_reflectivity: 1.0,
// weight: clearcoat_weight,
// layer: clearcoat_bsdf,
// base: omni_PBR_bsdf,
// normal: final_clearcoat_normal
// );
bsdf opt_opaque_clearcoat = df::weighted_layer(
weight: enable_clearcoat ? clearcoat_transparency : 1,
layer: ::df::tint(tint: enable_clearcoat ? clearcoat_tint : color(1), base: omni_PBR_bsdf),
base: ::df::diffuse_reflection_bsdf(tint: clearcoat_tint)
);
bsdf opt_omni_PBR_coated_bsdf = df::fresnel_layer(
ior: clearcoat_ior,
weight: enable_clearcoat ? clearcoat_weight : 0,
layer: clearcoat_bsdf,
base: opt_opaque_clearcoat,
normal: clearcoat_normal
);
bsdf final_bsdf = opt_omni_PBR_coated_bsdf;
} in material(
thin_walled: false,
surface: material_surface(
scattering: final_bsdf,
emission: material_emission(
df::diffuse_edf(),
intensity: enable_emission ? emissive_color * emissive_mask * color(emissive_intensity) : color(0)
)
),
geometry: material_geometry(
normal: enable_clearcoat ? state::normal() : normal,
cutout_opacity: enable_opacity ? (enable_opacity_cutout ? (alpha < alpha_cutout_cutoff ? 0.0 : 1.0) : alpha) : 1.0
)
);123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651/*****************************************************************************
* Copyright 1986-2020 NVIDIA Corporation. All rights reserved.
******************************************************************************
MDL MATERIALS ARE PROVIDED PURSUANT TO AN END USER LICENSE AGREEMENT,
WHICH WAS ACCEPTED IN ORDER TO GAIN ACCESS TO THIS FILE. IN PARTICULAR,
THE MDL MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL NVIDIA
CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
THE USE OR INABILITY TO USE THE MDL MATERIALS OR FROM OTHER DEALINGS IN
THE MDL MATERIALS.
*/
mdl 1.4;
import ::df::*;
import ::state::*;
import ::math::*;
import ::base::*;
import ::tex::*;
import ::anno::*;
import ::nvidia::core_definitions::file_texture;
import ::nvidia::core_definitions::normalmap_texture;
float4 raw_file_texture(
uniform texture_2d texture
[[ anno::description("The input texture") ]],
base::texture_coordinate_info uvw = base::texture_coordinate_info()
[[ anno::description("Custom value for texture coordinate") ]],
uniform float2 crop_u = float2(0.0, 1.0)
[[ anno::description("Restricts the texture access to sub-domain of the texture in the u direction") ]],
uniform float2 crop_v = float2(0.0, 1.0)
[[ anno::description("Restricts the texture access to sub-domain of the texture in the v direction") ]],
uniform tex::wrap_mode wrap_u = tex::wrap_repeat
[[ anno::description("Wrapping mode in the u direction") ]],
uniform tex::wrap_mode wrap_v = tex::wrap_repeat
[[ anno::description("Wrapping mode in the v direction") ]]
)
[[
anno::description("General texturing function for 2D bitmap texture stored in a file"),
anno::noinline()
]]
{
return tex::lookup_float4(texture, float2(uvw.position.x, uvw.position.y), wrap_u, wrap_v, crop_u, crop_v);
}
base::texture_return multiply_colors(
color color_1 = color(1.0, 1.0, 1.0),
color color_2 = color(.5, .5, .5),
float weight = 1.0
) [[
anno::hidden()
]]
{
return base::blend_color_layers(
layers: base::color_layer[](
base::color_layer(
layer_color: color_2,
weight: weight,
mode: base::color_layer_multiply
)),
base: color_1
);
}
base::texture_return add_colors(
color color_1 = color(.5, .5, .5),
color color_2 = color(.5, .5, .5),
float weight = 1.0
) [[
anno::hidden(),
anno::unused()
]]
{
return base::blend_color_layers(
layers: base::color_layer[](
base::color_layer(
layer_color: color_2,
weight: weight,
mode: base::color_layer_add
)),
base: color_1
);
}
base::texture_return blend_colors(
color color_1 = color(1.0, 1.0, 1.0),
color color_2 = color(.5, .5, .5),
float weight = 1.0
) [[
anno::hidden(),
anno::unused()
]]
{
return base::blend_color_layers(
layers: base::color_layer[](
base::color_layer(
layer_color: color_2,
weight: weight,
mode: base::color_layer_blend
)),
base: color_1
);
}
export material SimPBR_Opacity(
// -------------------- DIFFUSE REFLECTION ----------------------
uniform color diffuse_color_constant = color(0.2f)
[[
anno::display_name("Albedo Base Color"),
anno::description("The base albedo color to use if no texture is specified"),
anno::in_group("Diffuse")
]],
uniform texture_2d diffuse_texture = texture_2d()
[[
anno::display_name("Albedo Map"),
anno::description("The texture specifying the albedo value to use"),
anno::in_group("Diffuse")
]],
uniform color diffuse_tint = color(1.0f)
[[
anno::display_name("Albedo Tint"),
anno::description("This tints the albedo color or texture contant"),
anno::in_group("Diffuse")
]],
// -------------------- SPECULAR REFLECTION ----------------------
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")
]],
uniform float anisotropy_constant = 0.0f
[[
anno::display_name("Anisotropy Amount"),
anno::hard_range(-1.,1.),
anno::description("0 for isotropic, extents of -1 to 1 for anisotropy"),
anno::in_group("Specular")
]],
uniform float anisotropy_texture_influence = 0.0f
[[
anno::display_name("Anisotropy Map Influence"),
anno::hard_range(0.0, 1.),
anno::description("Blends between the constant value and the lookup of the anisotropy texture"),
anno::in_group("Specular")
]],
uniform texture_2d anisotropy_texture = texture_2d()
[[
anno::display_name("Anisotropy Map"),
anno::in_group("Specular")
]],
uniform float metallic_constant = 0.f
[[
anno::display_name("Metallic Amount"),
anno::hard_range(0.0,1.),
anno::description("Metallic Material"),
anno::in_group("Specular")
]],
uniform float metallic_texture_influence = 0.0f
[[
anno::display_name("Metallic Map Influence"),
anno::hard_range(0.0, 1.),
anno::description("Blends between the constant value and the lookup of the metallic texture"),
anno::in_group("Specular")
]],
uniform texture_2d metallic_texture = texture_2d()
[[
anno::display_name("Metallic Map"),
anno::in_group("Specular")
]],
// -------------------- ORM ----------------------
uniform bool enable_ORM_texture = true
[[
anno::display_name("Enable ORM Texture"),
anno::description("When True the ORM texture will be used to extract the Occlusion, Roughness and Metallic Map"),
anno::in_group("Reflectivity")
]],
uniform texture_2d ORM_texture = texture_2d()
[[
anno::display_name("ORM Map"),
anno::description("Texture that hae Occlusion, Roughness and Metallic map stored in the respective r, g and b channels"),
anno::in_group("Reflectivity")
]],
// -------------------- Clearcoat ----------------------
uniform bool enable_clearcoat = false
[[
anno::display_name("Enable Clearcoat Layer"),
anno::description("Adds a clearcoat layer on top of the material when enabled"),
anno::in_group("Clearcoat")
]],
color clearcoat_tint = color(1.0f)
[[
anno::display_name("Clearcoat Tint"),
anno::description("Clearcoat is tinted and affects the underlying material"),
anno::in_group("Clearcoat")
]],
float clearcoat_transparency = 1.0f
[[
anno::display_name("Clearcoat Transparency"),
anno::description("Adjusts the transparency of the clearcoat. Can be turned into a fully opaque clearcoat "
"covering the underlying layer"),
anno::in_group("Clearcoat")
]],
float clearcoat_reflection_roughness = 0.0f
[[
anno::display_name("Clearcoat Roughness"),
anno::description("Higher roughness values lead to more blurry reflections"),
anno::hard_range(0.0f, 1.0f),
anno::in_group("Clearcoat")
]],
float clearcoat_weight = 1.0f
[[
anno::display_name("Clearcoat Weight"),
anno::description("Sets the weight for clearcoat layer"),
anno::hard_range(0.0f, 1.0f),
anno::in_group("Clearcoat")
]],
float clearcoat_flatten = 1.0f
[[
anno::display_name("Clearcoat Flatten"),
anno::description("Flattens the clearcoat to even out the underlying bump maps"),
anno::hard_range(0.0f, 1.0f),
anno::in_group("Clearcoat")
]],
float clearcoat_ior = 1.56f
[[
anno::display_name("Clearcoat IOR"),
anno::description("Sets the Index of refraction for the clearcoat layer"),
anno::soft_range(1.0f, 4.0f),
anno::in_group("Clearcoat")
]],
uniform float clearcoat_bump_factor = 1.f
[[
anno::display_name("Clearcoat Normal Map Strength"),
anno::description("Strength of normal map."),
anno::in_group("Clearcoat")
]],
uniform texture_2d clearcoat_normalmap_texture = texture_2d()
[[
anno::display_name("Clearcoat Normal Map"),
anno::description("Enables the usage of the normalmap texture"),
anno::in_group("Clearcoat")
]],
// -------------------- REFLECTIVITY ----------------------
uniform bool enable_retroreflection = false
[[
anno::display_name("Enable Retroreflection"),
anno::in_group("Reflectivity")
]],
color retroreflection_color = color(.182,.800,.000)
[[
anno::display_name("Retro-reflection color"),
anno::description("The color of the retroreflection"),
anno::in_group("Reflectivity")
]],
uniform float normal_reflectivity = 0.5
[[
anno::display_name("Retro-reflection weight facing"),
anno::hard_range(0.0,1.),
anno::description("Reflectivity control for geometry facing the viewer"),
anno::in_group("Reflectivity")
]],
uniform float grazing_reflectivity = 1.0
[[
anno::display_name("Retro-reflection weight edge"),
anno::hard_range(0.0,1.),
anno::description("Reflectivity control for the reflectivity at geometry edges"),
anno::in_group("Reflectivity")
]],
// -------------------- AMBIENT OCCLUSION ----------------------
float ao_to_diffuse = 0.0
[[
anno::display_name("AO to Diffuse"),
anno::description("Controls the amount of ambient occlusion multiplied into the diffuse color channel"),
anno::in_group("AO")
]],
uniform texture_2d ao_texture = texture_2d()
[[
anno::display_name("Ambient Occlusion Map"),
anno::description("The Ambient Occlusion texture for the material"),
anno::in_group("AO")
]],
// -------------------- EMISSIVE ----------------------
uniform bool enable_emission = false
[[
anno::display_name("Enable Emission"),
anno::description("Enables the emission of light from the material"),
anno::in_group("Emissive")
]],
uniform 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")
]],
// -------------------- ALPHA ----------------------
uniform bool enable_alpha = true
[[
anno::display_name("Enable Alpha"),
anno::description("Enables or disables alpha functionality"),
anno::in_group("Alpha")
]],
uniform float alpha_constant = 1.0
[[
anno::display_name("Alpha Fallback Constant"),
anno::description("The base alpha constant to use if no texture is specified"),
anno::in_group("Alpha")
]],
uniform texture_2d opacity_texture = texture_2d()
[[
anno::display_name("Opacity Map"),
anno::description("The texture specifying the opacity value to use"),
anno::in_group("Alpha")
]],
uniform bool enable_alpha_cutout = false
[[
anno::display_name("Enable Alpha Cutout"),
anno::description("Enables or disables alpha cutout functionality"),
anno::in_group("Alpha")
]],
uniform float alpha_cutout_cutoff = 1.f
[[
anno::enable_if("enable_alpha_cutout == true"),
anno::hard_range(0.0, 1.0),
anno::display_name("Alpha Cutout Cutoff"),
anno::description("The cutoff value to to render as transparent up to and opaque past"),
anno::in_group("Alpha")
]],
// -------------------- NORMAL ----------------------
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")
]],
// -------------------- UV ADJUSTMENTS ----------------------
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 Scale"),
anno::description("Larger number increases size of 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 Opaque Alpha Cutout"),
anno::description("Supports the opaque alpha cutout material model of the Sim Renderer"),
anno::version( 1, 0, 0),
anno::author("NVIDIA CORPORATION"),
anno::key_words(string[]("Sim", "PBR", "opaque", "alpha", "cutout", "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
);
// Need to use a small value so the compiler doesnt optimize out this var...
float t = 0.00000001;//state::animation_time();
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 );
// Diffuse Color Lookup and AO
float4 base_lookup = tex::texture_isvalid(diffuse_texture) ? raw_file_texture(texture: diffuse_texture, uvw: transformed_uvw) : float4(1, 1, 1, 1);
float opacityValue = tex::texture_isvalid(opacity_texture) ? raw_file_texture(texture: opacity_texture, uvw: transformed_uvw).x : alpha_constant;
// Normal calculations
float3 normal_lookup = tex::texture_isvalid(normalmap_texture) ?
base::tangent_space_normal_texture(
texture: normalmap_texture,
factor: bump_factor,
uvw: transformed_uvw
) : state::normal();
float3 clearcoat_normal = base::tangent_space_normal_texture(
texture: clearcoat_normalmap_texture,
factor: clearcoat_bump_factor,
uvw: uvw
);
float3 flattened_clearcoat_normal = ::math::lerp(normal_lookup, ::state::normal(), clearcoat_flatten);
float3 final_clearcoat_normal = tex::texture_isvalid(clearcoat_normalmap_texture) ? clearcoat_normal : flattened_clearcoat_normal;
float ao_lookup = tex::texture_isvalid(ao_texture) ?
raw_file_texture(texture: ao_texture, uvw: transformed_uvw).x :
1.0f
[[anno::unused("Currently unused in material, may be utilized in the future")]];
color diffuse_color = tex::texture_isvalid(diffuse_texture) ? color(base_lookup.x, base_lookup.y, base_lookup.z) : diffuse_color_constant;
color base_color = multiply_colors(diffuse_color, diffuse_tint, 1.0).tint;
float3 ORM_lookup = tex::lookup_float3(
tex: ORM_texture,
coord: float2(transformed_uvw.position.x, transformed_uvw.position.y)
);
float roughness_lookup = tex::texture_isvalid(reflectionroughness_texture) ?
raw_file_texture(texture: reflectionroughness_texture, uvw: transformed_uvw).x :
reflection_roughness_constant;
float anisotropy_lookup = tex::texture_isvalid(anisotropy_texture) ?
(raw_file_texture(texture: anisotropy_texture, uvw: transformed_uvw).x * 2.0f - 1.0f) :
anisotropy_constant;
float metallic_lookup = tex::texture_isvalid(metallic_texture) ?
raw_file_texture(texture: metallic_texture, uvw: transformed_uvw).x :
metallic_constant;
float roughness_selection = enable_ORM_texture ? ORM_lookup.y : roughness_lookup;
float metallic_selection = enable_ORM_texture ? ORM_lookup.z : metallic_lookup;
color ao_color = enable_ORM_texture ? color(ORM_lookup.x) : color(ao_lookup);
color ao_weighted_base_color = multiply_colors(base_color, ao_color, ao_to_diffuse).tint;
float reflection_roughness = math::lerp(reflection_roughness_constant, roughness_selection, reflection_roughness_texture_influence);
float anisotropy = math::lerp(anisotropy_constant, anisotropy_lookup, anisotropy_texture_influence);
float metallic = math::lerp(metallic_constant, metallic_selection, metallic_texture_influence);
float squared_roughness = reflection_roughness * reflection_roughness;
float roughness_u = squared_roughness * (1 + anisotropy);
float roughness_v = squared_roughness * (1 - anisotropy);
bsdf diffuse_bsdf = df::weighted_layer(
weight: 1.0,
layer: df::diffuse_reflection_bsdf(
tint: ao_weighted_base_color,
roughness: 0.f ),
base: bsdf(),
normal: enable_clearcoat ? normal_lookup : state::normal()
);
bsdf ggx_smith_bsdf = df::microfacet_ggx_smith_bsdf(
roughness_u: roughness_u,
roughness_v: roughness_v,
tint: color(1.0, 1.0, 1.0),
mode: df::scatter_reflect
);
bsdf custom_curve_layer_bsdf = df::custom_curve_layer(
normal_reflectivity: 0.03,
grazing_reflectivity: 1.0,
exponent: 5.0,
weight: float(1.0),
layer: ggx_smith_bsdf,
base: diffuse_bsdf,
normal: enable_clearcoat ? normal_lookup : state::normal()
);
//
// Begin RETROREFLECTION SUPPORT
//
bsdf backscattering_glossy_bsdf = df::backscattering_glossy_reflection_bsdf(
tint: retroreflection_color,
roughness_u: reflection_roughness * reflection_roughness
);
bsdf retroreflection_bsdf = df::custom_curve_layer(
normal_reflectivity: 1.-normal_reflectivity,
grazing_reflectivity: 1.-grazing_reflectivity,
base: backscattering_glossy_bsdf,
layer: diffuse_bsdf,
normal: enable_clearcoat ? normal_lookup : state::normal()
);
//
// End RETROREFLECTION SUPPORT
//
bsdf directional_factor_bsdf = df::directional_factor(
normal_tint: ao_weighted_base_color,
grazing_tint: color(1.0, 1.0, 1.0),
exponent: 5.0f,
base: ggx_smith_bsdf
);
// CLEARCOAT
bsdf omni_PBR_bsdf = df::weighted_layer(
weight: metallic,
layer: directional_factor_bsdf,
base: enable_retroreflection ? retroreflection_bsdf : custom_curve_layer_bsdf,
normal: enable_clearcoat ? normal_lookup : state::normal()
);
bsdf clearcoat_bsdf = df::microfacet_ggx_smith_bsdf(
roughness_u: clearcoat_reflection_roughness * clearcoat_reflection_roughness,
roughness_v: clearcoat_reflection_roughness * clearcoat_reflection_roughness,
tint: color(1.0f),
mode: df::scatter_reflect
);
// bsdf omni_PBR_coated_bsdf = df::custom_curve_layer(
// normal_reflectivity: clearcoat_reflectivity * 0.08,
// grazing_reflectivity: 1.0,
// weight: clearcoat_weight,
// layer: clearcoat_bsdf,
// base: omni_PBR_bsdf,
// normal: final_clearcoat_normal
// );
bsdf opaque_clearcoat = df::weighted_layer(
weight: clearcoat_transparency,
layer: ::df::tint(
tint: clearcoat_tint,
base: omni_PBR_bsdf),
base: ::df::diffuse_reflection_bsdf(
tint: clearcoat_tint)
);
bsdf omni_PBR_coated_bsdf = df::fresnel_layer(
ior: clearcoat_ior,
weight: clearcoat_weight,
layer: clearcoat_bsdf,
base: opaque_clearcoat,
normal: final_clearcoat_normal
);
bsdf final_bsdf = enable_clearcoat ? omni_PBR_coated_bsdf : omni_PBR_bsdf;
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);
} in material(
thin_walled: false,
surface: material_surface(
scattering: final_bsdf,
emission: material_emission (
df::diffuse_edf(),
intensity: enable_emission ? emissive_color * emissive_mask * color(emissive_intensity) : color(0)
)
),
geometry: material_geometry(
normal: enable_clearcoat ? state::normal() : normal_lookup,
cutout_opacity: enable_alpha ? (enable_alpha_cutout ? (opacityValue < alpha_cutout_cutoff ? 0.0 : 1.0) : opacityValue) : 1.0
)
);123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290/*****************************************************************************
* Copyright 1986-2020 NVIDIA Corporation. All rights reserved.
******************************************************************************
MDL MATERIALS ARE PROVIDED PURSUANT TO AN END USER LICENSE AGREEMENT,
WHICH WAS ACCEPTED IN ORDER TO GAIN ACCESS TO THIS FILE. IN PARTICULAR,
THE MDL MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL NVIDIA
CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
THE USE OR INABILITY TO USE THE MDL MATERIALS OR FROM OTHER DEALINGS IN
THE MDL MATERIALS.
*/
mdl 1.4;
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(
// -------------------- SPECULAR REFLECTION/TRANSMISSION ----------------------
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")
]],
// -------------------- VOLUME ----------------------
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")
]],
// -------------------- EMISSIVE ----------------------
uniform bool enable_thin_walled = false
[[
anno::display_name("Enable Thin Walled"),
anno::description("Enables thin walled logic"),
anno::in_group("Geometry")
]],
// -------------------- EMISSIVE ----------------------
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")
]],
// -------------------- NORMAL ----------------------
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")
]],
// -------------------- UV ADJUSTMENTS ----------------------
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
);
// Need to use a small value so the compiler doesnt optimize out this var...
float t = 0.00000001;//state::animation_time();
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),
::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),
::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);
// Normal calculations
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
)
);12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152mdl 1.7;
using ::OmniPBR import OmniPBR;
import ::tex::gamma_mode;
import ::state::normal;
import ::base::mono_mode;
export material Plastic_B(*)
= OmniPBR(
diffuse_color_constant: color(),
diffuse_texture: texture_2d(),
albedo_desaturation: 0.0,
albedo_add: 0.0,
albedo_brightness: 1.0,
diffuse_tint: color(1, 1, 1),
reflection_roughness_constant: 0.5,
reflection_roughness_texture_influence: 1.0,
reflectionroughness_texture: texture_2d(),
metallic_constant: 0.0,
metallic_texture_influence: 1.0,
metallic_texture: texture_2d(),
specular_level: 0.5,
enable_ORM_texture: true,
ORM_texture: texture_2d("../textures/T_Plastic_ORM_1k.png", ::tex::gamma_linear),
ao_to_diffuse: 0.0,
ao_texture: texture_2d(),
enable_emission: false,
emissive_color: color(1, 0.1, 0.1),
emissive_color_texture: texture_2d(),
emissive_mask_texture: texture_2d(),
emissive_intensity: 40.0,
enable_opacity: false,
enable_opacity_texture: false,
opacity_constant: 1.0,
opacity_texture: texture_2d(),
opacity_mode: ::base::mono_average,
opacity_threshold: 0.0,
bump_factor: 1.0,
normalmap_texture: texture_2d("../textures/T_Plastic_Normal_1k.png", ::tex::gamma_linear),
detail_bump_factor: 0.30000001192092896,
detail_normalmap_texture: texture_2d(),
flip_tangent_u: false,
flip_tangent_v: true,
project_uvw: false,
world_or_object: false,
uv_space_index: 0,
texture_translate: float2(0, 0),
texture_rotate: 0.0,
texture_scale: float2(3, 3),
detail_texture_translate: float2(0, 0),
detail_texture_rotate: 0.0,
detail_texture_scale: float2(1, 1));12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152mdl 1.7;
using ::OmniPBR import OmniPBR;
import ::tex::gamma_mode;
import ::state::normal;
import ::base::mono_mode;
export material Plastic_B(*)
= OmniPBR(
diffuse_color_constant: color(),
diffuse_texture: texture_2d(),
albedo_desaturation: 0.0,
albedo_add: 0.0,
albedo_brightness: 1.0,
diffuse_tint: color(1, 1, 1),
reflection_roughness_constant: 0.5,
reflection_roughness_texture_influence: 1.0,
reflectionroughness_texture: texture_2d(),
metallic_constant: 0.0,
metallic_texture_influence: 1.0,
metallic_texture: texture_2d(),
specular_level: 0.5,
enable_ORM_texture: true,
ORM_texture: texture_2d("../textures/T_Plastic_ORM_1k.png", ::tex::gamma_linear),
ao_to_diffuse: 0.0,
ao_texture: texture_2d(),
enable_emission: false,
emissive_color: color(1, 0.1, 0.1),
emissive_color_texture: texture_2d(),
emissive_mask_texture: texture_2d(),
emissive_intensity: 40.0,
enable_opacity: false,
enable_opacity_texture: false,
opacity_constant: 1.0,
opacity_texture: texture_2d(),
opacity_mode: ::base::mono_average,
opacity_threshold: 0.0,
bump_factor: 1.0,
normalmap_texture: texture_2d("../textures/T_Plastic_Normal_1k.png", ::tex::gamma_linear),
detail_bump_factor: 0.30000001192092896,
detail_normalmap_texture: texture_2d(),
flip_tangent_u: false,
flip_tangent_v: true,
project_uvw: false,
world_or_object: false,
uv_space_index: 0,
texture_translate: float2(0, 0),
texture_rotate: 0.0,
texture_scale: float2(3, 3),
detail_texture_translate: float2(0, 0),
detail_texture_rotate: 0.0,
detail_texture_scale: float2(1, 1));12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152mdl 1.7;
using ::OmniPBR import OmniPBR;
import ::tex::gamma_mode;
import ::state::normal;
import ::base::mono_mode;
export material Plastic_B(*)
= OmniPBR(
diffuse_color_constant: color(),
diffuse_texture: texture_2d(),
albedo_desaturation: 0.0,
albedo_add: 0.0,
albedo_brightness: 1.0,
diffuse_tint: color(1, 1, 1),
reflection_roughness_constant: 0.5,
reflection_roughness_texture_influence: 1.0,
reflectionroughness_texture: texture_2d(),
metallic_constant: 0.0,
metallic_texture_influence: 1.0,
metallic_texture: texture_2d(),
specular_level: 0.5,
enable_ORM_texture: true,
ORM_texture: texture_2d("../textures/T_Plastic_ORM_1k.png", ::tex::gamma_linear),
ao_to_diffuse: 0.0,
ao_texture: texture_2d(),
enable_emission: false,
emissive_color: color(1, 0.1, 0.1),
emissive_color_texture: texture_2d(),
emissive_mask_texture: texture_2d(),
emissive_intensity: 40.0,
enable_opacity: false,
enable_opacity_texture: false,
opacity_constant: 1.0,
opacity_texture: texture_2d(),
opacity_mode: ::base::mono_average,
opacity_threshold: 0.0,
bump_factor: 1.0,
normalmap_texture: texture_2d("../textures/T_Plastic_Normal_1k.png", ::tex::gamma_linear),
detail_bump_factor: 0.30000001192092896,
detail_normalmap_texture: texture_2d(),
flip_tangent_u: false,
flip_tangent_v: true,
project_uvw: false,
world_or_object: false,
uv_space_index: 0,
texture_translate: float2(0, 0),
texture_rotate: 0.0,
texture_scale: float2(3, 3),
detail_texture_translate: float2(0, 0),
detail_texture_rotate: 0.0,
detail_texture_scale: float2(1, 1));12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152mdl 1.7;
using ::OmniPBR import OmniPBR;
import ::tex::gamma_mode;
import ::state::normal;
import ::base::mono_mode;
export material Plastic_B(*)
= OmniPBR(
diffuse_color_constant: color(),
diffuse_texture: texture_2d(),
albedo_desaturation: 0.0,
albedo_add: 0.0,
albedo_brightness: 1.0,
diffuse_tint: color(1, 1, 1),
reflection_roughness_constant: 0.5,
reflection_roughness_texture_influence: 1.0,
reflectionroughness_texture: texture_2d(),
metallic_constant: 0.0,
metallic_texture_influence: 1.0,
metallic_texture: texture_2d(),
specular_level: 0.5,
enable_ORM_texture: true,
ORM_texture: texture_2d("../textures/T_Plastic_ORM_1k.png", ::tex::gamma_linear),
ao_to_diffuse: 0.0,
ao_texture: texture_2d(),
enable_emission: false,
emissive_color: color(1, 0.1, 0.1),
emissive_color_texture: texture_2d(),
emissive_mask_texture: texture_2d(),
emissive_intensity: 40.0,
enable_opacity: false,
enable_opacity_texture: false,
opacity_constant: 1.0,
opacity_texture: texture_2d(),
opacity_mode: ::base::mono_average,
opacity_threshold: 0.0,
bump_factor: 1.0,
normalmap_texture: texture_2d("../textures/T_Plastic_Normal_1k.png", ::tex::gamma_linear),
detail_bump_factor: 0.30000001192092896,
detail_normalmap_texture: texture_2d(),
flip_tangent_u: false,
flip_tangent_v: true,
project_uvw: false,
world_or_object: false,
uv_space_index: 0,
texture_translate: float2(0, 0),
texture_rotate: 0.0,
texture_scale: float2(3, 3),
detail_texture_translate: float2(0, 0),
detail_texture_rotate: 0.0,
detail_texture_scale: float2(1, 1));12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152mdl 1.7;
using ::OmniPBR import OmniPBR;
import ::tex::gamma_mode;
import ::state::normal;
import ::base::mono_mode;
export material Plastic_B(*)
= OmniPBR(
diffuse_color_constant: color(),
diffuse_texture: texture_2d(),
albedo_desaturation: 0.0,
albedo_add: 0.0,
albedo_brightness: 1.0,
diffuse_tint: color(1, 1, 1),
reflection_roughness_constant: 0.5,
reflection_roughness_texture_influence: 1.0,
reflectionroughness_texture: texture_2d(),
metallic_constant: 0.0,
metallic_texture_influence: 1.0,
metallic_texture: texture_2d(),
specular_level: 0.5,
enable_ORM_texture: true,
ORM_texture: texture_2d("../textures/T_Plastic_ORM_1k.png", ::tex::gamma_linear),
ao_to_diffuse: 0.0,
ao_texture: texture_2d(),
enable_emission: false,
emissive_color: color(1, 0.1, 0.1),
emissive_color_texture: texture_2d(),
emissive_mask_texture: texture_2d(),
emissive_intensity: 40.0,
enable_opacity: false,
enable_opacity_texture: false,
opacity_constant: 1.0,
opacity_texture: texture_2d(),
opacity_mode: ::base::mono_average,
opacity_threshold: 0.0,
bump_factor: 1.0,
normalmap_texture: texture_2d("../textures/T_Plastic_Normal_1k.png", ::tex::gamma_linear),
detail_bump_factor: 0.30000001192092896,
detail_normalmap_texture: texture_2d(),
flip_tangent_u: false,
flip_tangent_v: true,
project_uvw: false,
world_or_object: false,
uv_space_index: 0,
texture_translate: float2(0, 0),
texture_rotate: 0.0,
texture_scale: float2(3, 3),
detail_texture_translate: float2(0, 0),
detail_texture_rotate: 0.0,
detail_texture_scale: float2(1, 1));12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152mdl 1.7;
using ::OmniPBR import OmniPBR;
import ::tex::gamma_mode;
import ::state::normal;
import ::base::mono_mode;
export material Plastic_B(*)
= OmniPBR(
diffuse_color_constant: color(),
diffuse_texture: texture_2d(),
albedo_desaturation: 0.0,
albedo_add: 0.0,
albedo_brightness: 1.0,
diffuse_tint: color(1, 1, 1),
reflection_roughness_constant: 0.5,
reflection_roughness_texture_influence: 1.0,
reflectionroughness_texture: texture_2d(),
metallic_constant: 0.0,
metallic_texture_influence: 1.0,
metallic_texture: texture_2d(),
specular_level: 0.5,
enable_ORM_texture: true,
ORM_texture: texture_2d("../textures/T_Plastic_ORM_1k.png", ::tex::gamma_linear),
ao_to_diffuse: 0.0,
ao_texture: texture_2d(),
enable_emission: false,
emissive_color: color(1, 0.1, 0.1),
emissive_color_texture: texture_2d(),
emissive_mask_texture: texture_2d(),
emissive_intensity: 40.0,
enable_opacity: false,
enable_opacity_texture: false,
opacity_constant: 1.0,
opacity_texture: texture_2d(),
opacity_mode: ::base::mono_average,
opacity_threshold: 0.0,
bump_factor: 1.0,
normalmap_texture: texture_2d("../textures/T_Plastic_Normal_1k.png", ::tex::gamma_linear),
detail_bump_factor: 0.30000001192092896,
detail_normalmap_texture: texture_2d(),
flip_tangent_u: false,
flip_tangent_v: true,
project_uvw: false,
world_or_object: false,
uv_space_index: 0,
texture_translate: float2(0, 0),
texture_rotate: 0.0,
texture_scale: float2(3, 3),
detail_texture_translate: float2(0, 0),
detail_texture_rotate: 0.0,
detail_texture_scale: float2(1, 1));12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152mdl 1.7;
using ::OmniPBR import OmniPBR;
import ::tex::gamma_mode;
import ::state::normal;
import ::base::mono_mode;
export material Plastic_B(*)
= OmniPBR(
diffuse_color_constant: color(),
diffuse_texture: texture_2d(),
albedo_desaturation: 0.0,
albedo_add: 0.0,
albedo_brightness: 1.0,
diffuse_tint: color(1, 1, 1),
reflection_roughness_constant: 0.5,
reflection_roughness_texture_influence: 1.0,
reflectionroughness_texture: texture_2d(),
metallic_constant: 0.0,
metallic_texture_influence: 1.0,
metallic_texture: texture_2d(),
specular_level: 0.5,
enable_ORM_texture: true,
ORM_texture: texture_2d("../textures/T_Plastic_ORM_1k.png", ::tex::gamma_linear),
ao_to_diffuse: 0.0,
ao_texture: texture_2d(),
enable_emission: false,
emissive_color: color(1, 0.1, 0.1),
emissive_color_texture: texture_2d(),
emissive_mask_texture: texture_2d(),
emissive_intensity: 40.0,
enable_opacity: false,
enable_opacity_texture: false,
opacity_constant: 1.0,
opacity_texture: texture_2d(),
opacity_mode: ::base::mono_average,
opacity_threshold: 0.0,
bump_factor: 1.0,
normalmap_texture: texture_2d("../textures/T_Plastic_Normal_1k.png", ::tex::gamma_linear),
detail_bump_factor: 0.30000001192092896,
detail_normalmap_texture: texture_2d(),
flip_tangent_u: false,
flip_tangent_v: true,
project_uvw: false,
world_or_object: false,
uv_space_index: 0,
texture_translate: float2(0, 0),
texture_rotate: 0.0,
texture_scale: float2(3, 3),
detail_texture_translate: float2(0, 0),
detail_texture_rotate: 0.0,
detail_texture_scale: float2(1, 1));123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562/*****************************************************************************
* Copyright 1986-2020 NVIDIA Corporation. All rights reserved.
******************************************************************************
MDL MATERIALS ARE PROVIDED PURSUANT TO AN END USER LICENSE AGREEMENT,
WHICH WAS ACCEPTED IN ORDER TO GAIN ACCESS TO THIS FILE. IN PARTICULAR,
THE MDL MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL NVIDIA
CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
THE USE OR INABILITY TO USE THE MDL MATERIALS OR FROM OTHER DEALINGS IN
THE MDL MATERIALS.
*/
mdl 1.4;
import ::df::*;
import ::state::*;
import ::math::*;
import ::base::*;
import ::tex::*;
import ::anno::*;
using .::SimPBR_Model import *;
using .::baking_annotations import *;
export material SimPBR(
// -------------------- DIFFUSE REFLECTION ----------------------
uniform color diffuse_color_constant = color(0.2f)
[[
anno::display_name("Albedo Base Color"),
anno::description("The base albedo color to use if no texture is specified"),
anno::in_group("Diffuse")
]],
uniform texture_2d diffuse_texture = texture_2d()
[[
anno::display_name("Albedo Map"),
anno::description("The texture specifying the albedo value to use"),
anno::in_group("Diffuse")
]],
uniform color diffuse_tint = color(1.0f)
[[
anno::display_name("Albedo Tint"),
anno::description("This tints the albedo color or texture contant"),
anno::in_group("Diffuse")
]],
uniform bool enable_transmission = false
[[
anno::display_name("Enable Diffuse Transmission"),
anno::description("Enables the diffuse transmission of light through thin diffuse scattering layer"),
anno::in_group("Diffuse")
]],
uniform float opacity_ratio = 1.f
[[
anno::enable_if("enable_transmission == true"),
anno::display_name("Opacity Ratio"),
anno::description("Amount of opacity"),
anno::in_group("Diffuse")
]],
uniform color opacity_tint = color(1.0f)
[[
anno::enable_if("enable_transmission == true"),
anno::display_name("Diffuse transmission tint"),
anno::description("Base diffuse transmission color"),
anno::in_group("Diffuse")
]],
uniform float opacity_multiplier = 1.f
[[
anno::enable_if("enable_transmission == true"),
anno::display_name("Diffuse transmission multiplier"),
anno::description("Base diffuse transmission multiplier"),
anno::in_group("Diffuse")
]],
// -------------------- SPECULAR REFLECTION ----------------------
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")
]],
float anisotropy_constant = 0.0f
[[
anno::display_name("Anisotropy Amount"),
anno::hard_range(-1.,1.),
anno::description("0 for isotropic, extents of -1 to 1 for anisotropy"),
anno::in_group("Specular")
]],
uniform float anisotropy_texture_influence = 0.0f
[[
anno::display_name("Anisotropy Map Influence"),
anno::hard_range(0.0, 1.),
anno::description("Blends between the constant value and the lookup of the anisotropy texture"),
anno::in_group("Specular")
]],
uniform texture_2d anisotropy_texture = texture_2d()
[[
anno::display_name("Anisotropy Map"),
anno::in_group("Specular")
]],
float metallic_constant = 0.f
[[
anno::display_name("Metallic Amount"),
anno::hard_range(0.0,1.),
anno::description("Metallic Material"),
anno::in_group("Specular")
]],
uniform float metallic_texture_influence = 0.0f
[[
anno::display_name("Metallic Map Influence"),
anno::hard_range(0.0, 1.),
anno::description("Blends between the constant value and the lookup of the metallic texture"),
anno::in_group("Specular")
]],
uniform texture_2d metallic_texture = texture_2d()
[[
anno::display_name("Metallic Map"),
anno::in_group("Specular")
]],
float specular_constant = 1.f
[[
anno::display_name("Specular amount"),
anno::hard_range(0.0, 1.0),
anno::description("Scale of the specular component"),
anno::in_group("Specular")
]],
uniform texture_2d specular_texture = texture_2d()
[[
anno::display_name("Specular Map"),
anno::in_group("Specular")
]],
// -------------------- ORM ----------------------
uniform bool enable_ORM_texture = true
[[
anno::display_name("Enable ORM Texture"),
anno::description("When True the ORM texture will be used to extract the Occlusion, Roughness and Metallic Map"),
anno::in_group("Reflectivity")
]],
uniform texture_2d ORM_texture = texture_2d()
[[
anno::display_name("ORM Map"),
anno::description("Texture that hae Occlusion, Roughness and Metallic map stored in the respective r, g and b channels"),
anno::in_group("Reflectivity")
]],
// -------------------- Clearcoat ----------------------
uniform bool enable_clearcoat = false
[[
anno::display_name("Enable Clearcoat Layer"),
anno::description("Adds a clearcoat layer on top of the material when enabled"),
anno::in_group("Clearcoat")
]],
color clearcoat_tint = color(1.0f)
[[
anno::display_name("Clearcoat Tint"),
anno::description("Clearcoat is tinted and affects the underlying material"),
anno::in_group("Clearcoat")
]],
float clearcoat_transparency = 1.0f
[[
anno::display_name("Clearcoat Transparency"),
anno::description("Adjusts the transparency of the clearcoat. Can be turned into a fully opaque clearcoat "
"covering the underlying layer"),
anno::in_group("Clearcoat")
]],
float clearcoat_reflection_roughness = 0.0f
[[
anno::display_name("Clearcoat Roughness"),
anno::description("Higher roughness values lead to more blurry reflections"),
anno::hard_range(0.0f, 1.0f),
anno::in_group("Clearcoat")
]],
float clearcoat_weight = 1.0f
[[
anno::display_name("Clearcoat Weight"),
anno::description("Sets the weight for clearcoat layer"),
anno::hard_range(0.0f, 1.0f),
anno::in_group("Clearcoat")
]],
float clearcoat_flatten = 1.0f
[[
anno::display_name("Clearcoat Flatten"),
anno::description("Flattens the clearcoat to even out the underlying bump maps"),
anno::hard_range(0.0f, 1.0f),
anno::in_group("Clearcoat")
]],
float clearcoat_ior = 1.56f
[[
anno::display_name("Clearcoat IOR"),
anno::description("Sets the Index of refraction for the clearcoat layer"),
anno::soft_range(1.0f, 4.0f),
anno::in_group("Clearcoat")
]],
uniform float clearcoat_bump_factor = 1.f
[[
anno::display_name("Clearcoat Normal Map Strength"),
anno::description("Strength of normal map."),
anno::in_group("Clearcoat")
]],
float3 clearcoat_normal_input = float3(0.0, 0.0, 0.0),
uniform texture_2d clearcoat_normalmap_texture = texture_2d()
[[
anno::display_name("Clearcoat Normal Map"),
anno::description("Enables the usage of the normalmap texture"),
anno::in_group("Clearcoat")
]],
uniform bool clearcoat_flip_tangent_u = false
[[
anno::display_name("Clearcoat Normal Map Flip U Tangent"),
anno::in_group("Clearcoat")
]],
uniform bool clearcoat_flip_tangent_v = true
[[
anno::display_name("Clearcoat Normal Map Flip V Tangent"),
anno::in_group("Clearcoat")
]],
// -------------------- REFLECTIVITY ----------------------
uniform bool enable_retroreflection = false
[[
anno::display_name("Enable Retroreflection"),
anno::in_group("Reflectivity")
]],
color retroreflection_tint = color(.182,.800,.000)
[[
anno::display_name("Retro-reflection tint"),
anno::description("The tint of the retroreflection"),
anno::in_group("Reflectivity")
]],
uniform float normal_reflectivity = 0.5
[[
anno::display_name("Retro-reflection weight facing"),
anno::hard_range(0.0,1.),
anno::description("Reflectivity control for geometry facing the viewer"),
anno::in_group("Reflectivity")
]],
uniform float grazing_reflectivity = 1.0
[[
anno::display_name("Retro-reflection weight edge"),
anno::hard_range(0.0,1.),
anno::description("Reflectivity control for the reflectivity at geometry edges"),
anno::in_group("Reflectivity")
]],
// -------------------- AMBIENT OCCLUSION ----------------------
float ao_to_diffuse = 0.0
[[
anno::display_name("AO to Diffuse"),
anno::description("Controls the amount of ambient occlusion multiplied into the diffuse color channel"),
anno::in_group("AO")
]],
float ao_input = float(1.0),
uniform texture_2d ao_texture = texture_2d()
[[
anno::display_name("Ambient Occlusion Map"),
anno::description("The Ambient Occlusion texture for the material"),
anno::in_group("AO")
]],
// -------------------- EMISSIVE ----------------------
uniform bool enable_emission = false
[[
anno::display_name("Enable Emission"),
anno::description("Enables the emission of light from the material"),
anno::in_group("Emissive")
]],
uniform 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")
]],
color emissive_mask_input = color(1.0),
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")
]],
// -------------------- ALPHA ----------------------
uniform bool enable_opacity = false
[[
anno::display_name("Enable Opacity"),
anno::description("Enables or disables alpha functionality"),
anno::in_group("Alpha")
]],
float alpha_constant = 1.0
[[
anno::enable_if("enable_opacity == true"),
anno::display_name("Opacity Fallback Constant"),
anno::hard_range(0.0, 1.0),
anno::description("The base alpha constant to use if no texture is specified"),
anno::in_group("Alpha")
]],
uniform texture_2d opacity_texture = texture_2d()
[[
anno::enable_if("enable_opacity == true"),
anno::display_name("Opacity Map"),
anno::description("The texture specifying the opacity value to use"),
anno::in_group("Alpha")
]],
uniform bool enable_opacity_cutout = false
[[
anno::enable_if("enable_opacity == true"),
anno::display_name("Enable Alpha Cutout"),
anno::description("Enables or disables alpha cutout functionality"),
anno::in_group("Alpha")
]],
uniform float alpha_cutout_cutoff = 1.f
[[
anno::enable_if("enable_opacity == true"),
anno::enable_if("enable_opacity_cutout == true"),
anno::hard_range(0.0, 1.0),
anno::display_name("Alpha Cutout Cutoff"),
anno::description("The cutoff value to to render as transparent up to and opaque past"),
anno::in_group("Alpha")
]],
// -------------------- NORMAL ----------------------
uniform float bump_factor = 1.f
[[
anno::display_name("Normal Map Strength"),
anno::description("Strength of normal map."),
anno::in_group("Normal")
]],
float3 normal_input = state::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::description("Flips the U Tangent vector."),
anno::in_group("Normal")
]],
uniform bool flip_tangent_v = true
[[
anno::display_name("Normal Map Flip V Tangent"),
anno::description("Flips the V Tangent vector. By Default, SimPBR materials setup for DirectX normal maps. Set Normal Map Flip V = false for OpenGL."),
anno::in_group("Normal")
]],
// -------------------- UV ADJUSTMENTS ----------------------
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 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"),
anno::description("Supports the opaque alpha cutout 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", "opaque", "alpha", "cutout", "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
);
// Need to use a small value so the compiler doesnt optimize out this var...
float t = 0.00000001;//state::animation_time();
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);
// Diffuse Color Lookup and AO
float4 base_lookup = tex::texture_isvalid(diffuse_texture) ? tex::lookup_float4(tex: diffuse_texture, coord: uv) : float4(1, 1, 1, 1);
float opacityValue = tex::texture_isvalid(opacity_texture) ? tex::lookup_float4(tex: opacity_texture, coord: uv).w : alpha_constant;
// Normal calculations
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
) : normal_input;
float3 clearcoat_normal = tex::texture_isvalid(clearcoat_normalmap_texture) ?
base::tangent_space_normal_texture(
texture: clearcoat_normalmap_texture,
factor: clearcoat_bump_factor,
uvw: uvw,
flip_tangent_u: clearcoat_flip_tangent_u,
flip_tangent_v: clearcoat_flip_tangent_v
) : clearcoat_normal_input;
float3 flattened_clearcoat_normal = ::math::lerp(normal_lookup, ::state::normal(), clearcoat_flatten);
float3 final_clearcoat_normal = tex::texture_isvalid(clearcoat_normalmap_texture) ? clearcoat_normal : flattened_clearcoat_normal;
float ao_lookup = tex::texture_isvalid(ao_texture) ? tex::lookup_float4(tex: ao_texture, coord: uv).x : ao_input;
color diffuse_color = tex::texture_isvalid(diffuse_texture) ? color(base_lookup.x, base_lookup.y, base_lookup.z) : diffuse_color_constant;
float3 ORM_lookup = tex::lookup_float3(
tex: ORM_texture,
coord: float2(transformed_uvw.position.x, transformed_uvw.position.y)
);
float roughness_lookup = tex::texture_isvalid(reflectionroughness_texture) ?
tex::lookup_float4(tex: reflectionroughness_texture, coord: uv).x : reflection_roughness_constant;
float anisotropy_lookup = tex::texture_isvalid(anisotropy_texture) ?
(tex::lookup_float4(tex: anisotropy_texture, coord: uv).x * 2.0f - 1.0f) : anisotropy_constant;
float metallic_lookup = tex::texture_isvalid(metallic_texture) ?
tex::lookup_float4(tex: metallic_texture, coord: uv).x : metallic_constant;
float specular_lookup = tex::texture_isvalid(specular_texture) ?
tex::lookup_float4(tex: specular_texture, coord: uv).x : specular_constant;
float roughness_selection = enable_ORM_texture ? ORM_lookup.y : roughness_lookup;
float metallic_selection = enable_ORM_texture ? ORM_lookup.z : metallic_lookup;
float ao = enable_ORM_texture ? ORM_lookup.x : ao_lookup;
float reflection_roughness = math::lerp(reflection_roughness_constant, roughness_selection, reflection_roughness_texture_influence);
float anisotropy = math::lerp(anisotropy_constant, anisotropy_lookup, anisotropy_texture_influence);
float metallic = math::lerp(metallic_constant, metallic_selection, metallic_texture_influence);
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) : emissive_mask_input;
} in SimPBR_Model(
diffuse_color: diffuse_color,
diffuse_tint: diffuse_tint,
roughness: reflection_roughness,
anisotropy: anisotropy,
metallic: metallic,
specular: specular_lookup,
normal: normal_lookup,
enable_clearcoat: enable_clearcoat,
clearcoat_tint: clearcoat_tint,
clearcoat_transparency: clearcoat_transparency,
clearcoat_reflection_roughness: clearcoat_reflection_roughness,
clearcoat_weight: clearcoat_weight,
clearcoat_ior: clearcoat_ior,
clearcoat_normal: final_clearcoat_normal,
enable_retroreflection: enable_retroreflection,
retroreflection_tint: retroreflection_tint,
normal_reflectivity: normal_reflectivity,
grazing_reflectivity: grazing_reflectivity,
ao_to_diffuse: ao_to_diffuse,
ao: ao,
enable_emission: enable_emission,
emissive_color: emissive_color,
emissive_mask: emissive_mask,
emissive_intensity: emissive_intensity,
enable_opacity: enable_opacity,
alpha: opacityValue,
enable_opacity_cutout: enable_opacity_cutout,
alpha_cutout_cutoff: alpha_cutout_cutoff,
opacity_ratio: enable_transmission ? opacity_ratio : 1.0,
opacity_tint : opacity_tint,
opacity_multiplier : opacity_multiplier
);123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212/*****************************************************************************
* Copyright 1986-2020 NVIDIA Corporation. All rights reserved.
******************************************************************************
MDL MATERIALS ARE PROVIDED PURSUANT TO AN END USER LICENSE AGREEMENT,
WHICH WAS ACCEPTED IN ORDER TO GAIN ACCESS TO THIS FILE. IN PARTICULAR,
THE MDL MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL NVIDIA
CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
THE USE OR INABILITY TO USE THE MDL MATERIALS OR FROM OTHER DEALINGS IN
THE MDL MATERIALS.
*/
mdl 1.4;
import ::df::*;
import ::state::*;
import ::math::*;
import ::base::*;
import ::tex::*;
import ::anno::*;
using .::baking_annotations import *;
base::texture_return multiply_colors(
color color_1 = color(1.0, 1.0, 1.0),
color color_2 = color(.5, .5, .5),
float weight = 1.0
)
[[
anno::hidden()
]]
{
return base::blend_color_layers(
layers: base::color_layer[](
base::color_layer(
layer_color: color_2,
weight: weight,
mode: base::color_layer_multiply
)
), base: color_1
);
}
export material SimPBR_Model(
color diffuse_color = color(0.2f) [[ target_baked_argument("diffuse_texture", "diffuse_color_constant", "RGBA8_UNORM") ]],
uniform color diffuse_tint = color(1.0f),
float roughness = 0.5f [[ target_baked_argument("reflectionroughness_texture", "reflection_roughness_constant", "R8_UNORM") ]],
float anisotropy = 0.0f [[ target_baked_argument("anisotropy_texture", "anisotropy_constant", "R8_SNORM") ]],
float metallic = 0.f [[ target_baked_argument("metallic_texture", "metallic_constant", "R8_UNORM") ]],
float specular = 1.f [[ target_baked_argument("specular_texture", "specular_constant", "R8_UNORM") ]],
float3 normal = float3(0.0, 0.0, 0.0) [[ target_baked_argument("normalmap_texture", "normal_input", "RGBA8_SNORM", baking_annotations::TRANSFORM_UNORM_VECTOR) ]],
uniform bool enable_clearcoat = false,
color clearcoat_tint = color(1.0f),
float clearcoat_transparency = 1.0f,
float clearcoat_reflection_roughness = 0.0f,
float clearcoat_weight = 1.0f,
float clearcoat_ior = 1.56f,
float3 clearcoat_normal = float3(0.0, 0.0, 0.0) [[ target_baked_argument("clearcoat_normalmap_texture", "clearcoat_normal_input", "RGBA8_SNORM", baking_annotations::TRANSFORM_UNORM_VECTOR) ]],
uniform bool enable_retroreflection = false,
color retroreflection_tint = color(.182,.800,.000),
uniform float normal_reflectivity = 0.5,
uniform float grazing_reflectivity = 1.0,
float ao_to_diffuse = 0.0,
float ao = 1.0f [[ target_baked_argument("ao_texture", "ao_input", "R8_UNORM") ]],
uniform bool enable_emission = false,
uniform color emissive_color = color(1.0, 0.1, 0.1),
color emissive_mask = color(1.0, 0.1, 0.1) [[ target_baked_argument("emissive_mask_texture", "emissive_mask_input", "R8_UNORM") ]],
uniform float emissive_intensity = 40.f,
uniform bool enable_opacity = false,
float alpha = 1.0,
uniform bool enable_opacity_cutout = false,
uniform float alpha_cutout_cutoff = 1.f,
uniform float opacity_ratio = 1.f,
uniform color opacity_tint = color(1.0f),
uniform float opacity_multiplier = 1.f
)
[[
target_material_model(),
target_material_rendering("..::SimPBR::SimPBR")
]]
= let {
color base_color = multiply_colors(diffuse_color, diffuse_tint, 1.0).tint;
color ao_weighted_base_color = multiply_colors(base_color, color(ao), ao_to_diffuse).tint;
float squared_roughness = roughness * roughness;
float roughness_u = squared_roughness * (1 + anisotropy);
float roughness_v = squared_roughness * (1 - anisotropy);
color diffuse_transmission_color = base_color * opacity_tint * opacity_multiplier;
bsdf diffuse_bsdf = df::weighted_layer(
weight: opacity_ratio,
layer: df::diffuse_reflection_bsdf(
tint: ao_weighted_base_color,
roughness: 0.0f
),
base: df::diffuse_transmission_bsdf(tint: diffuse_transmission_color),
normal: enable_clearcoat ? normal : state::normal()
);
bsdf ggx_smith_bsdf = df::microfacet_ggx_smith_bsdf(
roughness_u: roughness_u,
roughness_v: roughness_v,
tint: color(1.0, 1.0, 1.0),
mode: df::scatter_reflect
);
bsdf custom_curve_layer_bsdf = df::custom_curve_layer(
normal_reflectivity: 0.03,
grazing_reflectivity: 1.0,
exponent: 5.0,
weight: specular,
layer: ggx_smith_bsdf,
base: diffuse_bsdf,
normal: enable_clearcoat ? normal : state::normal()
);
//
// Begin RETROREFLECTION SUPPORT
//
color final_retroreflection_color = multiply_colors(retroreflection_tint, base_color, 1.0).tint;
bsdf backscattering_glossy_bsdf = df::backscattering_glossy_reflection_bsdf(
tint: final_retroreflection_color,
roughness_u: squared_roughness
);
/*bsdf retroreflection_bsdf = df::custom_curve_layer(
normal_reflectivity: 1.-normal_reflectivity,
grazing_reflectivity: 1.-grazing_reflectivity,
base: backscattering_glossy_bsdf,
layer: custom_curve_layer_bsdf,
normal: enable_clearcoat ? normal_lookup : state::normal()
);*/
// if normal_reflectivity and grazing_reflectivity are 1 and weight is 1, just the layer is used
bsdf opt_retroreflection_bsdf = df::custom_curve_layer(
normal_reflectivity: enable_retroreflection ? 1.-normal_reflectivity : 1,
grazing_reflectivity: enable_retroreflection ? 1.-grazing_reflectivity : 1,
base: backscattering_glossy_bsdf,
layer: custom_curve_layer_bsdf,
normal: enable_clearcoat ? normal : state::normal()
);
//
// End RETROREFLECTION SUPPORT
//
bsdf directional_factor_bsdf = df::directional_factor(
normal_tint: ao_weighted_base_color,
grazing_tint: color(1.0, 1.0, 1.0),
exponent: 5.0f,
base: ggx_smith_bsdf
);
// CLEARCOAT
bsdf omni_PBR_bsdf = df::weighted_layer(
weight: metallic,
layer: directional_factor_bsdf,
base: opt_retroreflection_bsdf, //enable_retroreflection ? retroreflection_bsdf : custom_curve_layer_bsdf,
normal: enable_clearcoat ? normal : state::normal()
);
bsdf clearcoat_bsdf = df::microfacet_ggx_smith_bsdf(
roughness_u: clearcoat_reflection_roughness * clearcoat_reflection_roughness,
roughness_v: clearcoat_reflection_roughness * clearcoat_reflection_roughness,
tint: color(1.0f),
mode: df::scatter_reflect
);
// bsdf omni_PBR_coated_bsdf = df::custom_curve_layer(
// normal_reflectivity: clearcoat_reflectivity * 0.08,
// grazing_reflectivity: 1.0,
// weight: clearcoat_weight,
// layer: clearcoat_bsdf,
// base: omni_PBR_bsdf,
// normal: final_clearcoat_normal
// );
bsdf opt_opaque_clearcoat = df::weighted_layer(
weight: enable_clearcoat ? clearcoat_transparency : 1,
layer: ::df::tint(tint: enable_clearcoat ? clearcoat_tint : color(1), base: omni_PBR_bsdf),
base: ::df::diffuse_reflection_bsdf(tint: clearcoat_tint)
);
bsdf opt_omni_PBR_coated_bsdf = df::fresnel_layer(
ior: clearcoat_ior,
weight: enable_clearcoat ? clearcoat_weight : 0,
layer: clearcoat_bsdf,
base: opt_opaque_clearcoat,
normal: clearcoat_normal
);
bsdf final_bsdf = opt_omni_PBR_coated_bsdf;
} in material(
thin_walled: false,
surface: material_surface(
scattering: final_bsdf,
emission: material_emission(
df::diffuse_edf(),
intensity: enable_emission ? emissive_color * emissive_mask * color(emissive_intensity) : color(0)
)
),
geometry: material_geometry(
normal: enable_clearcoat ? state::normal() : normal,
cutout_opacity: enable_opacity ? (enable_opacity_cutout ? (alpha < alpha_cutout_cutoff ? 0.0 : 1.0) : alpha) : 1.0
)
);123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651/*****************************************************************************
* Copyright 1986-2020 NVIDIA Corporation. All rights reserved.
******************************************************************************
MDL MATERIALS ARE PROVIDED PURSUANT TO AN END USER LICENSE AGREEMENT,
WHICH WAS ACCEPTED IN ORDER TO GAIN ACCESS TO THIS FILE. IN PARTICULAR,
THE MDL MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL NVIDIA
CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
THE USE OR INABILITY TO USE THE MDL MATERIALS OR FROM OTHER DEALINGS IN
THE MDL MATERIALS.
*/
mdl 1.4;
import ::df::*;
import ::state::*;
import ::math::*;
import ::base::*;
import ::tex::*;
import ::anno::*;
import ::nvidia::core_definitions::file_texture;
import ::nvidia::core_definitions::normalmap_texture;
float4 raw_file_texture(
uniform texture_2d texture
[[ anno::description("The input texture") ]],
base::texture_coordinate_info uvw = base::texture_coordinate_info()
[[ anno::description("Custom value for texture coordinate") ]],
uniform float2 crop_u = float2(0.0, 1.0)
[[ anno::description("Restricts the texture access to sub-domain of the texture in the u direction") ]],
uniform float2 crop_v = float2(0.0, 1.0)
[[ anno::description("Restricts the texture access to sub-domain of the texture in the v direction") ]],
uniform tex::wrap_mode wrap_u = tex::wrap_repeat
[[ anno::description("Wrapping mode in the u direction") ]],
uniform tex::wrap_mode wrap_v = tex::wrap_repeat
[[ anno::description("Wrapping mode in the v direction") ]]
)
[[
anno::description("General texturing function for 2D bitmap texture stored in a file"),
anno::noinline()
]]
{
return tex::lookup_float4(texture, float2(uvw.position.x, uvw.position.y), wrap_u, wrap_v, crop_u, crop_v);
}
base::texture_return multiply_colors(
color color_1 = color(1.0, 1.0, 1.0),
color color_2 = color(.5, .5, .5),
float weight = 1.0
) [[
anno::hidden()
]]
{
return base::blend_color_layers(
layers: base::color_layer[](
base::color_layer(
layer_color: color_2,
weight: weight,
mode: base::color_layer_multiply
)),
base: color_1
);
}
base::texture_return add_colors(
color color_1 = color(.5, .5, .5),
color color_2 = color(.5, .5, .5),
float weight = 1.0
) [[
anno::hidden(),
anno::unused()
]]
{
return base::blend_color_layers(
layers: base::color_layer[](
base::color_layer(
layer_color: color_2,
weight: weight,
mode: base::color_layer_add
)),
base: color_1
);
}
base::texture_return blend_colors(
color color_1 = color(1.0, 1.0, 1.0),
color color_2 = color(.5, .5, .5),
float weight = 1.0
) [[
anno::hidden(),
anno::unused()
]]
{
return base::blend_color_layers(
layers: base::color_layer[](
base::color_layer(
layer_color: color_2,
weight: weight,
mode: base::color_layer_blend
)),
base: color_1
);
}
export material SimPBR_Opacity(
// -------------------- DIFFUSE REFLECTION ----------------------
uniform color diffuse_color_constant = color(0.2f)
[[
anno::display_name("Albedo Base Color"),
anno::description("The base albedo color to use if no texture is specified"),
anno::in_group("Diffuse")
]],
uniform texture_2d diffuse_texture = texture_2d()
[[
anno::display_name("Albedo Map"),
anno::description("The texture specifying the albedo value to use"),
anno::in_group("Diffuse")
]],
uniform color diffuse_tint = color(1.0f)
[[
anno::display_name("Albedo Tint"),
anno::description("This tints the albedo color or texture contant"),
anno::in_group("Diffuse")
]],
// -------------------- SPECULAR REFLECTION ----------------------
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")
]],
uniform float anisotropy_constant = 0.0f
[[
anno::display_name("Anisotropy Amount"),
anno::hard_range(-1.,1.),
anno::description("0 for isotropic, extents of -1 to 1 for anisotropy"),
anno::in_group("Specular")
]],
uniform float anisotropy_texture_influence = 0.0f
[[
anno::display_name("Anisotropy Map Influence"),
anno::hard_range(0.0, 1.),
anno::description("Blends between the constant value and the lookup of the anisotropy texture"),
anno::in_group("Specular")
]],
uniform texture_2d anisotropy_texture = texture_2d()
[[
anno::display_name("Anisotropy Map"),
anno::in_group("Specular")
]],
uniform float metallic_constant = 0.f
[[
anno::display_name("Metallic Amount"),
anno::hard_range(0.0,1.),
anno::description("Metallic Material"),
anno::in_group("Specular")
]],
uniform float metallic_texture_influence = 0.0f
[[
anno::display_name("Metallic Map Influence"),
anno::hard_range(0.0, 1.),
anno::description("Blends between the constant value and the lookup of the metallic texture"),
anno::in_group("Specular")
]],
uniform texture_2d metallic_texture = texture_2d()
[[
anno::display_name("Metallic Map"),
anno::in_group("Specular")
]],
// -------------------- ORM ----------------------
uniform bool enable_ORM_texture = true
[[
anno::display_name("Enable ORM Texture"),
anno::description("When True the ORM texture will be used to extract the Occlusion, Roughness and Metallic Map"),
anno::in_group("Reflectivity")
]],
uniform texture_2d ORM_texture = texture_2d()
[[
anno::display_name("ORM Map"),
anno::description("Texture that hae Occlusion, Roughness and Metallic map stored in the respective r, g and b channels"),
anno::in_group("Reflectivity")
]],
// -------------------- Clearcoat ----------------------
uniform bool enable_clearcoat = false
[[
anno::display_name("Enable Clearcoat Layer"),
anno::description("Adds a clearcoat layer on top of the material when enabled"),
anno::in_group("Clearcoat")
]],
color clearcoat_tint = color(1.0f)
[[
anno::display_name("Clearcoat Tint"),
anno::description("Clearcoat is tinted and affects the underlying material"),
anno::in_group("Clearcoat")
]],
float clearcoat_transparency = 1.0f
[[
anno::display_name("Clearcoat Transparency"),
anno::description("Adjusts the transparency of the clearcoat. Can be turned into a fully opaque clearcoat "
"covering the underlying layer"),
anno::in_group("Clearcoat")
]],
float clearcoat_reflection_roughness = 0.0f
[[
anno::display_name("Clearcoat Roughness"),
anno::description("Higher roughness values lead to more blurry reflections"),
anno::hard_range(0.0f, 1.0f),
anno::in_group("Clearcoat")
]],
float clearcoat_weight = 1.0f
[[
anno::display_name("Clearcoat Weight"),
anno::description("Sets the weight for clearcoat layer"),
anno::hard_range(0.0f, 1.0f),
anno::in_group("Clearcoat")
]],
float clearcoat_flatten = 1.0f
[[
anno::display_name("Clearcoat Flatten"),
anno::description("Flattens the clearcoat to even out the underlying bump maps"),
anno::hard_range(0.0f, 1.0f),
anno::in_group("Clearcoat")
]],
float clearcoat_ior = 1.56f
[[
anno::display_name("Clearcoat IOR"),
anno::description("Sets the Index of refraction for the clearcoat layer"),
anno::soft_range(1.0f, 4.0f),
anno::in_group("Clearcoat")
]],
uniform float clearcoat_bump_factor = 1.f
[[
anno::display_name("Clearcoat Normal Map Strength"),
anno::description("Strength of normal map."),
anno::in_group("Clearcoat")
]],
uniform texture_2d clearcoat_normalmap_texture = texture_2d()
[[
anno::display_name("Clearcoat Normal Map"),
anno::description("Enables the usage of the normalmap texture"),
anno::in_group("Clearcoat")
]],
// -------------------- REFLECTIVITY ----------------------
uniform bool enable_retroreflection = false
[[
anno::display_name("Enable Retroreflection"),
anno::in_group("Reflectivity")
]],
color retroreflection_color = color(.182,.800,.000)
[[
anno::display_name("Retro-reflection color"),
anno::description("The color of the retroreflection"),
anno::in_group("Reflectivity")
]],
uniform float normal_reflectivity = 0.5
[[
anno::display_name("Retro-reflection weight facing"),
anno::hard_range(0.0,1.),
anno::description("Reflectivity control for geometry facing the viewer"),
anno::in_group("Reflectivity")
]],
uniform float grazing_reflectivity = 1.0
[[
anno::display_name("Retro-reflection weight edge"),
anno::hard_range(0.0,1.),
anno::description("Reflectivity control for the reflectivity at geometry edges"),
anno::in_group("Reflectivity")
]],
// -------------------- AMBIENT OCCLUSION ----------------------
float ao_to_diffuse = 0.0
[[
anno::display_name("AO to Diffuse"),
anno::description("Controls the amount of ambient occlusion multiplied into the diffuse color channel"),
anno::in_group("AO")
]],
uniform texture_2d ao_texture = texture_2d()
[[
anno::display_name("Ambient Occlusion Map"),
anno::description("The Ambient Occlusion texture for the material"),
anno::in_group("AO")
]],
// -------------------- EMISSIVE ----------------------
uniform bool enable_emission = false
[[
anno::display_name("Enable Emission"),
anno::description("Enables the emission of light from the material"),
anno::in_group("Emissive")
]],
uniform 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")
]],
// -------------------- ALPHA ----------------------
uniform bool enable_alpha = true
[[
anno::display_name("Enable Alpha"),
anno::description("Enables or disables alpha functionality"),
anno::in_group("Alpha")
]],
uniform float alpha_constant = 1.0
[[
anno::display_name("Alpha Fallback Constant"),
anno::description("The base alpha constant to use if no texture is specified"),
anno::in_group("Alpha")
]],
uniform texture_2d opacity_texture = texture_2d()
[[
anno::display_name("Opacity Map"),
anno::description("The texture specifying the opacity value to use"),
anno::in_group("Alpha")
]],
uniform bool enable_alpha_cutout = false
[[
anno::display_name("Enable Alpha Cutout"),
anno::description("Enables or disables alpha cutout functionality"),
anno::in_group("Alpha")
]],
uniform float alpha_cutout_cutoff = 1.f
[[
anno::enable_if("enable_alpha_cutout == true"),
anno::hard_range(0.0, 1.0),
anno::display_name("Alpha Cutout Cutoff"),
anno::description("The cutoff value to to render as transparent up to and opaque past"),
anno::in_group("Alpha")
]],
// -------------------- NORMAL ----------------------
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")
]],
// -------------------- UV ADJUSTMENTS ----------------------
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 Scale"),
anno::description("Larger number increases size of 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 Opaque Alpha Cutout"),
anno::description("Supports the opaque alpha cutout material model of the Sim Renderer"),
anno::version( 1, 0, 0),
anno::author("NVIDIA CORPORATION"),
anno::key_words(string[]("Sim", "PBR", "opaque", "alpha", "cutout", "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
);
// Need to use a small value so the compiler doesnt optimize out this var...
float t = 0.00000001;//state::animation_time();
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 );
// Diffuse Color Lookup and AO
float4 base_lookup = tex::texture_isvalid(diffuse_texture) ? raw_file_texture(texture: diffuse_texture, uvw: transformed_uvw) : float4(1, 1, 1, 1);
float opacityValue = tex::texture_isvalid(opacity_texture) ? raw_file_texture(texture: opacity_texture, uvw: transformed_uvw).x : alpha_constant;
// Normal calculations
float3 normal_lookup = tex::texture_isvalid(normalmap_texture) ?
base::tangent_space_normal_texture(
texture: normalmap_texture,
factor: bump_factor,
uvw: transformed_uvw
) : state::normal();
float3 clearcoat_normal = base::tangent_space_normal_texture(
texture: clearcoat_normalmap_texture,
factor: clearcoat_bump_factor,
uvw: uvw
);
float3 flattened_clearcoat_normal = ::math::lerp(normal_lookup, ::state::normal(), clearcoat_flatten);
float3 final_clearcoat_normal = tex::texture_isvalid(clearcoat_normalmap_texture) ? clearcoat_normal : flattened_clearcoat_normal;
float ao_lookup = tex::texture_isvalid(ao_texture) ?
raw_file_texture(texture: ao_texture, uvw: transformed_uvw).x :
1.0f
[[anno::unused("Currently unused in material, may be utilized in the future")]];
color diffuse_color = tex::texture_isvalid(diffuse_texture) ? color(base_lookup.x, base_lookup.y, base_lookup.z) : diffuse_color_constant;
color base_color = multiply_colors(diffuse_color, diffuse_tint, 1.0).tint;
float3 ORM_lookup = tex::lookup_float3(
tex: ORM_texture,
coord: float2(transformed_uvw.position.x, transformed_uvw.position.y)
);
float roughness_lookup = tex::texture_isvalid(reflectionroughness_texture) ?
raw_file_texture(texture: reflectionroughness_texture, uvw: transformed_uvw).x :
reflection_roughness_constant;
float anisotropy_lookup = tex::texture_isvalid(anisotropy_texture) ?
(raw_file_texture(texture: anisotropy_texture, uvw: transformed_uvw).x * 2.0f - 1.0f) :
anisotropy_constant;
float metallic_lookup = tex::texture_isvalid(metallic_texture) ?
raw_file_texture(texture: metallic_texture, uvw: transformed_uvw).x :
metallic_constant;
float roughness_selection = enable_ORM_texture ? ORM_lookup.y : roughness_lookup;
float metallic_selection = enable_ORM_texture ? ORM_lookup.z : metallic_lookup;
color ao_color = enable_ORM_texture ? color(ORM_lookup.x) : color(ao_lookup);
color ao_weighted_base_color = multiply_colors(base_color, ao_color, ao_to_diffuse).tint;
float reflection_roughness = math::lerp(reflection_roughness_constant, roughness_selection, reflection_roughness_texture_influence);
float anisotropy = math::lerp(anisotropy_constant, anisotropy_lookup, anisotropy_texture_influence);
float metallic = math::lerp(metallic_constant, metallic_selection, metallic_texture_influence);
float squared_roughness = reflection_roughness * reflection_roughness;
float roughness_u = squared_roughness * (1 + anisotropy);
float roughness_v = squared_roughness * (1 - anisotropy);
bsdf diffuse_bsdf = df::weighted_layer(
weight: 1.0,
layer: df::diffuse_reflection_bsdf(
tint: ao_weighted_base_color,
roughness: 0.f ),
base: bsdf(),
normal: enable_clearcoat ? normal_lookup : state::normal()
);
bsdf ggx_smith_bsdf = df::microfacet_ggx_smith_bsdf(
roughness_u: roughness_u,
roughness_v: roughness_v,
tint: color(1.0, 1.0, 1.0),
mode: df::scatter_reflect
);
bsdf custom_curve_layer_bsdf = df::custom_curve_layer(
normal_reflectivity: 0.03,
grazing_reflectivity: 1.0,
exponent: 5.0,
weight: float(1.0),
layer: ggx_smith_bsdf,
base: diffuse_bsdf,
normal: enable_clearcoat ? normal_lookup : state::normal()
);
//
// Begin RETROREFLECTION SUPPORT
//
bsdf backscattering_glossy_bsdf = df::backscattering_glossy_reflection_bsdf(
tint: retroreflection_color,
roughness_u: reflection_roughness * reflection_roughness
);
bsdf retroreflection_bsdf = df::custom_curve_layer(
normal_reflectivity: 1.-normal_reflectivity,
grazing_reflectivity: 1.-grazing_reflectivity,
base: backscattering_glossy_bsdf,
layer: diffuse_bsdf,
normal: enable_clearcoat ? normal_lookup : state::normal()
);
//
// End RETROREFLECTION SUPPORT
//
bsdf directional_factor_bsdf = df::directional_factor(
normal_tint: ao_weighted_base_color,
grazing_tint: color(1.0, 1.0, 1.0),
exponent: 5.0f,
base: ggx_smith_bsdf
);
// CLEARCOAT
bsdf omni_PBR_bsdf = df::weighted_layer(
weight: metallic,
layer: directional_factor_bsdf,
base: enable_retroreflection ? retroreflection_bsdf : custom_curve_layer_bsdf,
normal: enable_clearcoat ? normal_lookup : state::normal()
);
bsdf clearcoat_bsdf = df::microfacet_ggx_smith_bsdf(
roughness_u: clearcoat_reflection_roughness * clearcoat_reflection_roughness,
roughness_v: clearcoat_reflection_roughness * clearcoat_reflection_roughness,
tint: color(1.0f),
mode: df::scatter_reflect
);
// bsdf omni_PBR_coated_bsdf = df::custom_curve_layer(
// normal_reflectivity: clearcoat_reflectivity * 0.08,
// grazing_reflectivity: 1.0,
// weight: clearcoat_weight,
// layer: clearcoat_bsdf,
// base: omni_PBR_bsdf,
// normal: final_clearcoat_normal
// );
bsdf opaque_clearcoat = df::weighted_layer(
weight: clearcoat_transparency,
layer: ::df::tint(
tint: clearcoat_tint,
base: omni_PBR_bsdf),
base: ::df::diffuse_reflection_bsdf(
tint: clearcoat_tint)
);
bsdf omni_PBR_coated_bsdf = df::fresnel_layer(
ior: clearcoat_ior,
weight: clearcoat_weight,
layer: clearcoat_bsdf,
base: opaque_clearcoat,
normal: final_clearcoat_normal
);
bsdf final_bsdf = enable_clearcoat ? omni_PBR_coated_bsdf : omni_PBR_bsdf;
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);
} in material(
thin_walled: false,
surface: material_surface(
scattering: final_bsdf,
emission: material_emission (
df::diffuse_edf(),
intensity: enable_emission ? emissive_color * emissive_mask * color(emissive_intensity) : color(0)
)
),
geometry: material_geometry(
normal: enable_clearcoat ? state::normal() : normal_lookup,
cutout_opacity: enable_alpha ? (enable_alpha_cutout ? (opacityValue < alpha_cutout_cutoff ? 0.0 : 1.0) : opacityValue) : 1.0
)
);123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290/*****************************************************************************
* Copyright 1986-2020 NVIDIA Corporation. All rights reserved.
******************************************************************************
MDL MATERIALS ARE PROVIDED PURSUANT TO AN END USER LICENSE AGREEMENT,
WHICH WAS ACCEPTED IN ORDER TO GAIN ACCESS TO THIS FILE. IN PARTICULAR,
THE MDL MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL NVIDIA
CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
THE USE OR INABILITY TO USE THE MDL MATERIALS OR FROM OTHER DEALINGS IN
THE MDL MATERIALS.
*/
mdl 1.4;
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(
// -------------------- SPECULAR REFLECTION/TRANSMISSION ----------------------
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")
]],
// -------------------- VOLUME ----------------------
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")
]],
// -------------------- EMISSIVE ----------------------
uniform bool enable_thin_walled = false
[[
anno::display_name("Enable Thin Walled"),
anno::description("Enables thin walled logic"),
anno::in_group("Geometry")
]],
// -------------------- EMISSIVE ----------------------
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")
]],
// -------------------- NORMAL ----------------------
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")
]],
// -------------------- UV ADJUSTMENTS ----------------------
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
);
// Need to use a small value so the compiler doesnt optimize out this var...
float t = 0.00000001;//state::animation_time();
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),
::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),
::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);
// Normal calculations
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
)
);123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562/*****************************************************************************
* Copyright 1986-2020 NVIDIA Corporation. All rights reserved.
******************************************************************************
MDL MATERIALS ARE PROVIDED PURSUANT TO AN END USER LICENSE AGREEMENT,
WHICH WAS ACCEPTED IN ORDER TO GAIN ACCESS TO THIS FILE. IN PARTICULAR,
THE MDL MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL NVIDIA
CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
THE USE OR INABILITY TO USE THE MDL MATERIALS OR FROM OTHER DEALINGS IN
THE MDL MATERIALS.
*/
mdl 1.4;
import ::df::*;
import ::state::*;
import ::math::*;
import ::base::*;
import ::tex::*;
import ::anno::*;
using .::SimPBR_Model import *;
using .::baking_annotations import *;
export material SimPBR(
// -------------------- DIFFUSE REFLECTION ----------------------
uniform color diffuse_color_constant = color(0.2f)
[[
anno::display_name("Albedo Base Color"),
anno::description("The base albedo color to use if no texture is specified"),
anno::in_group("Diffuse")
]],
uniform texture_2d diffuse_texture = texture_2d()
[[
anno::display_name("Albedo Map"),
anno::description("The texture specifying the albedo value to use"),
anno::in_group("Diffuse")
]],
uniform color diffuse_tint = color(1.0f)
[[
anno::display_name("Albedo Tint"),
anno::description("This tints the albedo color or texture contant"),
anno::in_group("Diffuse")
]],
uniform bool enable_transmission = false
[[
anno::display_name("Enable Diffuse Transmission"),
anno::description("Enables the diffuse transmission of light through thin diffuse scattering layer"),
anno::in_group("Diffuse")
]],
uniform float opacity_ratio = 1.f
[[
anno::enable_if("enable_transmission == true"),
anno::display_name("Opacity Ratio"),
anno::description("Amount of opacity"),
anno::in_group("Diffuse")
]],
uniform color opacity_tint = color(1.0f)
[[
anno::enable_if("enable_transmission == true"),
anno::display_name("Diffuse transmission tint"),
anno::description("Base diffuse transmission color"),
anno::in_group("Diffuse")
]],
uniform float opacity_multiplier = 1.f
[[
anno::enable_if("enable_transmission == true"),
anno::display_name("Diffuse transmission multiplier"),
anno::description("Base diffuse transmission multiplier"),
anno::in_group("Diffuse")
]],
// -------------------- SPECULAR REFLECTION ----------------------
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")
]],
float anisotropy_constant = 0.0f
[[
anno::display_name("Anisotropy Amount"),
anno::hard_range(-1.,1.),
anno::description("0 for isotropic, extents of -1 to 1 for anisotropy"),
anno::in_group("Specular")
]],
uniform float anisotropy_texture_influence = 0.0f
[[
anno::display_name("Anisotropy Map Influence"),
anno::hard_range(0.0, 1.),
anno::description("Blends between the constant value and the lookup of the anisotropy texture"),
anno::in_group("Specular")
]],
uniform texture_2d anisotropy_texture = texture_2d()
[[
anno::display_name("Anisotropy Map"),
anno::in_group("Specular")
]],
float metallic_constant = 0.f
[[
anno::display_name("Metallic Amount"),
anno::hard_range(0.0,1.),
anno::description("Metallic Material"),
anno::in_group("Specular")
]],
uniform float metallic_texture_influence = 0.0f
[[
anno::display_name("Metallic Map Influence"),
anno::hard_range(0.0, 1.),
anno::description("Blends between the constant value and the lookup of the metallic texture"),
anno::in_group("Specular")
]],
uniform texture_2d metallic_texture = texture_2d()
[[
anno::display_name("Metallic Map"),
anno::in_group("Specular")
]],
float specular_constant = 1.f
[[
anno::display_name("Specular amount"),
anno::hard_range(0.0, 1.0),
anno::description("Scale of the specular component"),
anno::in_group("Specular")
]],
uniform texture_2d specular_texture = texture_2d()
[[
anno::display_name("Specular Map"),
anno::in_group("Specular")
]],
// -------------------- ORM ----------------------
uniform bool enable_ORM_texture = true
[[
anno::display_name("Enable ORM Texture"),
anno::description("When True the ORM texture will be used to extract the Occlusion, Roughness and Metallic Map"),
anno::in_group("Reflectivity")
]],
uniform texture_2d ORM_texture = texture_2d()
[[
anno::display_name("ORM Map"),
anno::description("Texture that hae Occlusion, Roughness and Metallic map stored in the respective r, g and b channels"),
anno::in_group("Reflectivity")
]],
// -------------------- Clearcoat ----------------------
uniform bool enable_clearcoat = false
[[
anno::display_name("Enable Clearcoat Layer"),
anno::description("Adds a clearcoat layer on top of the material when enabled"),
anno::in_group("Clearcoat")
]],
color clearcoat_tint = color(1.0f)
[[
anno::display_name("Clearcoat Tint"),
anno::description("Clearcoat is tinted and affects the underlying material"),
anno::in_group("Clearcoat")
]],
float clearcoat_transparency = 1.0f
[[
anno::display_name("Clearcoat Transparency"),
anno::description("Adjusts the transparency of the clearcoat. Can be turned into a fully opaque clearcoat "
"covering the underlying layer"),
anno::in_group("Clearcoat")
]],
float clearcoat_reflection_roughness = 0.0f
[[
anno::display_name("Clearcoat Roughness"),
anno::description("Higher roughness values lead to more blurry reflections"),
anno::hard_range(0.0f, 1.0f),
anno::in_group("Clearcoat")
]],
float clearcoat_weight = 1.0f
[[
anno::display_name("Clearcoat Weight"),
anno::description("Sets the weight for clearcoat layer"),
anno::hard_range(0.0f, 1.0f),
anno::in_group("Clearcoat")
]],
float clearcoat_flatten = 1.0f
[[
anno::display_name("Clearcoat Flatten"),
anno::description("Flattens the clearcoat to even out the underlying bump maps"),
anno::hard_range(0.0f, 1.0f),
anno::in_group("Clearcoat")
]],
float clearcoat_ior = 1.56f
[[
anno::display_name("Clearcoat IOR"),
anno::description("Sets the Index of refraction for the clearcoat layer"),
anno::soft_range(1.0f, 4.0f),
anno::in_group("Clearcoat")
]],
uniform float clearcoat_bump_factor = 1.f
[[
anno::display_name("Clearcoat Normal Map Strength"),
anno::description("Strength of normal map."),
anno::in_group("Clearcoat")
]],
float3 clearcoat_normal_input = float3(0.0, 0.0, 0.0),
uniform texture_2d clearcoat_normalmap_texture = texture_2d()
[[
anno::display_name("Clearcoat Normal Map"),
anno::description("Enables the usage of the normalmap texture"),
anno::in_group("Clearcoat")
]],
uniform bool clearcoat_flip_tangent_u = false
[[
anno::display_name("Clearcoat Normal Map Flip U Tangent"),
anno::in_group("Clearcoat")
]],
uniform bool clearcoat_flip_tangent_v = true
[[
anno::display_name("Clearcoat Normal Map Flip V Tangent"),
anno::in_group("Clearcoat")
]],
// -------------------- REFLECTIVITY ----------------------
uniform bool enable_retroreflection = false
[[
anno::display_name("Enable Retroreflection"),
anno::in_group("Reflectivity")
]],
color retroreflection_tint = color(.182,.800,.000)
[[
anno::display_name("Retro-reflection tint"),
anno::description("The tint of the retroreflection"),
anno::in_group("Reflectivity")
]],
uniform float normal_reflectivity = 0.5
[[
anno::display_name("Retro-reflection weight facing"),
anno::hard_range(0.0,1.),
anno::description("Reflectivity control for geometry facing the viewer"),
anno::in_group("Reflectivity")
]],
uniform float grazing_reflectivity = 1.0
[[
anno::display_name("Retro-reflection weight edge"),
anno::hard_range(0.0,1.),
anno::description("Reflectivity control for the reflectivity at geometry edges"),
anno::in_group("Reflectivity")
]],
// -------------------- AMBIENT OCCLUSION ----------------------
float ao_to_diffuse = 0.0
[[
anno::display_name("AO to Diffuse"),
anno::description("Controls the amount of ambient occlusion multiplied into the diffuse color channel"),
anno::in_group("AO")
]],
float ao_input = float(1.0),
uniform texture_2d ao_texture = texture_2d()
[[
anno::display_name("Ambient Occlusion Map"),
anno::description("The Ambient Occlusion texture for the material"),
anno::in_group("AO")
]],
// -------------------- EMISSIVE ----------------------
uniform bool enable_emission = false
[[
anno::display_name("Enable Emission"),
anno::description("Enables the emission of light from the material"),
anno::in_group("Emissive")
]],
uniform 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")
]],
color emissive_mask_input = color(1.0),
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")
]],
// -------------------- ALPHA ----------------------
uniform bool enable_opacity = false
[[
anno::display_name("Enable Opacity"),
anno::description("Enables or disables alpha functionality"),
anno::in_group("Alpha")
]],
float alpha_constant = 1.0
[[
anno::enable_if("enable_opacity == true"),
anno::display_name("Opacity Fallback Constant"),
anno::hard_range(0.0, 1.0),
anno::description("The base alpha constant to use if no texture is specified"),
anno::in_group("Alpha")
]],
uniform texture_2d opacity_texture = texture_2d()
[[
anno::enable_if("enable_opacity == true"),
anno::display_name("Opacity Map"),
anno::description("The texture specifying the opacity value to use"),
anno::in_group("Alpha")
]],
uniform bool enable_opacity_cutout = false
[[
anno::enable_if("enable_opacity == true"),
anno::display_name("Enable Alpha Cutout"),
anno::description("Enables or disables alpha cutout functionality"),
anno::in_group("Alpha")
]],
uniform float alpha_cutout_cutoff = 1.f
[[
anno::enable_if("enable_opacity == true"),
anno::enable_if("enable_opacity_cutout == true"),
anno::hard_range(0.0, 1.0),
anno::display_name("Alpha Cutout Cutoff"),
anno::description("The cutoff value to to render as transparent up to and opaque past"),
anno::in_group("Alpha")
]],
// -------------------- NORMAL ----------------------
uniform float bump_factor = 1.f
[[
anno::display_name("Normal Map Strength"),
anno::description("Strength of normal map."),
anno::in_group("Normal")
]],
float3 normal_input = state::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::description("Flips the U Tangent vector."),
anno::in_group("Normal")
]],
uniform bool flip_tangent_v = true
[[
anno::display_name("Normal Map Flip V Tangent"),
anno::description("Flips the V Tangent vector. By Default, SimPBR materials setup for DirectX normal maps. Set Normal Map Flip V = false for OpenGL."),
anno::in_group("Normal")
]],
// -------------------- UV ADJUSTMENTS ----------------------
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 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"),
anno::description("Supports the opaque alpha cutout 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", "opaque", "alpha", "cutout", "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
);
// Need to use a small value so the compiler doesnt optimize out this var...
float t = 0.00000001;//state::animation_time();
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);
// Diffuse Color Lookup and AO
float4 base_lookup = tex::texture_isvalid(diffuse_texture) ? tex::lookup_float4(tex: diffuse_texture, coord: uv) : float4(1, 1, 1, 1);
float opacityValue = tex::texture_isvalid(opacity_texture) ? tex::lookup_float4(tex: opacity_texture, coord: uv).w : alpha_constant;
// Normal calculations
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
) : normal_input;
float3 clearcoat_normal = tex::texture_isvalid(clearcoat_normalmap_texture) ?
base::tangent_space_normal_texture(
texture: clearcoat_normalmap_texture,
factor: clearcoat_bump_factor,
uvw: uvw,
flip_tangent_u: clearcoat_flip_tangent_u,
flip_tangent_v: clearcoat_flip_tangent_v
) : clearcoat_normal_input;
float3 flattened_clearcoat_normal = ::math::lerp(normal_lookup, ::state::normal(), clearcoat_flatten);
float3 final_clearcoat_normal = tex::texture_isvalid(clearcoat_normalmap_texture) ? clearcoat_normal : flattened_clearcoat_normal;
float ao_lookup = tex::texture_isvalid(ao_texture) ? tex::lookup_float4(tex: ao_texture, coord: uv).x : ao_input;
color diffuse_color = tex::texture_isvalid(diffuse_texture) ? color(base_lookup.x, base_lookup.y, base_lookup.z) : diffuse_color_constant;
float3 ORM_lookup = tex::lookup_float3(
tex: ORM_texture,
coord: float2(transformed_uvw.position.x, transformed_uvw.position.y)
);
float roughness_lookup = tex::texture_isvalid(reflectionroughness_texture) ?
tex::lookup_float4(tex: reflectionroughness_texture, coord: uv).x : reflection_roughness_constant;
float anisotropy_lookup = tex::texture_isvalid(anisotropy_texture) ?
(tex::lookup_float4(tex: anisotropy_texture, coord: uv).x * 2.0f - 1.0f) : anisotropy_constant;
float metallic_lookup = tex::texture_isvalid(metallic_texture) ?
tex::lookup_float4(tex: metallic_texture, coord: uv).x : metallic_constant;
float specular_lookup = tex::texture_isvalid(specular_texture) ?
tex::lookup_float4(tex: specular_texture, coord: uv).x : specular_constant;
float roughness_selection = enable_ORM_texture ? ORM_lookup.y : roughness_lookup;
float metallic_selection = enable_ORM_texture ? ORM_lookup.z : metallic_lookup;
float ao = enable_ORM_texture ? ORM_lookup.x : ao_lookup;
float reflection_roughness = math::lerp(reflection_roughness_constant, roughness_selection, reflection_roughness_texture_influence);
float anisotropy = math::lerp(anisotropy_constant, anisotropy_lookup, anisotropy_texture_influence);
float metallic = math::lerp(metallic_constant, metallic_selection, metallic_texture_influence);
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) : emissive_mask_input;
} in SimPBR_Model(
diffuse_color: diffuse_color,
diffuse_tint: diffuse_tint,
roughness: reflection_roughness,
anisotropy: anisotropy,
metallic: metallic,
specular: specular_lookup,
normal: normal_lookup,
enable_clearcoat: enable_clearcoat,
clearcoat_tint: clearcoat_tint,
clearcoat_transparency: clearcoat_transparency,
clearcoat_reflection_roughness: clearcoat_reflection_roughness,
clearcoat_weight: clearcoat_weight,
clearcoat_ior: clearcoat_ior,
clearcoat_normal: final_clearcoat_normal,
enable_retroreflection: enable_retroreflection,
retroreflection_tint: retroreflection_tint,
normal_reflectivity: normal_reflectivity,
grazing_reflectivity: grazing_reflectivity,
ao_to_diffuse: ao_to_diffuse,
ao: ao,
enable_emission: enable_emission,
emissive_color: emissive_color,
emissive_mask: emissive_mask,
emissive_intensity: emissive_intensity,
enable_opacity: enable_opacity,
alpha: opacityValue,
enable_opacity_cutout: enable_opacity_cutout,
alpha_cutout_cutoff: alpha_cutout_cutoff,
opacity_ratio: enable_transmission ? opacity_ratio : 1.0,
opacity_tint : opacity_tint,
opacity_multiplier : opacity_multiplier
);123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212/*****************************************************************************
* Copyright 1986-2020 NVIDIA Corporation. All rights reserved.
******************************************************************************
MDL MATERIALS ARE PROVIDED PURSUANT TO AN END USER LICENSE AGREEMENT,
WHICH WAS ACCEPTED IN ORDER TO GAIN ACCESS TO THIS FILE. IN PARTICULAR,
THE MDL MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL NVIDIA
CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
THE USE OR INABILITY TO USE THE MDL MATERIALS OR FROM OTHER DEALINGS IN
THE MDL MATERIALS.
*/
mdl 1.4;
import ::df::*;
import ::state::*;
import ::math::*;
import ::base::*;
import ::tex::*;
import ::anno::*;
using .::baking_annotations import *;
base::texture_return multiply_colors(
color color_1 = color(1.0, 1.0, 1.0),
color color_2 = color(.5, .5, .5),
float weight = 1.0
)
[[
anno::hidden()
]]
{
return base::blend_color_layers(
layers: base::color_layer[](
base::color_layer(
layer_color: color_2,
weight: weight,
mode: base::color_layer_multiply
)
), base: color_1
);
}
export material SimPBR_Model(
color diffuse_color = color(0.2f) [[ target_baked_argument("diffuse_texture", "diffuse_color_constant", "RGBA8_UNORM") ]],
uniform color diffuse_tint = color(1.0f),
float roughness = 0.5f [[ target_baked_argument("reflectionroughness_texture", "reflection_roughness_constant", "R8_UNORM") ]],
float anisotropy = 0.0f [[ target_baked_argument("anisotropy_texture", "anisotropy_constant", "R8_SNORM") ]],
float metallic = 0.f [[ target_baked_argument("metallic_texture", "metallic_constant", "R8_UNORM") ]],
float specular = 1.f [[ target_baked_argument("specular_texture", "specular_constant", "R8_UNORM") ]],
float3 normal = float3(0.0, 0.0, 0.0) [[ target_baked_argument("normalmap_texture", "normal_input", "RGBA8_SNORM", baking_annotations::TRANSFORM_UNORM_VECTOR) ]],
uniform bool enable_clearcoat = false,
color clearcoat_tint = color(1.0f),
float clearcoat_transparency = 1.0f,
float clearcoat_reflection_roughness = 0.0f,
float clearcoat_weight = 1.0f,
float clearcoat_ior = 1.56f,
float3 clearcoat_normal = float3(0.0, 0.0, 0.0) [[ target_baked_argument("clearcoat_normalmap_texture", "clearcoat_normal_input", "RGBA8_SNORM", baking_annotations::TRANSFORM_UNORM_VECTOR) ]],
uniform bool enable_retroreflection = false,
color retroreflection_tint = color(.182,.800,.000),
uniform float normal_reflectivity = 0.5,
uniform float grazing_reflectivity = 1.0,
float ao_to_diffuse = 0.0,
float ao = 1.0f [[ target_baked_argument("ao_texture", "ao_input", "R8_UNORM") ]],
uniform bool enable_emission = false,
uniform color emissive_color = color(1.0, 0.1, 0.1),
color emissive_mask = color(1.0, 0.1, 0.1) [[ target_baked_argument("emissive_mask_texture", "emissive_mask_input", "R8_UNORM") ]],
uniform float emissive_intensity = 40.f,
uniform bool enable_opacity = false,
float alpha = 1.0,
uniform bool enable_opacity_cutout = false,
uniform float alpha_cutout_cutoff = 1.f,
uniform float opacity_ratio = 1.f,
uniform color opacity_tint = color(1.0f),
uniform float opacity_multiplier = 1.f
)
[[
target_material_model(),
target_material_rendering("..::SimPBR::SimPBR")
]]
= let {
color base_color = multiply_colors(diffuse_color, diffuse_tint, 1.0).tint;
color ao_weighted_base_color = multiply_colors(base_color, color(ao), ao_to_diffuse).tint;
float squared_roughness = roughness * roughness;
float roughness_u = squared_roughness * (1 + anisotropy);
float roughness_v = squared_roughness * (1 - anisotropy);
color diffuse_transmission_color = base_color * opacity_tint * opacity_multiplier;
bsdf diffuse_bsdf = df::weighted_layer(
weight: opacity_ratio,
layer: df::diffuse_reflection_bsdf(
tint: ao_weighted_base_color,
roughness: 0.0f
),
base: df::diffuse_transmission_bsdf(tint: diffuse_transmission_color),
normal: enable_clearcoat ? normal : state::normal()
);
bsdf ggx_smith_bsdf = df::microfacet_ggx_smith_bsdf(
roughness_u: roughness_u,
roughness_v: roughness_v,
tint: color(1.0, 1.0, 1.0),
mode: df::scatter_reflect
);
bsdf custom_curve_layer_bsdf = df::custom_curve_layer(
normal_reflectivity: 0.03,
grazing_reflectivity: 1.0,
exponent: 5.0,
weight: specular,
layer: ggx_smith_bsdf,
base: diffuse_bsdf,
normal: enable_clearcoat ? normal : state::normal()
);
//
// Begin RETROREFLECTION SUPPORT
//
color final_retroreflection_color = multiply_colors(retroreflection_tint, base_color, 1.0).tint;
bsdf backscattering_glossy_bsdf = df::backscattering_glossy_reflection_bsdf(
tint: final_retroreflection_color,
roughness_u: squared_roughness
);
/*bsdf retroreflection_bsdf = df::custom_curve_layer(
normal_reflectivity: 1.-normal_reflectivity,
grazing_reflectivity: 1.-grazing_reflectivity,
base: backscattering_glossy_bsdf,
layer: custom_curve_layer_bsdf,
normal: enable_clearcoat ? normal_lookup : state::normal()
);*/
// if normal_reflectivity and grazing_reflectivity are 1 and weight is 1, just the layer is used
bsdf opt_retroreflection_bsdf = df::custom_curve_layer(
normal_reflectivity: enable_retroreflection ? 1.-normal_reflectivity : 1,
grazing_reflectivity: enable_retroreflection ? 1.-grazing_reflectivity : 1,
base: backscattering_glossy_bsdf,
layer: custom_curve_layer_bsdf,
normal: enable_clearcoat ? normal : state::normal()
);
//
// End RETROREFLECTION SUPPORT
//
bsdf directional_factor_bsdf = df::directional_factor(
normal_tint: ao_weighted_base_color,
grazing_tint: color(1.0, 1.0, 1.0),
exponent: 5.0f,
base: ggx_smith_bsdf
);
// CLEARCOAT
bsdf omni_PBR_bsdf = df::weighted_layer(
weight: metallic,
layer: directional_factor_bsdf,
base: opt_retroreflection_bsdf, //enable_retroreflection ? retroreflection_bsdf : custom_curve_layer_bsdf,
normal: enable_clearcoat ? normal : state::normal()
);
bsdf clearcoat_bsdf = df::microfacet_ggx_smith_bsdf(
roughness_u: clearcoat_reflection_roughness * clearcoat_reflection_roughness,
roughness_v: clearcoat_reflection_roughness * clearcoat_reflection_roughness,
tint: color(1.0f),
mode: df::scatter_reflect
);
// bsdf omni_PBR_coated_bsdf = df::custom_curve_layer(
// normal_reflectivity: clearcoat_reflectivity * 0.08,
// grazing_reflectivity: 1.0,
// weight: clearcoat_weight,
// layer: clearcoat_bsdf,
// base: omni_PBR_bsdf,
// normal: final_clearcoat_normal
// );
bsdf opt_opaque_clearcoat = df::weighted_layer(
weight: enable_clearcoat ? clearcoat_transparency : 1,
layer: ::df::tint(tint: enable_clearcoat ? clearcoat_tint : color(1), base: omni_PBR_bsdf),
base: ::df::diffuse_reflection_bsdf(tint: clearcoat_tint)
);
bsdf opt_omni_PBR_coated_bsdf = df::fresnel_layer(
ior: clearcoat_ior,
weight: enable_clearcoat ? clearcoat_weight : 0,
layer: clearcoat_bsdf,
base: opt_opaque_clearcoat,
normal: clearcoat_normal
);
bsdf final_bsdf = opt_omni_PBR_coated_bsdf;
} in material(
thin_walled: false,
surface: material_surface(
scattering: final_bsdf,
emission: material_emission(
df::diffuse_edf(),
intensity: enable_emission ? emissive_color * emissive_mask * color(emissive_intensity) : color(0)
)
),
geometry: material_geometry(
normal: enable_clearcoat ? state::normal() : normal,
cutout_opacity: enable_opacity ? (enable_opacity_cutout ? (alpha < alpha_cutout_cutoff ? 0.0 : 1.0) : alpha) : 1.0
)
);123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651/*****************************************************************************
* Copyright 1986-2020 NVIDIA Corporation. All rights reserved.
******************************************************************************
MDL MATERIALS ARE PROVIDED PURSUANT TO AN END USER LICENSE AGREEMENT,
WHICH WAS ACCEPTED IN ORDER TO GAIN ACCESS TO THIS FILE. IN PARTICULAR,
THE MDL MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL NVIDIA
CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
THE USE OR INABILITY TO USE THE MDL MATERIALS OR FROM OTHER DEALINGS IN
THE MDL MATERIALS.
*/
mdl 1.4;
import ::df::*;
import ::state::*;
import ::math::*;
import ::base::*;
import ::tex::*;
import ::anno::*;
import ::nvidia::core_definitions::file_texture;
import ::nvidia::core_definitions::normalmap_texture;
float4 raw_file_texture(
uniform texture_2d texture
[[ anno::description("The input texture") ]],
base::texture_coordinate_info uvw = base::texture_coordinate_info()
[[ anno::description("Custom value for texture coordinate") ]],
uniform float2 crop_u = float2(0.0, 1.0)
[[ anno::description("Restricts the texture access to sub-domain of the texture in the u direction") ]],
uniform float2 crop_v = float2(0.0, 1.0)
[[ anno::description("Restricts the texture access to sub-domain of the texture in the v direction") ]],
uniform tex::wrap_mode wrap_u = tex::wrap_repeat
[[ anno::description("Wrapping mode in the u direction") ]],
uniform tex::wrap_mode wrap_v = tex::wrap_repeat
[[ anno::description("Wrapping mode in the v direction") ]]
)
[[
anno::description("General texturing function for 2D bitmap texture stored in a file"),
anno::noinline()
]]
{
return tex::lookup_float4(texture, float2(uvw.position.x, uvw.position.y), wrap_u, wrap_v, crop_u, crop_v);
}
base::texture_return multiply_colors(
color color_1 = color(1.0, 1.0, 1.0),
color color_2 = color(.5, .5, .5),
float weight = 1.0
) [[
anno::hidden()
]]
{
return base::blend_color_layers(
layers: base::color_layer[](
base::color_layer(
layer_color: color_2,
weight: weight,
mode: base::color_layer_multiply
)),
base: color_1
);
}
base::texture_return add_colors(
color color_1 = color(.5, .5, .5),
color color_2 = color(.5, .5, .5),
float weight = 1.0
) [[
anno::hidden(),
anno::unused()
]]
{
return base::blend_color_layers(
layers: base::color_layer[](
base::color_layer(
layer_color: color_2,
weight: weight,
mode: base::color_layer_add
)),
base: color_1
);
}
base::texture_return blend_colors(
color color_1 = color(1.0, 1.0, 1.0),
color color_2 = color(.5, .5, .5),
float weight = 1.0
) [[
anno::hidden(),
anno::unused()
]]
{
return base::blend_color_layers(
layers: base::color_layer[](
base::color_layer(
layer_color: color_2,
weight: weight,
mode: base::color_layer_blend
)),
base: color_1
);
}
export material SimPBR_Opacity(
// -------------------- DIFFUSE REFLECTION ----------------------
uniform color diffuse_color_constant = color(0.2f)
[[
anno::display_name("Albedo Base Color"),
anno::description("The base albedo color to use if no texture is specified"),
anno::in_group("Diffuse")
]],
uniform texture_2d diffuse_texture = texture_2d()
[[
anno::display_name("Albedo Map"),
anno::description("The texture specifying the albedo value to use"),
anno::in_group("Diffuse")
]],
uniform color diffuse_tint = color(1.0f)
[[
anno::display_name("Albedo Tint"),
anno::description("This tints the albedo color or texture contant"),
anno::in_group("Diffuse")
]],
// -------------------- SPECULAR REFLECTION ----------------------
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")
]],
uniform float anisotropy_constant = 0.0f
[[
anno::display_name("Anisotropy Amount"),
anno::hard_range(-1.,1.),
anno::description("0 for isotropic, extents of -1 to 1 for anisotropy"),
anno::in_group("Specular")
]],
uniform float anisotropy_texture_influence = 0.0f
[[
anno::display_name("Anisotropy Map Influence"),
anno::hard_range(0.0, 1.),
anno::description("Blends between the constant value and the lookup of the anisotropy texture"),
anno::in_group("Specular")
]],
uniform texture_2d anisotropy_texture = texture_2d()
[[
anno::display_name("Anisotropy Map"),
anno::in_group("Specular")
]],
uniform float metallic_constant = 0.f
[[
anno::display_name("Metallic Amount"),
anno::hard_range(0.0,1.),
anno::description("Metallic Material"),
anno::in_group("Specular")
]],
uniform float metallic_texture_influence = 0.0f
[[
anno::display_name("Metallic Map Influence"),
anno::hard_range(0.0, 1.),
anno::description("Blends between the constant value and the lookup of the metallic texture"),
anno::in_group("Specular")
]],
uniform texture_2d metallic_texture = texture_2d()
[[
anno::display_name("Metallic Map"),
anno::in_group("Specular")
]],
// -------------------- ORM ----------------------
uniform bool enable_ORM_texture = true
[[
anno::display_name("Enable ORM Texture"),
anno::description("When True the ORM texture will be used to extract the Occlusion, Roughness and Metallic Map"),
anno::in_group("Reflectivity")
]],
uniform texture_2d ORM_texture = texture_2d()
[[
anno::display_name("ORM Map"),
anno::description("Texture that hae Occlusion, Roughness and Metallic map stored in the respective r, g and b channels"),
anno::in_group("Reflectivity")
]],
// -------------------- Clearcoat ----------------------
uniform bool enable_clearcoat = false
[[
anno::display_name("Enable Clearcoat Layer"),
anno::description("Adds a clearcoat layer on top of the material when enabled"),
anno::in_group("Clearcoat")
]],
color clearcoat_tint = color(1.0f)
[[
anno::display_name("Clearcoat Tint"),
anno::description("Clearcoat is tinted and affects the underlying material"),
anno::in_group("Clearcoat")
]],
float clearcoat_transparency = 1.0f
[[
anno::display_name("Clearcoat Transparency"),
anno::description("Adjusts the transparency of the clearcoat. Can be turned into a fully opaque clearcoat "
"covering the underlying layer"),
anno::in_group("Clearcoat")
]],
float clearcoat_reflection_roughness = 0.0f
[[
anno::display_name("Clearcoat Roughness"),
anno::description("Higher roughness values lead to more blurry reflections"),
anno::hard_range(0.0f, 1.0f),
anno::in_group("Clearcoat")
]],
float clearcoat_weight = 1.0f
[[
anno::display_name("Clearcoat Weight"),
anno::description("Sets the weight for clearcoat layer"),
anno::hard_range(0.0f, 1.0f),
anno::in_group("Clearcoat")
]],
float clearcoat_flatten = 1.0f
[[
anno::display_name("Clearcoat Flatten"),
anno::description("Flattens the clearcoat to even out the underlying bump maps"),
anno::hard_range(0.0f, 1.0f),
anno::in_group("Clearcoat")
]],
float clearcoat_ior = 1.56f
[[
anno::display_name("Clearcoat IOR"),
anno::description("Sets the Index of refraction for the clearcoat layer"),
anno::soft_range(1.0f, 4.0f),
anno::in_group("Clearcoat")
]],
uniform float clearcoat_bump_factor = 1.f
[[
anno::display_name("Clearcoat Normal Map Strength"),
anno::description("Strength of normal map."),
anno::in_group("Clearcoat")
]],
uniform texture_2d clearcoat_normalmap_texture = texture_2d()
[[
anno::display_name("Clearcoat Normal Map"),
anno::description("Enables the usage of the normalmap texture"),
anno::in_group("Clearcoat")
]],
// -------------------- REFLECTIVITY ----------------------
uniform bool enable_retroreflection = false
[[
anno::display_name("Enable Retroreflection"),
anno::in_group("Reflectivity")
]],
color retroreflection_color = color(.182,.800,.000)
[[
anno::display_name("Retro-reflection color"),
anno::description("The color of the retroreflection"),
anno::in_group("Reflectivity")
]],
uniform float normal_reflectivity = 0.5
[[
anno::display_name("Retro-reflection weight facing"),
anno::hard_range(0.0,1.),
anno::description("Reflectivity control for geometry facing the viewer"),
anno::in_group("Reflectivity")
]],
uniform float grazing_reflectivity = 1.0
[[
anno::display_name("Retro-reflection weight edge"),
anno::hard_range(0.0,1.),
anno::description("Reflectivity control for the reflectivity at geometry edges"),
anno::in_group("Reflectivity")
]],
// -------------------- AMBIENT OCCLUSION ----------------------
float ao_to_diffuse = 0.0
[[
anno::display_name("AO to Diffuse"),
anno::description("Controls the amount of ambient occlusion multiplied into the diffuse color channel"),
anno::in_group("AO")
]],
uniform texture_2d ao_texture = texture_2d()
[[
anno::display_name("Ambient Occlusion Map"),
anno::description("The Ambient Occlusion texture for the material"),
anno::in_group("AO")
]],
// -------------------- EMISSIVE ----------------------
uniform bool enable_emission = false
[[
anno::display_name("Enable Emission"),
anno::description("Enables the emission of light from the material"),
anno::in_group("Emissive")
]],
uniform 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")
]],
// -------------------- ALPHA ----------------------
uniform bool enable_alpha = true
[[
anno::display_name("Enable Alpha"),
anno::description("Enables or disables alpha functionality"),
anno::in_group("Alpha")
]],
uniform float alpha_constant = 1.0
[[
anno::display_name("Alpha Fallback Constant"),
anno::description("The base alpha constant to use if no texture is specified"),
anno::in_group("Alpha")
]],
uniform texture_2d opacity_texture = texture_2d()
[[
anno::display_name("Opacity Map"),
anno::description("The texture specifying the opacity value to use"),
anno::in_group("Alpha")
]],
uniform bool enable_alpha_cutout = false
[[
anno::display_name("Enable Alpha Cutout"),
anno::description("Enables or disables alpha cutout functionality"),
anno::in_group("Alpha")
]],
uniform float alpha_cutout_cutoff = 1.f
[[
anno::enable_if("enable_alpha_cutout == true"),
anno::hard_range(0.0, 1.0),
anno::display_name("Alpha Cutout Cutoff"),
anno::description("The cutoff value to to render as transparent up to and opaque past"),
anno::in_group("Alpha")
]],
// -------------------- NORMAL ----------------------
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")
]],
// -------------------- UV ADJUSTMENTS ----------------------
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 Scale"),
anno::description("Larger number increases size of 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 Opaque Alpha Cutout"),
anno::description("Supports the opaque alpha cutout material model of the Sim Renderer"),
anno::version( 1, 0, 0),
anno::author("NVIDIA CORPORATION"),
anno::key_words(string[]("Sim", "PBR", "opaque", "alpha", "cutout", "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
);
// Need to use a small value so the compiler doesnt optimize out this var...
float t = 0.00000001;//state::animation_time();
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 );
// Diffuse Color Lookup and AO
float4 base_lookup = tex::texture_isvalid(diffuse_texture) ? raw_file_texture(texture: diffuse_texture, uvw: transformed_uvw) : float4(1, 1, 1, 1);
float opacityValue = tex::texture_isvalid(opacity_texture) ? raw_file_texture(texture: opacity_texture, uvw: transformed_uvw).x : alpha_constant;
// Normal calculations
float3 normal_lookup = tex::texture_isvalid(normalmap_texture) ?
base::tangent_space_normal_texture(
texture: normalmap_texture,
factor: bump_factor,
uvw: transformed_uvw
) : state::normal();
float3 clearcoat_normal = base::tangent_space_normal_texture(
texture: clearcoat_normalmap_texture,
factor: clearcoat_bump_factor,
uvw: uvw
);
float3 flattened_clearcoat_normal = ::math::lerp(normal_lookup, ::state::normal(), clearcoat_flatten);
float3 final_clearcoat_normal = tex::texture_isvalid(clearcoat_normalmap_texture) ? clearcoat_normal : flattened_clearcoat_normal;
float ao_lookup = tex::texture_isvalid(ao_texture) ?
raw_file_texture(texture: ao_texture, uvw: transformed_uvw).x :
1.0f
[[anno::unused("Currently unused in material, may be utilized in the future")]];
color diffuse_color = tex::texture_isvalid(diffuse_texture) ? color(base_lookup.x, base_lookup.y, base_lookup.z) : diffuse_color_constant;
color base_color = multiply_colors(diffuse_color, diffuse_tint, 1.0).tint;
float3 ORM_lookup = tex::lookup_float3(
tex: ORM_texture,
coord: float2(transformed_uvw.position.x, transformed_uvw.position.y)
);
float roughness_lookup = tex::texture_isvalid(reflectionroughness_texture) ?
raw_file_texture(texture: reflectionroughness_texture, uvw: transformed_uvw).x :
reflection_roughness_constant;
float anisotropy_lookup = tex::texture_isvalid(anisotropy_texture) ?
(raw_file_texture(texture: anisotropy_texture, uvw: transformed_uvw).x * 2.0f - 1.0f) :
anisotropy_constant;
float metallic_lookup = tex::texture_isvalid(metallic_texture) ?
raw_file_texture(texture: metallic_texture, uvw: transformed_uvw).x :
metallic_constant;
float roughness_selection = enable_ORM_texture ? ORM_lookup.y : roughness_lookup;
float metallic_selection = enable_ORM_texture ? ORM_lookup.z : metallic_lookup;
color ao_color = enable_ORM_texture ? color(ORM_lookup.x) : color(ao_lookup);
color ao_weighted_base_color = multiply_colors(base_color, ao_color, ao_to_diffuse).tint;
float reflection_roughness = math::lerp(reflection_roughness_constant, roughness_selection, reflection_roughness_texture_influence);
float anisotropy = math::lerp(anisotropy_constant, anisotropy_lookup, anisotropy_texture_influence);
float metallic = math::lerp(metallic_constant, metallic_selection, metallic_texture_influence);
float squared_roughness = reflection_roughness * reflection_roughness;
float roughness_u = squared_roughness * (1 + anisotropy);
float roughness_v = squared_roughness * (1 - anisotropy);
bsdf diffuse_bsdf = df::weighted_layer(
weight: 1.0,
layer: df::diffuse_reflection_bsdf(
tint: ao_weighted_base_color,
roughness: 0.f ),
base: bsdf(),
normal: enable_clearcoat ? normal_lookup : state::normal()
);
bsdf ggx_smith_bsdf = df::microfacet_ggx_smith_bsdf(
roughness_u: roughness_u,
roughness_v: roughness_v,
tint: color(1.0, 1.0, 1.0),
mode: df::scatter_reflect
);
bsdf custom_curve_layer_bsdf = df::custom_curve_layer(
normal_reflectivity: 0.03,
grazing_reflectivity: 1.0,
exponent: 5.0,
weight: float(1.0),
layer: ggx_smith_bsdf,
base: diffuse_bsdf,
normal: enable_clearcoat ? normal_lookup : state::normal()
);
//
// Begin RETROREFLECTION SUPPORT
//
bsdf backscattering_glossy_bsdf = df::backscattering_glossy_reflection_bsdf(
tint: retroreflection_color,
roughness_u: reflection_roughness * reflection_roughness
);
bsdf retroreflection_bsdf = df::custom_curve_layer(
normal_reflectivity: 1.-normal_reflectivity,
grazing_reflectivity: 1.-grazing_reflectivity,
base: backscattering_glossy_bsdf,
layer: diffuse_bsdf,
normal: enable_clearcoat ? normal_lookup : state::normal()
);
//
// End RETROREFLECTION SUPPORT
//
bsdf directional_factor_bsdf = df::directional_factor(
normal_tint: ao_weighted_base_color,
grazing_tint: color(1.0, 1.0, 1.0),
exponent: 5.0f,
base: ggx_smith_bsdf
);
// CLEARCOAT
bsdf omni_PBR_bsdf = df::weighted_layer(
weight: metallic,
layer: directional_factor_bsdf,
base: enable_retroreflection ? retroreflection_bsdf : custom_curve_layer_bsdf,
normal: enable_clearcoat ? normal_lookup : state::normal()
);
bsdf clearcoat_bsdf = df::microfacet_ggx_smith_bsdf(
roughness_u: clearcoat_reflection_roughness * clearcoat_reflection_roughness,
roughness_v: clearcoat_reflection_roughness * clearcoat_reflection_roughness,
tint: color(1.0f),
mode: df::scatter_reflect
);
// bsdf omni_PBR_coated_bsdf = df::custom_curve_layer(
// normal_reflectivity: clearcoat_reflectivity * 0.08,
// grazing_reflectivity: 1.0,
// weight: clearcoat_weight,
// layer: clearcoat_bsdf,
// base: omni_PBR_bsdf,
// normal: final_clearcoat_normal
// );
bsdf opaque_clearcoat = df::weighted_layer(
weight: clearcoat_transparency,
layer: ::df::tint(
tint: clearcoat_tint,
base: omni_PBR_bsdf),
base: ::df::diffuse_reflection_bsdf(
tint: clearcoat_tint)
);
bsdf omni_PBR_coated_bsdf = df::fresnel_layer(
ior: clearcoat_ior,
weight: clearcoat_weight,
layer: clearcoat_bsdf,
base: opaque_clearcoat,
normal: final_clearcoat_normal
);
bsdf final_bsdf = enable_clearcoat ? omni_PBR_coated_bsdf : omni_PBR_bsdf;
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);
} in material(
thin_walled: false,
surface: material_surface(
scattering: final_bsdf,
emission: material_emission (
df::diffuse_edf(),
intensity: enable_emission ? emissive_color * emissive_mask * color(emissive_intensity) : color(0)
)
),
geometry: material_geometry(
normal: enable_clearcoat ? state::normal() : normal_lookup,
cutout_opacity: enable_alpha ? (enable_alpha_cutout ? (opacityValue < alpha_cutout_cutoff ? 0.0 : 1.0) : opacityValue) : 1.0
)
);123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290/*****************************************************************************
* Copyright 1986-2020 NVIDIA Corporation. All rights reserved.
******************************************************************************
MDL MATERIALS ARE PROVIDED PURSUANT TO AN END USER LICENSE AGREEMENT,
WHICH WAS ACCEPTED IN ORDER TO GAIN ACCESS TO THIS FILE. IN PARTICULAR,
THE MDL MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL NVIDIA
CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
THE USE OR INABILITY TO USE THE MDL MATERIALS OR FROM OTHER DEALINGS IN
THE MDL MATERIALS.
*/
mdl 1.4;
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(
// -------------------- SPECULAR REFLECTION/TRANSMISSION ----------------------
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")
]],
// -------------------- VOLUME ----------------------
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")
]],
// -------------------- EMISSIVE ----------------------
uniform bool enable_thin_walled = false
[[
anno::display_name("Enable Thin Walled"),
anno::description("Enables thin walled logic"),
anno::in_group("Geometry")
]],
// -------------------- EMISSIVE ----------------------
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")
]],
// -------------------- NORMAL ----------------------
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")
]],
// -------------------- UV ADJUSTMENTS ----------------------
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
);
// Need to use a small value so the compiler doesnt optimize out this var...
float t = 0.00000001;//state::animation_time();
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),
::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),
::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);
// Normal calculations
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
)
);12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152mdl 1.7;
using ::OmniPBR import OmniPBR;
import ::tex::gamma_mode;
import ::state::normal;
import ::base::mono_mode;
export material Plastic_B(*)
= OmniPBR(
diffuse_color_constant: color(),
diffuse_texture: texture_2d(),
albedo_desaturation: 0.0,
albedo_add: 0.0,
albedo_brightness: 1.0,
diffuse_tint: color(1, 1, 1),
reflection_roughness_constant: 0.5,
reflection_roughness_texture_influence: 1.0,
reflectionroughness_texture: texture_2d(),
metallic_constant: 0.0,
metallic_texture_influence: 1.0,
metallic_texture: texture_2d(),
specular_level: 0.5,
enable_ORM_texture: true,
ORM_texture: texture_2d("../textures/T_Plastic_ORM_1k.png", ::tex::gamma_linear),
ao_to_diffuse: 0.0,
ao_texture: texture_2d(),
enable_emission: false,
emissive_color: color(1, 0.1, 0.1),
emissive_color_texture: texture_2d(),
emissive_mask_texture: texture_2d(),
emissive_intensity: 40.0,
enable_opacity: false,
enable_opacity_texture: false,
opacity_constant: 1.0,
opacity_texture: texture_2d(),
opacity_mode: ::base::mono_average,
opacity_threshold: 0.0,
bump_factor: 1.0,
normalmap_texture: texture_2d("../textures/T_Plastic_Normal_1k.png", ::tex::gamma_linear),
detail_bump_factor: 0.30000001192092896,
detail_normalmap_texture: texture_2d(),
flip_tangent_u: false,
flip_tangent_v: true,
project_uvw: false,
world_or_object: false,
uv_space_index: 0,
texture_translate: float2(0, 0),
texture_rotate: 0.0,
texture_scale: float2(3, 3),
detail_texture_translate: float2(0, 0),
detail_texture_rotate: 0.0,
detail_texture_scale: float2(1, 1));12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152mdl 1.4;
using ::OmniPBR import OmniPBR;
import ::tex::gamma_mode;
import ::state::normal;
import ::base::mono_mode;
export material Plastic_Black_A(*)
= OmniPBR(
diffuse_color_constant: color(0.2, 0.2, 0.2),
diffuse_texture: texture_2d("../textures/T_Plastic_Black_A_Albedo.png", ::tex::gamma_srgb),
albedo_desaturation: 0.0,
albedo_add: 0.0,
albedo_brightness: 1.0,
diffuse_tint: color(1, 1, 1),
reflection_roughness_constant: 0.5,
reflection_roughness_texture_influence: 1.0,
reflectionroughness_texture: texture_2d(),
metallic_constant: 0.0,
metallic_texture_influence: 1.0,
metallic_texture: texture_2d(),
specular_level: 0.5,
enable_ORM_texture: true,
ORM_texture: texture_2d("../textures/T_Plastic_Black_A_ORM.png", ::tex::gamma_linear),
ao_to_diffuse: 0.0,
ao_texture: texture_2d(),
enable_emission: false,
emissive_color: color(1, 0.1, 0.1),
emissive_color_texture: texture_2d(),
emissive_mask_texture: texture_2d(),
emissive_intensity: 40.0,
enable_opacity: false,
enable_opacity_texture: false,
opacity_constant: 1.0,
opacity_texture: texture_2d(),
opacity_mode: ::base::mono_average,
opacity_threshold: 0.0,
bump_factor: 1.0,
normalmap_texture: texture_2d("../textures/T_Plastic_Black_A_Normal.png", ::tex::gamma_linear),
detail_bump_factor: 0.30000001192092896,
detail_normalmap_texture: texture_2d(),
flip_tangent_u: false,
flip_tangent_v: true,
project_uvw: false,
world_or_object: false,
uv_space_index: 0,
texture_translate: float2(0, 0),
texture_rotate: 0.0,
texture_scale: float2(3, 3),
detail_texture_translate: float2(0, 0),
detail_texture_rotate: 0.0,
detail_texture_scale: float2(1, 1));12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152mdl 1.7;
using ::OmniPBR import OmniPBR;
import ::tex::gamma_mode;
import ::state::normal;
import ::base::mono_mode;
export material Plastic_B(*)
= OmniPBR(
diffuse_color_constant: color(),
diffuse_texture: texture_2d(),
albedo_desaturation: 0.0,
albedo_add: 0.0,
albedo_brightness: 1.0,
diffuse_tint: color(1, 1, 1),
reflection_roughness_constant: 0.5,
reflection_roughness_texture_influence: 1.0,
reflectionroughness_texture: texture_2d(),
metallic_constant: 0.0,
metallic_texture_influence: 1.0,
metallic_texture: texture_2d(),
specular_level: 0.5,
enable_ORM_texture: true,
ORM_texture: texture_2d("../textures/T_Plastic_ORM_1k.png", ::tex::gamma_linear),
ao_to_diffuse: 0.0,
ao_texture: texture_2d(),
enable_emission: false,
emissive_color: color(1, 0.1, 0.1),
emissive_color_texture: texture_2d(),
emissive_mask_texture: texture_2d(),
emissive_intensity: 40.0,
enable_opacity: false,
enable_opacity_texture: false,
opacity_constant: 1.0,
opacity_texture: texture_2d(),
opacity_mode: ::base::mono_average,
opacity_threshold: 0.0,
bump_factor: 1.0,
normalmap_texture: texture_2d("../textures/T_Plastic_Normal_1k.png", ::tex::gamma_linear),
detail_bump_factor: 0.30000001192092896,
detail_normalmap_texture: texture_2d(),
flip_tangent_u: false,
flip_tangent_v: true,
project_uvw: false,
world_or_object: false,
uv_space_index: 0,
texture_translate: float2(0, 0),
texture_rotate: 0.0,
texture_scale: float2(3, 3),
detail_texture_translate: float2(0, 0),
detail_texture_rotate: 0.0,
detail_texture_scale: float2(1, 1));12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152mdl 1.4;
using ::OmniPBR import OmniPBR;
import ::tex::gamma_mode;
import ::state::normal;
import ::base::mono_mode;
export material Plastic_Black_A(*)
= OmniPBR(
diffuse_color_constant: color(0.2, 0.2, 0.2),
diffuse_texture: texture_2d("../textures/T_Plastic_Black_A_Albedo.png", ::tex::gamma_srgb),
albedo_desaturation: 0.0,
albedo_add: 0.0,
albedo_brightness: 1.0,
diffuse_tint: color(1, 1, 1),
reflection_roughness_constant: 0.5,
reflection_roughness_texture_influence: 1.0,
reflectionroughness_texture: texture_2d(),
metallic_constant: 0.0,
metallic_texture_influence: 1.0,
metallic_texture: texture_2d(),
specular_level: 0.5,
enable_ORM_texture: true,
ORM_texture: texture_2d("../textures/T_Plastic_Black_A_ORM.png", ::tex::gamma_linear),
ao_to_diffuse: 0.0,
ao_texture: texture_2d(),
enable_emission: false,
emissive_color: color(1, 0.1, 0.1),
emissive_color_texture: texture_2d(),
emissive_mask_texture: texture_2d(),
emissive_intensity: 40.0,
enable_opacity: false,
enable_opacity_texture: false,
opacity_constant: 1.0,
opacity_texture: texture_2d(),
opacity_mode: ::base::mono_average,
opacity_threshold: 0.0,
bump_factor: 1.0,
normalmap_texture: texture_2d("../textures/T_Plastic_Black_A_Normal.png", ::tex::gamma_linear),
detail_bump_factor: 0.30000001192092896,
detail_normalmap_texture: texture_2d(),
flip_tangent_u: false,
flip_tangent_v: true,
project_uvw: false,
world_or_object: false,
uv_space_index: 0,
texture_translate: float2(0, 0),
texture_rotate: 0.0,
texture_scale: float2(3, 3),
detail_texture_translate: float2(0, 0),
detail_texture_rotate: 0.0,
detail_texture_scale: float2(1, 1));12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152mdl 1.7;
using ::OmniPBR import OmniPBR;
import ::tex::gamma_mode;
import ::state::normal;
import ::base::mono_mode;
export material Plastic_B(*)
= OmniPBR(
diffuse_color_constant: color(),
diffuse_texture: texture_2d(),
albedo_desaturation: 0.0,
albedo_add: 0.0,
albedo_brightness: 1.0,
diffuse_tint: color(1, 1, 1),
reflection_roughness_constant: 0.5,
reflection_roughness_texture_influence: 1.0,
reflectionroughness_texture: texture_2d(),
metallic_constant: 0.0,
metallic_texture_influence: 1.0,
metallic_texture: texture_2d(),
specular_level: 0.5,
enable_ORM_texture: true,
ORM_texture: texture_2d("../textures/T_Plastic_ORM_1k.png", ::tex::gamma_linear),
ao_to_diffuse: 0.0,
ao_texture: texture_2d(),
enable_emission: false,
emissive_color: color(1, 0.1, 0.1),
emissive_color_texture: texture_2d(),
emissive_mask_texture: texture_2d(),
emissive_intensity: 40.0,
enable_opacity: false,
enable_opacity_texture: false,
opacity_constant: 1.0,
opacity_texture: texture_2d(),
opacity_mode: ::base::mono_average,
opacity_threshold: 0.0,
bump_factor: 1.0,
normalmap_texture: texture_2d("../textures/T_Plastic_Normal_1k.png", ::tex::gamma_linear),
detail_bump_factor: 0.30000001192092896,
detail_normalmap_texture: texture_2d(),
flip_tangent_u: false,
flip_tangent_v: true,
project_uvw: false,
world_or_object: false,
uv_space_index: 0,
texture_translate: float2(0, 0),
texture_rotate: 0.0,
texture_scale: float2(3, 3),
detail_texture_translate: float2(0, 0),
detail_texture_rotate: 0.0,
detail_texture_scale: float2(1, 1));12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152mdl 1.4;
using ::OmniPBR import OmniPBR;
import ::tex::gamma_mode;
import ::state::normal;
import ::base::mono_mode;
export material Plastic_Black_A(*)
= OmniPBR(
diffuse_color_constant: color(0.2, 0.2, 0.2),
diffuse_texture: texture_2d("../textures/T_Plastic_Black_A_Albedo.png", ::tex::gamma_srgb),
albedo_desaturation: 0.0,
albedo_add: 0.0,
albedo_brightness: 1.0,
diffuse_tint: color(1, 1, 1),
reflection_roughness_constant: 0.5,
reflection_roughness_texture_influence: 1.0,
reflectionroughness_texture: texture_2d(),
metallic_constant: 0.0,
metallic_texture_influence: 1.0,
metallic_texture: texture_2d(),
specular_level: 0.5,
enable_ORM_texture: true,
ORM_texture: texture_2d("../textures/T_Plastic_Black_A_ORM.png", ::tex::gamma_linear),
ao_to_diffuse: 0.0,
ao_texture: texture_2d(),
enable_emission: false,
emissive_color: color(1, 0.1, 0.1),
emissive_color_texture: texture_2d(),
emissive_mask_texture: texture_2d(),
emissive_intensity: 40.0,
enable_opacity: false,
enable_opacity_texture: false,
opacity_constant: 1.0,
opacity_texture: texture_2d(),
opacity_mode: ::base::mono_average,
opacity_threshold: 0.0,
bump_factor: 1.0,
normalmap_texture: texture_2d("../textures/T_Plastic_Black_A_Normal.png", ::tex::gamma_linear),
detail_bump_factor: 0.30000001192092896,
detail_normalmap_texture: texture_2d(),
flip_tangent_u: false,
flip_tangent_v: true,
project_uvw: false,
world_or_object: false,
uv_space_index: 0,
texture_translate: float2(0, 0),
texture_rotate: 0.0,
texture_scale: float2(3, 3),
detail_texture_translate: float2(0, 0),
detail_texture_rotate: 0.0,
detail_texture_scale: float2(1, 1));12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152mdl 1.7;
using ::OmniPBR import OmniPBR;
import ::tex::gamma_mode;
import ::state::normal;
import ::base::mono_mode;
export material Plastic_B(*)
= OmniPBR(
diffuse_color_constant: color(),
diffuse_texture: texture_2d(),
albedo_desaturation: 0.0,
albedo_add: 0.0,
albedo_brightness: 1.0,
diffuse_tint: color(1, 1, 1),
reflection_roughness_constant: 0.5,
reflection_roughness_texture_influence: 1.0,
reflectionroughness_texture: texture_2d(),
metallic_constant: 0.0,
metallic_texture_influence: 1.0,
metallic_texture: texture_2d(),
specular_level: 0.5,
enable_ORM_texture: true,
ORM_texture: texture_2d("../textures/T_Plastic_ORM_1k.png", ::tex::gamma_linear),
ao_to_diffuse: 0.0,
ao_texture: texture_2d(),
enable_emission: false,
emissive_color: color(1, 0.1, 0.1),
emissive_color_texture: texture_2d(),
emissive_mask_texture: texture_2d(),
emissive_intensity: 40.0,
enable_opacity: false,
enable_opacity_texture: false,
opacity_constant: 1.0,
opacity_texture: texture_2d(),
opacity_mode: ::base::mono_average,
opacity_threshold: 0.0,
bump_factor: 1.0,
normalmap_texture: texture_2d("../textures/T_Plastic_Normal_1k.png", ::tex::gamma_linear),
detail_bump_factor: 0.30000001192092896,
detail_normalmap_texture: texture_2d(),
flip_tangent_u: false,
flip_tangent_v: true,
project_uvw: false,
world_or_object: false,
uv_space_index: 0,
texture_translate: float2(0, 0),
texture_rotate: 0.0,
texture_scale: float2(3, 3),
detail_texture_translate: float2(0, 0),
detail_texture_rotate: 0.0,
detail_texture_scale: float2(1, 1));12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152mdl 1.4;
using ::OmniPBR import OmniPBR;
import ::tex::gamma_mode;
import ::state::normal;
import ::base::mono_mode;
export material Plastic_Black_A(*)
= OmniPBR(
diffuse_color_constant: color(0.2, 0.2, 0.2),
diffuse_texture: texture_2d("../textures/T_Plastic_Black_A_Albedo.png", ::tex::gamma_srgb),
albedo_desaturation: 0.0,
albedo_add: 0.0,
albedo_brightness: 1.0,
diffuse_tint: color(1, 1, 1),
reflection_roughness_constant: 0.5,
reflection_roughness_texture_influence: 1.0,
reflectionroughness_texture: texture_2d(),
metallic_constant: 0.0,
metallic_texture_influence: 1.0,
metallic_texture: texture_2d(),
specular_level: 0.5,
enable_ORM_texture: true,
ORM_texture: texture_2d("../textures/T_Plastic_Black_A_ORM.png", ::tex::gamma_linear),
ao_to_diffuse: 0.0,
ao_texture: texture_2d(),
enable_emission: false,
emissive_color: color(1, 0.1, 0.1),
emissive_color_texture: texture_2d(),
emissive_mask_texture: texture_2d(),
emissive_intensity: 40.0,
enable_opacity: false,
enable_opacity_texture: false,
opacity_constant: 1.0,
opacity_texture: texture_2d(),
opacity_mode: ::base::mono_average,
opacity_threshold: 0.0,
bump_factor: 1.0,
normalmap_texture: texture_2d("../textures/T_Plastic_Black_A_Normal.png", ::tex::gamma_linear),
detail_bump_factor: 0.30000001192092896,
detail_normalmap_texture: texture_2d(),
flip_tangent_u: false,
flip_tangent_v: true,
project_uvw: false,
world_or_object: false,
uv_space_index: 0,
texture_translate: float2(0, 0),
texture_rotate: 0.0,
texture_scale: float2(3, 3),
detail_texture_translate: float2(0, 0),
detail_texture_rotate: 0.0,
detail_texture_scale: float2(1, 1));assets/objects/dojo/blocks/blue_block.usdcAdded
assets/objects/dojo/blocks/green_block.usdcAdded
assets/objects/dojo/blocks/red_block.usdcAdded
assets/objects/dojo/blocks/sources.jsonAdded+109
assets/objects/dojo/bowl/sources.jsonAdded+16
assets/objects/dojo/pickup/book.usdcAdded
assets/objects/dojo/pickup/book_book (3).jpgAdded
.jpg)
assets/objects/dojo/pickup/book_texturs a (2).jpgAdded
.jpg)
assets/objects/dojo/pickup/eraser.usdcAdded
assets/objects/dojo/pickup/eraser_scan.jpgAdded

assets/objects/fruits_veggies/materials/SimPBR.mdlAdded+562
assets/objects/fruits_veggies/materials/SimPBR_Model.mdlAdded+212
assets/objects/fruits_veggies/materials/baking_annotations.mdlAdded+38
assets/objects/fruits_veggies/textures/lemon_01/materials/OmniPBR_Opacity.mdlAdded+426
assets/objects/fruits_veggies/textures/lemon_02/materials/OmniPBR_Opacity.mdlAdded+426
assets/objects/vomp/antiquelvasesmall/materials/SimPBR.mdlAdded+562
assets/objects/vomp/antiquelvasesmall/materials/SimPBR_Model.mdlAdded+212
assets/objects/vomp/antiquelvasesmall/materials/SimPBR_Opacity.mdlAdded+651
assets/objects/vomp/antiquelvasesmall/materials/SimPBR_Translucent.mdlAdded+290
assets/objects/vomp/anza_large/materials/SimPBR.mdlAdded+562
assets/objects/vomp/anza_large/materials/SimPBR_Model.mdlAdded+212
assets/objects/vomp/anza_large/materials/SimPBR_Opacity.mdlAdded+651
assets/objects/vomp/anza_large/materials/SimPBR_Translucent.mdlAdded+290
assets/objects/vomp/anza_medium/materials/SimPBR.mdlAdded+562
assets/objects/vomp/anza_medium/materials/SimPBR_Model.mdlAdded+212
assets/objects/vomp/anza_medium/materials/SimPBR_Opacity.mdlAdded+651
assets/objects/vomp/anza_medium/materials/SimPBR_Translucent.mdlAdded+290
assets/objects/vomp/bin_a01/materials/Plastic_B.mdlAdded+52
assets/objects/vomp/bin_a03/materials/Plastic_B.mdlAdded+52
assets/objects/vomp/bin_a05/materials/Plastic_B.mdlAdded+52
assets/objects/vomp/bin_b01/materials/Plastic_B.mdlAdded+52
assets/objects/vomp/bin_b04/materials/Plastic_B.mdlAdded+52
assets/objects/vomp/bin_b06/materials/Plastic_B.mdlAdded+52
assets/objects/vomp/bin_b07/materials/Plastic_B.mdlAdded+52
assets/objects/vomp/blackandbrassbowl_large/materials/SimPBR.mdlAdded+562
assets/objects/vomp/blackandbrassbowl_large/materials/SimPBR_Model.mdlAdded+212
assets/objects/vomp/blackandbrassbowl_large/materials/SimPBR_Opacity.mdlAdded+651
assets/objects/vomp/blackandbrassbowl_large/materials/SimPBR_Translucent.mdlAdded+290
assets/objects/vomp/blackandbrassbowl_small/materials/SimPBR.mdlAdded+562
assets/objects/vomp/blackandbrassbowl_small/materials/SimPBR_Model.mdlAdded+212
assets/objects/vomp/blackandbrassbowl_small/materials/SimPBR_Opacity.mdlAdded+651
assets/objects/vomp/blackandbrassbowl_small/materials/SimPBR_Translucent.mdlAdded+290
assets/objects/vomp/box_a01/materials/Plastic_B.mdlAdded+52
assets/objects/vomp/box_a01/materials/Plastic_Black_A.mdlAdded+52
assets/objects/vomp/box_a03/materials/Plastic_B.mdlAdded+52
assets/objects/vomp/box_a03/materials/Plastic_Black_A.mdlAdded+52
assets/objects/vomp/box_a06/materials/Plastic_B.mdlAdded+52
assets/objects/vomp/box_a06/materials/Plastic_Black_A.mdlAdded+52
assets/objects/vomp/box_a07/materials/Plastic_B.mdlAdded+52
assets/objects/vomp/box_a07/materials/Plastic_Black_A.mdlAdded+52