Remapping paths at render time!


New with Arnold 6.0.4 is path mapping.

All you have to do is create a json file that looks something like this:

{
         "windows": { "S:/": "\\server\projects\" },
         "mac": { "S:/": "/Volumes/projects/"},
         "linux": {"S:/": "/mnt/projects/"}
}

and then set ARNOLD_PATHMAP to point to the json path mapping file

How Arnold handles paths

When you render a frame, here’s what Arnold does for file paths:

  1. Replace backslashes

    When Arnold loads an ass file, Arnold replaces all backslashes ( \ ) with forward slashes ( / )

  2. Expand environment variables

    When Arnold uses a parameter, Arnold expands all environment variable references, which look like this: [MY_TEXTURE_PATH]

  3. Map paths

    After Arnold expands environment variables, Arnold applies the path-mapping rules specified by the Arnold pathmap file.

Arnold expands environment variable expansion and maps paths for:

  • search paths in the options node
  • filename parameters for these nodes:
    • alembic
    • color_manager
    • all driver nodes such as driver_deepexr, driver_exr, driver_jpg, driver_png, and driver_tiff
    • image
    • include_graph
    • materialx
    • photometric_light
    • procedural
    • volume
    • volume_implicit

Setting up path mapping

You can automatically remap paths at render time using a pathmap file.

To use a pathmap

  • Set the ARNOLD_PATHMAP environment variable to point a pathmap file

The pathmap file is a json file. For example:

{
         "windows": { "S:/": "\\server\projects\" },
         "mac": { "S:/": "/Volumes/projects/"},
         "linux": {"S:/": "/mnt/projects/"}
}

Path mapping uses regular expressions. The general format of an entry is this:

{
         "windows": { "regular expression": "replacement string" },
}

For example, this pathmap replaces all drive mappings like E:/ and S:/ with //SERVER/

{
         "windows": { "[A-Z]:/": "//SERVER/" },
}

Arnold converts backslashes ( \ ) to forward slashes ( / ) when it loads the ASS file.

Path mapping happens after that, so pathmaps never have to deal with backslashes.

There can be multiple mappings for each OS:

{
         "windows": { "[A-Z]:": "//SERVER", "sourceimages/": "textures/"},
}

[mtoa] Using dirmap to update paths


How can you update the paths used to load textures, standins, or volumes? Use dirmap.

You can use dirmap to update the paths for the following nodes:

  • aiImage (Image Name)
  • aiStandin (Path)
  • aiVolume (Filename)
  • MayaFile (Image Name)

For example, if I have a scene file that uses Linux paths like /server/assets/textures/noicon.tx, I can do this:

dirmap -en true;
dirmap -m "/server/assets" "D:/Assets/";

After I run that, when I load a scene Maya will replace “/server/assets” with “D:/Assets” in all file paths.

You can test your directory mapping (dirmap) like this:

dirmap -cd "/server/assets/textures/noicon.tx";
// Result: D:/Assets/textures/noicon.tx //

So:

  • Enable dirmap with dirmap -en, and then create a directory mapping with dirmap -m
  • Load a scene and the dirmap is applied.

TIP For batch rendering, you can use a pre-render script to apply dirmap.

BONUS TIP: dirmap does not update a path if the path is valid. dirmap replaces paths that cannot be resolved.