Direct and Indirect Lighting

With a few simple objects in a room, we are going to take a step-by-step approach to setting up photons for Global Illumination and Caustics. We will also look at Final Gathering, and how to incorporate it into the final lighting. Lastly, we will try to balance direct lighting, Global Illumination, Caustics and Final Gathering into the scene in order to achieve the subtle effects of natural lighting.

Basic set-up of the environment

In the scene, “Basic Set-up”, there is a green glass jar with a stopper. Both objects have an Incidence shader applied to their transparency setting of the Phong material, so the edges of the glass jar appears more opaque than its center. The Specular settings of both objects have been increased to obtain the sharp crisp highlight that glass normally has. Also there are reflection values on both objects,

Next to the glass jar is a cube with an orange Phong material applied. It has neither transparency nor reflection values.

These objects are in a room to which a white Lambert material has been applied. The room is small, so it will not take too great a distance for the photons to bounce around to do the work required. However, the room is big enough to have a spotlight and a camera within it.

Use Render Region to interactively preview lighteffect

  1. In the Render toolbar, choose Render >Region >Region Tool, or press q and draw a render region in viewport B (Camera view) around the jar and the cube. You create the render region by dragging the mouse pointer across the viewport. As soon as you release the mouse button, the region is drawn and rendered.
  2. A spotlight lights the green glass jar and the orange cube in a corner of the room. The default light has been deleted, so there is only one light source in the scene.

3) Position the mouse pointer on the right border of the render region and a sliding box appears. Slide the slider one notch above the default setting. The rendered image is now smoother.

Choose Render > Regions > Option, View Render Options property editor opens. Under the Aliasing Page, the Sampling is at Min level –3, Max level 0. If you move the slider on the render region’s boarder back to the default, the Sampling decreases to Min level –3, Max level –1, and the render region image looks more jagged. Adjusting the slider on the render region’s boarder adjusts the sampling of the anti-aliasing. Since we are using the render region for interactive previewing, keep the sampling low for faster previews. The setting only affects the render region and does not affect the final rendering. We are going to adjust the rendering options for the final output later.

You are looking at Raytacing

The image in the render region is lit by only one spotlight. The rendering method (that Mental ray uses) is the raytracing technique. Raytacing plots a view of every pixel in a scene through a virtual camera. When the ray strikes an object, a transmitted ray and a reflected ray are sent out into the environment. Each of these rays follows the same process of striking an object and sending out additional rays. The result is a ray tree of depth, or number of bounces.

After several bounces, you can quickly have many rays going at once. In order not to wait too long for the computer to calculate each ray, you can impose a limit on the depth of the rays before you begin rendering. However, you cannot limit the ray depth too much because in this scene the transparent objects need a certain amount of rays for it to looks properly transparent.

You can count the rays that are needed as follows:

The ray hits the glass (1),

Goes through the thickness of the glass (2),

Goes through the air in the glass (3),

Goes out the other side of the glass (4),

The ray hits the floor (5).

At least 5 refractive rays are needed for the glass object to look transparent.

Adjusting the Raytracing Depth

When you look at the image of the glass jar in the render region, you will see a portion of its wireframe. By default, the render region is set at RGB+Alpha. The wireframe of the jar, which is still showing, is actually the alpha information; which means there is not enough ray depth in that portion of the render image to provide enough RGB information.

4.

4) Choose Render > Regions > Option… View Render Options property editor opens. Under the Optimization page, in the area of the Raytracing Depth, the default setting is:

Reflection…2
Refraction…2

Maximum Ray Depth is 4. The refracted ray is going through the glass and the reflected ray is bouncing off the glass. Therefore change the refraction to 6, and the maximum ray depth to 8. The wireframe of the glass jar in the render region disappears because there is now sufficient ray depth information.

It is important to set enough raytracing depth not just for raytracing, but also for final gathering. Final gathering is a way that Mental ray calculates the look of global illumination without using photons. It is using rays to calculate both direct and indirect lighting. The difference between raytacing and final gathering is that final gathering uses rays cast from the object’s pixels rather than those emanating from the light.

Scene Ambience

5) Select the spotlight and hit Enter. Turn down the light by decreasing the Intensity of the light to 0. The render region looks dim, but you are still able to see the objects. That is because a certain amount of default light is used as fill, (ambient), light in the XSI environment.

