Render outputs

Since Arnold 7.4.5.0, the image outputs of a render are described by render_output nodes. A render_output node replaces one string in the older options.outputs array. This topic is for developers of Arnold plugins and for TDs who build or edit scenes by hand. It explains how the nodes are wired together, what each parameter does, and how to move a plugin from options.outputs to render_output nodes.

How the nodes connect

The old model put everything in one string, with the driver and filter referenced by name. The new model uses ordinary node links:

options.drivers  ->  driver.render_outputs  ->  render_output  ->  filter
                                                       |
                                                       +---------->  camera (optional)

The render_output node

Parameter Type Default Description
aov_name STRING RGBA The AOV to write, for example RGBA, N, diffuse, or the name of a light path expression. Wildcards are allowed. An empty string makes a driver-only output, used for raw drivers, which request the AOVs they need themselves.
type ENUM rgba The data type of the output, for example rgba, rgb, float, vector, or uint. It must be a type that the AOV can be converted to.
filter NODE none The filter node used to combine samples into pixels. Set it for every output that uses a non-raw driver.
layer_name STRING empty The layer (subimage or channel prefix) name passed to the driver. If aov_name has a wildcard that matches several AOVs, the name is applied to each match.
half_precision BOOL false Write the output as 16-bit half float. It is forced on if the driver has its own half_precision parameter set to true.
camera NODE none The camera for this output. If it is not set, Arnold uses options.camera, and then the first camera in the scene.
name STRING empty The node name. Other nodes refer to the output by this name, so give each output a unique one.

Light path expressions are not declared on the render_output node. Keep declaring them in options.light_path_expressions, and use the expression name as the aov_name.

Example

This scene writes the beauty and the normals to one EXR file. The normals go into a layer called normals.

options
{
 drivers 1 1 NODE
  "my_driver"
}

gaussian_filter
{
 name my_filter
}

render_output
{
 name beauty_output
 aov_name "RGBA"
 type "rgba"
 filter "my_filter"
}

render_output
{
 name normals_output
 aov_name "N"
 type "vector"
 filter "my_filter"
 layer_name "normals"
}

driver_exr
{
 name my_driver
 filename "render.exr"
 render_outputs 2 1 NODE
  "beauty_output" "normals_output"
}

In an .ass file, an array parameter is written with a header of three values before its elements: the number of elements, the number of motion keys, and the type. So render_outputs 2 1 NODE is an array of 2 nodes with 1 key, and drivers 1 1 NODE is an array of 1 node. Always write the full header for drivers and render_outputs. If you leave it out, as in render_outputs "beauty_output" "normals_output", only the first element is read and the other outputs are silently missing.

The same setup through the C++ API:

AtNode* options = AiUniverseGetOptions(universe);

AtNode* filter = AiNode(universe, AtString("gaussian_filter"), AtString("my_filter"));

AtNode* beauty = AiNode(universe, AtString("render_output"), AtString("beauty_output"));
AiNodeSetStr(beauty, AtString("aov_name"), AtString("RGBA"));
AiNodeSetStr(beauty, AtString("type"), AtString("rgba"));
AiNodeSetPtr(beauty, AtString("filter"), filter);

AtNode* normals = AiNode(universe, AtString("render_output"), AtString("normals_output"));
AiNodeSetStr(normals, AtString("aov_name"), AtString("N"));
AiNodeSetStr(normals, AtString("type"), AtString("vector"));
AiNodeSetPtr(normals, AtString("filter"), filter);
AiNodeSetStr(normals, AtString("layer_name"), AtString("normals"));

// the driver owns the list of outputs
AtNode* driver = AiNode(universe, AtString("driver_exr"), AtString("my_driver"));
AiNodeSetStr(driver, AtString("filename"), AtString("render.exr"));
AtArray* outputs = AiArrayAllocate(2, 1, AI_TYPE_NODE);
AiArraySetPtr(outputs, 0, beauty);
AiArraySetPtr(outputs, 1, normals);
AiNodeSetArray(driver, AtString("render_outputs"), outputs);

// and options lists the drivers
AtArray* drivers = AiArrayAllocate(1, 1, AI_TYPE_NODE);
AiArraySetPtr(drivers, 0, driver);
AiNodeSetArray(options, AtString("drivers"), drivers);

Moving from options.outputs

Each string in options.outputs becomes one render_output node. The drivers and filters that the string named are now node links.

Old string New nodes
"RGBA RGBA my_filter my_driver" A render_output with aov_name "RGBA", type "rgba" and filter "my_filter", listed in my_driver.render_outputs.
"diffuse RGB my_filter my_driver" The same, with aov_name "diffuse" and type "rgb".
"N VECTOR my_filter my_driver normals" The same, with aov_name "N", type "vector" and layer_name "normals".
"my_camera RGBA RGBA my_filter my_driver" The same as the first row, plus camera "my_camera".
"... HALF" (trailing token) half_precision true.
"my_driver" (driver only) A render_output with an empty aov_name, for raw drivers.

The old string accepts 1, 2, 4, 5 or 6 space-separated tokens, so the layer name and camera are both optional.

To migrate a plugin:

  1. Stop building output strings. Create one render_output node for each combination of AOV, layer and camera.
  2. Set render_outputs on each driver and drivers on options. Link by node pointer, not by name.
  3. Set layer_name and camera on the render_output. Leave camera unset to use options.camera.
  4. Leave options.light_path_expressions as it is.
  5. Do not also write options.outputs. If your plugin sets options.drivers itself and an old options.outputs value might still be present, clear it with AiNodeResetParameter(options, "outputs") so the legacy strings are not converted on top of your nodes.
  6. Check any code that uses an output's position in the array. AiRenderAddInteractiveOutput still takes an index into options.outputs, so interactive output selection needs separate handling.

Compatibility

Existing scenes keep working. At the start of each render, Arnold converts any strings in options.outputs into render_output nodes and adds them to the drivers they name. These nodes are combined with the ones you created, so a scene can use both forms. There is no deprecation warning, but new plugin code should use render_output nodes.

For example, this scene describes the same outputs as the .ass example above, using options.outputs. Both scenes write the same image data, with the same channels:

options
{
 outputs 2 1 STRING
  "RGBA RGBA my_filter my_driver"
  "N VECTOR my_filter my_driver normals"
}

gaussian_filter
{
 name my_filter
}

driver_exr
{
 name my_driver
 filename "render.exr"
}

Conversion of .ass files when you load or write them is controlled by a flag. AiSceneLoad and AiSceneWrite do not convert by default. To convert, set the boolean convert_string_outputs to true in the AtParamValueMap that you pass as params.

Plugin examples

MtoA creates one render_output for each driver, AOV, layer and camera, named <driver>.<aov>[.<layer>][.<camera>]. It looks up an existing node by name before it creates one, so re-exporting updates the same nodes. Denoised outputs get their own filter, render_output and driver clone. See COptionsTranslator::SetImageFilenames in the MtoA source.

Gaffer still builds options.outputs strings, in ArnoldOutput::append in IECoreArnold/Renderer.cpp. To move to render_output nodes, a plugin like this would:

Things to watch for

See also: AOVs, Light path expression AOVs, the Simple driver and the render_output page in the Node Reference.