Getting shader info from an ASS file


First, set things up so you can use the Arnold Python API. On Windows:

set PATH=C:\Users\blairs\AppData\Local\Programs\Python\Python39;%PATH%
set PYTHONPATH=C:\solidangle\arnold\Arnold-6.2.1.1-windows\python

rem Sometimes necessary
set PATH=C:\solidangle\arnold\Arnold-6.2.1.1-windows\bin;%PATH%

Then, run this Python script, which does the following:

  • Sets the logging verbosity
  • Loads an ASS file
  • Loops over all the shader nodes.
  • If a shader is a standard_surface, inspect the ID AOV parameters.
from arnold import *
AiBegin()
 
AiMsgSetConsoleFlags(AI_LOG_ALL)
 
# Required if the ASS file uses any SItoA shaders
#AiLoadPlugins('C:/softimage/workgroups/sitoa-3.4.0-2015/Addons/SItoA/Application/Plugins/bin/nt-x86-64')
 
AiASSLoad('C:/Users/blairs/Documents/maya/projects/default/scenes/denoiseme.0009.ass')
 
# Iterate over all shader nodes
iter = AiUniverseGetNodeIterator(AI_NODE_SHADER);
while not AiNodeIteratorFinished(iter):
    node = AiNodeIteratorGetNext(iter)
    print( "[script] AiNodeGetName: {0}".format( AiNodeGetName( node ) ) )

    ne = AiNodeGetNodeEntry( node )
#    print( "[script]  AiNodeEntryGetName: {0}".format( AiNodeEntryGetName( ne ) ) )
#    print( "[script]  AiNodeEntryGetType: {0}".format( AiNodeEntryGetType( ne ) ) )
#    print( "[script]  AiNodeEntryGetTypeName: {0}".format( AiNodeEntryGetTypeName( ne ) ) )

    if AiNodeIs( node, "standard_surface" ):
        
     
        # Plain color ID AOVs are easy
        aov_id1 = AiNodeGetStr( node, "aov_id1" )
        print( "[script]  aov_id1={0}".format( aov_id1 )  )   
        
        id1 = AiNodeGetRGB( node, "id1" )
        print( "[script]  id1={0} {1} {2}".format( id1.r, id1.g, id1.b)  )   


        # ID AOVs that use a linked shader take a bit more work     
        aov_id2 = AiNodeGetStr( node, "aov_id2" )
        print( "[script]  aov_id2={0}".format( aov_id2 )  )   
        if AiNodeIsLinked( node, "id2" ):
            id2 = AiNodeGetLink( node, "id2" )
            print( "[script]  id2={0}".format( AiNodeGetName( id2 ) ) )


AiNodeIteratorDestroy(iter)
AiEnd()

HtoA: Denoising AOVs with the Arnold Denoiser


HtoA lets you edit the layer names, and that’s how to generate the variance AOVs for denoising.

  • Add two AOVs with the same name (I used “custom” here), but give the second one a “_variance” layer name (“custom_variance).
  • Change the Pixel Filter to variance.
  • Render some EXRs (in my screenshot below, I should the part of the Arnold log that tells you that the variance AOV was rendered too)
  • In the Arnold Denoiser, put the AOV names in the Light Group AOVs text box.

HtoA and Python 3


If you see messages like this when you try to use HtoA

Syntax error: Missing parentheses in call to 'print'

or

AttributeError: '_Environ' object has no attribute 'has_key'

or

CreateProcess failed

that means the you have the Python 3 version of Houdini installed.

HtoA 5.6.1 and older do not support Python 3 yet, so you need to download and install the Python 2.7 version of Houdini.

You can get the Python 2.7 version of Houdini here: https://www.sidefx.com/download/daily-builds/?production=true

Deselect Python 3 to get the Python 2.7 versions of Houdini

[MtoA] Denoising AOVs with the Arnold Denoiser


To denoise AOVs, you need to add variance AOVs:

  1. Enable Output Denoising AOVs
  2. Add a new output driver to the AOVs, and set the filter to variance
  3. Tell noice to denoise the AOVs: enter the AOV names in the Light Group AOVs text box (or, if you’re using the command-line, add -l flags for each AOV)

