Today, nearly all respectable 3Dprograms have some sort of GI solution integrated.
Since Mayas renderer doesn't support any kind of GI, and many people just can't
live without it, AW decided to introduce miss Maya to one of the most advanced
renderer today, the MentalRay. If someone of you have used XSI before, you know
how powerfull MRay is. One of the most interesting features in MRay implementation
in Maya is capability to compute additional light distribution in the scene.
This is also called the global illumination.

In this tutorial I'll try to describe how do I use MRay to create scenes with
global illumination. There are a lot of pictures in this tutorial, so be patient
if you don't have fast connection.

MentalRay has two solutions for computing additional light distribution in
the scene. One is Globall Illumination, and other is Final Gather. In some situations,
you can use only one of this solutions, but the most powerfull thing is to combine
these two together. Globall Illumination (picture 1a) shoots photons from light
and tracks their distribution in the scene. It is fast solution, and produces
nice additional lighting of the scene, but it isn't as accurate as we want it
to be. That's why you must combine it with second method , the Final Gather
(picture 1b). The goal of final gather is same as global illumination, but aproach
is very different. Final gather is computed from point of view, and not from
the light source like global illumination. After primary ray hits the point
on objects, final gather is activated and shoots additional rays in the scene
collecting color informations around the point for which we are computing color.

In this tutorial, we will use two types of scenes for which we will create
Globall Illumination and Final Gather solutions. First few scenes represent
indoor type of scene and the second scenes are outdoor. For the Indoor scene
1, we will go throughout proces step by step, and for other scenes i'll just
point out what are satisfying values used to produce globall illumination and
final gather. For the outdoor scenes, we will show how FinalGather can be used
along with HDRI to light up the scene.

First of all you need to download the MRay plugin from AW site. After the instalation
start Maya and go to Window > Setting/Prefferences >Plug-in Manager to
check if Mayatomr is loaded. If it isn't, click on the box near option loaded. If you want to use MRay as your everyday rendering buddy you can also check
the auto load box. After that, jump to Rendering menu, and select MRay as your
default renderer Rendering > Render Using > mental ray.

INDOOR SCENE 1

Now you need to create one simple scene that will be used as the example of
indoor scene. Create one simple box Create > Polygon Primitives > Box.
After box apears in your scene, scale it in z direction and increase the subdivision
to 6 4 10. After you do that it should look like this:

Now to increase the complexity of the object we will extrude all faces of the
object except the front ones. Go to Polygons > Tool Options menu
and check if Keep Faces Together is unchecked. If it isn't please do so. After
that select the polygons as in next picture:

Then go to Edit Polygons > Extrude Face ‚,
increase the offset value to something like 0.05 and click Apply. After that
reset the offset value to 0, and set the Local Values Translate to 0 0 0.15,
and press Extrude Face. After this your object should look something like this:

Rotate the view so that you see the front (non extruded-flat) side of object
- select the 8 face in the center of this side and delete it. After this, the
object should have the hole on this side, and it will probably look like this:

Now we need to create one spot light, that points throught the hole that we
created. To create one spotligt, you must go to Create > Lights > SpotLight. The spotlight will apear in the center of the scene. Transform it so
that it points through the hole like this:

Switch to shaded display in view, and rotate camera so that it is inside box,
like in this picture:

Then go to the Attribute editor of the light (select light and press CTRL+A)
to change some options. First of all, switch the Decay Rate to Quadratic. I
use the quadric decay rate in many cases to get realistic light behavior. If
you want, you can leave the Decay Rate to no Decay and experiment with that.
Also, if you have used the Quadratic Decay Rate, increase intensity to something
like 120.

In Shadow > Raytrace Shadow Attributes check the Use Raytrace Shadows. This
will produce the sharp raytraced shadows. Later you can use the area light to
get more realistic shadow.

One more thing that we will do is that we will create Lambert shader, and assign
to our object. After you assign it, change the color of the shader to something
like orange.

