Los Angeles mental ray® User Group
 Home   About   Info   Summaries   Gallery   Forum   Resources   Contact   Jobs 


Resources Sections

General

Install/Setup

Options Settings

Performance Optimizations

mi Scene File

FG/AO/GI

Subsurface Scattering

Shiny Stuff

mrfm (Maya)

Shader Writing

Hair and Geometry Shaders

Charlotte Manning's Options Notes

  1. Sampling
  2. BSP
  3. Tesselation
  4. Final Gathering
  5. Know What Is In Your Scene

Sampling
sampling image

Sampling is controlled by two options parameters: contrast & samples.
min-max are the minimum and maximum sampling rates (where min actually means  2^2*minand max is 2^2*max. So,

  • 2^2*-1 = sample every 4 pixels
  • 2^2*2 = 16 samples per pixel
The actual sampling rate will vary over the image (going toward the maximum where contrast occurs, and toward the minimum where contrast is lacking).

The best strategy is to choose an acceptable range (-1 -> ; 2) and use the contrast setting to force the sampling into the higher range for good quality, and the lower range for low quality. This means you can leave the samples setting alone most of the time and just use contrast as a quality knob. Low quality would be a contrast of about 0.2, and high quality would be a contrast of about 0.01 (the lower the contrast, the more sensitive the threshold). Every now and then, a worse-case situation might occur where you would need to bump the sampling range up to 0->3.

 
 
BSP
bsp setting

Binary Spatial Partitioning (BSP) is the acceleration algorithm for ray tracing. The BSP depth controls the number of allowed levels (subdivisions) in the BSP voxel tree, and the BSP size controls the maximum number of triangles in a voxel (leaf). The fewer triangles in a voxel, the faster it can be searched during ray tracing. If a voxel contains more than the maximum number of triangles, it is split into two smaller voxels, generating a new level in the tree until the maximum number of levels is reached.

The BSP size is set to 10, the default, and can be left that way. BSP depth can range from 24-52. Larger tree depths reduce render time but increase memory consumption. A smaller scene (ie, character-only) should be fine with ~30. If the render is already reaching the machine's memory limit, you don't want to raise the depth setting - but for larger scenes with an intensive ray tracing operation like finalgather, something more like 40 may give you a dramatic speed-up. If you just don't have a good guess (this is a good thing to do anyway), try testing several values, and see what works out for you! Following is a graph that illustrates this:rendering time vs bsp depth

Try checking the diagnostics for BSP at the end of your test render. It will be labeled 'main bsp tree statistics'. The max depth will equal whatever you specified as the bsp depth. Compare the average depth: if it is too close to the maximum, parts of your scene may benefit from further subdivision.

Note the bsp memory (Kb) before and after you increase the max depth. If the average is much lower than the max, than either the maximum is higher than needed, or the scene is non homogeneous (all triangles grouped in one area, and a few in outlying areas).

Check that the average leaf size is 10 or less, and the max leaf size is hopefully under 100. To see an example of this process click here.

If you know the scene will be memory-intensive, try switching to the "large bsp" method:  the render will be ~20% slower but it may be the difference of whether a huge scene will render or not.   For now you may do this by editing your .mi file: in the options block at the top of the file change:
-> #acceleration bsp
   acceleration large bsp

OR, on the command line, add:  '-acceleration largebsp'

 
 
Tessellation settings
luigi approximation fields

The approx type options curvature and spatial are methods of approximation (tessellation) for objects:

  • curvature is synonymous with distance and
  • spatial is synonymous with length.

The approx kywd (we are using either none or view at the moment) determines whether the length or distance value -- specified by approx value -- is measured in object space (none) or raster (view) space. This is important. If you switch from none to view, make sure that your approx value makes sense in terms of corresponding measurement space and the method being used.


distancelength
distance
length

Distance measures the "distance" between the tessellated surface and the ideal or pure mathematical representation of the surface. So the more finely an object is tessellated, the smaller the distance is between the two. The renderer will subdivide and create more triangles until the distance is less than "approx value". This method is an efficient way to tessellate, because it puts more triangles in curvy areas where they are needed and less in flat areas.

For distance, it is a little difficult to visualize in order to pick a good starting value as a subdivision criterion. In object space, expect this to be quite small (for stitched characters where the tessellation needs to be fairly tight, we have had success with 0.001). In raster space, the value should be larger, but not as large as a pixel. Usually 0.1 is fine - yes that is 1/10th of a pixel, but keep in mind what we are measuring.

Length measures the "length" of an edge of a polygon. This is much easier to visualize. The renderer will keep subdividing until no triangle edge is greater than "approx value". When in object space, that value is measured in proportion to the scale of the object, and when in raster space, the length is measured by pixels. Normally with this method, a good value when in view mode is 1.0, which means one polygon per pixel, or no edge may be greater than 1.0 pixel.

Approx min/max are the subdivision limits. The render subdivides according to the specified criterion, but only up to the max number of subdivisions. This prevents runaway subdividing.  You can force a min level other than zero, but this is typically better used with displacement mapping and can be wasteful otherwise.

Tip: sometimes you can cut your triangle count and still maintain quality by lowering the max subdivision level to 3. When adjusting your tessellation settings, you should monitor the triangle count printed out in the statistics at the end of the render. A change in the approximation configuration can cut the triangle count dramatically while maintaining image quality. Lowering the triangle count isone of the many actions that will make your render go faster with less memory.

Some have asked me if mental ray has LOD (level of detail). LOD is the loading of different resolutions of an object at different camera distances, and then blending between them. There are two answers to this question: 1) no it doesn't exist as a feature, but the architecture is open enough that this could be implemented as a geometry shader & material 2) it's not necessary because mental ray has view-dependent tessellation (setting approx keyword to view which does the same thing: objects far away have few triangles, and objects close-up have as many triangles as needed.

Tesselation Summary
     distance = distance to true surface (minute quantity)
     length = length of poly edge
     none = approx value measured in object space
     view = approx value measured in raster space

 
 
Final Gather (FG) Falloff & Accuracy
FG settings

First some background on finalgather:

fg ptFinal gathering uses quasi-random sampling over a hemisphere centered at a sample point. To get an accurate solution, usually hundreds of samples are needed (a sample is obtained by shooting a ray). If a renderer performed finalgather for every eye ray (an eye ray is the initial ray originating from the camera to sample a pixel in the image), the render would take forever.

mental ray will choose - based on your finalgather parameters - only select points in the scene to perform this expensive operation. These FG points are determined during the finalgather precomputation phase just before the main render. The idea is to interpolate between these points to cover the entire image.  The placement of the points depends on the finalgather accuracy settings:

The FG accuracy setting has two parameters:

  • Number of Rays (= # of samples) and
  • Max Radius (= the maximum radius in which a final gather result can be interpolated or extrapolated).
More rays gives better sampling for a given finalgather point. The larger the radius, the less dense the FG points are, the less accurate the solution, and the faster the render time.

Here are some diagnostic images showing the distribution of finalgather points : (green = initial grid, red = final placement): *note the denser (more accurate) distribution of points on the right.


fgpts coursefg pts dense

The finalgather falloff (start/stop) limits the length of final gather rays to a distance of stop in world space. The start parameter defines the beginning of a linear falloff range. Effectively this limits the reach of indirect light for final gathering. This option is useful for keeping final gather rays from pulling remote parts of the scene, which may not affect illumination very much, into the geometry cache. Ray tracing normally has to keep the entire scene in memory -- by indicating that the rays need not search beyond a certain distance, mental ray can now cache the parts of the ray traced scene that are not currently needed, because they are beyond the falloff of the current sample point.

You can think of the distance in terms of the radius of the hemisphere centered at the current FG point. Typically ambient occlusion passes need much shorter falloff (less than 40 units, depending on the scale of your object, a stadium has a larger scale than a shrimp). This is because the purpose of an exposure pass is to measure local accessibility or exposure.

If using FG to sample bounce lighting, one part of the scene might actually be influenced by a remote region depending on the intensity of light at the point, so the falloff will have to be extended (sometimes to include the entire scene -- this would be the case for an enclosed room, whereas in an outside scene or large scale set, light influence only goes so far due to light attenuation). Use the measure tool in your 3D package to get a feel for what your scene extent is and try to think about light influence. Ultimately a good choice of falloff distance is an aesthetic decision - but keep in mind that this distance dramatically affects performance: as the distance increases, the renderers caching behavior degrades, which is a fancy way of saying the memory increases and the render goes slow (or no go at all).

 
 
KNOW WHAT IS IN YOUR SCENE

Is there a huge Dome object?
If there is, get rid of it. You can use a spherical environment shader and apply the same texture that was on the dome.

Are you rendering a single character, but the whole rest of the scene is in there (with visibility turned off)? Are there generally objects in the scene that shouldn't be there? Open your .mi in your favorite text editor, and search for "instgroup"... If an instance is listed in the instgroup, it will be rendered.


Discuss on LAmrUG forum


 © 2003-2006 Los Angeles mental ray® User Group, All Rights Reserved.
mental images and mental ray are registered trademarks of mental images GmbH, in the United States
and other countries. Other product names may be trademarks of their respective owners.


About Us| Contact Us