Quantcast
Channel: MTOA – Arnold Support Corner
Viewing all 107 articles
Browse latest View live

[MtoA] Creating the defaultArnold nodes in scripting

$
0
0

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] Per-light AOVs for volumes

$
0
0

 

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

WARNING mtoa_shading_groups: unresolved reference

$
0
0

Any time you see “node … is not installed” and “unresolved reference” warnings when you try to kick an ASS file exported from Maya, the problem is missing MtoA shaders.


00:00:00 18MB WARNING | [ass] line 259: node "MayaFile" is not installed
00:00:00 18MB WARNING | [ass] line 288: node "MayaShadingEngine" is not installed

00:00:03 23MB WARNING | [ass] line 238: pSphereShape1.mtoa_shading_groups: unresolved reference to 'aiStandard2SG'
00:00:03 23MB WARNING | [ass] line 137: aiSkyDomeLightShape1.color: unresolved reference to 'file1'
00:00:03 23MB WARNING | [ass] line 188: pPlaneShape1.shader: unresolved reference to 'aiStandard1SG'
00:00:03 23MB WARNING | [ass] line 197: pPlaneShape1.mtoa_shading_groups: unresolved reference to 'aiStandard1SG'
00:00:03 23MB WARNING | [ass] line 229: pSphereShape1.shader: unresolved reference to 'aiStandard2SG'

When you render with kick, you need to specify the location of the MtoA shaders. You can do this several ways:

  • Set the ARNOLD_PLUGIN_PATH environment variable. For example:
    export ARNOLD_PLUGIN_PATH=/home/render/solidangle/mtoa/2016/shaders
    set ARNOLD_PLUGIN_PATH=C:\solidangle\mtoadeploy\2016\shaders
  • Use the kick -l flag to specify the MtoA shader location.
  • In Maya, set the Shader Search Path in the Arnold Render Settings, then export the ASS file.

The case of the blue render view

$
0
0

Reason #35 why you should check the Arnold log

In this case, a scene that used to render yesterday, now just resulted in a blue render view, like this:

blue_render_view

Anytime the render view doesn’t update when your render, you can be fairly sure there’s some ERROR in the Arnold log.

In this case, the problem was a broken path to the IES file used by a photometric light. In the Arnold log, there was this ERROR:

00:00:04 870MB ERROR | [photometric] can't open C:/Assets/IES/example.ies

It’s easy to say “check the log”, but where do you find the log? It’s not like there’s a nice, color-coded button (red for error) on the render view UI that will pop up the log for you.

  • On Windows, you should see the Arnold log in the Output Windows. However, I find that this happens only when I start Maya from the command line. If I start Maya from the Windows Start menu, the Arnold log messages don’t show up in the Output Window. So I have to enable file logging, and check the log file.
  • On OSX and Linux, you’ll also have to enable file logging, unless you start Maya from a terminal.

 

 

[MtoA] Adding per-face and per-vertex user data

$
0
0

With Maya and MtoA, there’s no easy way to add per-face and per-vertex user data attributes to objects. You’ve got to do it with scripting: add an array attribute with addAttr and then provide the values. For example, here’s how to add per-face and per-vertex attributes, which MtoA will translate to UNIFORM (per-face) and VARYING (per-vertex) user data on the shape.

import maya.cmds as cmds
# Add UNIFORM (per-face) user data
cmds.addAttr("pPlaneShape1", dataType="vectorArray", longName="mtoa_uniform_myPerPolyColor")
cmds.setAttr("pPlaneShape1.mtoa_uniform_myPerPolyColor", 4,(0.48, 0.39, 0.35), (0.62, 0.63, 0.44), (0.47, 0.69, 0.33), (0.70, 0.38, 0.29), type="vectorArray")

# Add VARYING (per-face vertex) user data
cmds.addAttr("pPlaneShape2", dataType="vectorArray", longName="mtoa_varying_myPerPointColor")
cmds.setAttr("pPlaneShape2.mtoa_varying_myPerPointColor", 9, (0.46, 0.55, 0.66), (0.29, 0.40, 0.38), (0.69, 0.43, 0.68), (0.36, 0.58, 0.55), (0.59, 0.48, 0.27), (0.55, 0.52, 0.70), (0.48, 0.35, 0.26), (0.46, 0.46, 0.47), (0.34, 0.55, 0.31), type="vectorArray" )