Now, let's go and setup the globall illumination... There are two menus that
we are interested in. The first one is in light attribute editor and other is
in MentalRay Rendering Globals > Options. First thing we have do to is to
change few options in light attributes, so that our light emmits photons. To
do this, select the one and only spotlight in the scene and pres CTRL+A. After
attribute editor pop's up, go to the MentalRay options > Caustic and Globall
Illumination and turn on the Emit Photons button. After you do this, few options
below Emit Photons will not be faded any more. As you will see, there are three
options, Energy, Exponent, Physical. The Energy and Exponent are similiar options
... they are used to fade and boost up the overall brightness of globall illumination
effect in the scene.

If you render the scene at this point, you will get the same result as if there
was no globall illumination. Why? Because we have to turn on the globall illumination
in the MentalRay Globals. To do this open the render window Window > Rendering
Editors > Render View. After the Rendering View opens, go to the Options
> RenderGlobals (MentalRay). After the renderGlobals opens, go to the Quality
section, and press the box like button on the right side of the Render Quality
option. This will opet another menu called mentalrayOptions1. In this menu we
will turn on the globall illumination. To do that, go to the Caustics/Globall
Illumination section and turn on the Global Illum. This will turn on the calculation
of globall illumination in the scene. Let's make a test image to see what has
happened after turning on GI. The first picture shows the picture without GI,
and second with GI.

Without global illumination

With global illumination

As you see, there is a lot of additional lighting in the scene. The only problem
is that it doesn't have satisfying quality. Remember that after the we setup
the globall illumination we have to use the final gather to get the best illumination
that we can. For that reason, we have to fine tune the globall illumination
so that it serves the final gather when the time comes. So how can we tune the
globall illumination? As you remember there are some options in attribute editor
of the light and in MentalRay Globals > mentalrayOptions1. Options in the
light attribute are used to control the amount of photons in the scene and the
brightness of the globall illumination effect, and the options in MentalRay
Globals are used to fine tune the globall illumination, for example how many
photons will be collected and mixed at point x when renderer calculates the
illumination, or how bigg photons will be when they strike the objects in the
scene. This will all be demonstrated later.

To fine tune the globall illumination, we will first change some option in
attribute editor of the light. So, select the light and press CTRL+A. Go to
the Caustic and Globall Illumination options. As you see, the Global Illum Photons
has become available (not faded any more). This option tells renderer how much
GI photons will be shoot in the scene. The more photons you use, the more quality
you get, but it slows down the renderer. Our goal is to make the satisfying-fast
solution for GI, so we will not use too much photons. By looking at the rendered
scene, we see that after we have turn on the GI, the brightness of the scene
is exaggerated. We don't want this because when we turn on the final gather
it will introduce additional brightnes to the scene, and it will be too bright.
To change the impact that GI has on the scene we will increase the exponent
value to value 3.5. To show you how do exponent and energy values affect the
scene, I made a few pictures:

Energy 8000Exponent 2

Energy 8000Exponent 2.5

Energy 8000Exponent 3

Energy 8000Exponent 3.5

Energy 2000
Exponent 2

Energy 4000
Exponent 2

Energy 6000
Exponent 2

Energy 10 000
Exponent 2

As you can see, playing with exponent and enery values produces similiar effects.
So, what solution, from those above, would be the best? The one on the right
top, with Energy 8000 and Exponent 3.5. Is it too dark? Yes, that's true, but
remember that final gather will boost up the brightness of the scene. If we
only want to use the globall illumination, without final gather, then we will
probably go for the Energy 8000 and Exponent 3, or somwhere around these values.
But, for now set the exponent value to 2.8 so we have the better perception
of how GI affects the scene, and later after we are over with GI setup, we will
change it to the 3.5.

You will problably ask, what happens when we increase the Global Illumination
Photons option. Here are the pictures:

Energy 8000
Exponent 3Glob Ill Photons 1000

Energy 8000
Exponent 3Glob Ill Photons 10000

Energy 8000
Exponent 3Glob Ill Photons 100000

Energy 8000
Exponent 3Glob Ill Photons 1000000

The first picture doesn't have enough photons, so it is problably unusable.
The second and third give acceptable results and not too much time has been
spent on photon calculations. Last one delivers the best quality but it takes
too much time to calculate compared to others. Which one will we use? The one
that comes between second and third solution, that means increase the Global
Illumination Photons to somwhere around 50 000. This is what we get:

