Hi All
So I need to do as the title says. My scene uses 3 shading types , unlit , lit and node material
Obviously with glb , we can only set up the materials as lit or unlit. So I have some external data that tells my application which materials actually need to be a node material.
workflow is , assets are loaded , scene materials looped and using the material name , look in the external data if this material actually needs to be a node material.
I have this all working and the node materials themselves working but its creating and swopping out materials in the scene at runtime that is causing me headaches.
Firstly the new node material needs the same name as the material it is replacing. This is for the entire applications material update system to stay working… it targets materials by name.
I have tested just creating it with the same name , and trying to assign it to the same index in the scene materials array.
This doesnt really work , because when you create the node material , it gets inserted into the array already. Now you have duplicates.
Also , any mesh using the material ( the old one ) gets disconnected ( active material becomes None )
Does anyone know what the best workflow is for this. Ideally…
-
It would be great if creating a material doesnt auto inject itself ( because im trying to replace a material obviously )
-
It would be great if you could just assign the material value to an existing index in scene materials and all mesh objects using the material dont loose their connection to it.
any ideas?