After you run the script to add the attributes, you can use the aiUserData shaders to get the user data values and use them in your shader trees.

aiUserDataColor

For example, here’s the per-face and per-vertex user data colors on a simple grid:

uniform_varying_user_data

[MtoA] mtoa missing from Plug-in Manager

$
0
0

If mtoa.mll is not listed in the Plug-in Manager, that means that Maya did not find the MtoA module file (mtoa.mod). And if you try to manually load mtoa.mll, you’ll get errors like this:

// Error: file: C:/Program Files/Autodesk/Maya2016/scripts/others/pluginWin.mel line 781: Unable to dynamically load : C:/solidangle/mtoadeploy/2016/plug-ins/mtoa.mll
The specified module could not be found. // 
// Error: file: C:/Program Files/Autodesk/Maya2016/scripts/others/pluginWin.mel line 781: The specified module could not be found. (mtoa) //

To load MtoA, you need to make sure that Maya finds the MtoA module file.

By default, the MtoA installer puts the mtoa.mod file in the user’s modules folder. For example:

C:\Users\StephenBlair\Documents\maya\2016\modules

If you installed MtoA using one user account, and try to run Maya with a different user account, Maya will not find the module file.

The module file has to be in the MAYA_MODULE_PATH. For example, for the user account “StephenBlair”, here are the default places where Maya looks for modules:

  • C:/Program Files/Autodesk/Maya2016/modules
  • C:/Users/StephenBlair/Documents/maya/2016/modules
  • C:/Users/StephenBlair/Documents/maya/modules
  • C:/Program Files/Common Files/Alias Shared/Modules/maya/2016
  • C:/Program Files/Common Files/Alias Shared/Modules/maya
  • C:/Program Files/Common Files/Autodesk Shared/Modules/maya/2016

If you want MtoA to available to all users, then you could copy mtoa.mod to one of the common locations.

[MtoA] [Arnold] The case of the mesh light and the facing-ratio material

$
0
0

In this case, we have a torus as a mesh light.

The mesh light color is facing-ratio ramp, so that in the Beauty AOV, the polygons facing the incoming camera ray are red, and polygons facing away are green.

facing-ratio-1

The plane below the light has a [slightly non-realistic] combination of diffuse, specular, and reflection (Kd=0.7, Ks=0.5, Kr=0.2).

The question here is: why do we see red in the reflection AOV, but green only in the diffuse and specular AOVs? Why does the facing-ratio ramp return red for reflection rays, but green for diffuse and glossy rays?

The answer is that there are no diffuse or glossy rays in this situation. A mesh light gets a meshLightMaterial shader, which MtoA assigns to the mesh light color (and to the torus shape) when MtoA translates the scene to Arnold.

The meshLightMaterial shader doesn’t handle diffuse, glossy, or shadow rays. The first few lines of the meshLightMaterial shader look like this:

if (sg->Rt & (AI_RAY_DIFFUSE | AI_RAY_GLOSSY | AI_RAY_SHADOW))
 {
 sg->out.RGBA = AI_RGBA_BLACK; 
 return;
}

Let’s take a look at what’s happening in the different AOVs.

Reflection

The reflection rays hit the bottom of the torus, go through the facing-ratio ramp, and return red because most of the polygons are facing down towards the plane. In this case, we get the facing ratio of the polygon normals and the reflection ray.

facing_ration_reflection

Specular

We get the green from the light sampling, where there’s no rays.

facing-ratio-glossy

Since there’s no rays, we get the dot product of the surface normal and  0 0 0, which is 0. And that returns green from the ramp:

facing-ratio-ramp

Diffuse

The diffuse rays don’t make a contribution (because the meshLightMaterial doesn’t handle them) so we get green from the light sampling (just like for specular).

facing-ratio-diffuse

Indirect Specular

This would be black, since the meshLightMaterial doesn’t handle glossy rays, so the mesh light makes no contribution to the glossy reflections.

[MtoA] Exporting XGen archives

$
0
0

Finally, I have XGen > Generate > Export Selection as Archive working with Maya 2016 Extension 1 + SP5 on Windows 7.

