Microsoft Knowledge Base

INFO: OPTIMIZING MENTAL RAY

Last reviewed: April 22, 1997
Article ID: Q167243
The information in this article applies to:
  • Softimage 3D for IRIX, version 3.51
  • Softimage 3D for Windows NT, version 3.51

SUMMARY

This article describes a number of techniques you can employ to optimize mental ray rendering time and efficiency. There are no general rules for optimal settings that you can apply for different scenes; a scene's contents (number of triangles, reflections, transmissions, motion blur, etc.) all influence what settings will optimize the rendering process.

The following points will help you determine how to find the optimal settings based on the contents of your scene:

  • For small scenes with less than 150,000 triangles, use BSP Tree.
  • For scenes with a moderate number of triangles (under 100,000) but few reflective/transmissive surfaces and no motion blur, and a system with a lot of memory, BSP works well with a depth of 64 or higher and leaf size of 3 or more.
  • For scenes with very few triangles (under 50,000), the default BSP settings are fine and changes will have little impact.
  • When memory is a problem, the defaults for ray classification work best. (The amount of memory used by the ray classification scheme is a given whereas the BSP tree's use of memory is dependent on the number of triangles in the scene and the BSP tree depth and leaf size.)
  • For huge scenes (over 100,000 polygons) with many reflections/transmissions, motion blur, etc., ray classification is best. The ray classification settings do not appear to have much impact on render times.
  • BSP tree is usually faster when there is an unlimited amount of memory for rendering.
  • Increasing tree depth and decreasing leaf size slows down mental ray's preprocessing of the scene (it prints a message such as "subdividing scene…").
  • If you want to benchmark your scene, try using various settings and look at the mental ray status report. Track the "average rays per pixel," which measures the accuracy of the adaptive supersampling and memory and rendering time.
  • Beware of frequently misused numbers for surface approximation; they can significantly change your rendering time.
  • If you don't see the back of your objects, try rendering only the front faces instead of both front and back.
  • If your scene does not have reflection, transparency, refraction, or shadows, turn off the secondary rays and shadows.
  • If Ray Depth is not set too high, rendering time increases significantly.

MORE INFORMATION

BSP (Binary Space Partitioning) Tree

Finding the Optimum Value for Max Size (triangles per leaf):

Large leaf sizes and small tree depths reduce memory usage but increase rendering time because larger leafs need to be searched. Increasing the tree depth also leads to a slight increase of the preprocessing time required for building the acceleration data structure. You can fine tune rendering speed by experimenting with different maximum leaf size and maximum tree depths values.

When rendering with the -verbose option enabled, mental ray reports the size of the largest leaf node (before rendering) and the number of candidate triangles per ray (after rendering). If these numbers are larger than 10, you can build a deeper BSP tree by choosing a larger max depth, such as 30 or higher. This can have a dramatic effect on rendering speed. When there are more triangles than the max size parameter in the BSP tree of the specified depth and leaf size, mental ray ignores the maximum leaf size, resulting in large leaves even if the max size has a low setting.

In general, the BSP algorithm often leads to faster rendering times, particularly in complex scenes with many reflections and refractions and for scenes with motion blur. However, for very large scenes, or for motion- blurred scenes where large portions of the scene move very rapidly, ray classification is preferable because of the convenient method for controlling the memory required by this algorithm.

Finding the Optimum Value for Max Tree Depth:

There is no exact method for finding the proper max depth, but by adjusting the number of triangles per leaf and max depth, it is possible to find a combination that results in a faster rendering time. Empirical studies suggest that this number is just beyond the point where the number of leaves begins to decrease. To find this point, set the max depth to a large number (such as 50), activate the Bsptree statistics in the render options dialogue box and run the program (it is not necessary to render a complete picture; the program can be stopped when the first scanline appears). Exit the program and examine the status file. Look for the point where the number of leaves begins to decrease. Set the max depth to this number plus one.

It is best to have a small number of triangles per leaf, however, because as the number of triangles reduces, the memory required increases as well as the time for preprocessing. The BSP Tree is generally faster than Ray Classification, but it consumes more memory for larger scenes.

Ray Classification

Finding the Optimum Value for Visible and Shadow:

For both visible and shadow rays, positive numbers subdivide more finely while negative numbers generate fewer subdivisions. Using positive numbers reduces the number of boxes that must be examined. However, overhead for generating the acceleration data structures and intersection testing increases. For optimal speed, small adjustments from -2, 2 are recommended. Negative numbers reduce the rendering time.

Find the Optimum Value for Memory Limit:

The amount of memory used for acceleration is constant and defaults to approximately six megabytes per CPU. Even very large scenes with over a million triangles work at maximum speed with no more than twelve megabytes per CPU for acceleration data structures.

Surface Approximation

To achieve optimal resolution, Surface Approximation allows you to alter your Patch or NURBS object's tessellation parameters at render time. If your geometry consists of polygons, then the Surface Approximation settings do not apply.

By default, your Patch objects will be subdivided evenly across their surfaces based on the number of U and V steps specified. You can lower the triangle count on your object by lowering your Static Parametric values. However, it will be uniformly modified across your entire ISO lines and your number of triangles will remain constant from frame to frame.

You can also optimize your object's total number of triangles by using the Adaptive Surface Approximation method. With the Spatial settings, you can determine the maximum triangle size that gets distributed evenly across your object. Additionally, you can set subdivision limits to achieve a minimum and maximum resolution based on that triangle size.

The most efficient method is to use the Curvature Surface Approximation. It allows you to optimize your object's tessellation by adding triangles only where they are needed the most. With the Cord Length (distance from the tessellation to the curve) and the Angle (dihedral angle between adjacent triangle normal), you can set a series of thresholds that the render will respect until the conditions are met. The Curvature method also lets you set min and max subdivision values to control your overall resolution parameters.

For both the Spatial and Curvature Adaptive settings, you have the choice to use System (SI units) or pixel units (triangle diagonal length). The System length is intuitive and useful when you measure your object's overall dimensions and set your values accordingly. The Pixel length is advantageous because it allows you to increasingly optimize your object's tessellation and make it dependent on its proximity to the camera. The further your object is from the camera, the less subdivision is required to achieve the same visible level of resolution.

Because the Adaptive Surface Approximation can't give you a total triangle count for your object based on your settings until render time, refer to the mental ray verbose output for the information. Once the render is activated, mental ray gives you an approximated surface triangle count for each object in the scene. This information is located in the soft.status file or in your SI3D Command Prompt where you initiate your render. If you are rendering from the shell, use the [-verbose on] option for mr to get the same output. You can compare the optimized triangle count number to the default Static Parametric triangle count value that is located in Info -> Selection. This will give you an idea of whether you have increased or decreased your object's triangle count.

For visual feedback, you can also output a mental ray contour render from the options menu in the Render Setup. You will be able to see the overall distribution of triangles over your surface and determine whether you need more or less subdivision.

REFERENCES

To query the Microsoft Knowledge Base for additional information on rendering with mental ray, enter the keyword "si3dmr" in the "Enter your search phrase field."

If you have any questions concerning the information contained in this article, contact support@softimage.com by e-mail.


Keywords : kbgraphic kbusage si si3d si3dmr si3dren kbinfo
Version : 3.51 | 3.51
Platform : IRIX NT WINDOWS
Issue type : kbinfo


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 22, 1997
©1997 Microsoft Corporation. All rights reserved. Legal Notices.