Using Material Overrides to Specify Textures
If you have exposed parameters on a material that define the textures to use, you can use material overrides to create new object specific versions of materials with the relevant textures.
The material that is to be used in common on a number of objects can be assigned to those objects (or assigned higher up the hierarchy and inherited), and a material override set on the objects to override shader parameters that specify textures with new object specific values.
This can be done directly using MaterialAssign nodes, but since all MaterialAssign nodes do is create attributes under a group called materialOverride we can also set up material overrides by directly setting those attributes directly by any other process, such as using OpScripts.
For instance, this fragment of OpScript reads the attribute value contained in tx_name and use it to override a shader with a parameter called textureFile:
tx_name_attr = Interface.GetAttr("tx_name") if tx_name_attr then Interface.SetAttr("materialOverride.parameters.textureFile", tx_name_attr) end
This means that a new copy of the material is created for the object with the shader's textureFile parameter changed to the appropriate values.
Note: Material overriding actually takes place as part of MaterialResolve, one of Katana's implicit resolvers. During MaterialResolve it looks for attributes in the 'materialOverride' group, and creates a new copy of the material at that location with the relevant changed to shader parameters.