Updating procedural file paths with string_replace


This is actually pretty cool…you can use an operator to update file paths before an ASS file or ABC file is loaded, then use another operator to touch the geometry loaded by that procedural.

For example, suppose at render time you want to replace trex_proxy.abc with trex.abc. You can easily do that with a string replace operator:

  • *.(@node==’alembic’) selects all Alembic procedural nodes
  • Match matches any file name that ends with “_proxy.abc”
  • Replace replaces “_proxy.abc” with “.abc”

And that all happens before the abc file is loaded.

We can see this in the Arnold log (Debug verbosity). First the string replace operator is applied; then after the abc file is loaded, a set parameter operator is applied to the nodes loaded from the abc file.

| initializing 16 nodes …
| [operators] init op: 'aiStringReplace1'
| [operators] cook op: 'aiStringReplace1' | node: '/aiStandIn/aiStandInShape'
| [proc] /aiStandIn/aiStandInShape: loaded 1 nodes (1 objects, 0 shaders)
| [operators] init op: 'TRex:tRexShape_aiSetParameter1'
| [operators] cook op: 'TRex:tRexShape_aiSetParameter1' | node: '/TRex:tRex/TRex:tRexShape'

backdoor Arnold: setting visibility


If you want to control object visibility with operator, or the Arnold Python API, or by editing an ASS file, you need to understand Arnold’s visibility parameter.

In the UI, the object visibility options look like a bunch of separate parameters:

 

but in Arnold, all those options are stored in one visibility parameter.

For example, if an object is visible to the camera (primary visibility), and to transmission (both diffuse and specular), then that’s visibility 13.

Why 13? Because 13 = 1 + 4 + 8

  • camera rays = 1
  • diffuse transmission rays = 4
  • specular transmission rays = 8

The Arnold visibility parameter tells Arnold the rays to which the object is visible.

  • visibility 0 means the object isn’t visible to any rays
  • visibility 255 means the object is visible to all rays
  • visibility 253 means the object isn’t visible to shadow rays (so the object does not cast shadows).

Here’s the decimal values for all the different ray types.

To figure out the visibility, just add up the values for the rays you want.

Ray typeDecimal Value
Camera (Primary Visibility)1
Shadow (Casts Shadows)2
Diffuse transmission4
Specular transmission8
Volume16
Diffuse reflection32
Specular reflection64
SSS (subsurface)128