Now about the noise in the picture. To get rid of the annoying noise go to
the RenderGlobals (MentalRay) > mentalrayOptions1. We will play a little
bit with the Global Illum Accuracy and Global Illum Radius options and see how
does that impact the picture. What does Global Illum Accuracy do? It tells renderer
how much photons will collect from sorounding area when it calculates the globall
illumination intensity at the point that we are shading. Second option tells
renderer how big is the area from which photons are collected. The pictures
can tell more than any words:

Global Illum Accuracy 1
Global Illum Radius 0

Global Illum Accuracy 50
Global Illum Radius 0

Global Illum Accuracy 100
Global Illum Radius 0

Global Illum Accuracy 300
Global Illum Radius 0

Global Illum Accuracy 100Global Illum Radius 0

Global Illum Accuracy 100
Global Illum Radius 0.1

Global Illum Accuracy 100Global Illum Radius 0.2

Global Illum Accuracy 100Global Illum Radius 0.5

From the first picture above you can see that there are a lot of spots in the
scene. These are the photons. If you set Global Illum Accuracy to 1, the intensity
of photons is not mixed together. That's why there are a lot of spots in this
pic. If you increase the Global Illum Accuracy, more photons are collected together
and mixed to get average value. This is the situation in pictures 2 3 and 4
in row 1. You can see that increasing of accuracy over 100 doesn't have too
much effect, so you can leave the accuracy at that value.

As for the radius, if you leave it at 0, the renderer will automatically set
the value that he thinks is the best. This is the case at the first picture
in second row. But that is not acceptable solution in our situation, so we will
have to set it on our own. By increasing the radius level, illumination becomes
more suitable for this scene. The last one, with accuracy 100 and radius 0.5
is probably the best solution. It does'h have too much noise, and every part
of picture is illuminated enough. That's why we will use this settings.

That's the end of globall illumination setup part. Now it's time to invite
the final gather and raise the quality of the illumination. But first, go to
the attribute editor of the spotlight and in globall illumination section increase
the exponent to 3.5.

To turn on the final gather, go to the mentalrayOptions1 in the RenderGlobals
(MentalRay). Open the section Final Gather and turn on the Final Gather option.
There are three important options in this section, the Final Gather Rays, Min
Radius and Max Radius. By default these options have default values of 100 0
0. All three options have a great impact on the rendering speed. FG Rays is
number of ray shots at the scene to esstimate the final gather values. The more
rays you have the more quality you get, but rendering speed drops drasticaly.
The Max and Min radius tell the renderer at which radius from shading point
will FG collect information about sorounding light. If these values are set
to 0 0 then the renderer estimates the value of these two. But, in this case
we will set it manually. Let's see few pictures produced by changing these three
values.

Time 1m 36sFinal Gather Rays 100

Time 2m 17sFinal Gather Rays 200

Time 2m 57sFinal Gather Rays 300

Time 3m 24sFinal Gather Rays 400

Time 1m 27s
Final Gather Rays 100Mix Radius 0.01
Max Radius 1

Time 0m 51s
Final Gather Rays 100Mix Radius 0.05
Max Radius 1

Time 0m 31s
Final Gather Rays 100Mix Radius 0.1
Max Radius 1

Time 0m 21s
Final Gather Rays 100Mix Radius 0.5
Max Radius 1

Time 1m 21s
Final Gather Rays 100
Mix Radius 0.1Max Radius 0.1

Time 0m 41s
Final Gather Rays 100
Mix Radius 0.1Max Radius 0.2

Time 0m 32s
Final Gather Rays 100
Mix Radius 0.1Max Radius 0.5

Time 0m 31s
Final Gather Rays 100
Mix Radius 0.1Max Radius 1

As you can see, the more FG rays renderer shoots at the scene, the more time
it tooks to render, but you get a better quality. And, if Min and Max radius
are increased, it takes less time to render the picture. For the best quality/speed
balance you need to find the most apropriate values for these options. By looking
at the pictures above, you can estimate that Rays could be set to somewhere
around 300. Since we are increasing the FG rays value, the rendering will probably
slow down so we will compensate that with the min and max radius for which we
will choose the values min 0.25 and max 1. Now, if you render the picture, the
result will look like this:

