Wills Maya Global Illumination Tweaking Guide 1
Copyright (C) Will Smith , July 2003
All text and models released under the Gnu Free Documentation License,
with no invariant sections, and the Public Documentation License.
Introduction
Maya 5.0 introduces mental ray renderer built in. For the first
time, global illumination and caustics are easily accessible to Maya
users.
This guide documents some common mistakes when using GI (I learnt from
making them myself). I am by no means an expert on GI, so this is
only Guide number 1. Hopefully there will be more to come.
Rather than starting off with a scene and tweaking until we have a nice
look, I will start with a scene that is as good as I can get it, then I
will experiment with changing some of the settings. The errors /
artifacts introduced will hopefully help you when you see them, you'll
know what's causing them and know what options to change.
Credits
I based the model on the model from Toni Bratincevic, which he kindly made
available for download (see http://www.3dluvr.com/intercepto/maya/tutorials/mray_thegathering/outdoor01.htm) . The model has very minor cosmetic
modifications compared to Toni's, and the render settings are increased
for a very slow, high quality render.
System Specifications
All my settings are based on a Athlon XP 1800+ on a Nvidia Nforce2
based motherboard. The CPU runs at 11x150MHz = 1650Mhz, and the
1Gb of DDR memory runs at memory at 150MHz ( 300Mhz DDR). Since
Maya mainly cares about raw CPU speed, my Athlon is therefore equivalent
to approximately a 1900+.

This 480x360 render takes 5:42 = 342 seconds.
There no antialiasing issues (except some strange light blue in the
interface between the ground and the sky that I haven't debugged
yet). The scene is illuminated partly by the blue sky, and partly
by an orange/yellow spotlight. The spotlight has an area light to
give softer shadows. The inside of the Acropolis is made slightly
lighter by the use of global illumination.
Tweaking Final Gathering Ray Count
Final gathering is confusingly named, since it seems to occur before
any of the rendering you can see. It's perhaps the final stage of
all the global illumination. We currently have this set to
1000. I reduced it to 50
(download maya file). The setting is in Render Globals ...
mental ray tab .. Final Gather ... Final Gather Rays.

This 480x360 render takes 2:28 = 148 seconds.
Final gather is very costly in render time. We've made a big
decrease, over 50% faster. But now there are ugly blotches in the
steps on the lefthand side and inside the Acropolis, i.e. in areas where
there are compound or complex shadows.
Let's try to find a compromise. I tried increasing final gather
rays back to 200 (download
maya file)

This 480x360 render takes 3:14 = 194 seconds.
There is still slight blotchiness. It's not ugly, but compared to
the original image, it's clear that it shouldn't be there. Maybe
500 gather rays is necessary (download
maya file)

This 480x360 render takes 4:33 = 273 seconds, (reduction of 20%
compared to benchmark original).
There is still a tiny bit of blotchiness, however this is only visible
if we do an image comparison in the Maya output window. We
will leave final gather at 500 from now on, so our new 'benchmark' time
is 273 seconds.
Conclusion : Final Gather Rays count
is critical in optimizing rendering time. Values that are too low
cause blotchiness in shadows and areas that should be evenly
shaded. Halving your final gather ray count will take perhaps
10-20% off your render times.
Tweaking
Sampling Quality
Sampling quality is something similar to antialiasing. It is
accessible from Render Global ... mental ray tab ... Sampling Quality.
The 'min samples' and 'max samples' are (I think) the key. Maya
recommends that 'max samples' is set to 'min samples' + 2. The
manual implies that every time you increase the values by 1, the
possible number of pixels sampled for antialiasing can double.
Lets reduce our current setting of 'min samples' = 1, 'max samples' = 3
(I abbreviate to 1, 3) down to -2, 0 (download maya
file). This big reduction should help us see easily see the
effect on visual quality and render times.

This 480x360 render takes 2:13 = 133 seconds.
There are now ugly antialiasing effects, visible anywhere there is a
sharp contrast, especially on the darker lefthand columns.
However, we did get a big reduction in render time (down by 50%) so it's
worth tweaking some more.
Let's try increasing sampling quality up to -1, 1 to see if it is
sufficient (download
maya file).

This 480x360 render
takes 2:26 = 146 seconds.
That's excellent. Only incredibly close comparison reveals a few
pixels different on one or two columns, and we have almost halved
rendering time. These settings and 146 seconds becomes our new
benchmark.
Conclusion : sampling quality 'min
samples' = -1, 'max samples' = 1 is probably sufficient unless you
notice antialiasing problems. An increase to 1, 3 could well
double you render times.
Tweaking Sampling Filter
Currently, we are using the
'Gauss' filter, which defaults to 'filter width' = 3, 'filter height' =
3 (these are in render global ... mental ray tab .. sampling
quality). Let's try changing back to the default, and presumably
lower quality, box filter (download
maya file).

This 480x360 render takes 219 = 139 seconds.
There is no perceptible difference in quality that I can detect, but
the time gained is about 5%. Let's try the more complicated filter
types, just to see if we can see any effect First, the Lanczos
filter (download
maya file).

This 480x360 render takes 2:29 = 149 seconds.
Interesting. This gives a much sharper, crisper image. A
read of the Maya manual implies to me that this is similar to the
unsharp mask function in Photoshop. So, use it if you want
crispness, but don't over-use it! There is almost no time penalty
for using this filter.
Now let's try the Mitchell filter type (download
maya file).

This 480x360 render takes 2:22 = 144 seconds (same render time as
previous benchmark, slightly sharper image).
Mitchell is a bit softer than Lanczos, but a bit sharper than 'box' or
'gauss'. Let's leave it on, this becomes the new benchmark
default. It's the same speed as our previous benchmark, but I like
the sharpness.
Conclusion : Sampling filter does not
affect render times significantly, but controls the sharpness of the
final image. Gauss and Box give a slightly soft, blurred
effect, Mitchell is a compromise, and Lanczos gives very sharp
images. For the sharper filters, you may experience slight
problems with antialiasing though, possibly needing a higher sampling
quality, which will slow your render.
Global Illumination Accuracy
Currently I have the global illumination accuracy set to 250 (render
global ... mental ray tab .. caustics and global illumination ... global
illum accuracy).. Maya default to 64. Let's take it down to
32 to see what the effects are (download maya file).

This 480x360 render takes 1:54 = 114 seconds.
The scene does not show any major defects, but the whole lefthand side
of the image is significantly brigher than it was before, and the
righthand steps seem to glow a little. On the plus side, we
reduced the rendering time by 20%. Let's take the quality to a
compromise 100, and see how things look (download maya
file).

This 480x360 render takes 2:03 = 123 seconds.
The render times are now within 15% of the original render times, but
there is a noticable difference in the image (at least, if you compare
them in Maya's render window). It is not objectionable, but I hate
to accept an image that I know is not as 'accurate' as it could be.
Let's try it the other way, to see if even the 250 accuracy setting can
be improved on, in terms of image quality. Let's increase the GI
accuracy right up to 1000 (download maya
file).

This 480x360 render takes 3:28 = 208 seconds.
We are way back up in long render times. There is a some
difference between this (GI accuracy = 1000) and the previous benchmark
(GI accuracy = 250). This is slightly duller at the righthand
side. Presumably the building is blocking some light from some of
the sky hitting the righthand steps, and the lower qualities doesn't
take that into account somehow.
OK, let's return the GI accuracy to 250, where we started. The
benchmark time remains at 144 seconds, we can forget all this GI
accuracy tweaking.
Conclusion : Low GI accuracy can
result in areas with the incorrect brightness. The effects are not
ugly. A GI accuracy of 1000 can add 40% to a render time compared
with 250, and a GI accuracy of 32 can reduce render time by 20% compared
with 250. Overall, a fairly high value like 250 will ensure
accuracy without excessive render times.
Area Light Sampling
Currently we are using a spotlight for the sun, with an 'attached'
mental ray area light.
The area light is set to type 'sphere', with sampling '3,3', low level
= 0, and low sampling = 2,2 (see spotlightshape1 ... mental ray ... area
light).
Let's set the sampling down to 1,1. For all the settings (sampling and
low sampling both set to 1,1) (download
maya file).

This 480x360 render takes 2:20 = 140 seconds.
Ugh, the edges of the shadows are really ugly, and we only saved a few
seconds off our previous benchmark of 144 seconds. Let's try the
other way - can we get even nicer shadows by taking all the area light
sampling values right up to 4,4 (download
maya file)?

This 480x360 render takes 2:31 = 151 seconds.
There's a tiny, subtle difference between this and the benchmark.
The render time has increased from 144 to 151 seconds, or 5%. I
think it's worth it - it just makes the shadows perfect, not a hint of
grainyness at the edges. This becomes our new benchmark.
Mental Ray Raytrace Levels
Currently we have the mental ray raytrace levels (in render global ..
mental ray .. quality .. general) set to:
- max reflection rays = 4
- max refraction rays = 1
- max ray depth = 4
- scanline = off
- faces = both
Let's try tweaking some of these. I'll refer to this combination
as (4,1,4,off,both).
'Scanline' controls whether any part of the scene is rendered with the
traditional renderer, and 'faces' somehow relates to whether we properly
render all the hidden faces. Let's try turning them both to the
lower quality settings (scanline = on, faces = front) (download
maya file).

This 480x360 render takes 2:13 = 133 seconds.
OK something weird happened. I'm guessing it's the
faces=front. Let's leave scanline=on for the moment, and have
faces=both (download
maya file).

This 480x360 render takes 2:38 = 158 seconds.
This is actually worse than the 151 second benchmark. Maybe our
timings are variable, maybe it's actually slightly slower. The
image has not changed in any way. Let's revert scanline=off.
Let's now try reducing the ray depths a long way, to see the
effect. We have no refraction so we should be able to set that =
0, and the other 2 at 2.
So our original (4,1,4,off,both) becomes (2,0,2,off,both) (load
maya file).

This 480x240 render takes 2:29 = 149 seconds.
That's not much different from the benchmark (151 seconds), and the
difference is imperceptible. Using Maya's comparison tool shows a
tiny difference in the detail of the steps in the front corner, but it's
not clear which is better.
With a slight time gain to 149 seconds, this becomes our new benchmark.
Conclusion: Scanline on or off tends
to make little difference. Rendering only front or back faces may
produce strange effects. Increasing the ray trace values from
2,0,2 to 4,1,4 doesn't make much difference in quality or render times
for fairly simple scenes such as this (perhaps it does for more complex
scenes).
Mental Ray Memory and Performance
These are available in Render Globals ... mental ray ... Memory and
Performance. Currently, we have Acceleration Method = BSP, BSP
size = 10, BSP Depth = 40.
For the benchmark, maximum memory used during render for the maya
process = 172Mb.
With settings changed to BSP size = 3, BSP depth = 80 (load
maya file)

This 480x360 render takes 2:30 = 150 seconds.
Maximum memory used during the render = 185Mb Memory is hard to
trace accurately, in Maya it depends on which subwindows are visible,
whether you've minimized the application recently, etc. So no
change in rendering time, possible slight increase in memory
usage. With 1Gb of RAM available, I don't see that we've gained or
lost anything, so lets revert. The image itself is identical.
OK, let's try the 'grid' acceleration method with the default settings
(resolution=0, max size=128, depth=2) (download maya file).

This 480x360 render takes 4:27 = 267 seconds.
The memory usage reduced slightly to 170Mb, but the render time has
gone way up! Let's go back to BSP and leave this section well
alone.
Conclusion : leave the memory and
performance options to the default (method=BSP, BSP size=10, BSP
size=40) unless you have memory problems. Avoid the 'grid' method
unless you know what you are doing.
Polygon Count, NURBS quality.
Let's see if the complexity of the scene is causing problems. We
can find the total polygon count of the scene using 'Display ... Head up
Display ... Poly Count'. Currently we have Verts=64, Edges=92,
Faces=41, UVs=104. That sounds low already.
However, I am aware that some of the tesselation qualities etc are
quite high on some of the components of the scene.
In an attempt to reduce this, modified the following:
Modified all the columns from (curve precison=15, crv precision
shaded=4, simplify mode=0, simplify u=1, simplify v=1, divisions =3,
divisions v=3) down to (4,2,0,1,1,0,0).
Modify the two domes creating the sky and the light from the sky, so
that their tesselation is reduced from (high quality, u divisions
factor=12, v divisions factor = 12) down to the default of (medium
quality, 4.5, 4.5), also changed their curve precision etc down to
(4,2,0,1,1,0,0) (download
maya file).

This 480x360 render takes 2:23 = 143 seconds.
There's little differnce in the image, except the blue line at the
horizon (which I don't want anyway) is more consistent. Let's make
this the new benchmark. Possibly at higher resolutions better
tesselation is necessary, but the defaults are fine at 480x360.
We've reduced the render time from 149 seconds to 143 seconds, 4%
faster.
Conclusion : at relatively low
resolutions, stick with low tesselations, and tesselation qualities, and
the default values in the 'nurbs surface display' settings, for a
slight benefit in render times.
Area Light - Global
Illumination Photons
Currently we the spotlight with the area light emits 50000 photons,
with energy 8000,8000,8000 and exponent 1.6 (Spotlightshape1
..mental ray ..Caustics and global Illumination). Can we
get the same quality with less photons, or somehow faster?
Let's turn the GI photons off for the spotlight (the sun) to better
understand what effect the GI is having (download maya file).

This 480x360 render takes 1:13 = 73 seconds.
Clearly, GI on the spotlight both adds a lot to the render time, but
also contributes a lot of warm light to the scene, and more
importantly, helps to light the inside of the Acropolis realistically,
rather than leaving it dark inside from the absense of any direct light
rays. However, the comparison does reveal that perhaps in the
original picture, there is too much orange light coming from the
spotlight (sun), making the illumination on the righthand side just a
little too
What about if we just have a few GI photons coming from the
spotlight? Let's try 100 (download maya file).

This 480x360 render takes 1:13 = 73 seconds.
The render time hasn't changed, clearly this small number of photons is
very quick to calculate. But now the scene is very blotchy.
Perhaps each photon now makes a big difference, and the bright bits are
where these photons land. I'm guessing that with more photons,
each makes a lower contribution to the overall lighting, so the more
there are, the more even the GI effect is.
So we can tune the number of photons between 0 (73 seconds) and 50000
(143 seconds). Perhaps the relationship is linear. Let's
try a compromise of 10000 photons, if adding more photons adds extra
time linearly, I predict this will take (73 + (10000/50000)*(143-73)) =
87 seconds (download
maya file).

This 480x360 render takes 1:43 = 103 seconds.
OK, our theory is incorrect - small amounts of photons (few thousand)
adds more time than the extra time for the larger amount of photons
(tens of thousands).
The image is very slightly different from our previous benchmark -
slightly duller on the righthand steps. However, if anything, the
version with lower photons looks more realistic, slightly softer.
Let's make this our new benchmark, since we made a decrease gain in
rendering time of almost 30%, but let's not try to push the photon
count lower, since we area already experiencing subtle changes in the
scene appearance from the higher photon (theoretically more accurate)
values.
Conclusion : number of photons
emitted by GI emitting light sources makes a big contribution to render
time. Too low number of photons makes a uneven effect in the
lighting, with bright and dark spots. Above say 10000 photons,
you will get only subtle changes in the scene smoothness, and your
render times will continue to grow.
Area Light - Global Illumination Energy and Exponent
Currently, for the area light (the sun) in the light's 'Caustics and
GI' section, we have exponent=1.6, and all the energies = 8000.
Let's understand what the energies do. Instead of
energy=(8000,8000,8000), let's drop to (8000,0,0) (download
maya file)

This 480x360 render takes 1:44 = 104 seconds.
The rendering time has not changed, but all the GI inside the Acropolis
is just red. (8000,0,0) must is RGB. Probably, we should
leave all values identically unless we want some strange effect.
According to the Maya manual, exponent is the way that light should
reduce its effect as it gets further from the source. The most
realistic, real world value should be 2. Let's see what happens
with exponent = 1, first (download maya file).

This 480x360 render takes 1:42 = 102 seconds.
There is simply too much GI. The low exponent is causing it to be
too powerful, and almost to amplify itself inside the building.
Let's try 2.0, and increasing the energy to (16000,16000,16000) - which
should perhaps balance the higher exponent - to see whether we can get
a good looking scene using an exponent of 2.0, which should be most
realistic (download
maya file).

This 480x360 render takes 1:43 = 103 seconds.
The inside is quite a bit duller, but I think it's more
realistic. Let's take the energy up to (24000,24000,24000) to
make it just a bit warmer (download
maya file).

This 480x360 render takes 1:44 = 104 seconds.
OK, that's a bit nicer, a warm glow to the righthand side, but the
inside's dullness feels (to me) a bit more natural, not so warm.
This is our new benchmark - the realism is better, but the rendering
time is the same.
Conclusion : For light sources that emit
GI photons, keep the GI energies the same unless you are sure they
shouldn't be. Preferably keep the exponent at 2.0. Try with
no GI light to see what it's affecting. Then tune the amount of
GI light added to the scene by altering the energy values.
Area Light - Shadow Map
Why would we want a shadow map, when we already have ray traced
shadows? The Maya manual doesn't make this clear. It does
suggest using shadow maps instead of ray tracing, for more speed.
Let's try turning on a mental ray shadow map. It's not clear
whether this turns off raytracing somehow. Let's leave render
globals alone for the moment. This gives us settings in
'spotLightShape1 .. mental ray .. shadow maps' of resolution=256,
samples=1, softness=0 (download
maya file).

This 480x360 render takes 1:39 = 99 seconds.
Ugh! The shadow is totally unrealistic, and all of our columns
don't even emit a shadow. There's a slight benefit in rendering
time. Let's try a much more detailed shadow map (resolution 1024)
to see if that helps (download
maya file).

