What's the best way to apply a material to an instanceable prim?

Hi,
I’m having some issues displaying the textures after I set a prim to “instanceable=True”.
I’m creating the asmbs by referencing the cmpts with “instanceable=True” set. This is making the textures to disappear. The material is applied by switching a variant set where you can enable/disable it.
If you switch the variant set to display the material in a prim with “instanceable=True” the textures do not appear, while not having defined that attribute, or setting it to “False”, allows you to see the textures properly.

Where’s the problem? Is it the fact that I’m trying to change an attribute in an “instanceable” prim? If that’s the case, how do you manage to enable/disable a material in an “instanceable” prim?

Thanks,
Manu.

Could you explain these abbreviations? :slight_smile: Is this assemblies and components?


Aside of that your question sounds quite similar to this topic. Where an answer was:

Hi,
first of all, yes, you are right, cmpt & asmb are component and assembly :slight_smile:

I saw the other topic and I tried to implementing it. I defined the variant set where I add the material inside a class and later I inherited that class but it did not work.

My current structure for an assembly is: assembly.usd ← reference ← component.usd

My assembly is referencing the component like:

def Xform "MyAssembly"
{
    def Xform "MyComponent" (
        instanceable = true
        references = @component.usd@
    )
    {
    }
{
}

For the component I have something similar to: component.usd ← payload.usd ← reference ← material.usd

In the material.usd I have:

def Scope "MyComponent" (
    inherits = </__MTLClass/MyComponent>
)
{
}

class "__MTLClass"
{
    class "MyComponent"(
        variants = {
            string Material = "noMtl"
        }
        prepend variantSets = "Material"
    )
    {
        variantSet "Material" = {
            "noMaterial" {
            }
            "addMaterial" {
                # Add material here
            }
        }
    }
}

This seems to work fine as long as I do not have instanceable=True. But the moment I set that attribute, the material is gone.

I suspect that you are establishing the Material bindings or other key information “outside” of the collection of scene description that encapsulates the instance (or rather its prototype), and therefore when you enable instancing, those “overrides” can no longer apply and are disregarded.

But it’s difficult to say for sure without a working/non-working example… if I’m right, I don’t think you would even see any errors in the console, as opinions that unsuccessfully “override” an instance are, by design, silently ignored.