Time 0m 50s
Final Gather Rays 300
Mix Radius 0.2
Max Radius 1

It looks good, and renders relatively fast... we achieved our goal. At the
end, go to the mentalrayOptions1, section Sampling Quality and increase the
Max Samples to 2 and turn on Jitter. Then go to RenderGlobals (Maya Software)
and increase the resolution to 800 600. That's it, press render and let mental
ray do his job. Result:

If you want an aditional realism to the scene you can use the area light instead
of the spot light. That will produce blurry, more realistic shadow. To do this,
select the light, go to his attribute editor and under MentalRay > AreaLight
turn on Area Light. This picture was rendered without area light.

Since we passed step by step the first part of tutorial, this time we will
go faster. Our next scene is a little bit different from the first. It is also
a type of indoor scene. Let's take a peek at the geometry behind it, and light
positions.

The geometry, lights and camera ...

Open GL Shaded scene from the point of Camera

As you can see, there are two lights, and two holes trough which the light
will strike the object in the scene. The geometry is simple, but the light distribution
will be a little bit complicated than in the first scene. Now, about lights.
The one on the left has these characteristics: Color 1 0.708 0.326 Intensity
800 Decay Rate Quadric. The second light on the right: Color 0.486 0.829 1 Intensity
500 Decay Rate Quadric.

Let's go to work and test some global illumination solutions. We will set the
global illumination for both lights. For the lights on the left and right I've
tested a few global illumination setups, and I decided to go for the next ones:

There's still some noise in the right picture from above. To improve the global
illumination effect a little bit go to the RenderGlobals (MentalRay). In the
Quality section click on the box on the right side of the Render Quality options.
In the mentalrayOptions1 change the Global Illum Accuracy to 100 and Global
Illum Radius to 5. This will smooth up the global illumination. If you render,
you'll get this:

Global Illum Accuracy 100
Global Illum Radius 5

It looks good. Now,we'll setup the final gather. As you already learned, the
final gather options are in the RenderGlobals (MentalRay) > mentalrayOptions1,
section Final Gather. If you go with default options, you'll get a result as
in the first picture bellow:

Time 6m 54sFinal Gather Rays 1000
Mix Radius 0
Max Radius 0

Time 1m 33sFinal Gather Rays 100
Mix Radius 0
Max Radius 0

Time 1m 55sFinal Gather Rays 250Mix Radius 0.1Max Radius 5

Time 1m 12sFinal Gather Rays 180Mix Radius 0.3
Max Radius 5

First one is probably the most accurate since there are 1000 rays used there,
but render time is very slow. Second one uses ten times less rays than first
one. That's why there are blotches in the scene. For first two pictures I left
the max and min radius to 0 values so that renderer estimates these values.
For the last two pics I continued to play a little bit with final gather rays,
and I've changed the min and max values. As you can see, in third picture I'have
increased the min radius to smooth the result of final gather, but not enough.
Because of that, there are still some blotches on the walls and boxes. The goal
is to get as near as we can to the illumination quality from the first picture,
but with improved speed. The last one is our choice. It renders fast compared
to others and it has nice smooth illumination over the scene. There are still
some problems in few areas, so if that looks annoying to you, you can continue
to refine the illumination of the scene.

There are 2 main llight sources that light up the objects when it comes to
daylight outdoor scenes, the sky with its blue light and the sun with bright
yellow light. The sun can be simulated with the simple light source, and the
blue sky light can be simulated using one giant sphere around the scene. But
how can that sphere illuminate objects? The trick is in the final gather algorithm,
and the sphere that has the shader that simulates self illumination. How does
that affect the scene, we will see later. In some situations, the use of final
gather will be enough for lighting up the scene. The problem comes with type
of scenes where some parts of scenes are not directly illuminated by sun or
by sky. The flaw of final gather, compared to global illumination solutions
in other renderers is that you can't set the max final gather ray bounces in
the scene. Because of that, we must ask for help from photons used to calculate
global illumination.

So let's go to work. For our scene, we will use one simple temple model. Here
it is:

Open GL shaded model

