Hi experts, I’m learning about MDL and USD. USD file is able to refer to MDL file as assert. For example:
def Material "sample"
{
color3f inputs:base_color = (0.5, 0.5, 0.5)
float inputs:anisotropy = 0
float inputs:anisotropy_rotation = 0
token outputs:mdl:surface.connect = </sample/flex_material.outputs:out>
token outputs:mdl:volume.connect = </sample/flex_material.outputs:out>
token outputs:mdl:displacement.connect = </sample/flex_material.outputs:out>
def Shader "flex_material"
{
uniform token info:implementationSource = "sourceAsset"
uniform asset info:mdl:sourceAsset = @nvidia/core_definitions.mdl@
uniform token info:mdl:sourceAsset:subIdentifier = "flex_material"
color3f inputs:base_color.connect = </sample.inputs:base_color>
float inputs:anisotropy.connect = </sample.inputs:anisotropy>
float inputs:anisotropy_rotation.connect = </sample.inputs:anisotropy_rotation>
}
}
But if there was another shader in the Material “sample”, and the shader refer to another MDL file, could the material work? And Is this case meaningful?
Hi @xiaobai9007 . Welcome to the forums! Please consider also joining us on Discord: NVIDIA Omniverse .
Yes, a material can be built up of more than one MDL. Here’s an example created using the material graph in USD Composer:
def Xform "World"
{
def Scope "Looks"
{
def Material "BlendedMaterial"
{
token outputs:mdl:displacement.connect = </World/Looks/BlendedMaterial/blend.outputs:out>
token outputs:mdl:surface.connect = </World/Looks/BlendedMaterial/blend.outputs:out>
token outputs:mdl:volume.connect = </World/Looks/BlendedMaterial/blend.outputs:out>
def Shader "blend" (
prepend apiSchemas = ["NodeGraphNodeAPI"]
)
{
uniform token info:implementationSource = "sourceAsset"
uniform asset info:mdl:sourceAsset = @nvidia/core_definitions.mdl@
uniform token info:mdl:sourceAsset:subIdentifier = "blend"
token inputs:base (
displayName = "Base material"
doc = "The material the blend is based on"
hidden = true
renderType = "material"
)
token inputs:base.connect = </World/Looks/BlendedMaterial/PBRShader.outputs:out>
token inputs:blend (
displayName = "Blend Material"
doc = "Surface properties to use for the blend"
hidden = true
renderType = "material"
)
token inputs:blend.connect = </World/Looks/BlendedMaterial/OmniSurfaceBase.outputs:out>
float inputs:weight (
customData = {
float default = 0
dictionary range = {
float max = 1
float min = 0
}
}
displayName = "Blend weight"
doc = "Blend weight or mask texture"
hidden = false
renderType = "float"
)
float inputs:weight.connect = </World/Looks/BlendedMaterial/lookup_float.outputs:out>
token outputs:out (
renderType = "material"
)
uniform token ui:nodegraph:node:expansionState = "open"
uniform float2 ui:nodegraph:node:pos = (-413.5083, 30.022224)
}
def Shader "OmniSurfaceBase" (
prepend apiSchemas = ["NodeGraphNodeAPI"]
)
{
uniform token info:implementationSource = "sourceAsset"
uniform asset info:mdl:sourceAsset = @OmniSurface/OmniSurfaceBase.mdl@
uniform token info:mdl:sourceAsset:subIdentifier = "OmniSurfaceBase"
float outputs:out (
renderType = "float"
)
uniform token ui:nodegraph:node:expansionState = "closed"
uniform float2 ui:nodegraph:node:pos = (-767.252, 289.14746)
}
def Shader "PBRShader" (
prepend apiSchemas = ["NodeGraphNodeAPI"]
)
{
uniform token info:implementationSource = "sourceAsset"
uniform asset info:mdl:sourceAsset = @OmniPBR.mdl@
uniform token info:mdl:sourceAsset:subIdentifier = "OmniPBR"
token outputs:out (
renderType = "material"
)
uniform token ui:nodegraph:node:expansionState = "minimized"
uniform float2 ui:nodegraph:node:pos = (-782.1521, 19.353767)
}
}
}
}
1 Like
Thank you very much for the example! @mati-nvidia
And I come up with another question, can a USD shader reference multiple MDL files?
Hi @xiaobai9007 . I’m pretty sure that’s not possible, but I can ask to confirm. It would help if you describe what you are trying to do and why you would want one USD shader to reference multiple MDL files.
system
Closed
May 1, 2023, 7:29pm
5
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.