When you denoise the AOVs, you’ll see something like this in the Arnold Denoiser log:

C:\Program Files\Autodesk\Arnold\maya2020\bin\noice -i C:/project/images/denoiser_test.0002.exr -o C:/project/images/denoiser_test.0002_denoised.exr -ef 0 -sr 9 -pr 3 -v 0.5 -l diffuse -l direct -l indirect -l specular 

Denoising image C:/project/images/denoiser_test.0002.exr 
------------------------ (1/1)
noice 6.2.0.1 [903992ac] - the Arnold denoiser
Using 48 threads.
Loading images...
Loading file "C:/project/images/denoiser_test.0002.exr".
Using feature AOV 'diffuse_albedo' with filter 'gaussian_filter'
Using feature AOV 'N' with filter 'gaussian_filter'
Using feature AOV 'Z' with filter 'gaussian_filter'
Working with 1 frame at 960x540
Will denoise AOV "RGBA", using associated variance
   Output file will be "C:/project/images/denoiser_test.0002_denoised.exr"
Will denoise AOV "diffuse", using associated variance
   Output file will be "C:/project/images/denoiser_test.0002_denoised.exr"
Will denoise AOV "direct", using associated variance
   Output file will be "C:/project/images/denoiser_test.0002_denoised.exr"
Will denoise AOV "indirect", using associated variance
   Output file will be "C:/project/images/denoiser_test.0002_denoised.exr"
Will denoise AOV "specular", using associated variance
   Output file will be "C:/project/images/denoiser_test.0002_denoised.exr"
Start denoising (patch radius 3, search radius 9, variance 0.5)
Denoising RGBA
Denoising diffuse
Denoising direct
Denoising indirect
Denoising specular
Finished denoising
Saving image C:/project/images/denoiser_test.0002_denoised.exr (960 x 540 x 16)

How to get a list of AOVs and LPEs


Here’s a simple kick trick to get a list of AOVs and LPEs.

The -laovs flag lists all the AOVs in the loaded scene, but if you give kick no input, you’ll get a list of all built-in AOVs defined by Arnold.

For example, on Windows, run kick -laovs -i Nul

On Linux or macOS, run kick -laovs -i /dev/null

kick -laovs -i Nul
Available aovs:
    Type:    Name:                        LPE:
    --------------------------------------------------------------
    VECTOR2  motionvector (~)
    RGBA     RGBA                         C.*
    VECTOR   N (~)
    FLOAT    Z (~)
    RGB      direct                       C[DSV]L
    RGB      indirect                     C[DSV][DSVOB].*
    VECTOR   Pref (~)
    RGB      albedo                       C[DSV]A
    RGB      emission                     C[LO]
    RGB      diffuse_direct               C<RD>L
    RGB      background                   CB
    RGB      denoise_albedo               ((C<TD>A)|(CVA)|(C<RD>A))
    RGB      sss_albedo                   C<TD>A
    RGB      specular_albedo              C<RS[^'coat''sheen']>A
    RGB      diffuse                      C<RD>.*
    FLOAT    cputime (~)
    RGB      diffuse_indirect             C<RD>[DSVOB].*
    RGB      sss_indirect                 C<TD>[DSVOB].*
    RGB      diffuse_albedo               C<RD>A
    RGBA     shadow_matte
    FLOAT    volume_Z (~)
    RGB      specular                     C<RS[^'coat''sheen']>.*
    RGB      coat_direct                  C<RS'coat'>L
    RGB      specular_direct              C<RS[^'coat''sheen']>L
    RGB      specular_indirect            C<RS[^'coat''sheen']>[DSVOB].*
    RGB      volume_direct                CVL
    RGB      coat                         C<RS'coat'>.*
    RGB      coat_indirect                C<RS'coat'>[DSVOB].*
    RGB      coat_albedo                  C<RS'coat'>A
    RGB      sheen                        C<RS'sheen'>.*
    RGB      transmission                 C<TS>.*
    RGB      transmission_direct          C<TS>L
    RGB      transmission_indirect        C<TS>[DSVOB].*
    VECTOR2  AA_offset (~)
    RGB      transmission_albedo          C<TS>A
    VECTOR   P (~)
    RGB      sheen_direct                 C<RS'sheen'>L
    RGB      volume                       CV.*
    RGB      sheen_indirect               C<RS'sheen'>[DSVOB].*
    NODE     shader (~)
    RGB      sheen_albedo                 C<RS'sheen'>A
    RGB      sss                          C<TD>.*
    RGB      sss_direct                   C<TD>L
    RGB      volume_indirect              CV[DSVOB].*
    RGB      volume_albedo                CVA
    FLOAT    A (~)
    FLOAT    ZBack (~)
    RGB      opacity (~)
    RGB      volume_opacity (~)
    FLOAT    raycount (~)
    UINT     ID (~)
    NODE     object (~)
    FLOAT    AA_inv_density (~)
    RGBA     RGBA_denoise (~)
    --------------------------------------------------------------
    (~) No opacity blending

