To achieve professional-quality, realistic renders in the Autodesk® Maya® program, you need to master the mental ray® render plug-in that comes with Maya. mental ray is a complex rendering system that is incorporated through the Maya interface. Learning how to use it properly and efficiently takes time, study, and practice. Chapter 8, “mental ray Shading Techniques,” Chapter 9, “Texture Mapping,” and Chapter 11, “Rendering for Compositing,” discuss various aspects of working with mental ray.
This chapter is concerned with using mental ray lighting tools and techniques to create realistic renders. Options available within mental ray allow you to achieve a wide variety of effects. You won’t need to use all of them in every case, but a good understanding of what is available will help you make better decisions when approaching a lighting problem in a scene.
In this chapter, you will learn to
You can create two types of shadows in mental ray: cast shadows and ambient occlusion. Several methods are available for creating them. Any combination of cast shadows and ambient occlusion can be used in a mental ray scene:
Cast Shadows Cast shadows are created when an object blocks the rays of light coming from a light source. Cast shadows are the most familiar type of shadow. They are a good indication of the type, location, and orientation of the light source casting the shadow.
Ambient Occlusion Ambient occlusion occurs when indirect light rays are prevented from reaching a surface. Ambient occlusion is a soft and subtle type of shadowing. It’s usually found in the cracks and crevices of 3D objects and scenes.
In this section, you’ll create and tune cast shadows using lights in mental ray. Ambient occlusion is discussed later in the chapter, in the sections “Indirect Lighting: Global Illumination” and “Indirect Illumination: Final Gathering,” as well as in Chapter 11, “Rendering for Compositing.”
A light source in a Maya scene casts either raytrace or depth map shadows. When you create a light in Maya, its shadows are set to raytrace by default. You can use depth map and raytrace shadows together in the same scene, but each light can cast only one or the other type of cast shadow.
When you create a shadow-casting light in a Maya scene, you can preview the position of the shadow in the viewport window.
This scene shows a bicycle. The shaders used for the vehicle are simple standard Maya Blinn materials. When you’re setting up lights for a scene, it’s usually a good idea to use simple shaders as you work. This makes test rendering faster, and it also keeps the focus on how the lighting will work within the composition. Later, as you refine the lighting of the scene, you can add more complex shaders and textures.
bicycle_v01.ma
scene from the chapter7chapter7scenes
folder at the book’s web page (www.sybex.com/go/masteringmaya2016
).Create a spot light by choosing Create ➣ Lights ➣ Spot Light.
To position the spot light, use the Move and Rotate tools. You can also look through the light as if it were a camera, which is often a faster and easier way to place the light in the scene.
You won’t see any shadows until you activate shadows for the lights in the scene.
bicycle_v02.ma
.To see a version of the scene, open the bicycle_v02.ma
file from the chapter7scenes
folder at the book’s web page.
Depth map shadows (also known as shadow maps) are created from data stored in a file that is generated at render time. The file stores information about the distance between the shadow-casting light and the objects in the scene from the light’s point of view. Depth map shadows usually take less time to render than raytrace shadows and produce excellent results in many situations.
When using mental ray, you can choose to use the native depth map shadows in Maya or mental ray’s own depth map format. In this exercise, you will compare the results produced using various depth map shadow settings.
Open the streetCorner_v01.ma
scene from the chapter7scenes
folder at the book’s web page. This scene shows a section of a city street corner.
All of the objects in the scene have been assigned to lambert1. Using a simple Lambert shader speeds up the render and allows you to focus on how the shadows look on the surfaces without the distraction of reflections and specular highlights.
Open the Render Settings window (Windows ➣ Rendering Editors ➣ Render Settings), and make sure that mental ray is the selected option in the Render Using menu.
Switch to the Quality tab; then go to the menu bar at the top of the Render Settings window and choose Presets ➣ Load Preset to load the Production preset (see Figure 7.3).
You’ll see the render appear in the window after a few seconds. By default, the quality of depth map shadows is pretty poor. With some tweaking, you can greatly improve the look of the shadows.
The shadow is generated using a special depth file, which is an image. As such, the image has a resolution that is controlled by the Resolution slider. When the resolution is low, you can see a grainy quality in the shadows, as shown in Figure 7.4.
To improve the look of the shadow, you can balance the resolution with the filter size:
Using a low resolution (such as 512) and a high filter size (such as 4), as shown on the right side of Figure 7.5, creates soft shadows—the kind you might expect on an overcast day. One weakness in using a high filter size is that the blurring is applied to the entire shadow. In reality, shadows become gradually softer as the distance increases between the cast shadow and the shadow-casting object.
The Use Mid Dist feature is enabled by default. This option corrects banding artifacts that can occur on curved and angled surfaces. The Mid Dist Map is a second image file that records the points midway between the first and second surfaces encountered by the light. The second image is used to modify the depth information of the original depth map file to help eliminate banding artifacts. This image is created internally, unless you turn on Disk Based Dmaps.
The Bias slider provides a similar function for eliminating artifacts. The slider adjusts the depth information in the depth map file. Increasing the bias pushes surface points closer to the shadow-casting light to help eliminate artifacts. This transformation of surface points occurs in the depth map file, not in the actual geometry of the scene.
If you are encountering artifacts on the surface of objects and Use Mid Dist is enabled, you can use the Bias slider to reduce the artifacts. Change the bias values in small increments as you create test renders. If the bias is too high, you’ll see a gap between the shadow-casting object and the shadow.
The Use Auto Focus setting automatically adjusts the objects within the field of the light’s viewable area to the maximum size of the shadow map resolution. Thus if from the light’s point of view an object is surrounded by empty space, the light will zoom into the object in the depth map image. This helps optimize the use of the pixels within the depth map image so that none are wasted. It’s usually a good idea to leave this setting enabled when using spot lights; however, you may encounter a different situation with other types of lights.
Now try this:
The shadow is very blocky when the light is switched to directional (see Figure 7.6).
When you use spot lights, the size of the viewable area from the light’s point of view is restricted by the cone angle and the distance between the light and the subject. When you use directional lights, the size of the viewable area is always adjusted to fit all of the objects in the scene. This is because directional lights do not factor in their position in the scene when calculating shadows, only their orientation.
In this situation, you can use the new Shadow Map Camera feature described in the next section, “mental ray Shadow Map Overrides.”
The mental ray overrides offer settings that are similar to those for the standard Maya shadow maps. In addition to the Resolution setting, there are Samples and Softness settings. The Softness setting is similar to the Filter Size attribute for Maya shadow maps. You can click the Take Settings From Maya button to load the settings created for standard Maya shadow maps automatically into the mental ray attributes:
streetCorner_v02.ma
scene from the chapter7scenes
folder at the book’s web page. In the Render Settings window, make sure that Render Using is set to mental ray. Switch to the Quality tab, and make sure that the Production preset is loaded.Set Samples to 64, and create another test render. The graininess is reduced without significantly impacting the render time. Store the image in the render view.
Detail shadow maps are a more advanced type of shadow map that stores additional information about the surface properties of shadow-casting objects. This information includes surface properties such as transparency. The render takes longer, but the shadows are improved.
streetCorner_v03.ma
.Rendering with Detail Shadow Maps enabled will take more time, but the quality is improved. Detail shadow maps are more sensitive to changes in the Softness setting in the Shadow Map Overrides rollout. There are also additional Samples and Accuracy settings in the Detail Shadow Maps rollout that can be used to tune the quality of the maps. You can use the Shadow Map File Name field to set a name for saved shadow maps and then reuse the shadow maps to improve render time as long as the lights or shadow-casting objects are not animated. The settings for saving shadow maps are found in the Shadows section of the Render Settings window on the Quality tab.
The bottom line is that when using depth map shadows, you can use a number of options to improve the quality of the shadows. The goal is to strike a balance between render time and quality.
To see a version of the scene up to this point, open the streetCorner_v03.ma
scene from the chapter7scenes
folder at the book’s web page.
Raytrace shadows are created by tracing the path of light rays from the light source to the rendering camera. Using raytrace shadows produces more accurate results, but it often takes a little more time and processor power to calculate. This has become less of an issue in recent years because of improvements in computer processor speeds, and it is now the default setting in Maya.
These are some advantages raytrace shadows have over shadow maps:
To activate raytrace shadows, make sure to enable Use Ray Trace Shadows on each light. When you choose the Production quality preset for mental ray, Raytracing is enabled by default (see Figure 7.9).
Raytrace shadows are typically very crisp when enabled. To add softness to the shadow, increase the Shadow Rays and Light Radius values in the Raytrace Shadow Attributes section. In Figure 7.10, you can see how increasing the Light Radius and Shadow Rays values adds softness to the shadow. The render in the left image uses a Light Radius of 0 and a Shadow Rays setting of 1. The render in the right image has a Light Radius of 3, and Shadow Rays is set to 20. Notice that the blurring on the shadow increases as the distance between the shadow and the shadow-casting object increases.
The Light Radius setting is giving the light a random position within the given radius for each pixel of shadow. Since the position of directional lights is of no consequence, their shadows are softened with a channel called Light Angle, which randomizes the angle of the light.
Increase the Ray Depth Limit value when you need a shadow to be visible in reflections. Each level of the Ray Depth Limit corresponds to the number of raytrace bounces the light will calculate before the shadow is no longer visible (see Figure 7.11).
In reality, when a ray of light hits an opaque surface, it is either absorbed or reflected (or a little of both) by the surface. If the light ray is reflected, it reenters the environment and continues to bounce off reflected surfaces until it is absorbed by another surface. Objects illuminated by reflected light are thus lit indirectly.
As light rays bounce around in an environment, fewer of them reach the parts that are hidden in corners, cracks, and crevices. The lack of light in these areas creates a type of shadowing known as ambient occlusion. You can see ambient occlusion shadowing in the crevices of the photograph in Figure 7.12.
mental ray has three methods for simulating indirect lighting and ambient occlusion shadowing: the Global Illumination, Final Gathering, and Ambient Occlusion shaders. You can use them separately or together depending on what you are trying to achieve in your render.
In this section, you’ll get some hands-on experience working with global illumination; the next section covers Final Gathering. Using ambient occlusion will be discussed along with ambient occlusion render passes in Chapter 11.
Global illumination simulates photons of light bouncing off geometry in a Maya scene. Autodesk Maya 2016 greatly simplifies rendering global illumination. It is no longer necessary to control the photons of individual lights. Photon emission happens automatically.
In this exercise, you’ll use global illumination to light a hospital room. There are no textures or colors in the scene, so you can focus specifically on how global illumination reacts with surfaces.
hospitalRoom_v01.ma
scene from the chapter7scenes
folder at the book’s web page. In the scene, a camera named renderCam has already been created and positioned.Using a directional light is a perfectly reasonable choice for creating the look of light coming through a window. The light rays cast by a directional light are parallel, which simulates the way light from a distant source, such as the sun, behaves (see Figure 7.13).
The photon-casting properties of a light are completely separate and unrelated to the light’s intensity. In practice, it’s often a good idea to use one light to cast direct light as well as to create cast shadows and another light to create the indirect light.
If you are in a situation where the same light is casting direct and indirect illumination, raising the intensity can cause the area around the light to become overexposed. In this situation, you may want to use two lights as follows:
Create a test render of the scene, and store the image in the Render View window.
The render is a big improvement. The default settings still require some tuning, but the scene is now illuminated with bounced light.
hospitalRoom_v02.ma
.To see a version of the scene up to this point, open the hospitalRoom_v02.ma
scene from the chapter7scenes
folder at the book’s web page.
When light is reflected from a colored surface, the color of that surface affects the color of the light reflecting from it. mental ray’s global illumination simulates this property.
hospitalRoom_v03.ma
scene from the chapter7scenes
folder at the book’s web page. This scene has a bucket added close to where the sunlight strikes the floor and the wall.Color bleeding is a part of global illumination and occurs automatically when colored objects are near the photon-emitting lights.
Final Gathering is another method for calculating indirect lighting. It can be used on its own or in conjunction with global illumination. Final Gathering uses irradiance sampling and ambient occlusion to create the look of ambient and indirect lighting. When Final Gathering is enabled, rays are cast from the camera into the scene. When a ray intersects with a surface, a Final Gathering point is created that samples the irradiance value of the surface and determines how it is affected by other scene elements, such as nearby objects, lights, and light-emitting surfaces.
Final Gathering uses raytracing rather than photon casting. Each Final Gathering point that the camera shoots into the scene lands on a surface and then emits a number of Final Gathering primary rays, which gather information about the irradiance values and proximity of other scene elements. The information gathered by the rays is used to determine that the surface is shading normal at the Final Gathering point. Imagine a hemispherical dome of rays that are emitted from a point on a surface; the rays gather information about other surfaces in the scene. Like global illumination, this allows it to simulate color bleeding from nearby surfaces.
One of the most interesting aspects of Final Gathering is that you can use objects as lights in a scene. An object that has a shader with a bright incandescent or ambient color value actually casts light in a scene. This works particularly well for situations in which geometry needs to cast light in a scene. For example, a cylinder can be used as a fluorescent lightbulb (see Figure 7.15). When a shader is assigned to the cylinder with a bright incandescent value and Final Gathering is enabled, the result is a very convincing lighting scheme.
In this exercise, you’ll light the bicycle seen earlier in the chapter using only objects with incandescent shaders. Polygon planes will be used as “light cards” to simulate the look of diffuse studio lighting. You’ll find that it’s easy to get a great-looking result from Final Gathering rendering while still using simple, standard Maya shaders.
bicycle_v01.ma
scene from the chapter7scenes
folder at the book’s web page.Scroll to the bottom of the window, and expand the Render Options rollout. Make sure that the Enable Default Light option is not checked.
The Enable Default Light option is normally on so that when you create a test render in a scene with no lights, you can still see your objects. When you add a light to the scene, the default light is overridden and should no longer illuminate the objects in the scene. However, since you won’t be using actual lights in this scene, you need to deselect Enable Default Light.
Create another test render. Make sure renderCam is chosen as the rendering camera.
You’ll see the bicycle appear as the scene renders. There are no lights in the scene. However, the white color of the background is used in the Final Gathering calculations. You’ll notice that the scene renders twice.The Final Gathering render takes place in two stages:
In the second stage, the Final Gathering points calculate irradiance values, and the image is actually rendered and appears at its proper quality.
You’ll often notice that the first pass appears brighter than the final render.
The bicycle has simple shaders applied and no textures. The shadowing seen under the bicycle and in the details is an example of ambient occlusion that occurs as part of a Final Gathering render (see Figure 7.16).
Create another test render. The bicycle should be more visible now compared to its appearance in the test render from step 17 (see Figure 7.17).
Using incandescent objects is a great way to simulate the diffuse light boxes used by photographers. You can easily simulate the lighting used in a studio by strategically placing incandescent planes around the bicycle. However, you’ll notice that the lighting is somewhat blotchy.
The white polygon is reflected in the surface of the bicycle. The shader that is applied to the body is a very simple Phong-type shader, and it looks pretty good.
bicycle_v03.ma
.To see a version of the scene up to this point, open the bicycle_v03.ma
scene from the chapter7scenes
folder at the book’s web page.
The previous exercises demonstrated how Final Gathering can render a scene without lights by using only incandescent objects. However, for many situations, you’ll want to combine Final Gathering with lights so that specular highlights and clear shadows are visible in the render. If you take a look outside on a sunny day, you’ll see examples of direct lighting, cast shadows, indirect lighting, and ambient occlusion working together. Likewise, a typical photographer’s studio combines bright lights, flashbulbs, and diffuse lights to create a harmonious composition. You’ll also find that combining lights and Final Gathering produces a higher-quality render.
Image-based lighting (IBL) uses the color values of an image to light a scene. This can often be done without the help of additional lights. When you enable IBL, you have the choice of rendering the scene using Final Gathering, IBL with Global Illumination, or IBL with the mental ray Light Shader. This section will describe all three methods.
You can use high dynamic range (HDR) images with IBL. An HDR image is a 16- or 32-bit floating-point format image that stores multiple levels of exposure within a single image. Standard 8-bit formats store their color values as integers (whole numbers), whereas a 32-bit floating-point file can store colors as fractional values (numbers with a decimal). This means that the 8-bit formats cannot display a full range of luminance values, whereas the 16- or 32-bit floating-point images can. Multiple levels of exposure are available in HDR floating-point images, which can be used to create more dynamic and realistic lighting in your renders when you use IBL.
HDR images come in several formats, including HDR, OpenEXR (.exr
extension), floating-point TIFFs, and Direct Draw Surface (DDS). Most often you’ll use the HDR and OpenEXR image formats when working with IBL.
When an HDR image is used with IBL, the lighting in the scene looks much more realistic, using the full dynamic range of lighting available in the real world. When integrating CG into live-action shots, a production team often takes multiple HDR images of the set and then uses these images with IBL when rendering the CG elements. This helps the CG elements match perfectly with the live-action shots.
The downside of HDR images is that they require a lot of setup to create. However, you can download and use HDR images from several websites, such as www.openfootage.net
.
Several companies, such as Dosch Design (www.doschdesign.com
), sell packages of HDR images on DVD that are very high quality.
HDR images are available in several styles, including angular (light probe), longitude/latitude (spherical), and vertical or horizontal cubic cross. mental ray supports angular and spherical. You can convert one style to another using a program such as Paul Debevec’s HDRShop (www.hdrshop.com
). Debevec is a pioneer in the field of computer graphics and virtual lighting. He is currently a researcher at the University of Southern California’s Institute for Creative Technologies.
To use IBL in a scene, open the Render Settings window and make sure that mental ray is chosen as the renderer. Switch to the Scene tab, and click the Image Based Lighting Create button under the Environment rollout. This creates all of the nodes that you’ll need in the scene to use IBL.
You can have more than one IBL node in a scene, but only one can be used to create the lighting.
Using IBL with Final Gathering is similar to the concept of using light-emitting objects. When you enable IBL, a sphere is created, and you can map an HDR image to the sphere. The scene is rendered with Final Gathering enabled, and the luminance values of the image mapped to the sphere are used to create the lighting in the scene. You can use additional lights to create cast shadows and specular highlights or use IBL by itself. The following exercise takes you through the process of setting up this scenario.
You’ll need a high dynamic range image (HDRI) to use for the mentalrayIbl node. You can download a number of these images free of charge from Debevec’s website at www.pauldebevec.com/Probes/
. Download the all_probes.zip
file and unzip it; place the files in the sourceimages
folder of your current project.
bicycle_v01.ma
scene from the chapter7scenes
folder at the book’s web page.building_probe.hdr
image from the images you downloaded from www.pauldebevec.com/Probes/
.Expand the Light Emission rollout, and check Emit Light. Change the Quality setting to 0.5.
When the Emit Light option is enabled in the mentalrayIbl node, the image used for the IBL node emits light as if the image itself were made up of directional lights. Each directional light gets a color value based on a sampling taken from the image mapped to the sphere. You can control the overall quality with a single slider.
Create a test render using the renderCam camera.
In this case, you’ll see that the image is blown out. You can also see the HDR image in the background of the scene.
bicycle_v06.ma
.To see a version of the scene, open the bicycle_v06.ma
scene in the chapter7scenes
folder at the book’s web page. Note that you will need to connect the IBL node to the building_probe.hdr
image in order for this scene to render correctly.
You can see that the bicycle is now lit entirely by the HDR image. The HDR image is also visible in the reflective surfaces of the bike. If you want to disable the visibility of the reflections, turn off Visible As Environment (in the Render Stats section).
If you need to adjust the size and position of the IBL sphere, turn off the Infinite option at the top of the node’s Attribute Editor.
mental ray provides a special network of lights and shaders that can accurately emulate the look of sunlight for outdoor scenes. Using the Physical Sun and Sky network requires rendering with Final Gathering. It’s very easy to set up and use.
To create the Physical Sun and Sky network, use the controls in the Scene tab of the Render Settings window:
streetCorner_v04.ma
scene from the chapter7scenes
folder at the book’s web page.Switch to the Scene tab in the Render Settings window, and click the Create button for Physical Sun And Sky from under the Environment rollout.
Clicking the Create button creates a network of nodes that generates the look of sunlight. These include the mia_physicalsun, mia_physicalsky, and mia_exposure simple nodes. You’ll notice that there is a directional light named sunDirection that has been added to the scene. To control the lighting of the scene, you’ll change the orientation of the light. The other light attributes (position, scale, intensity, color, and so on) will not affect the lighting of the scene. To change the lighting, you need to edit the mia_physicalsky node in the Attribute Editor.
Store the rendered image in the Render View window.
The rendered image includes cast shadows from the sun, ambient occlusion created by Final Gathering, and a sky gradient in the background that is reflected in the windows of the building.
Create another test render, and compare it with the first.
When you change the orientation of the sunDirection light, it affects the color of the lighting as well as simulating accurately the lighting you see at different times of day.
streetCorner_v05.ma
.To see a finished version of the scene, open the streetCorner_v05.ma
scene from the chapter7scenes
folder at the book’s web page.
To change the look of the sky in the scene, use the settings found on the mia_physicalsky node.
A number of settings in the Attribute Editor for the sunDirection node help define the color and quality of the sky and the sun in the render. Here is a brief description of some of these settings (see Figure 7.21):
Multiplier This setting adjusts the overall brightness of the sky.
R, G, and B Unit Conversions These settings adjust the coloring of the sky in the R (red), G (green), and B (blue) channels when these values are changed incrementally.
Haze This setting adds haziness to the sky.
Red/Blue Shift Use this option to shift between warm and cool lighting in a scene. Negative numbers shift colors toward blue; positive numbers shift colors toward red. The value range should be kept between –1 and 1.
Saturation The saturation is physically accurate at a value of 1.0. Changing the value to 0.0 removes the color values, causing a grayscale image. Increasing it to its maximum value of 2.0 raises the color intensities.
Horizon Height and Blur These settings change the position and blurriness of the horizon line visible in the renders behind the geometry.
Ground Color This option changes the color of the area below the horizon. Note that the horizon does appear in reflective shaders applied to the geometry in the scene.
Night Color This option affects the color of the sky when the sun is rotated close to 180 degrees.
Sun Direction This setting rotates the sunDirection light in the scene to change the sun direction. Fields should be left at 0.
Sun This option connects the sun settings to a different light in the scene.
Sun Disk Intensity, Sun Disk Scale, and Sun Glow Intensity These settings affect the look of the sun when it is visible in the render.
Use Background This option adds a texture for the environment background. Use this setting as opposed to the standard Maya environment shaders.
Y Is Up Defines which axis points to up in the world. When unchecked, the sun and sky are oriented to Z up.
Flags This parameter is for internal testing and should always be set to 0.
Visibility Distance Defines the distance at which the haze effect becomes hazier.
Update Camera Connections This button adds a new renderable camera to the scene after you create the Physical Sun and Sky network. The network applies specific shaders to all of the renderable cameras in the scene when it is first created. Any new cameras added to the scene will not have these connections enabled by default. Click this button each time you add a new camera to the scene.
Remove Camera Connections This option removes all cameras from the Physical Sun and Sky network.
If you need to delete the Physical Sun and Sky network from the scene, open the Render Settings window and click the Delete button for the Physical Sun And Sky attribute.
mental ray area lights are designed to create a simulation of light sources in the real world. Most lights in Maya emit light rays from an infinitely small point in space. In the real world, light sources are three-dimensional objects, such as a lightbulb or a window, that have a defined size.
Lighting a scene using standard lights, such as the point and spot lights, often requires additional fill lighting to compensate for the fact that these lights do not behave like real-world light sources. Area lights are designed as an alternative to this approach. A mental ray area light is essentially an array of spot lights. The array creates a 3D light source, which results in more realistic light behaviors, especially with regard to shadow casting. The downside is that area lights often take longer to render, so they are not always ideal for every situation.
Follow the steps in this exercise to understand how to use area lights in mental ray:
hospitalRoom_v01.ma
scene from the chapter7scenes
folder at the book’s web page.Store the image in the render view.
The render looks very blown out and grainy. You can reduce the grainy quality by increasing the shadow rays used on the light. However, there is something important and potentially confusing that you should know about using a standard Maya area light with mental ray. The light as it stands right now is not actually taking advantage of mental ray area light properties. To make the light a true mental ray area light, you need to enable the Use Light Shape attribute under the mental ray rollout under the Area Light section. Until you enable this attribute, you’ll have a hard time getting the area light to look realistic.
In the mental ray ➣ Area Light rollout, activate Use Light Shape and create another test render (see Figure 7.22).
The new render is less blown out, and the shadows are much softer (although still grainy).
Unlike standard Maya area lights, the scale of the light does not affect the intensity of mental ray area lights. To change the intensity, use the Intensity slider at the top of the Attribute Editor. The shape of the shadows cast by mental ray area lights is affected by the shape specified in the Type menu and the scale of the light.
To improve the quality of the shadows, increase the High Samples setting. The High Samples and Low Samples settings control the quality of the shadow in reflected surfaces. These can be left at a low value to improve render efficiency.
Create a test render, and compare the render to the previous versions (see Figure 7.23).
Area lights come with several different preset shapes. The Sphere type area light is similar to a point light, but instead of emitting light from an infinitely small point in space, it emits from a spherical volume, making it ideal for simulating light cast from things such as lightbulbs.
You can also create an area light that behaves like a spot light.
hospitalRoom_v05.ma
.The light quality and shadow shape remain the same as in the previous renders. However, switching the light Type setting to Spot Light adds the penumbra shape you would expect from a spot light. This allows you to combine the properties of spot lights and mental ray area lights. The Visible option in the mental ray settings does not work when using a spot light as the original light.
To see a version of the scene, open the hospitalRoom_v05.ma
scene from the chapter7scenes
folder at the book’s web page.
mental ray has a number of light shaders that can be applied to lights in a scene. The purpose of these shaders is to extend the capabilities of Maya lights to allow for more lighting options. When a mental ray shader is applied to a Maya light, specific attributes on the original light node are overridden. The light’s attributes can then be set using the controls on the light shader node.
Some shaders, such as the Mib_blackbody and Mib_cie_d shaders, are very simple. These two shaders translate the color of the light as a temperature specified in kelvin. Other shaders are more complex, providing a number of attributes that can be used in special circumstances.
This section will discuss some of the light shaders and how you can use them in Maya scenes.
The Physical Light shader is a type of shadow-casting light that is used in combination with indirect lighting (Final Gathering, global illumination) to create more physically accurate light behavior. There are also certain materials, such as the mental ray Architectural (mia) materials, that are designed to work with physical lights (these materials are discussed in Chapter 8, “mental ray Shading Techniques”).
Physical lights always cast raytrace shadows, and the falloff rate for the light obeys the inverse square law, just like lights in the real world. This law states that the intensity of light is inversely proportional to the square of the distance from the source. Thus the light intensity decreases rapidly as the light travels from the source.
Physical lights are easy to set up and use. Once you are comfortable with them, consider using them whenever you use indirect lighting, such as Global Illumination and Final Gathering. This exercise will show you how to create a physical light. The scene has a number of area lights positioned to match the recessed lighting fixtures in the ceiling.
hospitalRoom_v05.ma
scene from the chapter7scenes
folder at the book’s web page.Choose physical_light from the right panel to create a light shader. This connects the shader to the area light.
The attributes for the physical_light shader will open in the Attribute Editor. You’ll see the settings for the shader:
Color The Color setting controls the color and intensity of the light by adjusting the color values in the color swatch.
Cone The Cone setting is used when the Physical Light shader is applied to mental ray spot and area spot lights to define the cone angle and penumbra. Higher values create a softer penumbra.
Threshold The Threshold setting defines a minimum illumination value. When you increase the threshold, the lighting in the scene is contracted around the brighter areas, giving you more control over the precise areas of light in the scene. This can cause hard edges to appear around the edges of light cast by spot lights even after you adjust the Cone value.
Cosine Exponent Similar to the Cone setting, the Cosine Exponent attribute contracts the area of light cast when the shader is applied to mental ray area lights. As the value of Cosine Exponent increases, the light cast by the area light becomes more focused.
Store the render in the Render View window.
The lighting looks too bright. To fix this, you’ll use the Color swatch value in physical_light1’s Attribute Editor. The default value for the light is 1000.
hospitalRoom_v06.ma
.To see a version of this scene, open hospitalRoom_v06.ma
from the chapter7scenes
folder at the book’s web page.
Rendering using physical lights often results in a very blown-out image. This is because computer monitors are unable to display the full range of luminance values created by physical lights. To correct this, you will want to color manage the final image.
hospitalRoom_v06.ma
scene from the chapter7scenes
folder at the book’s web page.hospitalRoom_v07.ma
.To see a version of the scene, open the hospitalRoom_v07.ma
scene from the chapter7scenes
folder at the book’s web page.
Photometric lights allow you to attach light profiles created by light manufacturers so that you can simulate specific lights in your scenes. These profiles are often available on light manufacturers’ websites. The profile itself is a text file in the IES format.
The profiles simulate the qualities of the light, such as falloff and the influence of the light fixture. A light profile can include the sconces and fixtures attached to the light itself. This is most helpful in creating accurate architectural renderings.
To use a photometric light, you can attach the mib_light_photometric shader to a point light and then attach the profile to the light using the Profile field in the shader’s attributes. You can also skip using the shader altogether and attach the IES profile directly to the point light in the Light Profile field available in point lights.
In many cases, you’ll need to adjust the shadows cast by lights using a profile to make them more realistic. Use raytrace shadows, and adjust the Shadow Rays and Light Radius values to improve the look of the shadows.
If you’d like to experiment using light profiles, you can download IES-format light profiles from www.lsi-industries.com/products/products-home.aspx
. Browse to any of their lights, and you can download the IES photometrics.
Use shadow-casting lights. Lights can cast either depth map or raytrace shadows. Depth map shadows are created from an image projected from the shadow-casting light, which reads the depth information of the scene. Raytrace shadows are calculated by tracing rays from the light source to the rendering camera.
Master It Compare mental ray depth map shadows to raytrace shadows. Render the
crystalGlobe.ma
scene using soft raytrace shadows.
Render with global illumination. Global illumination simulates indirect lighting by emitting photons into a scene. Global illumination photons react with surfaces that have diffuse shaders. Global illumination works particularly well in indoor lighting situations.
Master It Render the
rotunda_v01.ma
scene, found in thechapter7scenes
folder at the book’s web page, using global illumination.
Render with Final Gathering. Final Gathering is another method for creating indirect lighting. Final Gathering points are shot into the scene from the rendering camera. Final Gathering includes color bleeding and ambient occlusion shadowing as part of the indirect lighting.
Master It Create a fluorescent lightbulb from geometry that can light a room.
Use image-based lighting. Image-based lighting (IBL) uses an image to create lighting in a scene. High dynamic range images (HDRIs) are usually the most effective source for IBL. There are three ways to render with IBL: Final Gathering, global illumination, and with the light shader. These can also be combined if needed.
Master It Render the bicycle scene using the Uffizi Gallery probe HDR image available at
http://ict.debevec.org/~debevec/Probes
.
Render using the Physical Sun and Sky network. The Physical Sun and Sky network creates realistic sunlight that’s ideal for outdoor rendering.
Master It Render a short animation showing the street corner at different times of day.
Understand mental ray area lights. mental ray area lights are activated in the mental ray section of an area light’s shape node when the Use Light Shape option is enabled. mental ray area lights render realistic, soft raytrace shadows. The light created from mental ray area lights is emitted from a three-dimensional array of lights as opposed to an infinitely small point in space.
Master It Build a lamp model that realistically lights a scene using an area light.