[C4DtoA] Installing C4DtoA in a custom location


The C4DtoA installer puts the C4DtoA plugin in the default location: the plugins folder of the Cinema 4D install.

If you want to put C4DtoA somewhere else, like a shared network location, you can use the C4D_PLUGINS_DIR environment variable to point to your custom plugin location.

For example, on Windows I moved C4DtoA to a different drive and then set my environment like this:

set C4D_PLUGINS_DIR=F:\plugins
set PATH=F:/plugins/C4DtoA/arnold/bin;%PATH%

Note that I had to set PATH so C4D could find ai.dll, and that I had to use forward slashes (on Windows, C4D doesn’t like backslashes in the PATH and drops them).

On Windows, the C4DtoA installer puts a second copy of ai.dll in the C:\Program Files\MAXON\CINEMA 4D R17, so you’ll have to remove that ai.dll, and use PATH to point to the ai.dll in the C4DtoA arnold/bin folder.

Portable ASS files with relative paths and the Texture Search Path


You can make your ASS files portable across different platforms by using relative paths and the texture search path. For example, if all textures are specified by relative paths like “textures/noicon.tx”, then you just have to set options.texture_searchpath to specify the location of the textures folder.

For example

kick -set options.texture_searchpath //server/project/ -dp -dw example.ass

Or if the texture search path is set to an environment variable

export ARNOLD_TEXTURE_PATH=//server/project
./kick example.ass

To use relative paths for texture file names in nodes like MayaFile, aiImage, aiPhotometricLight, and aiSkydomeLight, you just need to do the following:

  • Put a relative path in the file name box (for example, in Photometry File box of an aiPhotometricLight node, or the Image Name box of an aiImage node)
  • Set the Texture Search Path (Render Settings > System > Search Paths)
  • Clear the Absolute Texture Paths check box

You can put multiple locations, using either : or ; to separate the paths (Arnold supports both separators on all platforms: OSX, Linux, and Windows)

You can use environment variables by putting the environment variable name in square brackets. For example:

"[ARNOLD_TEXTURE_PATH]:C:/Assets/IES/;C:/maya/projects/Support/sourceimages"

Forward slashes work on all platforms.

MtoA appends the current project’s sourceimages folder to the texture search path.

Why can’t I use kick -set options.shader_searchpath ?


You may wonder: why can’t I use kick -set options.shader_searchpath to tell Arnold where to find shaders?

Well, it’s because kick loads the ASS file first, then applies the kick -set parameter overrides. And also, Arnold when loads an ASS file, Arnold automatically loads shaders from the shader_searchpath as soon as Arnold loads the options node.

Here’s the sequence of events:

  1. kick loads all plugins specified by -l or by ARNOLD_PLUGIN_PATH before it loads the ASS file
  2. kick¬†loads the ASS file. When Arnold loads the options node, Arnold automatically loads all plugins specified by options.shader_searchpath.That’s why the options node is at the top of an ASS file: so Arnold can load any required shaders before loading the shader nodes. It you move the options to bottom of the ASS file, the¬†shader nodes in the ASS file¬†won’t be loaded.
  3. Finally, after all the nodes are loaded, the -set parameter overrides are applied. At this point, it’s too late for any shaders from the -set options.shader_searchpath loacation. The corresponding nodes were already discarded during the loading of the ASS file.

 

[MtoA] Per-light AOVs for volumes


 

Arnold 4.2.12.2 added support for per-light AOVs for volumetrics.

Here’s how to set up per-light AOVs in MtoA 1.2.6.0:

  1. In the light Attribute Editor, enter a name for the light group.
  2. Create a custom AOV for the light group. Give the AOV¬†a name that starts with “volume_”. For example, if the light group name is “red”, then the AOV name is “volume_red”.

aov_light_group

[MtoA] Creating the defaultArnold nodes in scripting


Loading MtoA isn’t enough to create the defaultArnoldRenderOptions node. The defaultArnoldRenderOptions node isn’t created until a user opens the Arnold Render Settings for the first time.

In code, you can do it like this:

from mtoa.core import createOptions
createOptions()

# Set default render options
setAttr( "defaultArnoldRenderOptions.motion_blur_enable", 1 )

When createOptions() creates the defaultArnoldRenderOptions node, it also creates the defaultArnoldDisplayDriver, defaultArnoldDriver, defaultArnoldFilter nodes and hooks them up to the defaultArnoldRenderOptions node.

defaultArnoldRenderOptions

Note that for setting defaults like this, you can also user a userSetup.py file. createOptions() calls hook functions that you can implement in your userSetup.py.

[MtoA] MayaFile node uses a default color for missing textures


Here’s something important to remember when you’re debugging a scene…

By default, the MayaFile node uses a default color if a texture is missing.

MayaFile_Use_Default_Color

This means the render won’t abort because of missing textures, and you won’t see ERRORs like these in the Arnold log for missing texture files:

ERROR   |   [texturesys] OpenImageIO could not open "sourceimages/noicon.tx" as tx: Could not open file "sourceimages/noicon.tx"
ERROR   |   [texturesys] Invalid image file "sourceimages/noicon.tx"

So missing textures can easily go unnoticed.

If you need to disable Use Default Color for testing, an easy way is to export an ASS file and then render it with kick -set MayaFile.useDefaultColor false.

I suppose you could also modify the Maya scene file directly:

import maya.cmds as cmds
import os

def set_useDefaultColor(b):
    filenodes=cmds.ls(type="file")
    for item in filenodes:
        cmds.setAttr( "%s.aiUseDefaultColor" % item, b )

set_useDefaultColor( False )

And finally, you can change the default value of the Use Default Color parameter by adding this to shaders/mtoa_shaders.mtd:

[node MayaFile]
	[attr useDefaultColor]
		default		BOOL	false