Kicking Bifrost ASS


You can export a Bifrost scene to an Arnold ass file and then render it with kick.

Just use the -l flag (or the ARNOLD_PLUGIN_PATH environment variable) to point to the Arnold plugins that comes with the Bifrost install. For example, on Windows:

kick -v 5 -dp bifrost_aeroColors.ass 
-l "C:\Program Files\Autodesk\Bifrost\Maya2020\2.2.0.2\bifrost\arnold-6.2.0.0"
kick render of a Bifrost graph

In the Arnold log, we see that Arnold loads the procedural nodes for Bifrost:

00:00:00 88MB | loading plugins from C:\Program Files\Autodesk\Bifrost\Maya2020\2.2.0.2\bifrost\arnold-6.2.0.0 …
00:00:00 100MB | arnold_bifrost.dll: bifrost_graph uses Arnold 6.2.0.0
00:00:00 100MB | arnold_bifrost.dll: bifrost_object uses Arnold 6.2.0.0
00:00:00 100MB | arnold_bifrost.dll: bifrost_multires_volume uses Arnold 6.2.0.0
00:00:00 100MB | arnold_bifrost.dll: bifrost_multires_implicit uses Arnold 6.2.0.0
00:00:00 100MB | arnold_bifrost.dll: bifrost_volume uses Arnold 6.2.0.0
00:00:00 100MB | arnold_bifrost.dll: bifrost_points uses Arnold 6.2.0.0
00:00:00 100MB | arnold_bifrost.dll: bifrost_implicit uses Arnold 6.2.0.0
00:00:00 100MB | arnold_bifrost.dll: bifrost_polymesh uses Arnold 6.2.0.0
00:00:00 100MB | arnold_bifrost.dll: bifrost_blocks uses Arnold 6.2.0.0
00:00:00 100MB | loaded 9 plugins from 1 lib(s) in 0:00.06

In other applications, like CINEMA 4D or Houdini or Katana, you can do the same thing by setting the Plugin Search Path.

ERROR: out-of-range shader index


If you see this error in your Arnold log, it most likely means that you have more than 256 per-face shaders. Arnold has a hard limit of 256 shaders that can be assigned to a single object.

[polymesh] /pPlane1/pPlaneShape1: out-of-range shader index (5/3)

You may also see this warning if you have a large number of objects merged into one single object (for example, an Alembic archive that consists of many objects). In some cases, an Alembic archive like that may have more than 256 shaders assigned to the sub-objects.

Tangent space normal maps


The built-in N AOV is in world space. So how to get a tangent-space N AOV?
Like this:

In brief, I read the N AOV, transform the normals from world to tangent space, and then map the normal values to the range 0.5, 1 (I used the range node here, but I could have used Add and Multiply to do the same thing).

Here’s the shader tree. You can save this in a .ass file and import it into Maya or whatever application you use. Then set up an AOV shader to write the custom Ntangent AOV

range
{
 name aiRange1
 input space_transform
 output_min 0.5
}

space_transform
{
 name space_transform
 input read_N_AOV
 type "normal"
 to "tangent"
 tangent 1 0 0
 normal 0 1 0
 normalize on
}

aov_read_rgb
{
 name read_N_AOV
 aov_name "N"
}

aov_write_rgb
{
 name defaultArnoldRenderOptions/aov_write_rgb_Ntangent
 aov_input aiRange1
 aov_name "Ntangent"
}