How can I configure what bits of USD are being read by a StaticMesh?

I am currently working on a bespoke USD importer for my pipeline and attempting to leverage bits of the USD importer code provided by Epic. Specifically, the UsdStageImportOptions combined with an AssetImportTask. I only want to leverage the geometry import aspects of it. I have noticed that the StaticMesh produced by the importer will point at a single USD stage but have various bits of metadata in a USD Mesh Asset User Data object on the StaticMesh. This seems to hold various prim paths and other information (such as variant choices).

The problem I am running into is that if I want to properly share assets between different stages that I import, identical meshes will be set as different StaticMesh when they theoretically should be re-used since I have that option set in the importer. I am not sure if it’s because the source USD files are different even though they reference the same source USD layer that contains the Mesh.

For example, I have Stage A which references Stage B and makes a variant choice on Prim A. If I use the importer on both Stage A and on Stage B, I get two different StaticMesh when it should be the same re-used asset. It could also be due to the variant being set explicity to ‘K’ in Stage A but when I import Stage B directly, the variant is ‘default’ (I think because it doesn’t say what it is actually reading in the StaticMesh asset). The problem is I cannot point the Stage B import at a variant choice.

Is there a better way to do what I am trying? Are there unexposed controls on the StaticMesh I can access? Do I have to add/change something in the USD Mesh Asset User Data object (is that what is controlling what StaticMesh is reading?), or do I need to be even more explicit in what I pass to the importer by referencing the exact Mesh prim for the variant choice I want rather than just pointing at the asset (i.e. Component kind) prim above it?

Hi Christopher,

I’m not sure if I understood correctly what you’re trying to do, but from what I gather in the information you’ve given is that you get different StaticMesh assets because they are different variants? The importer itself doesn’t handle variant selection (except for the special case of LODs) and relies on the composition of the USD stage, thus with the variants set on the stage, to retrieve the mesh data. If Stage A explicitly sets variant ‘K’ and Stage B sets variant ‘default’ and those variants are in fact different meshes, then you’ll get different static mesh assets as expected when you import the stages separately.

You mentioned AssetImportTask so are you trying to automate import through Python? SetVariantSelection is not exposed in the UE USD wrappers but you can use it through Python to force the selection of a variant on a prim or you can use SetGlobalVariantFallbacks before opening a stage to force a global variant fallback selection (ref: Variant Management section in https://openusd.org/docs/api/class\_usd\_stage.html). The variant of a prim can also be set interactively through the USD Stage Editor, but that’s probably not relevant in your case.

Hope this helps,

Anousack