I am using the drag and drop from the omni.kit.browser.material where i can get both the sourceAsset and the subIdentifier
Sometimes the subIdentifier is N/A which creates an error or a faulty shader file being created
I can solve this if i disregard the N/A and instead use the sourceAsset as the subIdentifier it works most of the time
BUT for instance in the basic collection there is a material called Gold
So what i’m getting as the sourceAsset is Gold which accurately creates a Gold material prim with a shader
The shader mdl:sourceAsset has the correct path to the aws server but the sourceAsset name here is
Metal_Ceramic_Brakes_Golden.mdl
Metal_Ceramic_Brakes_Golden is also the name of the subIdentifier which creates the error because i’m looking for a subIdentifier called Gold so in some instance i have to go in and manually correct the shader because of the missmatch in names.
Is there a way that i can refer to the number 0 item in the list of subIdentifiers instead of the name as this might not always match?
This is the thumbnail and name in the Material Window
It corresponds with the material created when i double click it in the Material Window
Also searchable
But if i try to use something like the code below where i want to populate the mtl_url using the built in drag and drop feature. Then i can’t take the name from the Material Window(Agent_Gray) to use it as the sourceAsset because the actual name of the .mdl material is Carpaint_Solid.mdl with the subIdentifier: Agent_Gray. This is in the Vmaterials_2 collection.
import omni.kit.commands
success, result = omni.kit.commands.execute('CreateMdlMaterialPrimCommand',
mtl_url='OmniPBR.mdl', # This can be path to local or remote MDL
mtl_name='OmniPBR', # sourceAsset:subIdentifier (i.e. the name of the material within the MDL)
mtl_path="/World/Looks/OmniPBR" # Prim path for the Material to create.
)
sourceAsset:subIdentifier you would think is something like Agent_Gray:Agent_Gray_Agent_Gray
but in reality it is Carpaint_Solid:Carpaint_Solid_Agent_Gray
So the thumbnail picture should have the name Carpaint_Solid_Agent_Gray
Because Agent Gray is not the original material only a subIdentifier
Like with the ABS_Hard_Leather:ABS_Hard_Leather_Pop_Lime
where the thubnail is ABS_Hard_Leather_Pop_Lime
and the original material is ABS_Hard_Leather.mdl
I am just curious but is there a reason you are not just using our already built and assembled Material Browser ? You can call it with kit and customize it to your needs, but you don’t need to re-build it from scratch.