Category Archives: maya

Using Mayatomr: Normal Displacement

Normal displacement is displacement relative to the surface normal.  Heres a quick tutorial for using normal displacement with Mayatomr.

Full mesh, level 5

Reference mesh, divisions 5

Start with

  • Base mesh (created by down-res’ing a high-res reference mesh)
  • Normal displacement map (exported with values that match the base mesh to the reference mesh)

Step-by-step

Open Maya; import base mesh; apply material shader.  Typically your base mesh will have a low poly count:

poly_base1

Base mesh, divisions 1

From the material’s shadingEngine, attach a displacement shader.

shadingEngine > Shading Group Attributes > Dispacement mat. [map button]

Select the “File” node from prompt and load the correct displacement map. Note: Maya automatically creates a displacementShader between the shading group and the file node. Because normal displacement only requires a scalar (greyscale) value, the file node connects to the displacementShader via it’s alpha channel. “Alpha Is Luminance” has also been enabled so that the alpha is the average of the RGB channels. Set the file node’s Filter Type to Off.

file > File Attributes > Filter Type = Off

This is important because you do not want Maya to try and interpolated displacement samples. If you render now, you’ll get an interesting looking result.

lda_base_no_offset

cool, but not useful

The reason the image looks like this is because the displacement map is only 8-bit.  Mental ray expects negative values to be inward displacement, positive values to be outward displacement, and zero to be neutral displacement.  Because 8-bit images only map to positive values (0.0 to 1.0), the sculpting application has exported a displacement map where 0.5 corresponds to neutral.  Offsetting the alpha by that amount (subtracting) will adjust for difference.

file > Color Balance > Alpha Offset = -0.5

You will most likely want to leave Alpha Offset at 0.0 for 32-bit/floating-point displacement maps (depending on how it was exported).

Better

Better

The mesh still does not match.  Here’s why:

  1. The base mesh still has hard normals causing the displacement to open up seams as it pushes the surface outward.
  2. As soon as you attach a displacement shader, Mayatomr “helps” users by applying a length-distance-angle approximation to the polygon surface.  This is not ideal.

We can fix both these problems by turning the mesh into a Catmull-Clark subdivision surface (ccmesh).  Using the approximation editor, apply a parametric subdivision to the surface.  By default, applying this approximation triggers Mayatomr to export the object as a ccmesh.

Window > Rendering Editors > mental ray > Approximation Editor
mental ray Approximation Editor > Subdivisions (Polygons and Subd. Surfaces) > Create
mentalraySubdivApprox > Subdivision Surface Quality > Approx Method = Parametric

N Subdivisions = 2

N Subdivisions = 2

The seams have closed up, however the mesh has lost all detail.  The shadows look particularly bad because of the low triangle count.   Increasing the number of subdivisions will bring back detail.  To match the reference mesh, set N Subdivisions = N(reference) – N(base), in this case 5 – 1 = 4.

N Subdivisions = 4

N Subdivisions = 4

Lower N Subdivisions result in a loss of detail.

N Subdivisions 3

N Subdivisions 3

 Larger N Subdivisions may cause visual artifacts as you exceeded the resolution of the displacement map (displacement map pixels become visible).

N Subdivisions 6

N Subdivisions 6

Unfortunately, normal displacement is inherently limited in the geometry it can describe. For modern workflows (and the my next blog post!) use vector displacement.

nVidia iray in Maya 2014 *update: iray layered material (MDL)*

iray Mixer

iray Mixer

 

**Update** mental ray 3.13 is scheduled to include MDL natively, meaning using mia_materials or the Max version of the Layered Material will no longer be necessary.

If you are curious how to run iray in Maya 2014, you can follow similar steps found in the GPU Ambient Occlusion post. However you need to add some files to those copied into the created directory. Similar requirements from the iray in Maya 2013 post still apply as well as an important samples workaround I will explain later in this post. A more complete set of steps follows here: (you can find information on the layered material at the bottom of this post)

How do I set iray up in 2014?

You will need the libraries for iray that are included with licensed copies of 3ds Max 2014 or mental ray Standalone.

Special note: for OSX and Linux users you need to install the CUDA driver separately Also note that as time passes since the publish of this article, we usually recommend you go with a recent build of whatever drivers you may want to use. And important to realize that older/newer generations of NVIDIA hardware may not be supported since the time of this post.

