[MAXtoA] Setting up an Object ID AOV

Here’s how to use the 3ds Max object ids for a simple Object ID AOV.

And here’s the material (aka shader tree) that writes the AOV. Use a text editor to save this as Arnold Scene Source (.ass) file, and then import it into 3ds Max (like I did in the video).

An ASS file is a plain-text file.

### exported: Thu May 21 07:53:19 2020
### from:     Arnold [991b08e9] windows icc-17.0.2 oiio-2.2.1 osl-1.11.0 vdb-4.0.0 clm- rlm-12.4.2 optix-6.7.0 2020/04/17 09:11:12
### host app: MAXtoA (2021) 3ds Max 23.0.915.2021 

 name /Write_Object_ID_AOV
 aov_input /gBufID_Switch
 aov_name "object_id"
 declare nodeName constant STRING
 nodeName "Material #43"

 name /gBufID_Switch
 index /gBufID
 input1 1 0 0 1
 input2 0 1 0 1
 input3 0 0 1 1

 name /gBufID
 attribute "gBufID"

Overriding shader parameters in procedurals

Procedurals (aka standins) don’t expose the parameters of objects and shaders inside the procedural.

For example, you cannot override shader parameters like standard.Kd (diffuse color) or standard.emission (emission scale) by setting those parameters on a procedural node.

But what you can do is use “user data parameters”. Inside the procedural, use user data shaders to set shader parameters, but don’t define the user data parameters on the shape.

For example, if I wanted to be able to override the emission scale, then I would set up a shader like this:


A userDataFloat shader sets the Emission. The important thing is that the custom attribute emission_scale is not defined on the shape, so the default value is used instead.

By doing that, I can put an emission_scale attribute on the procedural node, and the aiUserDataFloat shader picks up that value.


In the above example, I’ve added a mtoa_constant_emission_scale attribute to the standinShape, and that allows me to set the Emission for that specific standin.

In Arnold scene source (ASS) format, I have this in my main scene file:

 name ArnoldStandIn1Shape
 dso "standin_torus_w_emission.ass"
 declare emission_scale constant FLOAT
 emission_scale 0.649999976

And in the ASS file loaded by the procedural, I have this:

 name pTorusShape1
 shader "someshader"
 # NO user data declared here 

 name someshader
 emission aiUserDataFloat1

 name aiUserDataFloat1
 floatAttrName "emission_scale"
 defaultValue 0.100000001


[MtoA] Adding user data to standin instances

The standard way to add user data to an Arnold node is to add an mtoa_constant attribute to the shape node in Maya. MtoA translates the mtoa_constant attributes to user data, so you can use shaders like AiUserDataColor.

Instances in Maya, however, don’t have their own shape node: they all share the shape node of the original object. So you can’t use an mtoa_constant attribute on the shape to get different user data for each instance.

But you can use override sets to get user data on instances. Put the instances in a set, and then add the mtoa_constant as an override attribute.


Then each instance in the set will get that user data.

Another way to add user data to instances is with the particle instancer: you can add per-particle attributes, and then list them in the Arnold > Export Attributes text box. MtoA translates all those attributes to user data on the particle instances.