Questions about material handling

Hello,

we`ve written a connector that syncs highly customizable products into and USD scene. Currently we are using predefined materials we upload to the nucleus when used for the first time. Then we reference those material files in our usd scenes.

Now we are thinking of a more dynamic approach where the materials are not stored into mdl files on the nucleus and are created directly inside of the usd scene. How could this affect the performance? Especially when we think of many users that could reuse the mdl files (don´t know if cache (for example) caches some kind of complied result for a material file or something like that, that is reused by other sessions).

How do materials that are currently not used affect the resource consumption of a scene? Think of a product that is configured in “red”. Our connector creates than the materials and links that to the scene nodes. In the next step the product color is changed to “blue”, so the connector creates the “blue” material and changed the binding on the scene nodes. Currently we do not remove the previously created “red” material… would it make sense to remove that unused material in this case?

Is there a way to override parameters of a material when binding it? Or do I have to create a new instance for every combination of parameters I need?

Thanks for your help

Carl

Hello Carl,

I’ve passed your questions on to the devs. Thanks for you interest!

USD material bindings can be overwritten the same as other USD attributes. Here’s a small example

def "asset" (

        instanceable = false

        prepend references = @./asset.usd@

    )

    {

        float3 xformOp:rotateXYZ = (0, -0, 0)

        float3 xformOp:scale = (1, 1, 1)

        double3 xformOp:translate = (0, 0, 0)

        uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ", "xformOp:scale"]

        over "Cube"

        {

            rel material:binding = </World/Looks/PreviewSurface> (

                bindMaterialAs = "weakerThanDescendants"

            )

        }

    }

I think most of the question is resolved by overriding material parameters for the bindings. Alternatively, you can also create multiple materials in USD that reference the same MDL file and then set individual parameters in the USD shade node. This makes the replacement of the red by the blue material obsolete as you can simply make the color a parameter of your MDL material and override /change the color value from USD.
And if I understand the question correctly, it should also address the first part. You would create an MDL material that can be referenced from multiple scenes and each time you would set/override parameter values in USD. There is no need to write blue, red, yellow, … materials to disk if a parameter is the only difference.
I suggest you experiment a bit in the Create app and write out .usda files which can be inspected using a text editor.

The performance questions depend on whether the above solved your workflow question.
If you have the same MDL material that differs only in simple parameters like a color values, we do have a cache which makes material loading and compilation faster. I’m not sure if that cache is shared among different users in your setup but you will benefit even if the cache is local only.

Thank you for your reply.

I`m not sure if I understood the sample right, but I cannot see where is the changed parameter in that sample. As I understood the sample, it only overrides the bound material itself. That the way we do it now… so we create a separate material for every combination of parameters and then bind those materials to the related nodes. My question was if it is possible to override single material parameters on the binding (for example “use material X on this node, but with detail normal y”) - without the need to create a separate material instance before.

Thanks

Carl

I’m not 100% that my example will properly address this issue, but I thought I might share it. I’m doing this:

  • I created a material in Unreal with a few parameters that you can override once you export them as USD/MDL.

  • If we use the Create a material overrides sublayer the Unreal USD/MDL exporter will create USD materials and reference them in an overs layer that demonstrates what I think you’re asking about

  • I opened the USD stage in Create and set the edit layer as materialOversExample_MaterialOvers.usda - then I edited a couple of the parameters in the two exported materials. The materials are referenced as overs, if you like you can duplicate these to generate lots of different materials with different parameter values:

        def Material "SimpleTestMaterial" (
            prepend references = @./Materials/SimpleTestMaterial.usda@
        )
        {
            over "SimpleTestMaterial"
            {
                float4 inputs:Color = (0.32999998, 0, 0, 0) (
                    customData = {
                        float4 default = (0, 0.796875, 0.037067, 0)
                    }
                    displayName = "Color"
                    hidden = false
                )
            }
        }

MaterialOversExample.7z (1.5 MB)

1 Like