6) In the Render toolbar, choose Render > Modify > Ambience. The default settings of RGB are at 0.25, turn the setting down to 0. Now, nothing is visible in the render region!

The reason that we turn down the scene ambience to 0 is that when working with global illumination and caustics, without any light the photon effects will be more visible.

What are Photon effects?

Global Illumination and Caustic are photon effects. The light energy for both the global illumination and caustic are measured in photons. It is based on the principles of energy transfer, which describes how light bounces among parts of an environment. Photon rays emanate from the light source rather than from the camera. When the photons hit an object in the scene, some “stick” and others are reflected and refracted. When the photons stick to the surface they leave energy behind to the receiving objects. If not, these reflected and refracted rays go on to illuminate other surfaces. With each bounce off the transmitting object, the ray gets weaker until it is invisible.

Global Illumination

Global illumination simulates the real-life lighting phenomenon that occurs when light reflects off an object and causes its surroundings to inherit some of the object’s color. This includes both direct and indirect lighting caused by diffuse reflections.

To set-up global illumination:

1) Define which objects act as the global illumination receivers.

2) Define which objects act as the global illumination transmitters.

3) Set the light to emit global illumination photons.

4) Set the Render Options to enable global illumination.

Define the Receiver

Photon receivers are objects that absorb and store photon energy. As the photons travel around the scene, they bounce off the transmitters until they hit the receiver.

In this scene, the room is the only object that will be defined as the photon receiver.

5) Select the room object.

6) Press 8 to open the explorer. In the explorer, click e to isolate the room as a selection.

7) Double clicks the Visibility icon under the room object. The visibility property editor opens. Enable Receivers under the Global Illumination area.

The room object is now a photon receiver.

Creating the Transmitters Group

Photon transmitters are objects that bounce the photon energy. Photons bounce off transmitters and bleed their colors onto the receivers.In this scene, the green glass jar, its top and the orange cube are defined as the photon transmitters.You can define objects as transmitters the same way you define the object as a receiver: by enabling Transmitters under the visibility property of the object. Since we are going to define many objects, it will be more organized to create a group of the global illumination transmitters.

8) Select the orange cube.

9) Click the Group button in the main command area. The Group property editor opens.

10.

10) Change the group’s name to GI_transmitter.

11.


11) With the GI_transmitter group selected, choose Get > Property > Override from the Render toolbar. The Override property editor opens.

12) Click the Add Parameters button to open a pop-up explorer.

13) Under the cube’s Visibility, locate and select the Global Illumination Transmitters property to add it to the override.

14) Click outside the pop-up explorer to accept the selection.

15.

15) The globtrans parameter now appears in the override property editor. Enable it.

16) Select the green glass jar, then press the Shift key and multi-select its top in the explorer. Then drag and drop them into the GI_transmitter group. They are now added to the group and share the same override.

The green glass jar, its top and the orange cube are now the photon transmitters.

Creating the Photon Emitter Light

An object can be both a transmitter and receiver of photons, however only a light can emit photons. A photon emitter is a light that shoots photons into the scene. The photons bounce around, from transmitters to receivers, creating the global illumination effect.

17.

17) Select the spotlight and hit Enter. The Spotlight property editor opens. Rename it Spot_Global Illumination.

18.

18) Under the soft_light page, make sure the Intensity value of the light is still at 0. By turning off the light’s intensity, the photon effect will be more visible.

19.

19) From the Photon property page, enable Global Illumination. The light is now a photon emitter.

20) Keep the spotlight property editor open by clicking the lock icon. We are going to adjust the Energy and the Number of emitted photons later.

Setting the Render Options

After you have set up the emitter, transmitters and receivers, the next step is to set the render region to render Global Illumination to preview the effect.

21.

21) From the Render toolbar, choose Render > Region > Options. The View Render options property editor opens.

22) From the Photon property page, enable Global Illumination.

23) Click the lock icon to keep the Photon Property editor open.

24). Press q to activate the render region tool and draw a region in the camera viewport.

If the required components are all set correctly, the global illumination effect will be rendered. If you see an error message, check if the emitter, transmitter and receivers are set correctly. You must have at least one global illumination emitter, global illumination transmitter and global illumination receiver defined in order for the Global Illumination photon effect to work.

Adjusting the Global Illumination Effect

The global illumination effect may look either too dim or too bright when the parameters that control it are set to their default values.You have to adjust the properties of both the photons coming from the emitters and the render options.

