Hello everyone!
My team and I want to implement a new extension for our omniverse kit app. We have a very very large scene with millions of prims. At a certain point we receive information from an external source. Based on this information, we want to quickly apply some materials or highlights to the prims that match the information and grey out all other prims. So basically, we need to traverse the stage for every prim and apply to all prims or meshes the desired material. I’ve managed to get something working with commands.execute, but the performance is pretty poor for the big stage (takes several minutes to apply).
def bind_material_batch(self, prims: List[Usd.Prim], mat: Material):
omni.kit.commands.execute('BindMaterialCommand',
prim_path=[prim.GetPath() for prim in prims],
material_path=mat.GetPath() if mat.GetPath() != Sdf.Path.emptyPath else "",
strength=UsdShade.Tokens.weakerThanDescendants)
For a single prim, I found another solution using the MaterialBindingAPI, but I can’t find a way to use this API for a collection of prims:
prim.ApplyAPI(UsdShade.MaterialBindingAPI)
UsdShade.MaterialBindingAPI(prim).Bind(mat, UsdShade.Tokens.weakerThanDescendants, UsdShade.Tokens.allPurpose)
Do you know of any other ways to archive something like a super performant highlighting / material switching of prims in a very large scene?