USD materials... import/reuse from scene

Hey

So I have a maya scene with usd preview materials that I want to save as USD and load in UR5 & use existing UE5 materials that have the same names.

Does UE provide any way of doing it ?

On anot her side, I was digging in to API/python for usd to add the materials myself in usd file post save/export…

From what I can tell for it to “work” I need to map my geos/materials >

        def Material "UnrealMaterial"
        {
            token outputs:unreal:surface.connect = </group1/pPlane2/UnrealMaterial/UnrealShader.outputs:out>

            def Shader "UnrealShader"
            {
                uniform token info:implementationSource = "sourceAsset"
                uniform asset info:unreal:sourceAsset = @/Game/materials/USD_MAT_B.USD_MAT_B@
                token outputs:out
            }
        }

Now I need to either usd pythonAPI to add it manually or hack some text editor… “Fun times” in any case, would any1 know where/how to do it & could give me a head start?
Any idea where in source UE5 does it ?

Hey @Dariusz1989,
I believe it’s under the Python class USD Stage Actor.
https://docs.unrealengine.com/5.0/en-US/PythonAPI/class/UsdStageActor.html
But, I could be overlooking it.
I hope this can help!
-Zen

Some options are Houdini, the Omniverse toolset, or through script / tools for Python in Maya.

Here’s an example on how I did it with Houdini

from pxr import UsdShade, Sdf

node = hou.pwd()
input_node = node.inputs()[0]

material_name = "MyMaterial"

# Get a reference to your stage
stage = node.editableStage()

material = UsdShade.Material.Define(stage, '/' + material_name)
shader = UsdShade.Shader.Define(stage, '/' + material_name + '/UnrealShader')

shader_output = shader.CreateOutput('out', Sdf.ValueTypeNames.Token)
material_output = material.CreateOutput('unreal:surface', Sdf.ValueTypeNames.Token)
material_output.ConnectToSource(shader_output)

shader.SetSourceAsset('/Game/Materials/MyMaterial')

Did you find any way of doing this?