There are two main steps:

  1. Move the necessary files to a better location (only has to be done once for the machine)
  2. Setup the String Options (once per scene using .mel)

Moving the files from your copies of Max or Standalone:

The files you want are:

  • cudart64_42_9.dll
  • libiray.dll
  • libiraymr.dll

1. Copy the files to a new directory you create in your user Maya folder. For example, create a folder called: mental ray  The new path would be something like this: C:\Users\UserName\Documents\maya\2014-x64\mentalray

2. Copy the above .dll files to that directory.

3. Go up one directory and find the Maya.env file. Open it with a text editor and put this text in it and save:

MI_LIBRARY_PATH = $MAYA_APP_DIR/2014-x64/mentalray
PATH = $MI_LIBRARY_PATH;$PATH

Ok you’re done with that part and that should work from here on out regardless of scene. Now, open Maya and create a very simple scene.

Creating the String Options

Now you need the correct string options to make iray render.

In the string options found in the shipped Maya 2014, you will already find the string options for iray true/false.  You will need to change this to “true” or “on” to work. Below are the other options you might want to add:

select miDefaultOptions;
$idx = `getAttr -size miDefaultOptions.stringOptions`;
setAttr -type "string" miDefaultOptions.stringOptions[$idx].name "progressive min samples";
setAttr -type "string" miDefaultOptions.stringOptions[$idx].value "1";
setAttr -type "string" miDefaultOptions.stringOptions[$idx].type "integer";
$idx = `getAttr -size miDefaultOptions.stringOptions`;
setAttr -type "string" miDefaultOptions.stringOptions[$idx].name "progressive max samples";
setAttr -type "string" miDefaultOptions.stringOptions[$idx].value "1024";
setAttr -type "string" miDefaultOptions.stringOptions[$idx].type "integer";
$idx = `getAttr -size miDefaultOptions.stringOptions`;
setAttr -type "string" miDefaultOptions.stringOptions[$idx].name "progressive max time";
setAttr -type "string" miDefaultOptions.stringOptions[$idx].value "0";
setAttr -type "string" miDefaultOptions.stringOptions[$idx].type "integer";
$idx = `getAttr -size miDefaultOptions.stringOptions`;
setAttr -type "string" miDefaultOptions.stringOptions[$idx].name "progressive error threshold";
setAttr -type "string" miDefaultOptions.stringOptions[$idx].value "0.05";
setAttr -type "string" miDefaultOptions.stringOptions[$idx].type "scalar";
$idx = `getAttr -size miDefaultOptions.stringOptions`;
setAttr -type "string" miDefaultOptions.stringOptions[$idx].name "iray architectural sampler";
setAttr -type "string" miDefaultOptions.stringOptions[$idx].value "off";
setAttr -type "string" miDefaultOptions.stringOptions[$idx].type "boolean";
$idx = `getAttr -size miDefaultOptions.stringOptions`;
setAttr -type "string" miDefaultOptions.stringOptions[$idx].name "iray caustic sampler";
setAttr -type "string" miDefaultOptions.stringOptions[$idx].value "off";
setAttr -type "string" miDefaultOptions.stringOptions[$idx].type "boolean";
$idx = `getAttr -size miDefaultOptions.stringOptions`;
setAttr -type "string" miDefaultOptions.stringOptions[$idx].name "iray mode";
setAttr -type "string" miDefaultOptions.stringOptions[$idx].value "gpu";
setAttr -type "string" miDefaultOptions.stringOptions[$idx].type "string";

Now the workaround part. . .You’ll notice I added the Progressive Controls. This might be seen as redundant since Maya 2014 includes Unified Sampling which also controls iray sampling.

However, in this version of mental ray for Maya 2014, there is a regression that causes iray to stop refining the image after 100 passes using the Unified Sampling controls. So in this case you need to switch Maya 2014 to a different type of rendering algorithm like Legacy Sampling (this disables the Unified Sampling controls) and use the above controls instead.

For “iray mode” there are three options:

  • “gpu” (default)
  • “cpu”
  • “mixed”

You can substitute these for each other.

I also included options for the Architectural and Caustic Samplers.