Before we start to work on the sunllight, we will make two spheres that sorround
the temple model. The inner sphere is invisible to user and serves as illumination
source and second one is visible and doesn't have an effect on the lighting
of the scene. So just create first sphere, and scale it to 40 40 40. Open the
hypershade in one of the window, create lambert shader and assign it to the
sphere you've just created. Go to the attribute editor of that lambert shader
(just double click on it). In attribute editor set the Diffuse to 0, and Incadescence
to skyblue color. I've used R0.269 G0.38 B0.537. Don't choose too bright color
or the sky light will have too bright effect on the scene. You can also change
the name of the Lambert shader to something like Inner_Sphere. After you done
that, go to the viewport, select the sphere and opet attribute editor for it
(ctrl+A). In attribute editor > nurbsSphereShape1 open the Render Stats section
and turn of Cast Shadow, Receive Shadow, Primary Visibility. Visible in Refraction
and Visible in Reflection. That will hide this sphere when you try to render,
but when you turn on final gather renderer will use it as illumination source.

After you have created the first sphere, create another one and scale it to
41 41 41. Also, create another lambert shader and assign it to this sphere.
In the attribute editor of this sphere set the Diffuse and Color values to 0,
and for Incadescence choose the color you want. This is the sphere that will
be visible when rendering the scene but it will not affect the illumination
of the scene. Why did I created the two spheres when I could have done it with
only one? Because if you do it like this, you'll have a greater control on how
much illumination will sky light radiate in to the scene (controled with first
sphere) and on the other hand what the sky will look like when rendered (controled
with second sphere).

If you render the scene at this stage you'll get something like this:

Without FG and GI

So how can our sphere become illumination source? The solution is in using
final gathering. As you have learned before, go to the RenderGlobals(MentalRay)
> Quality section > click on the box near the RenderQuality option. After
mentalrayOptions1 opens, go to the Final Gather section an turn on the Final
Gather. To make the quick preview render set the Final Gather Rays to 100 and
render the scene.

Skylight effect when using Final Gather

Now you see how does the sky affect the scene. This is the end of skylight
setup.

Next step is to create sunlight. To do this create on spotlight. You would
probably ask why didn't I use the directional light since it produces the lighting
similiar to sunlight. I did that because directional light can not be used to
calculate globall illumination, and since we will need the help of GI, we must
use some other best solution and that would be spotlight. Because of that we
must move spotlight far away from the model so that the rays that hit the objects
can be nearly paralel like in distant light.

After you have created the spotlight, move it away from the temple, somwhere
near the edge of the inner sphere (x-18.6 y23.23 z15.58) , and direct the spotlight
to the temple. Then go to the atribute editor of spotlight and set the light
color to bright orange, like R1 G0.87 B0.571, and set intensity to 0.75. Also
change the Cone Angle to 90, and in the Shadow > Raytrace Shadow Attributes
turn on the Use Raytrace Shadow. Now if you render the scene you'll probably
get something like this:

Skylight+Sunlight with Final Gather

I'd say it looks nice. Yes, it needs some final gather tunning, but we will
do that later. Now, remember when I told you that you can't set final gather
ray bounces as in other renderers. The flaw of that is that in picture above,
the area inside the temple is not illuminated and it should be when you look
at few real life examples. That's why we need the help from global illumination.

To setup the global illumination, go to the attribute editor of the spotlight
and in mental ray > Caustics and Global Illumination section turn on Emit
Photons. Also, in Render Globals (MentalRay) > mentalrayOptions1 > Caustics/Global
Illumination turn on Global Illum. After you have done that we'll create one
test render. You'll see that by turning on the global illumination we didn't
make too much difference in indirect lighting at the dark areas of scene. That's
because global illumination is too dark in this case. To make global illumination
more visible, in attribute editor of spotlight decrease the exponent value of
global illumination to 1.6 and render the scene:

Final Gather and Global Illum

This is what we want! Now that we have setup the intensity of the final gather
and global illumination, we will give the final touch to picture by fine tuning
these two methods. Since we have done the step by step tunning in first part
of tutorial this time I'll just tell you what values we will use. First thing
we have to do is increase the Global Illum Photons in light attribute editor
to 50000, and in mentalrayOptions1 we will set the Global Illum Accuracy to
250 and Global Illum Radius to 3. This will slow down rendering a little bit
but it will also increase the quality of illumination. In Final gather options
we will choose 250 for the Final Gather Rays, 0.75 for Min Radius and 8 for
Max Radius.