25.

25) From the Photon property page, under the Global Illumination Spotlight property editor, the Photon Energy Intensity controls the brightness of the effect. If the photon effect is too soft, increase the value. If the effect is too strong, lower the value. By adjusting the intensity first, you will get a general idea of where photons are hitting the scene and what areas are most strongly affected by the effect. Energy Intensity values do not affect rendering time.

26) Set and tweak the Number of emitted photons. If there are too few photons hitting the surface of the scene, there will be fuzzy puddles of light. The more photons you throw into the scene, the more refined the effect will be. Keep in mind that the higher this value is, the longer it takes to render.

After adjusting the photon energy intensity and the number of photons, the result will probably still look spotty. You can smooth the final effect by adjusting the Global Illumination Accuracy and Radius values.

27.

27) From the Photon property page of the View Render Options property editor, increase the Accuracy value if the global illumination effect looks grainy. Higher values make the effect smoother but take longer to render. Keep the Accuracy value as low as possible because it can increase rendering time considerably.

28) Radius is measured in SOFTIMAGE units; this parameter defines how far the renderer will search for photons in a scene. Increase the Radius value to give the effect a final smoothing. If the radius is too big, it washes out the surface by including too large a sample value.

Accuracy is used to precomputes the global illumination light effect. Once the photon map is calculated and displayed, you can then zoom, pan, or play back your animation in the render region using the precomputed map of the global illumination effect instead of re-computing the effect each time the render region is refreshed.

Caustic Lighting

Light is distorted when it bounces off surface specularity or passes through refractive objects or volumes. It is the complex light pattern created by the focusing of specular reflections or refraction of light onto a diffuse surface. A commonplace example is the pools of light at the bottom of a swimming pool.

Setting up caustics is identical to setting up global illumination.

To set-up caustic lighting:

1) Define which objects are the caustic receivers.

2) Define which objects are the caustic transmitters.

3) Set the light to emit caustic photons.

4) Set the Render Options to enable caustics.

Define the Receiver

Photons are only stored on diffuse surfaces, so the caustic receiving object must not be black. Purely black object absorb all of the photons, so it won’t create an effect. In this scene, the room is the only object that will be defined as the photon receiver.

5) Select the room object.

6) Press 8 to open the explorer. In the explorer, click e to isolate the room as a selection.

7.

7) Double clicks the Visibility icon under the room object. The visibility property editor opens. Enable Receivers under the Caustics area.

The room object is now a photon receiver for both global illumination and caustics.

Define the Transmitter

Caustics refer to light focused by a curved object through reflection and/or refraction. Photons are only emitted towards any caustic generating objects in the scene. Since the caustic effects is driven by the object’s specularity, the object’s material has to be highly specular, and the sum of reflection and transparency has to be close or larger than 1. In the scene, the green glass jar and its top are the two objects that are able to create the caustic effect. They will become the transmitters.

8.

8) Multi-select the green glass jar and its top.

9) Open either one of the object’s Visibility property editor, and assign them as the Caustics Transmitter.

The glass jar and its top are now photon transmitters for both caustics and global illumination.

Creating the Photon Emitter Light

The same Global Illumination spotlight can be used as the photon emitter for caustic lighting. However, if you use another light for the caustics, you will be able to have more control on each effect.

10) Select the Global Illumination spotlight, press Ctrl+d to duplicate the light. Both lights are located at the same place.

11) Select the new spotlight in the explorer and rename it Spot_Caustics.

12) Under the soft_light page, make sure the Intensity value of the light is still at 0. By turning off the light’s intensity, the photon effect will be more visible.

13.

13) From the Photon property page, enable Caustics and disable Global Illumination. The light is now a photon emitter for caustics.

14) Keep the spotlight property editor opens by clicking the Lock icon.

Setting the Render Options

Now you have set up the emitter, transmitters and receiver, the next step is to set the render region to render Caustics to preview the effect.

  1. From the Render toolbar, choose Render > Region Options. The View Render options property editor opens.
  2. From the Photon property page, enable Caustics and disable Global Illumination.
  3. Click the lock icon to keep the Photon Property editor open.
  4. Press q to activate the render region tool and draw a region in the camera viewport.

If the required components are all set correctly, the caustic effect will be rendered. If you see an error message, check if the emitter, transmitter and receivers are set correctly. You must have at least one Caustic emitter, Caustic transmitter and Caustic receiver defined in order for the Caustic photon effect to work.

Adjusting the Caustics Effect

Caustics effects depend heavily on the specularity of the transmitting objects, their surface bumpiness and their refractive index. They also depend on the photon energy intensity and number of emitted photons.

  1. Select the Spot_Caustics spotlight and open its property editor.
  2. From the Spot property editor, go to the Photon property page in the Light parameter set.
  3. Increase or decrease the Energy Intensity value until the caustic effect’s “hotspots” become visible, and not too dull nor too overly bright.

The Photon Energy Intensity contributes to the brightness of the caustic effects. It determines the intensity of the refracted light that hits the receiving objects. By adjusting the intensity first, you will be able to see where photons are hitting the scene and where the caustics “hotspots” appear.

4. If the effect appears blotchy, increase the Number of Emitted Photons. The more photons you shoot at the scene, the more accurate your caustics are. However, the higher the number of photons, the longer the render time.

After adjusting the photon energy intensity and the number of photons, most likely the effect’s “hotspots” are too sharply defined. You can soften them by adjusting the Caustics Accuracy and Radius values.

5. From the View Render Options property editor, go to the Photon property page. Increase the Caustics Accuracy value to soften the effect.


6. Increase the Radius value to blur the effect a little.

After you set the values that give the caustic effect the look that you want, also enable the global illumination effect. This will give you some idea how the photon effects affect the scene.

7. You already have a render region drawn. From the View Render Options property editor, enable Global Illumination and Caustics.

You can select the Global Illumination spotlight and increase the intensity value under the soft-light page, so as to put some direct illumination back into the scene. Rather than using actual lights, you are going to use Final Gathering to fill the scene with light in the next step.

Final Gathering

Final Gathering allows you to use any object to emit light, simulating the photographic technique of using white boards as “reflectors” to bounce light into a scene. Final Gathering is a way of calculating global illumination without using photon energy. Unlike global illumination, Final Gathering only computes single bounces of indirect light on diffuse surfaces. The overall effect is that every object in the scene becomes a “light source”. It gives you better details in areas of the scene where there are many edges, corners, and sharp light variations.

Lighting a Scene Without Using Lights

Because Final Gathering uses objects to light the scene, you don’t need any active lights. However, you do need to have a single light in the scene. Even with zero intensity, this “non-light” is needed to enable the calculation of Final Gathering at render time.

  1. Select the Global Illumination spotlight and press Enter. In the Soft Light shader’s property editor, bring down the intensity value of the light to 0. Also make sure the Spot_Caustics spotlight intensity is also at 0. This allows you to see the Final Gathering effect by itself.
  2. From the Render toolbar, choose Render > Region > Option. The View Render Options property editor opens.
  3. From the Photon parameter set, enable Final Gathering. Disable Global Illumination and Caustics.
  4. Keep the View Render Options property editor open by clicking the Lock icon.
  5. If you draw a render region now, you will not see much because there is no light in the scene.
  6. In the Render toolbar, choose Render > Modify > Ambience. The default settings of RGB are at 0. Turn the setting up to 0.01. Since final gathering is using bounce light, it is better to have some default ambience light in the scence.

Setting Up the Reflector

7. Select the room object, press u to ray-cast and select the polygon that is behind the spotlight.

8.Press Ctrl+d to duplicate the polygon.

9.With the duplicated selected, choose Get > Material > Constant from the main menu. The Constant shader’s property editor opens.

10. Set the constant shader’s color to white by holding down the Ctrl key and dragging one of the color sliders all the way to 1. This will set all the color values to 1.

11. If you already have a render region drawn, the scene will be flooded with light as Final Gathering is bouncing light off the constant shaded wall, which now is acting as a bounce light source.

12. As the duplicated polygon of the wall is still selected, scale it down locally on the XZ axis. As you scale the constant shaded polygon down, the light will be less intense. Scale this reflector polygon down until you have enough light in the scene.

Adjusting the Final Gathering

13.

13. As the Photon page in the View Render Options property editor is still open, increase the Accuracy value to 100 under the Final Gathering parameter set. Notice the Final Gathering effect becomes less grainy. You may want to increase the value to 200 for the final rendering.

14. Click the Automatic Compute button to automatically calculate the appropriate Min Radius and Max Radius values.

The Accuracy is the number of rays sent from the surface point to be evaluated towards the light source, whereas the Radius is the size of the area where they originate. Once the rays hit the light source, mental ray calculates the average color and applies it to the surface point.

A Cloud Texture on the Reflector

  1. As the duplicated polygon is still selected, in the Render toolbar, choose Get > Texture > Image.The Image property editor opens.
  2. In the Texture page, under the Image area, hit New >New from Files and select cloud02_pic image.
  3. Apply Planar YZ as the Texture Projection.

Now that the image of the cloud is projected on the reflector, Final Gathering is actually bouncing the blue colors of the image as light onto the objects in the scene.

Global Illumination, Caustics, Final Gathering

  1. From the Photon property page under the View Render Options property editor, enable Global Illumination, Caustics, and Final Gathering.

2. Now you can add small amounts of direct lighting to the scene in order to create shadows. Select the Global Illumination spotlight and increase the Intensity value to 0.3 under Colors. Also enable Shadows and set the Umbra value to 0 under the Soft Light property page.

3. Set a very low value (0.01) to the Global Ambience Setting, in Render toolbar, Modify > Ambience, which will increase the bouncing of colors and better illuminate the scene.

4. The lighting created by final gathering and direct illumination are added together. As all the effects are added together, the scene becomes too bright Adjust the size of the polygon reflector to bring the brightness back down to a more pleasing level. Use the render region to view the light effect.

Now that you have raytracing and photon lighting all working in the scene, there may be some objects that are still too bright or too dark. The orange cube looks a little dull in the scene.

Adjusting Objects’ Radiance

Another way to fine-tune the photon effects is to adjust the Radiance of the photon receiver objects. Radiance controls the strength of the photon effect on the object’s surface. This is a useful technique for brightening or darkening photon lighting in specific areas of the scene in Global Illumination. This also is helpful to fine-tune the caustics effect for individual objects.

  1. Select the orange cube.
  2. From the Render toolbar, choose Modify > Shader. The cube’s Phong shader property editor opens.
  3. From the Indirect Illumination property page, increase the Radiance color value to 1.3. Notice now the orange cube becomes brighter.

Rendering a Still Image

When you are satisfied with the look of the scene in the render region, you are ready to render out a final image.

  1. Choose Render > Render > Options from the Render toolbar. The Render Options Property editor opens.
  2. Click the Copy Options from the Region button to copy the Final Gathering Options that you set in the render region.
  3. From the Output property page, make sure that the scene is being rendered to a valid path and set both the Start and End frames to 1. You will get one still image.
  4. From the Format property page, under Image Resolution, make sure the Pixel Ratio is set to 1. If not, the image will look squashed.
  5. From the Aliasing property page, increase the Sampling to Min Level to 0, Max Level to 3. This will give you a smoother anti-aliasing result.
  6. From the Active Effects property page, under Photons, make sure Caustics, Global Illumination, and Final Gathering are all enabled.
  7. From Optimization property page, under the Render Mode section, make sure Raytracing is on. When rendering with Final Gathering, the Raytracing option must be on. Under Raytracing Depth section, make sure there is enough Ray Depth for the rays to go through the glass objects. Set the Reflection to 2, Refraction to 6, and the Maximum Ray Depth to 8.
  8. Under Face section, make sure the Mode is set to Both. Since the camera is inside the room, the normals of the room object are actually flipped (inside-out). You must enable both sides of the objects for the rendering to look right.

From Photon property page, you have copied the settings from the render region. Remember to increase the Accuracy for Final Gathering to 200.

  1. Click the Render button.
  2. 2. To see your final rendered image, open the flipbook.

    3.From the bottom of the Render toolbar’s main menu, choose Flipbook to open the Open Images property editor. Click on the button on the far right under File name, Browse for Images property editor open. From there, look for the file of the image that you just rendered. Click O.K. to open the image.

Conclusion

At the bottom of this page, there is a link to open the slide show. Click the link to open a new page. Use the Previous and Next Arrows to flip through the images, one frame at a time.

You will see the progress of turning a scene’s lighting from raytracing to photon effects, which include Global Illumination and Caustics. Finally, we used Final Gathering as the fill light source and balanced the indirect lighting with direct lighting.

Knowledge of these lighting techniques will help you to light a scene. However, good lighting is an art and takes more than just knowing how to use the tools that XSI provide.

click to see more

Click here to view the slide show. (10.9MB)