MR Rendering an interior scene with artificial lighting (GI and FG)
- 1 Introduction
- 2 Preparation
- 3 Setting up the first light
- 4 Exposure Control
- 5 First test render
- 6 Render Settings - Global Illumination
- 7 Tuning Light and Render Settings for better quality
- 8 Adding more lights
- 9 Enabling Final Gathering
- 10 Going up to Production Quality for the final renderings
- 11 Common problems
- 12 Advanced topics
This tutorial assumes you're using Maya 2008. It's strongly recommended to use 2008 instead of 8.5 as a lot of bugs and annoyances for Mental Ray have been fixed in 2008 (which uses the new Mental Ray 3.6 engine).
We assume you have a scene with your geometry. Please make sure you remove all lights before you start to make your light setup. It's recommended to start with the default Render Settings.
It's of paramount importance that the (interior) model is enclosed properly. If you omit large parts of the walls or ceiling (e.g because they are not in sight of the camera), the light will not distribute correctly throughout your model. Of course normal windows and other openings are allowed.
Making a good Global Illumination setup at your first attempt can be a fairly complex task by itself. So it's important to make sure you can keep overview and keep things as simple as possible. That means: eliminating unnecessary variables and unknowns. Start with a simple model (will also make sure it renders quickly) and start with one light.
When you've got a working setup with one light in a simple model, you can start to expand and improve your scene: adding more lights and geometry.
- Setup a single light
- Setup Global Illumination for the lights and in the Render Settings
- Setup mental rays Physical Light shader and Exposure control
- Fine-tuning the settings
- Setup any other lights (if required)
- Some more fine-tuning
- Adjusting the settings to go to production quality
Load your scene and open the Render Settings window. Set Render Using to mental ray.
Make sure the mental ray plug-in is already loaded! Open
In the Common tab under the Image Size section change Presets to 320x240 for fast preview rendering.
In the Quality tab under the Sampling section change the Sampling Mode to Legacy Sampling Mode to change the Anti-Aliasing Quality of the render. Make sure the Legacy Sampling Mode is set to Adaptive Sampling and set the Max Sample Level to 1 for medium image quality.
Under Sample Options you may choose to set Filter to Triangle.
Open the Indirect Lighting tab and under the Global Illumination section check Global Illumination. The settings will be covered later.
Setting up the first light
Create a 'normal' Maya light, typically an Area Light, Point Light or Spot Light. Position it in your scene. Make sure you make the required settings:
Open the Attribute Editor for the light.
In the Shadows section make sure Use Ray Trace Shadows is checked:
Scroll down to the mental ray section, enable Emit Photons. Set the Photon intensity to 2000 for now;
Solution: Use the slider to set the value. This bug has been fixed in Maya 2012.
Increase the default number of photons to 50000:
When creating an arealight, make sure you check Use Light Shape in the mental ray section! This will convert the light to a Mental Ray arealight which produces more accurate results.
Direct and Indirect Light
Mental Ray splits lighting in two basic classes: direct- and indirect illumination. The direct light is typically calculated using raytracing and works pretty much like the basic software rendering. Indirect light is calculated using either Global Illumination (Photons) or Final Gather or both.
You set the intensity for direct illumination separately from the intensity that is used by Global Illumination. Getting both tuned to properly match is quite tricky and is more complex than you might have thought. To get the direct light to behave more realistic and to get it to match the indirect light, we're going to 'upgrade' the light, using a special Mental Ray shader for the light: the Mental Ray Physical Light Shader.
Physical Light shader
So to get the direct light to (more or less) match with the indirect light from the light and to get physically accurate result, we're going to upgrade the light with the MR Physical Light Shader.
In the mental ray section of the Attribute Editor of your light, scroll down to the Custom shaders section
Click the checker box next to the Light Shader field. The following window will pop-up:
Scroll down to the MentalRay Lights section and select the Physical Light node.
You can set the intensity for direct light emitted by this light, using the color value of the Physical Light node that you've just connected. Click the color sample field:
The intensity is set using the Value field. We start off by setting it to the same value as the Photon Intensity divided by PI, so: 2000 / 3.14 = 640, which is physically accurate.
If you're using a recent version of Maya with the new color-picker, make sure to set it to HSV-mode, as shown in the image above.
Alternatively you could use this method as a workaround: connect a mib_blackbody node to the color value of the physical_light. You can control the light color by setting the color temperature and set the intensity value to any value required.
We are going to need some fine-grain control over the light balance of the image as the light range produced by Mental Ray is far too wide to 'fit' within a traditional image format. We're going to use the mia_exposure_simple node to do what is called tone mapping. It is also crucial to get correct color interpretations for the lighting of your scene.
The Mental Ray mia_exposure node is connected to the camera, so you need to set it up for each camera you're going to use for rendering (don't forget the persp camera when you're making test renders from persp).
Open the Hypershade and go to the Cameras tab:
Drag each of the cameras you want to use for rendering to the Work Area below using you middle mouse button (MMB).
Now we're going to create the mia_exposure_simple node. This is a Mental Ray Node, so we need to switch the inventory at the left to Create Mental Ray Nodes:
Scroll to the Lenses section and open it. Click the mia_exposure_simple icon. A new node will be created and displayed in your Work Area:
Now it's time to connect it to our cameras. MMB drag the mia_exposure node onto the camera icon and release your mouse button. A pop-up will appear asking you what type of connection should be created. Choose default in this case.
That's it. The mia_exposure is now connected to your camera and can be used to adjust the rendered image. We'll keep the default settings for now. We will adjust them shortly.
You can repeat this process for other cameras. In most cases a single mia_exposure_control node will suffice, just connecting it to multiple cameras. In other cases you may want to create multiple mia_exposure nodes as well, allowing you to fine-tune per camera.
If you want to create an existing mia_exposure_simple node to one of your cameras, but your Work Area is empty, you can find existing mia_exposure_simple nodes in the Utilities tab. You can MMB-drag them into your Work Area to connect them.
Important note when using file textures
When you are using file textures in your model, it's very important to make sure you use the proper gamma settings when rendering using Mental Ray and MIA Exposure control. If you don't change the default settings, your textures will be very bleach ('washed out'). The solution is described here: Exposure control and File textures.
First test render
Now you're set to make your first test render.
There are three basic options:
- Your render is way too dark
- Your render is way too bright
- Your render is about right; the highlights are may be too bright, but the rest is about right.
The resulting image will probably be very coarse and filled with spots. That's something we can solve later on, we're now concerned with basic lighting.
The first test render is too dark
Increase the intensity of the light until it's about right. Make sure you change both the Photon intensity and the intensity of the direct light in the Physical Light Color value.
Once the illumination in the darker areas of your render are about right, the highlights are now probably over-exposed. You can continue in the The highlights are too bright section.
The first test render is too bright
Decrease the intensity of the light until it's about right. Make sure you change both the Photon intensity and the intensity of the direct light in the Physical Light Color value.
Once the illumination in the darker areas of your render is about right, the highlights are probably still over-exposed. You can continue in the The highlights are too bright section.
Fine-tuning the image highlights
You're about where you want to be, but the highlights are too bright. This is very common, as computer screens cannot handle the huge contrast range the human eye (and brain) can handle. So you need to compromise and tweak a little. We're going to use the Mental Ray Exposure Control to do this. You can find your mia_exposure_simple node(s) in the 'Utilities' tab of the Hypershade. Double-click it to open the setting in the Attribute Editor.
Change the Gain only when needed (if the overall brightness is still a bit too high or low). Consider the darker areas of your image and determine if your image is too bright or too dark there.
If that's all about right, use the Compression to compress the brighter areas of your image so they are no longer over-exposed. Compression values of up to 50 can be needed. If you need higher compression values, make sure the intensity of you light is not too high after all.
The left side shows our previous render, the right side shows the render where we've adjusted the compression of the mia_exposure_simple to darken the highlights just a little bit.
Finding the right settings is a process of adjusting one setting and making a new test render. Continue this process until your satisfied with the results.
Render Settings - Global Illumination
We need to tweak some Global Illumination Settings to get better results. As you'll notice the may seem to get worse first...
Open the Render Settings and go to the Caustics and Global Illumination section in the Mental Ray tab.
- Determines the number of photons Mental Ray will consider when determining the illumination of a given point.
At the moment our light is emitting 50000 photons, so when MR needs to consider 500 (default accuracy), it uses 1% of the total number of photons to calculate the illumination for a single pixel (sample). This may produce strange results in corners and other areas with high contrast differences (for instance near lighting fixtures).
A rule of thumb you can use, is that the accuracy should never be more that 1/10000th to 1/1000th of the total number of photons emitted by your lights. So with 50000 photons, your accuracy should be between 5 - 50. Start with a value of 20.
In the Global Illumination Options sub-section, you'll find the photon Radius.
- The area of influence of a single photon. It's effect gets spread and will help to smooth out the results.
When radius is set to 0, Mental Ray will automatically determine a radius. This is fine in most cases.
The resulting render may appear to be worse, but we'll fix that in a bit. In the end the quality and accuracy will be better.
Tuning Light and Render Settings for better quality
Your render probably still has strange looking spots in it. This is due to limited accuracy in the Global Illumination calculations. To get better results, you need to increase the number of photons. Open the Attribute Editor of you light and increase the number of global illumination photons.
For medium-sized renderings a total number of photons (add up all photon-emitting lights) for the final image is typically between 200000 and 1500000. You could increase the number of photons straight away, but rendering could get quite slow. It's recommended to use intermediate settings for now: increase the number of photons emitted by your light to 100000 - 200000.
In this tutorial we're going to finish by enabling Final Gathering. If you plan to use Final Gathering, the result from rendering without FG doesn't need to be perfectly smooth. Final Gathering will take care of that.
Adding more lights
If you want your scene to have more than one light source, now is the time to add them.
We want a little more light in the back, so we've created a light there. We've used an arealight, but in this case the Type (Attributes > Mental ray > Area Light) is set to disc. Don't forget to configure it properly and to add a Physical Light shader.
Be careful though: having a large number of photon-emitting lights can be tricky. In many cases there are better alternatives. See the Advanced section in this page for details.
If the overall light of the scene was ok with the one light you created, you probably need to lower the intensity (photon intensity and direct light intensity) of your light when you add more lights. Keeping the total 'intensity' of all the lights the same value, seems to work pretty well. So if you lit your scene with one light with an intensity of 2000, two lights with an intensity of 1000, or four with 500 should be a pretty good starting point.
We've added some more lights (in this case also disc-shaped arealights) and tweaked the intensity of each light:
Enabling Final Gathering
When all the basic settings are ok, you can enable Final Gathering to improve the quality of your rendering. When combining Final Gathering with Global Illumination, you can keep the settings of FG quite low.
Open the Render Settings and go to the Final Gathering section in the Mental Ray tab. enable Final Gathering.
We're not going to discuss the properties in depth here. Refer to Rendering Mental Ray: Final Gather for more information on each of the settings. Keep in mind that the values given there are for interior rendering with only Final Gathering (no Global Illumination). This tutorial covers specific values when combining Global Illumination with Final Gathering.
- Start with a value of 20. Only increase if the results aren't smooth enough and make test-renderings to see if increasing it has the desired effect.
- Point Density
- Start with a value of 0.6
- Point Interpolation
- Start with a value of 10.
Our rendering with Final Gathering enabled looks like this:
Lights and reflective surfaces may produce bright spots in Final Gathering (they disappear when you disable Final Gathering).
If you see any of these bright spots in your rendering: Open the Final Gathering Options section in the Render Settings. Set Filter to 1.
On the left our previous rendering without FG filter, rendering with FG filter set to 1 on the right.
In some cases it may cause the scene to become very dark; in that case you can only solve the bright spots by increasing your Accuracy, Point Density (0.8 - 1.4) and optionally Point Interpolation.
Going up to Production Quality for the final renderings
For your final rendering, you're probably going to increase the image size. You need to adjust the other render settings as well. It takes some practice and experience to get a feeling for the settings. It's difficult to give general values that apply for every rendering. This sections gives some pointers, but won't apply exactly for each and every rendering.
Increase the total number of photons emitted by the lights in your scene. It's tricky to generalize what values you need, but to give you some pointers: use 200k - 1 million for medium sized renderings, 1 million - 5 million for renderings > 1280 x 1024 pixels. Large renderings and scenes with complex lighting situations may require > 5 million photons.
Increase the number of photons in steps and make test renderings (temporarily disable Final Gather to see the effects) to see if you need to increase the values further.
Set the Global Illumination Accuracy to about 1/10000th - 1/1000th of the total number of photons, so start with about 200 when using 1 million photons. You can then increase it up to 500 - 1000 if needed.
- Increase to about 40. Only increase further if the results aren't smooth enough and make test-renderings to see if increasing it has the desired effect.
- Point Density
- Increase to 0.8 when your rendering is larger than 1024x768. Increase to 1.0 for renderings larger than 1600x1200. You shouldn't need to increase it above 1.
- Point Interpolation
- Increase to 20 and further if you've also increased your Accuracy further.
Render Settings for better image quality are covered in: Rendering Mental Ray: Anti Aliasing Settings.
Our final rendering compared to the previous version:
The light itself is not visible
In the Attribute Editor of the arealight, open the Mental Ray section, then open the Area Light subsection.
Make sure Use light shape is enabled and enable Visible.
Obviously this option is only available for arealights.
Light 'leaks', causing incorrect rendering of the scene as shown in de lefts side of the image below.
Cause: This is caused by a GI Accuracy setting that is too high for the number of photons (or a too small number of photons).
Solution: Make sure the accuracy is between 1/10000th to 1/1000th of the total number of photons in your scene.
Graininess near arealights
Cause: the number of samples Mental Ray uses to calculate the light for this arealight is too low, causing aberrations.
Solution: In the Attribute Editor of the arealight(s), open the Mental Ray section, then open the Area Light subsection. Increase the High Samples for any light that produces grainy direct light on surfaces. In most cases a value between 32 and 64 should suffice, but it may be necessary to increase to up to 256 in rare cases.
The left side of the image below shows a rendering with a low sampling setting, the right side shows an increased sampling setting.
A test you could do to determine if it is not another artifact: The graininess stays when you render without Global Illumination and Final Gather, excluding problems with FG or GI settings.
Keep the number of lights as low as possible
It's not necessary to create a photon-emitting light for each and every light fixture that is in your scene. Alternatives are to skip photons on small or distant lights or to use the Additional Color (Incandescence for Maya Lambert and Blinn) value of a material to 'generate' light from it, thereby mimicking a light source.