This 480x360 render takes 1:50 = 110 seconds.
OK, we've solved the issue of the missing shadows from the columns - we
just needed a higher resolution. But the shadow edges are still
ugly, and we have increased the render time over the raytraced
shadows. It's also confusing me how the light has settings for
raytraced shadows and depth mapped shadows, as well as the Shadow Maps
option within mental ray. I think I'll leave this all alone and
investigate another day!
Area Light - Raytrace Settings
Currently, the area light has 'Shadows ... Raytrace Shadow Attributes'
set to Light Radius=0, Shadow Rays=32, Ray Depth Limit=5. Let's
experiment with reducing Shadow Rays down to 2 (download
maya file).

This 480x360 render takes 1:43 = 103 seconds.
There's no difference in the rendered image, and no difference in the
render times.
What about changing the radius to > 0 of the raytraced light, and
using this instead of the area light? Can that give us faster
render times with the same effect? Using the distance measure
tool (Create ... Measure Tool ... Distance Tool) we see that the
circumference of the area light is 5.3. So maybe setting the
radius to 2.6 will have the same effect? (download
maya file)

This 480x360 render takes 1:18 = 78 seconds.
This looks like we have some potential - we made a big decrease in the
render time, and need to increase the quality of the shadow borders a
bit, maybe we can do this by increasing the Shadow Rays, and still save
on render times. Also, our guess of 2.6 for the light radius
seems too high - the shadows are much more blurred at the edge than
with the previous area light.
Let's try with the light radius = 1.7, and the shadow rays set to the
same value as before we started experimenting, 32. I actually
experimented with a few values, they are not interesting enough to show
them all here, until I had an image as close as possible to the one
with the area light. (download
maya file)

This 480x360 render takes 1:56 = 116 seconds.
It seems that the raytraced light is very sensitive to the number of
shadow rays. Without shadow rays up to 16 or 32, there is
significant reduction in quality. But with shadow rays up to 32,
the render is now taking longer than the benchmark, so we won't persue
this further.
Finally, can we turn off ray traced shadows and just leave the area
light to do the work? (download
maya file).

This 480x360 render takes 1:33 = 93 seconds.
The answer is no. We need some kind of raytracing or the area
light doesn't work.
Conclusion : You can get similar
results with a raytrace shadow producing spotlight with radius, as with
a spotlight with a mental-ray added area light. The render times
are also similar, for similar qualities. Increasing the shadow
rays from 2 to 32 makes the edges of shadows near-perfectly smooth, but
adds perhaps 50% to the render time. Make sure you don't have a
radius > 0 as well as an area light, or you get longer render times
with no benefit. Make sure to leave 'ray traced shadows' turned
on to some extent, or you get no shadows at all.
Final Gather Files
We already noticed that 'final gather' is a very expensive stage.
Can we optimize this (perhaps not for a single render, but for
subsequent renders, for example in a movie) using some kind of disk
caching?
I tried going into 'Render Global ... mental ray ... Final
Gather'. Now, I turned 'final gather rebuild' off, and changed
Final Gather File to be 'save_final_gather_034' (download maya file).

This 480x360 render takes 1:45 = 105 seconds (run 1), 32 seconds (run
2).
That's quite a benefit, the 2nd time we run, we reduced the render time
by 70%! The cache file itself is stored in
projects/projectname/mentalray/finalgMap/fg_save_500 in this
case. It is a 11.3Mb file - not too bad. Now, we need to
know when we can and when we can't use this method.
Can we use it to render a scene with the camera in a different
position? If so, this would be great for flypasts etc.
Let's try moving the camera to the front of the building, closer
inside, and rerendering (download
maya file).

This 480x360 render takes 1:38 = 98 seconds (run 1), 37 seconds (run 2).
The algorithm seems to detect when the camera has moved, and does a
recalc. Interestingly though, some experimentation shows that the
more the camera moves, the more the first render has to start from
scratch. If the camera only moves a tiny bit, the first render is
able to gains some benefit from the cache.
Conclusion : final gather rebuild =
off can save significant times, especially for flyby movies and
similar, where the camera has only moved a tiny bit.
Summary
OK, we've been through the some of the main settings in Mental ray
renderer. In this example, we reduced render times to less than
30% of what we started with, while learning how to keep image quality
constant, and the effects of lots of other tweaks.
I hope this guide was of some use.
Will Smith.
7 July 2003
If you have any comments, mail me