Since we have used the simple spotlight source to simulate the sun light, it
will produce sharp shadow which is not very realistic. Because of that we will
use mentalray's area light. To do that, in spotlight attribute editor at mentalray
> Area Light section turn on Area Light and choose the Sphere for light Type.
With sampling options you can increase the quality of shadow if you want, but
for now we will leave it as it is. If you switch to the wireframe mode in viewport
you will se that the sphere apeared around the spotlight shape. This sphere
represents the size of area light. Since it is a bit small at this moment, we
will scale it to 2 2 2. That's it. We can render final picture in higher resolution:

Final Picture
Time 4min 5sec at 480x360

from Different Angles

OUTDOOR SCENES USING HDRI

At the end we will explore the world of using HDRI images in rendering. I assume
that you already know what is the HDRI image (short for High Dynamic Range Image).
If you don't know, go to thehttp://www.debevec.org and found out. The final gather method is the key when rendering using HDRI
images. There are no lights in the scene, the only illumination in the scene
comes from sorrounding sphere that has HDRI image mapped on it. Final gather
collects the information from HDRI image and illuminates the scene.

Now we can get to work. Start the HDRShop and open the hdr image you downloaded.
Because the HDR image is an angular map, since and we want to apply it to the
sphere, we will transform it to Latitude/Longitude map. To do this, go to Image
> Panorama > Panoramic Transformations. On the right side, where source
image is set the Format to Light Probe and on the right side set the Format
to Latitude/Longitude and press ok. After some period, the new image will pop
up. Click save as, chose Radiance HDR format and save the image.

Since Maya doesn't support the HDRI image format you will not see it in viewport
when you map it to an object.

Switch to Maya and load the simple scene that I created. If you examine the
scene you will see that I have used the blinn shader for all object. That's
because lambert shader can't be set to reflect the environment, and that's what
we want at this picture since the beauty of HDRI rendering also comes when object
are reflecting the environment. Create the sphere on which we will map HDRI
image. Scale sphere to these values: 20 20 20. After you have done that, create
one lambert shader and assign it to sphere. Go to the attribute editor of Lambert
shader that you just created and make these changes: click on the right box
near Ambient Color, and from 2D Textures section select File. When file menu
opens, click on the folder icon on the right side of Image Name and select the
hdr image that you saved before. Also, in hypershade connect the output color
from file to the color channel of the same Lambert shader. Since the image is
not mapped propertly to the sphere you need to correct this. Go to the place2DTexture
node of the image and set Rotate Frame to 90. Now the image is propertly mapped.

As you already learned before, turn on final gather: RenderGlobals(Mental Ray)
> Quality > RenderQuality press on the box and in Final Gather section
click on Final Gather. To make fast test render, change Final Gather Rays to
100 and render the scene. The image will probably look like this:

Time 0 min 59 sec
Finalgather Rays 100
Min Radius 0
Max Radius 0

Not bad, but since there are some blotches in the scene, we must tune the final
gather a little bit. Because we would only use final gather without global illumination,
100 rays will not be enough, so we will set this to higher value, maybe somwere
around 300-400. I have used the 350 for next example:

Time 1 min 37 sec
Finalgather Rays 350
Min Radius 0
Max Radius 0

Now there are far less blotches than in the example from above, and it render
time is not increased to much. To smooth up the result a little bit we will
increase the FG Rays value to 500 and set the Min Radius to 0.3 and Max Radius
to 8. This is the result:

Time 1 min 22 sec
Finalgather Rays 500
Min Radius 0.3
Max Radius 8

It is better than the last one. We will stick to this solution. Since the image
is a little dark we will increase the illumination of the scene. To do that
go select the file node that is connected to Lambert shader assigned to out
giant sphere and press Ctrl+A to jump to it's attribute editor. Open the Color
Balance section and click on the color box of the Color Gain option. When Color
Choser pop up, set the V to 1.7 and click Accept. This will increase the brightness
of the HDRI image and illumination of the scene. Sometimes the HDRI image used
as illumination source can be to dark. If that happens increase the illumination
like you did it now. This is the final render: