User guide
126
For instance, the fragment of AttributeScript below reads the attribute value contained in textures.SpecMap and
uses it to override an Arnold shader parameter called SpecMapTexture:
SpecMapPath = GetAttr( 'textures.SpecMap' )\
SetAttr( 'materialOverride.arnoldSurfaceParams.\
SpecMapTexture', SpecMapPath )
The result is a new copy of the material created for each object the Attribute Script runs on, with the shader's
SpecMapTexture parameter changed to the value stored in textures.SpecMap.
NOTE: Material overrides actually take place as part of MaterialResolve, one of Katana's implicit resolvers.
During MaterialResolve Katana looks for attributes in the materialOverride group, and creates a new
copy of the material at that location with the relevant changes to shader parameters.
Using the {attr:xxx} Syntax for Shader Parameters
You can declare string shader parameters to use the value of another attribute. If you define any string parameter
on a shader to be {attr:xxx} then during MaterialResolve it looks for an attribute called xxx at the location the
material is being assigned to, and uses that as the shader value.
For example, if you have an Arnold image reader shader with a parameter called filename and you set filename to
{attr:textures.SpecMap}, filename is set to the value of the attribute textures.SpecMap on any location the
material is assigned to. This means you can set up the original shader to automatically pick up relevant texture name
attributes for every object it is applied to. For example, create an Arnold Network Material with an ImageRead node,
and have the filename parameter of the ImageRead node linked to a textures.ColMap attribute on geometry
locations:
1. In an empty Katana scene create two ArnoldShadingNodes, set one to type image, and one to type standard.
Link the output of the image node, to the Kd_Color parameter of the standard node.
2. In the filename field in the Image node’s parameters enter:
{attr:textures.ColMap}
3. Add a NetworkMaterial node, with an Arnold standard terminal. Connect the output of the ArnoldShadingNode
of type standard to the input of the NetworkMaterial node.
4. Add two PrimitiveCreate nodes, and two AttributeSet nodes. With the AttributeSet nodes set a string attribute
with the attributeName textures.ColMap on each primitive location. Set the stringValue for each to the path to a
texture (for example /tmp/yourTexture.tx and /tmp/yourOtherTexture.tx).
5. Add a CameraCreate node.
6. Connect the outputs of PrimitiveCreate nodes, the CameraCreate, and the NetworkShading node to inputs on a
Merge node. Add a MaterialAssign node below the Merge node. Assign the NetworkShading material to each
applicable scene graph location. For example, use the CEL statement:
/root/world/geo//*
17 HANDLING TEXTURES |