I recently updated to SP5 from SP4, but I don’t know if that’s part of why the export works now. But I do know that I had to install mental ray for Maya 2016. I didn’t need to load Mayatomr, I just needed it installed. And then Export Selection as Archive worked!

PS I did see that thread on cgtalk about modifying xgenMR.py and xgenMRExport.py, but that didn’t work on my Windows 7 machine.


[MtoA] Adding user data to standin instances

$
0
0

The standard way to add user data to an Arnold node is to add an mtoa_constant attribute to the shape node in Maya. MtoA translates the mtoa_constant attributes to user data, so you can use shaders like AiUserDataColor.

Instances in Maya, however, don’t have their own shape node: they all share the shape node of the original object. So you can’t use an mtoa_constant attribute on the shape to get different user data for each instance.

But you can use override sets to get user data on instances. Put the instances in a set, and then add the mtoa_constant as an override attribute.

set_overrides

Then each instance in the set will get that user data.

Another way to add user data to instances is with the particle instancer: you can add per-particle attributes, and then list them in the Arnold > Export Attributes text box. MtoA translates all those attributes to user data on the particle instances.

[MtoA] Use any mesh for a standin

$
0
0

MtoA 1.2.7.0 includes an enhancement (“standin as attribute group”) that allows you to use any mesh as a standin. So instead of the aiStandin node, you can have a proxy geometry to represent your standin.

For example, here’s a mesh shape that loads an animated ASS sequence exported from Softimage:

procedural_mesh_transslator
Note that in the shape Attribute Editor, the Arnold Translator is set to procedural.

This feature uses the mesh bounding from Maya, so it’s possible your standin maybe clipped. You can work around this either by disabling Defer Procedural Load, or by using the User Options to set the procedural min and max (for example: min -1 -1 -1 max 1 1 1).

Hat tip: Alf

[MtoA] Running a silent install on Windows

$
0
0

On Windows, if MtoA isn’t already installed, then the /S flag will do a silent install:

MtoA-1.2.7.3-2016.exe /S

You can also specify an install location with the /D flag:

MtoA-1.2.7.1-2016.exe /S /D=C:\solidangle\mtoadeploy\2016-1.2.7.1
There’s no help, but I found the /S and /D via Google:

There is no silent install on OSX or Linux.

If another version of MtoA is installed, there will be some pop-up dialogs. You can get around that by doing a silent uninstall, like this:
C:\solidangle\mtoadeploy\2016-1.2.7.1\uninstall.exe /S

or, if you want to keep the existing install around, you could do this:

reg DELETE HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\MtoA2016 /f

After you delete that registry key, an MtoA install won’t detect an existing installation, so you get to keep the old install, and install a new version.

 

[MtoA] The case of the missing mtoa.mll

$
0
0

I woke up this morning and my MtoA was gone😉

2016-04-06_06-20-40.png

It turned out that mtoa.mll, ai.dll, and all the other DLLs were gone from the MtoA installation directory. How’d that happen? Probably when my computer had a critical Kernel Power error at 4:30am and crashed.

 

Setting the procedural’s load_at_init parameter to true would also fix this.

$
0
0

There’s an Arnold error that recommends setting the load_at_init parameter, but people don’t always know where to find that in their favorite Arnold plugin.

ERROR| [proc] c4d|Arnold_Procedural: bounds supplied to procedural node are not large enough to contain the actual underlying geometry.
Replace given bounds: (-1, -1, -1) X (1, 1, 1), with: (-9.4028616, -9.43616867, -9.21633244) X (9.3304739, 9.43616867, 9.21633244).
Setting the procedural's load_at_init parameter to true would also fix this.

The load_at_init parameter controls whether the procedural (standin) is loaded during scene intialization (before rendering starts), or during rendering (when a ray hits the procedural bounding box).

By default, load_at_init is false, which means that procedural loading is deferred until render time.

And so, in MtoA, C4DtoA, and SItoA, the load_at_init parameter is exposed as Defer Standin Load, which is enabled by default. In HtoA, you have a Load At Init parameter on for the Arnold Procedural node.

load_at_init_htoa load_at_init_mtoa load_at_init_c4dtoa load_at_init_sitoa

[MtoA] Unable to dynamically load mtoa.mll …The specified procedure could not be found.

$
0
0

If the MtoA plug-in  does not load and you get a “The specified procedure could not be found” error like this:

// Error: line 1: Unable to dynamically load : C:/solidangle/mtoadeploy/2016/plug-ins/mtoa.mll
The specified procedure could not be found.
 //
// Error: line 1: The specified procedure could not be found.
 (mtoa) //

then there’s a few basic things you need to check first:

  • Does your processor support SSE4.2? As of Arnold 4.2.13.0 (MtoA 1.2.7.0), support for SSE4.2 is required. You won’t be able to load MtoA or use Arnold if your processor doesn’t support SSE4.2.
  • Do you have the right MtoA version for your version of Maya? Major versions of Maya are not binary compatible, so for Maya 2016 you need “MtoA for Maya 2016”.
    And Maya 2016 Extension 2 is not binary compatible with Maya 2016 Extension 1, so if you have Extension 2, you need “MtoA for Maya 2016.5”

If your processor is good and you have the right version of MtoA, then it’s on to basic troubleshooting:

  • Check the environment in Maya. For example, does the PATH include any older versions of MtoA? If you’re on Windows, run the MEL command system(“set”) to get the environment. On OSX or Linux, run system(“printenv”).
  • Check for missing or conflicting libraries. On Windows, you can use Dependency Walker to  check for any conflicts or missing DLLs.

    Download and extract Dependency Walker. Then start it from inside Maya (to inherit the Maya environment). For example, I do something like this:
    system( “start C:/Users/stephen/Downloads//depends22_x64/depends.exe” );

    Then load mtoa.mll.

[MtoA] Switching between multiple versions of MtoA

$
0
0

start_menu_mtoa

If, like me, you need to switch between different versions of MtoA, here’s a recipe for setting that up.

First, you have to install multiple versions. As you probably already know, the MtoA installer always wants to uninstall first. I take care of that by zapping the Uninstall registry entry with this command:

reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\MtoA2016" /f

Then I run the MtoA installer and install in a folder with the version name, like this:
C:\solidangle\mtoadeploy\2016-1.2.7.3

I start Maya with a batch file that creates a symbolic link named “C:\solidangle\mtoadeploy\2016” that links to the version of MtoA I want to use:

rmdir C:\solidangle\mtoadeploy\2016
mklink /D C:\solidangle\mtoadeploy\2016 C:\solidangle\mtoadeploy\2016-1.2.7.3
rem mklink /D C:\solidangle\mtoadeploy\2016 C:\solidangle\mtoadeploy\2016-1.2.2.0

set RLM_DEBUG=arnold
start "" "C:\Program Files\Autodesk\Maya2016\bin\maya.exe" %* -log %TEMP%\maya.log

My batch file also adds the location of my custom mtoa.mod to MAYA_MODULE_PATH. My custom mtoa.mod points to “C:\solidangle\mtoadeploy\2016”, and handles all versions of Maya:

+ MAYAVERSION:2016 mtoa any C:\solidangle\mtoadeploy\2016
PATH +:= bin
+ MAYAVERSION:2015 mtoa any C:\solidangle\mtoadeploy\2015
PATH +:= bin
+ MAYAVERSION:2014 mtoa any C:\solidangle\mtoadeploy\2014
PATH +:= bin
+ MAYAVERSION:2013 mtoa any C:\solidangle\mtoadeploy\2013
PATH +:= bin

 


Updating MtoA 1.2.7.3 with Arnold 4.2.14.0

$
0
0

MtoA 1.2.7.3 ships with Arnold 4.2.13.

If you want to take advantage of the improvements in Arnold 4.2.14.0 (like the increase  in the maximum number of threads from 128 to 256), here’s what you need to do:

  • Download  Arnold 4.2.14.0 and extract the archive
  • Replace Arnold (libai.so, ai.dll, libai.dylib), kick, and maketx in the MtoA bin folder with the versions from the Arnold 4.2.14.0 download
  • Replace the Arnold Python bindings in  the MtoA scripts/arnold folder with the Python bindings from the Arnold python/arnold folder. For example, replace this folder:
       C:\solidangle\mtoadeploy\2016-1.2.7.3\scripts\arnold

    with the python\arnold folder from the Arnold 4.2.14.0 download. For example:

       C:\solidangle\arnold\Arnold-4.2.14.0-windows\python\arnold

You must update the Arnold Python bindings, otherwise MtoA won’t load. That’s because Arnold 4.2.14.0 included a number of API changes, including the removal of some API (like AiLicenseSetServer). The older Python bindings still refer to the removed API, so there will be Python errors that prevent MtoA from loading.

[MtoA] Renderman performance warning

$
0
0

If you have both Renderman and MtoA installed, you may see a warning that says “Arnold for Maya degrades Renderman performance.” Unless you are running a version of MtoA from 20 months ago, this performance warning is false. MtoA does not degrade Renderman performance.

This was fixed in Arnold 4.2.3.1 (fix #4393 main thread was pinned to a single core) back in January 2015.

[MtoA] Getting an Arnold log

$
0
0

The Arnold log is important, not just for troubleshooting and getting help from us at Solid Angle, but also for understanding what’s going on when Arnold renders your scene.

To get an Arnold log:

  1. In Maya, click Render > Render Settings
  2. In the Render Using list, click Arnold Renderer
  3. Click the Diagnostics tab.
    mtoa_render_settings_diagnostics
  4. Set the Verbosity level to at least Warnings + Info
  5. Click the File check box to enable file logging (by default, the log file will be saved in the last folder you browsed to with  Maya; see Finding your log file).
  6. If you want to be absolutely sure of where to find the log file, click the folder icon beside the Filename box, and select a location for the Arnold log file.
  7. Depending on what OS you use, and how you started Maya, the log is also output to the Output Window (Windows) or to the terminal (on OSX and Linux if you started Maya from a terminal)

For batch rendering, Arnold log messages go into mayaRenderLog.

  • [Windows] %USERPROFILE%\Documents\maya\mayaRenderLog.txt
  • [OSX] ~/Library/Logs/Maya/mayaRender.log
  • [Linux] ~/maya/mayaRenderLog.txt

Exporting ASS files to specific locations

$
0
0

For the render -rt 1 command, you can specify the output ASS name in
the defaultArnoldRenderOptions.output_ass_filename attribute. For example:

set PRE_RENDER_MEL="setAttr -type \"string\"
defaultArnoldRenderOptions.output_ass_filename
 \"c:/Users/StephenBlair/Documents/test\";"

 render -s 6 -e 8 -r arnold -rt 1 -preRender %PRE_RENDER_MEL%
 C:\projects\Support\scenes\_2016\XSI_deformed_logo.mb

The scene should have the Frame/Animation ext set to something like
“name.#.ext”. Otherwise, if it is “name.ext” you’ll get filenames like
“example.ass.0004.ass”

output_ass_filename can have environment variables, but you have to be
careful to use forward slashes. For example:

set PRE_RENDER_MEL="setAttr -type \"string\" defaultArnoldRenderOptions.output_ass_filename \"%OUTPUT_ASS_FILENAME%\";"
set OUTPUT_ASS_FILENAME=C:/Users/StephenBlair/Documents/example

render -s 6 -e 8 -r arnold -rt 1 -preRender %PRE_RENDER_MEL% C:\projects\Support\scenes\_2016\XSI_deformed_logo.mb

There’s also the arnoldExportASS command, if you want to script the export.

maya -batch -file scene.mb -command "arnoldExportAss
-f "/home/blairs/Desktop/example.ass" -mask 255 -lightLinks 1 -compressed
 -shadowLinks 2 -cam sideShape;"

Force Translate Shading Engines?

$
0
0

You may have noticed the Force Translate Shading Engine option in the export dialog (or in the Feature Overrides section of the Render Settings).
force_translate_shading_engine

Force Translate Shading Engines forces MtoA to export shape nodes with a shader link, like this:

polymesh
{
 ...
 shader "aiStandard1SG"
 declare mtoa_shading_groups constant ARRAY NODE
 mtoa_shading_groups "aiStandard1SG"
}

where “aiStandard1SG” is the name of a MayaShadingEngine shader node.

This allows you to keep your shapes and shaders in separate ASS files. For example, you could have one standin that loads the shapes, and a second standin that loads the shaders. As long as the shape nodes include links to the shaders, Arnold will resolve the links and render the shapes with the right shaders.

Viewing all 107 articles
Browse latest View live