How does the "MDL Render Context" in the USD Stage Actor actually work?

Universal Scene Description in Unreal Engine | Unreal Engine 5.0 Documentation

This page states that there is Nvidia MDL support for the Stage Actor in Unreal 5.
You can try it by enabling the MDL Rendering Context in the Stage Actor.

I have tried this with various permutations of seemingly-correct USD schemas for MDL materials but simply cannot get it to work - it always gives me an error in the log that it cannot convert the MDL material.

Is there some minimal working example I can try? Has anybody gotten this working?
I’m not looking to do a hard import of the material with the MDL plugin, I specifically want the Stage Actor to pick up the MDL material and create a transient Unreal material for my use case.

Here is an example snippet of USDA code that defines an MDL material based on an MDL module I’ve created with Substance Designer and is located in the same directory as the USDA file.

def Scope "materials"
    {
        def Material "suzanne"
        {
            token outputs:mdl:displacement.connect = </root/materials/suzanne/Shader.outputs:out>
            token outputs:mdl:surface.connect = </root/materials/suzanne/Shader.outputs:out>
            token outputs:mdl:volume.connect = </root/materials/suzanne/Shader.outputs:out>
            token outputs:surface.connect = </root/materials/suzanne/Shader_preview.outputs:surface>

            def Shader "Shader"
            {
                uniform token info:implementationSource = "sourceAsset"
                uniform asset info:mdl:sourceAsset = "metallic_roughness.mdl"
                uniform token info:mdl:sourceAsset:subIdentifier = "M_R"
                float inputs:albedo_add = 0
                float inputs:albedo_brightness = 1 (
                    customData = {
                        dictionary HoudiniPreviewTags = {
                            double default_value = 1
                            string ogl_diff_intensity = "1"
                        }
                    }
                )
                float inputs:albedo_desaturation = 0
                asset inputs:ao_texture = @@ (
                    colorSpace = "auto"
                )
                float inputs:ao_to_diffuse = 0
                float inputs:bump_factor = 1
                float inputs:detail_bump_factor = 0.3
                asset inputs:detail_normalmap_texture = @@ (
                    colorSpace = "auto"
                )
                float inputs:detail_texture_rotate = 0
                float2 inputs:detail_texture_scale = (1, 1)
                float2 inputs:detail_texture_translate = (0, 0)
                color3f inputs:diffuse_color_constant = (0, 0.5, 0) (
                    customData = {
                        dictionary HoudiniPreviewTags = {
                            double3 default_value = (0.2, 0.2, 0.2)
                            string ogl_diff = "1"
                        }
                    }
                )
                asset inputs:diffuse_texture = @@ (
                    colorSpace = "auto"
                    customData = {
                        dictionary HoudiniPreviewTags = {
                            string default_value = ""
                            string ogl_tex1 = "1"
                        }
                    }
                )
                color3f inputs:diffuse_tint = (1, 1, 1)
                color3f inputs:emissive_color = (1, 0.1, 0.1)
                asset inputs:emissive_color_texture = @@ (
                    colorSpace = "auto"
                )

Hey Suzanne,

I’m not a pro on that either, but at the first glance comparing your piece to the official schema, there are a few things missing.

The generic out (token outputs:out) is missing as well as connecting your USD parameters to the MDL ones:

float inputs:anisotropy.connect = </sample.inputs:anisotropy>

The connect identifier on the left must match your exposed input of the MDL.

Also check, if all needed MDL modules you link in your MDL are accessible to the Unreal mdl importer plugin. It refers to the env variable MDL_SYSTEM_PATH.

I would suggest you to simplify both your usd and mdl to just one parameter to debug it. Also make sure you have the output log open in Unreal, when switching to mdl as render context - the MDL importer plugin luckily gives a lot of info to debug.

Hope that helps!
KR
Ralf

Try saving the usd unflattened with the material in its own file.
Just an idea. I’m trying to get mtlx context working.