The iray Architectural Sampler is used mostly for interior scenes where light may come from small openings. The Architectural Sampler is currently a form of Metropolis Light Transport and may be updated later. You should find scenes with that type of lighting converge much faster than before.

The iray Caustics Sampler is also available for scenes where the effect contributes to the image significantly.

You can find out more about iray features by visiting the blog for the iray developers. It’s found on the link sidebar of this blog.

We are working on ways to get the iray material to work in Maya 2014 as well with some success. However a few bugs in Maya may cause headaches with using the arrays. Stay tuned. . .!

**layered material update**

You can use this with Maya 2014 if you:

A) follow the above directions
B) download the newest package from here: http://blog.irayrender.com/post/5294…in-for-3ds-max (Max 2014)
C) rename the .dll to iray_layered_material.dll
D) Use this .mi file: http://db.tt/Jz67Ua8q

!!! And now a warning: !!!

Maya has a bug (not mental ray, this is MAYA). If you close and re-open a scene, the arrays holding your materials are lost because they are not saved. This means your assigned layers disappear and you have to start over. We don’t have a fix for that yet. Looks like a Maya bug and no current workaround.

Below, rendered in Maya:

iray in Maya 2014 with Layered Material (MDL)

iray in Maya 2014 with Layered Material (MDL)

Shutter Efficiency – mental ray 3.11

Motion blur interface controls for "shutter shape function"

Motion blur interface controls for “shutter shape function”

Starting with 3.11, mental ray supports a shutter shape function ability for applying arbitrary exposure shapes to the shutter interval.  This allows for motion blur that better matches film.  While programmers can write their own functions, the built in trapezoid shape is good enough for most production needs.

Shutter Efficiency

Motion picture cameras use a rotary disc—a semicircular disk that spin in front of the film gate—as the shutter device.  Light is only captured when the missing part of the disk exposes the film gate.  This is referred to as the shutter interval.  The portion of the complete circle that the disk is missing is referred to as the shutter angle.  A shutter angle of 180˚ is considered normal for a motion picture camera.  A larger shutter angle results in a longer shutter interval and more motion blur effect.

A shutter that is completely open for the entire interval would capture the most light possible and would be said to be 100% efficient.  The physical nature of rotary disks means that the time it takes for shutters to fully open and close is non-zero.  This results in less light being captured at the ends of the shutter interval.  This softens the appearance of motion blur at its edges.

Shutter Shapes and Efficiency

Shutter Shapes and Efficiency

You can conceptualize shutter efficiency with a graph that plots exposure vs. shutter interval.  An idealized shutter would correspond to a box shaped function on this graph.  Real-world cameras have a more rounded shape that can be approximated as a trapazoid.  The minimum efficiency of a trapezoidal function is 50%.  Most real-world cameras are around 80% efficient.

Why do Maya cameras have a default shutter angle of 144˚ if 180˚ is more ‘correct’?

This is because renderers typically—and incorrectly—describe shutter exposure as being 100% efficient.  Using a shutter angle of 144˚ with a 100% efficient shutter matches the total exposure of a real-world camera.  That is:

144˚ × 100% = 180˚ × 80%

144° None (Box), 144° Trapezoidal Shutter @ 80%, 180° Trapezoidal Shutter @ 80%

144° None (Box), 144° Trapezoidal Shutter @ 80%, 180° Trapezoidal Shutter @ 80%

If you decide to apply an 80% efficient trapezoidal shutter shape to your scene, you may also want to adjust your render camera’s shutter angle to 180˚.  This will give you a similar result to the idealized case, except now with more physically accurate (and visually pleasing!) motion blur.

camera shutter angle

camera shutter angle

Public render settings updated for Maya 2014

I’ve released a new public render setting user interface for Maya 2014: mr-rendersettings_v0.4.zip.

Features:

  • Native environment lighting mode integration.
  • Exposed trapezoidal shutter shape function for more realistic motion blur.  I’ll explain these settings in another post.
  • Renamed “Contrast As Color” UI option to “Quaily As Color”.  This is more consistent with current naming and is also more intuitive.
  • Slight layout rearrangement to improve workflow.
  • Moved Adsk specific shader options to legacy.

Feedback and comments are welcome.  Please report bugs on on the google code page.

Download here.

quality2014indirect2014