Chapter 11
Autodesk® Maya® Rendering

Rendering is the last step in creating your CG work. It’s the process by which the computer calculates the surface properties, lighting, shadows, movement, and shape of objects, and it saves a sequence of images. Although the computer does all the thinking at this point, you still need to set up your cameras and the render to get exactly what you want.

This chapter will show you how to render your scene using the Autodesk® Maya® Software renderer and mental ray® for Maya, as well as how to create reflections and refractions. In this chapter, you’ll use a wine bottle and a still life from previous chapters, and you’ll animate a camera to render a sequence.

  1. Learning Outcomes: In this chapter, you will be able to

Rendering Setup

When your lighting scene from the previous chapter is complete, you’ve had a celebration smoothie for your hard work, and you’re ready to start a render, you’ll need to set up how you want it rendered. Although this is the last part of the CG process, from now on you should be thinking about rendering throughout your production. When you create models and textures with the final image in mind and you gear the lighting toward showing off the scene elegantly, the final touches are relatively easy to set up.

c11f001.tif

Figure 11-1: The Render Settings window

Decide which of the render engines included with Maya you’ll use: Maya Software, Maya Hardware (or Hardware 2.0), mental ray for Maya (the most popular of the renderers standard with Maya 2015), or Maya Vector. Each engine has its own particular workflow and can yield entirely different results, although mental ray and Maya Software are close in appearance if you don’t use the special features of mental ray. The choice of a rendering method depends on the final look you want and sometimes on the number of machines and licenses with which you can render. Maya Software rendering comes with an unlimited number of licenses, which means you can render on any machine you have (with Maya installed), although you can work with the Maya application only on as many machines for which you have licenses. There are also third-party developers in the CG field that have created other render engines that plug right into Maya, such as V-Ray® for Maya, Maxwell®, and Pixar’s RenderMan® for Maya.

No matter which renderer you use, the lighting and general setup are fairly common across the board. Even then, it’s a good idea to choose your render engine as you begin creating your scene. It’s best to begin with basic mental ray to pick up the fundamentals of lighting, texturing, and rendering before you venture into mental ray special features or try other renderers.

Regardless of the type of render, you need to specify a set of common attributes in the Render Settings window. Choose Window ⇒ Rendering Editors ⇒ Render Settings to open the Render Settings window. Figure 11-1 shows the Render Settings window for the Maya Software renderer and its tabs: the Common tab and the Maya Software tab. You use the options in this window’s Common tab to set up all your rendering preferences, including the resolution, file type, frame range, and so forth.

The Common tab contains the settings common to all the rendering methods, such as image size. The Maya Software tab gives you access to render-specific attributes, such as quality settings, raytracing settings, motion blur, and so on.

If you switch the Render Using pull-down menu from the default Maya Software setting to mental ray, you’ll notice several tabs: Passes, Features, Quality, Indirect Lighting, and Options. These tabs give you access to all the settings for the powerful mental ray renderer.

You may notice that some of the render engines like mental ray may not show up in the Render Settings window right away. In this case, the renderers’ respective plug-ins must be loaded first. I’ll discuss this further in the section “mental ray for Maya” later in this chapter.

Choosing a Filename

Rendered images are identified by a filename, a frame number, and an extension, in the form name.#.ext. This is an example: stillife.0234.tif.

In the File Name Prefix text box, enter the image sequence name. If you don’t enter anything in this text box, Maya automatically names your rendered images after your scene file (stillife in the example). This is the preferred naming convention; using it, you can immediately identify the scene file from which a particular image file was rendered.

In the Frame/Animation Ext drop-down list box, select name.#.ext to render out a sequence of files. If you leave this setting at the default of name.ext, only a single frame will render, no matter what the animation range is in the Time slider.

The extension portion of the image name is a three-letter abbreviation for the type of file you’re writing to disk to ensure that you can identify the file type.

Image Format

In the Image Format drop-down list box, select the type of image file you want to render. Maya will add the appropriate extension to the filename.

The image format you choose depends on your own preference and your output needs. For example, JPEG files may be great for the small file sizes preferred on the Internet, but their color compression and lack of alpha channel (a feature discussed later in this chapter) make them undesirable for most professional CG work beyond test renders.

It’s best to render a sequence of images rather than a movie file for two reasons. First, you want your renders to be their best quality with little or no image compression. Second, if a render fails during a movie render, you must re-render the entire sequence. With an image sequence, however, you can pick up where the last frame left off.

The best file type format to render to is TIFF. This format enjoys universal support, has little to no compression, and supports an alpha channel. Almost all image-editing and compositing packages can read Targa- and TIFF-formatted files, so either is a safe choice most of the time. For more on image formats, see Chapter 1, “Introduction to Computer Graphics and 3D.”

Frame Range

Maya defaults to the frame range 1–10, which you may likely need to change to render your entire sequence. You must choose a naming convention other than Name (Single Frame) to access the frame range. Enter the Start Frame and End Frame attributes for part of the sequence or the entire sequence.

The By Frame attribute specifies the intervals at which the sequence will render. For example, if you want to render only the odd-numbered frames, set the Start Frame attribute to 1, and set the By Frame attribute to 2. If you want to render only even-numbered frames, set Start Frame to 2, set By Frame to 2, and so on. Typically, you leave By Frame set to 1 so that Maya renders each frame.

The Frame Padding attribute and slider have to do with the way an operating system, such as Windows or Mac OS X, orders its files by inserting leading zeros in the frame number. For example, if Frame Padding is set to 4, the filename contains three leading zeros; therefore, frame 8 is name.0008.tif as opposed to name.8.tif (which is set to a padding of 1).

Large sequences of files are easier to organize if they all have a frame padding of at least 3. Figure 11-2 shows an image sequence without padding and with padding. The files without padding aren’t shown in numeric order.

c11f002.tif

Figure 11-2: Images rendered without frame padding (left). Frame padding makes file sequences easier to organize (right).

Camera and Channels

Under the Renderable Cameras heading, you choose the camera to render and enable the Alpha and Depth channels.

Image files are composed of red, green, and blue channels. Each channel specifies the amount of the primary additive color (red, green, or blue, respectively) in the image. (See Chapter 1 for more on how computers define color.) Some file formats save a fourth channel, called the alpha channel. This channel defines the image’s transparency level. Just as the red channel defines how much red is in an area of the image, the alpha channel defines how transparent the image is when layered or composited on another image. If the alpha channel is black, the image is perfectly see-through. If the alpha channel is white, the image is solid and opaque. The alpha channel is also known as the matte. An object with some transparency like tinted glass will render with a gray alpha channel, as shown in Figure 11-3.

c11f003.tif

Figure 11-3: This wine bottle’s transparency renders with a gray alpha channel.

The alpha channel can be displayed in the Render View window. As discussed later in this chapter, your test renders also display in this window.

c11f004.tif

Figure 11-4: Output an alpha channel.

Most renders have the alpha channels selected in the Render Settings window, so leave the Alpha Channel (Mask) check box selected at all times, as shown in Figure 11-4. Note, however, that JPEG, Graphics Interchange Format (GIF), and Windows bitmap files don’t support alpha channels, regardless of whether the Alpha Channel (Mask) check box is selected.

Setting Resolution

The Width and Height attributes set the pixel size of the image to be rendered, a.k.a. the image resolution. In the Image Size section of the Render Settings window, you can select a resolution from the Presets drop-down list. The commonly used resolution for professional broadcast is 1920×1080 High Definition, which appears as HD 1080 in the Presets list. To composite Maya CG into a home-shot digital video (DV) movie, you use the standard DV resolution of 720×480 to render your scene, but you must enter that resolution manually in the Width and Height fields. (For more on resolutions, see Chapter 1.)

The Device Aspect Ratio and Pixel Aspect Ratio attributes adjust the width of the image to accommodate certain professional output needs; you do not need to adjust them here.

The higher your resolution, the longer the scene will take to render. With large frame sequences, it’s advisable to render tests at half the resolution of the final output or less to save time. In addition to turning down the resolution for a test, you can use a lower-quality render.

Selecting a Render Engine

Maya allows you to select a render engine in the Render Settings window. Although mental ray for Maya is most commonly used, the other rendering methods give you flexibility in choosing a final look for your project.

Maya Software

Maya Software, the default software rendering method, can capture just about everything you want in your scene, from reflections to motion blur and transparencies. You can use the software rendering method in a couple of ways.

Using Raytracing

Raytracing, a topic introduced in Chapter 10, “Autodesk® Maya® Lighting,” is used to incorporate two optical effects into a rendering that the default software rendering method can’t handle. Raytracing traces rays of light from each light source to every object in the shot and then traces the light’s reflection from the object to the camera’s lens. This allows true reflections and refractions to appear in the render as well as highly defined shadows (for more on shadows, see Chapter 10).

  1. True Reflections True reflections occur when every object in the scene is viewed in a reflective surface, as a reflection, of course. You can also have objects with reflections explicitly turned off through the Render Stats section in the Attribute Editor in case you don’t want a particular reflection, which is common. Although it’s possible to simulate reflections in Maya Software using reflection maps, true reflections can be generated only through raytracing. (In Chapter 7, “Autodesk® Maya® Shading and Texturing,” the TableLamp project shows how to apply reflection maps.)
  2. Refractions Refractions occur when light bends as it passes through one medium into another medium of different density. For example, a pencil in a glass of water appears to be broken. Refraction can also be turned on or off explicitly through Render Stats for objects that you don’t want to see refracting through another clear object.

You saw in the previous chapter that raytracing is also a vital component of mental ray for Maya as well as the Maya Software renderer.

As soon as raytracing is enabled, any reflective surface receives a true reflection of the objects and environment in the scene. Even objects with reflection maps reflect other objects in addition to their reflection maps. For more on reflection maps, see the section “Reflections and Refractions” later in this chapter.

Render Quality

With software rendering, the render quality depends most noticeably on anti-aliasing. Anti-aliasing is the effect produced when pixels appear to blur together to soften a jagged edge on an angled line. Increasing the anti-aliasing level of a render produces an image that has smoother angles and curves. The Render Settings window contains presets that specify this level and a few others to set the quality of your render. Follow these steps:

  1. In the Render Settings window, make sure Maya Software is selected in the Render Using drop-down list and click the Maya Software tab.
  2. In the Anti-aliasing Quality section, select either Preview Quality or Production Quality from the Quality preset drop-down list.

Figure 11-5 shows the fruit still life from Chapter 10 rendered with the Preview Quality preset and the same image with the Production Quality preset. Of course, the higher the quality, the longer the render will take.

c11f005.tif

Figure 11-5: With Preview Quality (left), the edges of the fruit are jagged. With Production Quality (right), the jaggedness is gone.

Maya Hardware and Hardware 2.0

The hardware rendering method uses your graphic card’s processor to render the scene. Hardware renders are similar to what you may see when you play a 3D video game.

This method results in faster render times, but it lacks some of the features and quality you get from a software render. In Figure 11-6, the first image shows a wine bottle as rendered through hardware. The render time is blazingly fast, but the quality suffers. The second image shows the software render of the same frame. Hardware rendering becomes a good way to test-render a scene, although only certain video cards fully support Maya Hardware rendering.

c11f006.tif

Figure 11-6: The hardware-rendered wine bottle (left) lacks some subtleties. The software-rendered wine bottle shows better specularity and surface detail (right).

To use the Maya Hardware renderer, in the Render Settings window, make sure Maya Hardware is selected in the Render Using drop-down list. To specify hardware quality, select a level from the Number Of Samples drop-down list on the Maya Hardware tab.

mental ray for Maya

mental ray for Maya has become a standard for rendering through Maya, supplanting the Maya Software renderer because of its stability and quality results. The mental ray for Maya rendering method can also let you emulate the behavior of light even more realistically than the other rendering methods, as you saw in the previous chapter’s Physical Sun and Sky exercise. Based on raytracing, mental ray takes the concept further by adding photon maps to the light traces. That is, it projects photon particles from lights and records their behavior and trajectory. The end result allows the phenomena of light caustics and bounce, also known as global illumination.

The mental ray for Maya renderer can be an advanced and intricate rendering language with shaders and procedures all its own. This chapter briefly covers one of the popular mental ray methods called Final Gather using HDR image based lighting. To use mental ray, you still need to be experienced with the basics of lighting and rendering. At its base, mental ray will give you results similar to those of Maya Software when all of the bells and whistles of mental ray are not enabled. So it’s often best to just use mental ray throughout.

Maya Vector

Vector rendering lets you render your objects with an illustrated or cartoon look. You can render “ink” outlines of your characters to composite over flat-color passes. Figure 11-7 shows the fruit still life rendered with Maya Vector. This rendering method is different from the Maya toon-shading feature, which is briefly covered in Chapter 12, “Autodesk® Maya® Dynamics and Effects.”

c11f007.tif

Figure 11-7: The fruit still life as a vector render

Maya Vector can output animated files in Adobe Flash format for direct use in web pages and animations, as well as Adobe Illustrator files and the usual list of image formats. To specify the attribute settings for Maya Vector, you use the Maya Vector tab in the Render Settings window (see Figure 11-8).

c11f008.tif

Figure 11-8: The Maya Vector rendering settings

In the Fill Options section, click the Fill Objects check box, and select the number of colors for each object to set the look of the render. If you want the renderer to include an outline of the edges of your geometry, in the Edge Options section, click the Include Edges check box and set the line weights.

Previewing Your Render: The Render View Window

The Render View window automatically opens when you test-render a frame, as you’ve already seen in your work through this book. To open it manually, choose Window ⇒ Rendering Editors ⇒ Render View. Your current scene renders in the Render View window. Figure 11-9 shows the names of the icons in this window, and below we explore what the more important ones do.

  1. Redo Previous Render Renders the last-rendered view panel.
  2. Render Region Renders only the selected portion of an image. To select a portion of an image, click within the image in the Render View window and drag a red box around a region.
    c11f009.eps

    Figure 11-9: The Render View window

  3. Snapshot Grabs a snapshot of the currently selected modeling panel and inserts it as a background in the Render View. You can more easily do a render region this way.
  4. Open Render Settings Window Opens the Render Settings window (also known as the Render Globals window in previous versions of Maya).
  5. Display RGB Channels Displays the full color of the image.
  6. Display Alpha Channel Displays only the alpha matte of the render as a black-and-white image.
  7. Display Real Size Resets the image size to 100 percent to make sure the image displays properly. When the Render View window is resized or when you select a new render resolution, the image renders to fit the window, and the image is resized if needed. If your render looks blocky, make sure the Render View window is displaying at real size before adjusting the options in the Render Settings window.
  8. Render Using Pull Down Menu Lets you select the rendering method. This is the same as selecting it in the Render Settings window.
  9. Exposure and Gamma Correction Controls These sliders allow you to adjust the brightness of the rendered image for viewing purposes. The first slider controls the overall brightness of the image while the second slider (Gamma Control) effectively runs the relative brightness of the lights and darks in the image, which in essence controls the contrast.
  10. Information Readout At the bottom of the Render View window is a readout of information about the frame rendered. This information tells you the resolution, renderer used, frame number, render time, and camera used to render. This readout is a huge help in comparing different render settings and different frames as you progress in your work, especially when you keep images in the buffer (as explained later).

Saving/Loading an Image

Although you typically use the Render View window to test a scene, you can also use it to save single frames by choosing File ⇒ Save Image to save in any image formats supported in Maya. Likewise, choose File ⇒ Open Image to display any previously rendered image file in this window. If your task in Maya is to create a single frame, this is the best way to render and save it.

Keep/Remove Image

The Render View window is a prime place to see adjustments to various parts of your scene. You can store images in its buffer by clicking the Keep Image icon. When you do, a scroll bar appears at the bottom of the window, and you can scroll through any saved images. This is handy for making a change, rendering it, and scrolling back and forth between the old saved image and the new render to make sure the change is to your liking. You can store a number of images in the buffer. For a faster way to preview changes, use IPR rendering, as discussed next.

IPR Rendering

As you saw in Chapter 7, a fast way to preview changes to your scene is to use Maya Interactive Photorealistic Rendering (IPR). After you IPR-render a view panel, specify the region you want to tune by dragging a box around that area of the image in the Render View window. Maya updates that region every time you make a shader or lighting change to the scene. Figure 11-10 shows the decorative box as an IPR mental ray render as the color and specular levels are being fine-tuned against a wireframe snapshot of the model.

c11f010.tif

Figure 11-10: IPR rendering lets you fine-tune your textures and lighting with near-real-time feedback.

IPR is perfect for finding just the right lighting and specular levels. It will, however, register raytracing elements such as refractions and true reflections only if the scene is set to render through mental ray for Maya. Overall, IPR quality is fairly close to that of a full render while still allowing you to watch your tuning in near real time.

Setting the Default Renderer

By default, whenever you launch Maya, it sets Maya Software as the renderer of choice. To change this to mental ray, for example, in the main menu bar select Window ⇒ Settings/Preferences ⇒ Preferences. In the Preferences window, select Rendering in the list on the left side, and set the Preferred renderer drop-down menu to mental ray and click Save. From hereon, new scenes will default to using mental ray.

Reflections and Refractions

As you saw in Chapter 7, creating a “faked” reflection with a map for an object is pretty simple. To generate true reflections without the use of maps, however, you’ll need to manually enable raytracing in Maya Software or use mental ray for Maya, which has raytracing enabled by default. With raytracing, Maya or mental ray reflects any objects in the scene that fall in the proper line of sight. All you need to do is use shaders that have reflection attributes such as Phong or Blinn. Note that Lambert shader does not reflect.

Raytraced Reflections

c11f011.tif

Figure 11-11: Enabling raytracing in Maya Software rendering

Rendering reflections using mental ray is simple. Just assign shaders to your objects that have a Reflection attrbiute such as Phong or Blinn. If you prefer not to use mental ray however, you must enable raytraced reflections with Maya Software rendering. First, make sure to use a material that has a Reflections attribute (for example, Phong or Blinn). Then, open the Render Settings window and choose Maya Software as your renderer. On the Maya Software tab, click the Raytracing check box in the Raytracing Quality section. (See Figure 11-11.)

The sliders control the quality of the render by specifying how many times to reflect or refract for any given object. Setting Reflections to 2, for example, enables an object’s reflection in a second object to appear as part of its reflection in a third object.

The first image in Figure 11-12 shows the still life reflecting onto the surface of its table. In this case, Reflections is set to 1. If you increase Reflections to 2, however, you’ll see the reflections of the pieces of fruit in each other also reflecting in the surface of the table.

c11f012.eps

Figure 11-12: Reflections set to 1 (left); Reflections set to 2 (right)

Notice the difference in the reflections of the fruit in the table between the two renders. Raytraced reflections can consume valuable render resources and time, so it’s a good idea to make your scene efficient.

You can control the number of reflections on a per-object basis as opposed to setting limits on the entire scene through the Render Settings window. To access a shader’s reflection limits, select the shader in the Hypershade and open the Attribute Editor. In the Raytrace Options section, drag the Reflection Limit slider to set the maximum number of reflections for that shader. The lower value (either this value or the Reflections value in the Render Settings window) dictates how many reflections are rendered for every object attached to that shader. The default shader reflection limit is 1, so make sure you change the Reflections value as well as each shader’s value if you want more than one level of reflection.

Furthermore, you may not want some objects to cast reflections in a scene with raytraced reflections. To specify that an object doesn’t cast reflections, select the object in a Maya panel and open the Attribute Editor. In the Render Stats section, clear the Visible In Reflections check box.

Rendering Refractions

Refractions are also a raytraced-only ability. Refractions require that an object be semitransparent so that you can see through it to the object (or objects) behind it being refracted. To control refractions, use the shader.

To enable refractions in either Maya Software or mental ray rendering, select the appropriate shader in the Hypershade and open the Attribute Editor. In the Raytrace Options section, click the Refractions check box. Now you need to set a refractive index for the shader and a refraction limit, similar to the reflection limit.

The refractive index must be greater or less than 1 to cause a refraction. Typically, a number within 0.2 of 1 is perfect for most refraction effects. The first image in Figure 11-13 is raytraced with a refractive index of 1.2 on the wine bottle and glasses; the second image has a refractive index of 0.8 on both bottle and glasses.

c11f013.tif

Figure 11-13: Refractive index of 1.2 (left render); refractive index of 0.8 (middle render); setting the refraction quality in the Render Settings and the shader (right two windows)

You can specify whether an object is visible in a refracting object by clicking or clearing the Visible In Refractions check box in the Render Stats section of the object’s Attribute Editor.

When rendering refractions, make sure the Refractions attribute under Raytracing Quality in the Maya Software tab of the Render Settings is set to at least 2 or higher; otherwise, your refraction may not appear properly. For mental ray, it is the Refractions attribute found under the Raytracing heading on the Quality tab, as shown in Figure 11-13 (right). You will also need to set the Refraction Limit found under the Raytrace Options heading in the Attribute Editor for the refractive shader in question.

Using Cameras

Cameras capture all the animation fun in the scene. The more you know about photography, the easier these concepts are to understand.

The term camera, in essence, refers to any perspective view. You can have as many cameras in the scene as you want, but it’s wise to have a camera you’re planning to render with placed to frame the shot and a different camera acting as the perspective work view so you can move around your scene as you work. The original persp view panel fits that latter role well, although it can be used as a render camera just as easily.

You can also render any of your work windows to test-render orthogonal views of your model the same way you render a perspective view.

Creating a Camera

The simplest way to create a new camera is to choose Panels ⇒ Perspective ⇒ New, as you’ve seen in a previous exercise. This creates a new camera node in Maya and sets that active panel to its view. Cameras will work in any renderer, though some renderers such as VRay may provide their own specialized cameras or camera attributes.

You can select a camera in a view panel and transform it (move it, rotate it, scale it) just as you would select and transform any other object in Maya to be animated or positioned. Furthermore, you can move a camera and rotate it using the Alt/Option key and mouse button combinations.

For example, click inside a new Maya Scene Perspective window to make it active. Select that view’s camera by choosing View ⇒ Select Camera. The camera’s attributes appear in the Channel Box. Try moving the view around using the Alt/Option key and mouse button combinations. Notice how the attributes change to reflect the new position and rotation of the camera. You can animate the camera—for example, zoom in or out or pan across the scene—by setting keyframes on any of these attributes.

Camera Types

You can create three types of nonstereo cameras for your scene: Camera; Camera And Aim; and Camera, Aim, And Up (also known as single-node, two-node, and three-node cameras, respectively). To create any of these cameras, choose Create ⇒ Cameras. You can also change the type of these cameras at any time through the Attribute Editor. The other two options for creating cameras are Stereo Camera and Multi Stereo Rig to allow for a stereoscopic effect, although they aren’t covered in this book.

The single-node camera (Camera) is the most common (see Figure 11-14). This camera consists of a single camera node that you move and rotate as you would any other object for proper positioning. The persp view panel’s camera is a single-node camera.

c11f014.tif

Figure 11-14: A single-node camera

The two-node camera (Camera And Aim) consists of the camera node and an aim node. You use the aim node to point the camera as opposed to rotating it to orient it properly. This is useful for animating a camera following an object. You animate the movement of the aim node to follow your object much as you’d follow a car around a racetrack. The camera pivots to follow its aim point and, hence, the object. (See Figure 11-15.)

The three-node camera (Camera, Aim, And Up) has a camera node, an aim node, and an up node. The additional up node is to orient the camera’s up direction. This gives you the ability to animate the side-to-side rotation of the camera as well as its aim direction. (See Figure 11-16.)

c11f015.tif

Figure 11-15: A two-node camera

c11f016.tif

Figure 11-16: A three-node camera

Camera Attributes

As an example, download the still_life_render_v02.mb scene from the Lighting project on the book’s web page, www.sybex.com/go/introducingmaya2015, and set your project to Lighting. You’ll see a green box in the persp view panel that displays the resolution (set to 640×480) and the name of the camera (camera1).

Special attributes control the function of camera nodes. To set these attributes, follow these steps:

  1. With camera1 selected, open the Attribute Editor (press Ctrl+A or choose View ⇒ Camera Attribute Editor).
    c11f017.tif

    Figure 11-17: The Attribute Editor for the persp camera

  2. At the top of the window, select the type of camera controls you want. The Controls attribute sets the type of camera from single- to two- to three-control nodes. Figure 11-17 shows the Attribute Editor for the camera1 camera.

Focal Length

The Focal Length attribute specifies the length of the lens. The lower the focal length (a.k.a. short lens), the wider the view. At very low numbers, however, the image is distorted, as you can see in the comparison in Figure 11-18. The higher the focal length, the closer the subject seems to the camera.

Although adjusting the Focal Length attribute of a camera zooms in and out, it isn’t the same as moving the camera closer to your subject using the Alt+RMB+click procedure to zoom in view panels (which is called trucking the camera). Focal-length zooming can create optical distortions, such as can be created with a fish-eye lens.

If you need to match some CG element in Maya to a photograph or video that you’ve imported as an image plane, set your camera’s focal length to match that of the real camera used for the background photo.

c11f018.eps

Figure 11-18: Different focal lengths

Clipping Planes

All cameras in Maya have clipping planes that restrict the amount of information that can be seen through them. The clipping plane is defined by the Near Clip Plane and Far Clip Plane attributes. These set the minimum and maximum distances, respectively, of the clipping plane. Any object or portion of an object that passes beyond these distances won’t show in the window and should not render.

If you notice objects disappearing as you move your camera and create a scene, it may be because of the clipping plane. Increase the Far Clip Plane attribute, and the objects should reappear in the view. You can display the near and far clipping planes of any camera with the check boxes in the Frustrum Display Controls section, as well as view your angle of view by turning on Display Frustrum.

Film Back

The Film Back attributes concern the type of output you’ll be dealing with after your renders are finished and you’re ready to put your animation on tape, DVD, film, or what have you.

  1. Film Gate Defines the aspect ratio of your camera’s view. Images that are output to HD television have an aspect ratio of 1:1.78, which funnily enough does not have a preset in the Film Gate drop-down list. For an HD camera output, simply set Film Aspect Ratio to 1.78. For standard-definition TV output, simply select 35mm TV Projection from the Film Gate drop-down list. (For more on aspect ratios, see Chapter 1.)
  2. Fit Resolution Gate Allows you to align footage you may have imported as an image plane to match up CG properly to live action.

Overscan

Found in the Display Options section for the camera’s Attribute Editor, Overscan lets you resize the view without changing the film gate that will render. For example, the scene on the left in Figure 11-19 is set up with an Overscan setting of 1.3, allowing you to see more than what will render, which is defined by the outline box. The scene on the right in Figure 11-19 is set up with an Overscan setting of 2, which increases even more how much you see in the camera1 panel but doesn’t change the view when rendered.

c11f019.tif

Figure 11-19: Overscan settings define how much you can see of your scene in the camera but not how much renders in the image.

c11f020.tif

Figure 11-20: Camera display options

You can turn the green box in the panel on and off through the camera’s Attribute Editor. Also in the Display Options section are Display Film Gate and Display Resolution check boxes, shown in Figure 11-20. Ideally, these two green boxes should align perfectly in the view pane. If the resolution box (the solid green line) doesn’t line up with the film gate box (the dashed green line), change your film gate selection to match the resolution’s aspect ratio in the Render Settings window. A resolution of 640×480, for example, has an aspect ratio of 1.33, the same as the 35mm TV Projection film gate currently selected for this scene.

Environment

In the Environment section, you’ll find attributes to adjust the background color that renders and to create an image plane, as shown in Figure 11-21.

c11f021.tif

Figure 11-21: Adjusting the camera’s environment and creating camera image planes

If you want to use a solid color as the camera’s background when you render, click the color swatch next to Background Color to change the background color in your renders using the Color Chooser. The slider allows you to control the value, or brightness, of the current color. Neither changes the background color of your view panels, however.

Camera Image Planes

A camera image plane isn’t like the reference planes you used for modeling the red wagon in Chapter 6, “Practical Experience.” In this case, an image plane is created to be a background specific for that particular camera or view panel, but it’s typically also used as a reference, much like the planes you created and mapped in Chapter 6. Camera image planes are useful when you’re matching your scene to existing footage or an image. For example, if you need to animate a flying saucer into a home video of a family gathering, you would import the video as an image sequence into Maya through a perspective camera to be able to line up your UFO properly to zap your cousins.

You can import an image plane by clicking the Create button in the Environment section of the Attribute Editor (see Figure 11-21) or directly through a view panel’s menu, as you’ll see in the next exercise.

In this exercise, you’ll learn how to import a sketch of an axe into the Front view panel for a modeling assignment. (You won’t actually model the axe, however.) The image, a sketch of a simple axe design, is to be used as a template for outlining the model. You can find the file Axe_outline_1.tif in the sourceimages folder of the Axe project on the companion web page; it’s shown in Figure 11-22.

c11f022.tif

Figure 11-22: An image to import as a camera image plane

Follow these steps:

  1. Choose File ⇒ New Scene.
  2. Import the sketch of the axe into Maya as a camera image plane for the Front view panel. In your Front window, choose View ⇒ Image Plane ⇒ Import Image.
  3. Point to Axe_outline_1.tif in the Axe project’s sourceimages folder and load it. The sketch displays in your Front window and as a selected plane in the Perspective window (see Figure 11-23). You should see the image plane’s attributes in the Attribute Editor. At first, the plane looks a little small in your view panels, but you can adjust the size of the image plane in the Attribute Editor under the Placement Extras heading using the Width and Height attributes. Just make sure that the Maintain Pic Aspect Ratio box is checked. In Figure 11-23, the Width and Height settings have been adjusted to 25.0×17.325.

Now you’d be ready to trace the outline of the axe easily in the Front view panel, if you were going to model the axe.

c11f023.tif

Figure 11-23: Importing a camera image plane into the Front view panel

Image Plane Sequence

A movie file or a sequence of files can also be brought in to animate or to track motion (a.k.a. matchmoving) as a camera image plane. It’s generally best to use a frame sequence, however. When you bring in an image for an image plane, check the Use Image Sequence box in the image plane’s Attribute Editor window, as shown in Figure 11-24. Maya will automatically load the image to correspond to the frame number in the scene. For example, at frame 29 in your Maya animation, Maya loads frame 29 of your image sequence. But your image file sequence must be numbered correctly (such as filename.###.tif). You can import an image plane into any perspective view in the same way.

c11f024.tif

Figure 11-24: Importing a sequence of image files as a camera image plane

Motion Blur

Motion blur is an optical phenomenon that occurs when an object moves quickly in front of a camera: the object looks blurred as it crosses the frame. Maya Software rendering renders motion blur in two ways—2D blur or 3D blur—although neither will render as reflections.

I’ll briefly cover motion blur in mental ray for Maya later in the chapter.

To enable motion blur for the Maya Software renderer, open the Render Settings window. In the Motion Blur section on the Maya Software tab, click the Motion Blur check box. Then, choose 2D or 3D blur.

Typically, you control the amount of blur rendered for 2D and 3D by setting the Blur By Frame attribute—the higher the number, the greater the blur. Using additional controls, however, you can increase or decrease the 2D blur effect in the render. The Blur Length attribute affects the streakiness of the blur to further increase or decrease the amount of motion blur set with the Blur By Frame attribute.

Batch Rendering

So far, you’ve used single-frame rendering numerous times to see a scene in the Render View window. But how do you start rendering an animation sequence to disk? This is called batch rendering in Maya, whichever renderer you use. To batch-render an entire scene, follow these steps:

  1. Open the Render Settings window.
  2. Choose Maya Software to use to render, enter the start and end frames of your animation, and select your image format. Select your quality and resolution settings. Finally, set the camera you want to render in the Renderable Camera attribute.
  3. In the main Maya window under the Rendering menu set, choose Render ⇒ Batch Render optionbox.tif to open the Batch Render Animation dialog box (or the Batch Render Frame box when rendering a single image). Figure 11-25 shows the Maya Software rendering batch options on top, and the bottom image shows the batch options for mental ray rendering.
    c11f025.tif

    Figure 11-25: The Batch Render Frame dialog box for Maya Software (top) and mental ray rendering (bottom)

  4. If you have a multiprocessor, hyperthreading, or dual-core machine, select how many CPUs you would like to use to render your scene. A value of 0 will use all processors on the machine.
  5. Click Batch Render to render the frame range you specified in the Render Settings window. The render occurs in the background, and you see progress updates in the Command line at the bottom of your Maya screen and in the Script Editor window if you open it.

To see a frame as the batch render progresses, choose Render ⇒ Show Batch Render. To cancel a batch render, choose Render ⇒ Cancel Batch Render.

c11f026.tif

Figure 11-26: The Render Settings window shows you where the images will be rendered.

When you batch render, your image files are written to the images folder of the current project. Make sure your project is properly set; otherwise, your files will end up in an unexpected folder. You can always see the render path and the image name at the top of the Render Settings window, as shown in Figure 11-26.

Rendering the Wine Bottle

In this section, you’ll set up and render an animated camera to move over 25 frames of a wine bottle still life using Maya Software rendering at first.

Set your current project to the Lighting project downloaded from the book’s web page and then load still_life_render_v01.mb. You’ll adjust your render settings and some shader properties to make the wine bottle look more like glass.

Selecting Render Settings Options

Set your resolution and quality settings in the Render Settings window.

  1. Open the Render Settings window and select Maya Software. Click the Maya Software tab.
  2. From the Quality drop-down list, select Production Quality. Doing so presets the appropriate settings to produce a high-quality render.
  3. Click the Common tab. Set Frame/Animation Ext to name.#.ext, set Start Frame to 1, set End Frame to 25, and set Frame Padding to 2.
  4. From the Image Format drop-down list, select TIFF.
  5. Make sure Renderable Camera is set to camera1. In the Image Size section, set Presets to 640×480.

Setting Up the Scene

Now, set up some of the objects in the scene. The wine bottle has been imported into the still life scene, and three wine glasses have been added. All the lights are in place, as is the camera.

Start by setting up this scene to raytrace to get true reflections and refractions.

  1. Turn on refractions for the Glass shaders. In the Hypershade, select the Glasses material and open the Attribute Editor. In the Raytrace Options section, click the Refractions check box, and set Refractive Index to 1.2. Set Reflection Limit to 2. Select the Wine_Bottle material and repeat the previous steps.
  2. You need to change your lights’ shadows to raytraced shadows. Remember that semitransparent objects cast solid shadows unless shadows are raytraced, so the glasses and wine bottle will cast shadows as if they were solid and not glass. In the Outliner, select spotLight1. In the Attribute Editor, in the Shadows section, enable Use Ray Trace Shadows. Repeat these steps for the remaining two shadow-casting lights: spotLight4 and spotLight3. Figure 11-27 shows the three shadow-casting lights in the scene in white.
  3. Open the Render Settings window and turn on raytracing in the Raytracing Quality section. Set Reflections to 2.
    c11f027.tif

    Figure 11-27: Shadow lights

Setting Up the Camera

Next, you’ll set up the camera to render the scene.

  1. Make sure you are looking through the camera1 camera. Open the camera’s Attribute Editor through the camera1 panel (choose View ⇒ Camera Attribute Editor).
  2. Select the Display Film Gate option in the Display Options section to turn on a dashed green box in the camera1 panel. Enable the Display Resolution option. Notice that the two boxes aren’t aligned.
  3. Because the resolution is 640×480, you’ll use a 1.33 aspect ratio. Select 35mm TV Projection from the Film Gate drop-down list. The two green boxes now align. Although it’s not absolutely necessary to match the resolution with the film gate, it’s definitely good practice to do so, especially if you’ll later insert CG in live-action videos.
  4. As soon as you change the film gate, the framing of the scene changes. You must move the camera out to frame the entire still life. If you try to use the Alt key and mouse button combinations to zoom out, you’ll notice that you can’t move the camera in this scene: The movement attributes for the camera have been locked to prevent accidental movement that would disrupt the shot.
  5. To unlock the camera, choose View ⇒ Select Camera. The camera’s attributes appear in the Channel Box. Some are grayed out, signifying that they’re locked and can’t be changed. Highlight the locked attributes and RMB+click Unlock Selected in the Channel Box.
  6. Create an animated camera move to pull out and reveal the still life slowly over 25 frames. Set your Range slider to 1 to 25 frames. Go to frame 1. The camera1 view should be similar to that shown in Figure 11-28. Select all three Translate and Rotate channels in the Channel Box and RMB+click Key Selected to set keyframes for the first camera position.
  7. Zoom (actually, truck) the camera out by pressing Alt+RMB+click to a wider framing to reveal the entire still life. Highlight the Translate and Rotate channels again in the Channel Box and set keyframes for them. (See Figure 11-29.)

Scrub your animation, and you’ll see a pullout revealing the full scene.

c11f028.tif

Figure 11-28: The camera view at the beginning of the animation

c11f029.tif

Figure 11-29: Pull out the camera.

Batch Rendering and Playing Back the Sequence

Now, you’re ready to render the 25-frame sequence. Choose Render ⇒ Batch Render.

c11f030.tif

Figure 11-30: FCheck, shown here with a sample image, plays back your rendered sequence.

Because you’re raytracing this scene at full resolution, this render could take 20 minutes or longer. To chart the progress of the render, open the Script Editor by clicking its icon on the Help line or by choosing Window ⇒ General Editors ⇒ Script Editor.

To see the frames play back, you’ll need a program that can load the images in sequence and play them back for you. You can also import the image sequence into a compositing or editing program, such as Adobe After Effects or Premiere, to play back as a clip and edit as you like.

You can also use FCheck, a frame viewer that is included with Maya. This small and surprisingly powerful program plays back your images in real time so that you can judge your finished animation. To use FCheck, follow these steps:

  1. In Windows, choose Start ⇒ All Programs ⇒ Autodesk ⇒ Autodesk Maya 2014 ⇒ FCheck to open the FCheck window, as shown in Figure 11-30.
  2. Choose File ⇒ Open Animation.
  3. In the file browser, find your images folder in your project and click the first frame of the sequence you want to play back. FCheck loads the images frame by frame into RAM and then plays them back in real time. Just set your playback speed and use the DVD controls to play back your sequence.

mental ray for Maya

c11f031.tif

Figure 11-31: Use the Plug-in Manager to load mental ray for Maya.

You had some experience with mental ray rendering in the previous chapter as you lighted using Physical Sun and Sky, which automatically used Final Gather to render. In this part of the chapter, I’ll discuss mental ray options to begin to scratch the surface of this powerful renderer.

First, if you haven’t done so already, be sure that mental ray is loaded. When you first start up, mental ray for Maya may not load because it’s considered a plug-in. Choose Window ⇒ Settings/Preferences ⇒ Plug-in Manager to open the Plug-in Manager, shown in Figure 11-31. Make sure both the Loaded and Auto Load check boxes for Mayatomr.mll (or Mayatomr.bundle for Mac users) are checked so that mental ray for Maya loads by default.

To render with mental ray, open the Render Settings window and change the Render Using drop-down menu selection to mental ray, as shown in Figure 11-32 (shown with the Features tab selected). The Render Settings window now has the Common tab along with five other mental ray–specific tabs: Passes, Features, Quality, Indirect Lighting, and Options.

c11f032.tif

Figure 11-32: The Render Settings window for mental ray, showing the Features tab

mental ray Quality Settings

As with the Maya Software renderer, the primary quality settings for the mental ray renderer center on anti-aliasing. However, mental ray for Maya offers you finer control over how you set the quality levels through the Render Settings window. On the Quality tab, you’ll find these attributes:

  1. Sampling Mode (Under the Sampling Heading) This drop-down menu sets the type of sampling mental ray performs in the render. Sampling is the number of times mental ray reads and compares the color values of adjacent pixels in order to smooth the resulting render to avoid jagged lines. The choices are Unified Sampling (default), Legacy Rasterizer Mode, and Legacy Sampling Mode. Unified Sampling is generally the best choice because it sets the best range based on the Min and Max Samples you set along with a single Quality value. With the Min and Max Samples set to 1 and 100, respectively, the Quality value slider is key. A Quality setting at about 1.0 is considered good for production-quality renders, though you may need slightly higher than 1.0 in some cases. Quality of about 0.2 is a good fast render for previews. Experimenting with Min and Max Sample values will make more minor adjustments to the look of your render than would making changes to Quality.
  2. For those who are already familiar with previous mental ray workflows, Legacy Sampling Mode will give you access to additional sampling modes available in previous versions of mental ray for Maya. Legacy Sampling is discussed in the “Legacy Sampling Mode” sidebar. However, Unified Sampling mode attempts to greatly simplify the quality settings for mental ray for Maya and is preferred for use.
  3. Sample Options Heading Filtering is done on the results of the sampling of pixels to blend the pixels of a region together to form a coherent image. A high filter size tends to blur the image, whereas low filter values may look overly crisp. Gauss is the default filter and gives a slightly softer result to help deal with any grainy image noise. Usually, render times don’t vary much between different filter modes—it’s not as if Gaussian takes four times longer to render the same frame over the Box filter type. But each gives a slightly different type of softness depending on its Filter Size setting.

Sample Lock is turned on to reduce noise and artifacts in rendered sequences that have lots of movement.

Rather than setting high sample rates with just the Min and Max Sample Level attributes, carefully increase the Quality value to force mental ray to use a sample rate closer to the Max Samples only where it needs to do so. You’ll see this in action in the next section.

When you’re ready to render your scene to disk, you still use batch rendering; however, the options in the Batch Render Option window are different (Figure 11-33) than they are for Maya Software.

c11f033.tif

Figure 11-33: mental ray batch render options

Render Settings in Action!

In this section, you’ll look at how Quality values and how the number of Min and Max Samples work together to determine the quality of the render of a toy wagon. You can find the scene (RedWagonRenderSettings.ma) to render in the RedWagon project on the book’s web page. Make sure to set your project to RedWagon.

Open the Render Settings window, making sure you are set to mental ray, and open the Quality tab. Set your Sampling Mode value to Unified Sampling. Occasionally you may see that Sampling Mode reverts to Legacy Sampling Mode when you open a file even though it was set to Unified Sampling. If that is the case, any settings you’ve created for Unified Sampling Mode do remain intact. Quality should be set to 0.50, Min Samples to 1.0, and Max Samples to 1.0 in this file already.

These render quality settings are low at first and will yield the render shown in Figure 11-34, which took just less than two minutes. You can see jagged highlights on the wagon, especially the white lines on the side body, the reflections in the front black nose, and the edge of the white rims on the back wheel.

If you increase Max Samples to 100 and Min Samples to 1.0, you’ll see an immediate increase in quality (especially in the reflections of the wagon and the white decal lines) and a noticeable increase in render time (about 50 percent as long), as shown in Figure 11-35, which took just under three minutes to render.

c11f034.tif

Figure 11-34: A toy wagon rendered with low sampling values. Notice the jagged highlights on the white decal lines and the back wheel.

c11f035.tif

Figure 11-35: Better sampling improves the wagon’s appearance.

You can get an even cleaner render. If you crank up the Quality value to the heavens, such as 2.0, you get a far cleaner render than before but with a much longer render time. Figure 11-36 shows the same frame with the Quality value set to 2.0 instead of the default of 0.5. The Min Samples is still set to 1, and the Max Samples is left at 100. The wood panels and the reflections of the wagon in the checkered floor are both noticeably nicer in this render. Your results as you render the scene on your own computer will be more noticeable than the images shown here. But this render took 4:35.

c11f036.tif

Figure 11-36: The wagon has still better sampling with a higher Quality value. You’ll see it better in your own renders.

For a very quick render to check composition and lighting, set your Quality, Min, and Max Samples values all to 0.1. You should get a super-fast render, though good luck discerning much detail. It’s easy enough to crank the numbers to the sky, but render times will quickly become unacceptable, especially when you have a supervisor or client breathing down your neck. Find just the right combination of numbers for acceptable results in a minimum of time. Each scene will be different.

Motion Blur with mental ray

Now that you have a primer on quality settings in mental ray for Maya, you’ll learn how motion blur works.

  1. Load the Planets_motionBlur.ma scene file from the Solar_System project on the web page. This is an animated scene of the solar system with just the first few planets and moons, as shown in Figure 11-37. A blast from the past!
    c11f037.tif

    Figure 11-37: The Solar_System project is back!

  2. Open the Render Settings window. The scene should already be set to render with mental ray. If your scene isn’t, make sure the mental ray for Maya plug-in is loaded and set the scene to render with mental ray.
  3. On the Common tab, set Frame/Animation Ext to name.#.ext, Frame Padding to 3, Start Frame to 1, and End Frame to 100.
  4. Set Image Size to 640×480 for now and leave the renderable camera to persp.
  5. Go to frame 75 and render a frame from the persp view panel. Figure 11-38 shows the result.
  6. In Render Settings, click to open the Features tab. In the Rendering Features heading, select No Deformation in the Motion Blur drop-down menu, as shown in Figure 11-39. This setting is the faster of two motion blur methods and works for objects that move in the scene without deformation. Deformations occur when the mesh or surface of an object changes, such as when you use a lattice or a skeleton rig like IK to drive a character. For deforming objects, you need to use Full as the Motion Blur setting.
  7. Click to open the Quality tab in Render Settings. Set Sampling Mode to Unified Sampling, and set Quality to 0.5 and Min Samples and Max Samples each to 1.0. In the Motion Blur ⇒ Motion Blur Optimization heading, set the Motion Blur By attribute from 1.0 to 3.0 for quite a bit of blur. Render a frame at frame 75. (See Figure 11-40.)
    c11f038.tif

    Figure 11-38: A render of frame 75 shows the planets in motion without any motion blur.

    c11f039.tif

    Figure 11-39: Turn on motion blur.

    c11f040.tif

    Figure 11-40: Render a frame with motion blur turned on.

  8. The render is very fast and shows quite a bit of blur; however, the quality is low. You see a lot of graininess in your render, especially with the yellow and red planets at the bottom of the screen. On the Quality tab of the Render Settings window, leave Sampling Mode at Unified Sampling, but change Max Samples to 50. This render should be fast but cleaner, with a smoother but still-grainy motion blur for the planets. Notice, however, that the render time increases by about 50 percent! Now try Max Samples at 100 and Quality at 2.0 (Figure 11-41 shows this much cleaner render). You control the amount of motion blur in your scene with the Motion Blur By attribute (step 7) for your scene.
    c11f041.tif

    Figure 11-41: Motion blur looks much better with higher sampling levels.

Render Layers

Most of the time, it’s best to composite different elements together to form a final CG image. Professional CG workflow almost always requires multiple render passes that are composited together later for the maximum in efficiency and quality.

Maya does a great job of making rendering in layers much easier with render layers. As you saw earlier in this book, using display layers helps a lot in keeping your scene organized. Render layers operate in basically the same way, although they function by separating different elements of the scene into separate renders.

I’ll address the most basic and commonly utilized render layer functionality here: separating objects into different renders. You’ll select elements in a scene and assign them to different render layers. When you batch-render the scene, Maya will render each of the layers separately and save the files into their own subfolders in the images folder of your current project. You’ll then need to load all the different rendered layers into a compositing program, such as The Foundry’s NUKE or Adobe After Effects, and composite the layers together.

Render Passes in mental ray

Two powerful features in mental ray rendering, Render Passes and Pass Contribution Maps, make rendering in passes and elements much more efficient. Passes allow you to separate shadows, reflections, diffuse color, and so on, from the render to give the most control in compositing over the image. This mental ray–specific workflow is fairly advanced and requires an existing knowledge of rendering and compositing render passes (such as you will do with render layers) to fully grasp. Thus, I won’t cover these features in this book; however, you should be aware of this mental ray rendering pipeline as you move beyond this introduction and continue rendering with mental ray in your own work.

Rendering the Still Life in Layers

In this example, you’ll separate a scene into different layers for rendering with mental ray, though the render layer workflow here applies to Maya Software rendering as well.

To separate a scene into different layers, follow these steps:

  1. Set your project to the Lighting project downloaded from the book’s web page and open the still life scene (still_life_renderLayers_v01.mb from the scenes folder to start there). The lights and a camera are already set up in this scene. Set your camera view to camera1. Open Render Settings and make sure mental ray is the current renderer. Set Sampling Mode to Unified Sampling, set Quality to 2.0, and set Min/Max Samples to 1.0 and 100, respectively.
  2. To separate the scene into different renders, in the Layer Editor, click the Render tab to switch to the Render-Layers view. Select the foreground lemon and click the Create New Layer And Assign Selected Objects icon (c11g003.tif). Doing so creates a new render layer called layer1 and assigns the lemon to it. (See Figure 11-42.)
  3. Click layer1, and everything but the lemon disappears from the scene (see Figure 11-42). Double-click layer1 in the Layer Editor and rename it lemonPass, as shown in Figure 11-43.
  4. If you test-render a frame, the frame should turn black. You need to assign your lights to the render layer as well. Select all the lights in the scene using the Outliner, as shown in Figure 11-44. Right-click the lemonPass layer in the Layer Editor and select Add Selected Objects from the context menu. If you render a test frame now, the lemon renders as shown in Figure 11-45.
    c11f042.tif

    Figure 11-42: The newly created render layer with the foreground lemon assigned

    c11f043.tif

    Figure 11-43: Rename the render layer to lemonPass.

    c11f044.tif

    Figure 11-44: Add the lights to the lemonPass render layer.

    c11f045.tif

    Figure 11-45: The lemon rendered on its very own layer

  5. Create a render layer for the column and floor. Click the masterLayer render layer and then select the column, the floor, and all the lights in the scene. As you did with the lemon, click the Create New Layer And Assign Selected Objects icon (c11g003.tif) and then click the new layer to select and display it. Double-click the layer name to rename the render layer columnPass (see Figure 11-46).
    c11f046.tif

    Figure 11-46: The background is assigned to its own render layer.

  6. Click back to the masterLayer; then select all the rest of the pieces of fruit, as shown in Figure 11-47, and create their render layer called fruitPass. You should now have three render layers and the default masterLayer. The masterLayer is always present to house all the elements of the scene. It switches to being not renderable as soon as you create a new render layer, as evidenced by the little red X in its Renderable icon (c11g004.tif).
    c11f047.tif

    Figure 11-47: The newly created fruitPass render layer

    c11f048.tif

    Figure 11-48: Rendering the rest of the fruit

  7. Using the first icon on each of the render layer entries in the Layer Editor, you can toggle whether that layer will render. Make sure all your render layers are renderable, and leave the masterLayer off. Because all the elements of the scene are assigned to one render layer or another, the whole scene is covered. The masterLayer nonetheless is always present because it represents all the objects in the scene, assigned to layers or not.
  8. With the fruitPass render layer selected, test-render a frame, as shown in Figure 11-48. You should see just the fruit and not the background, column, or foreground lemon. Notice the reflections in the fruit.

Test-Rendering Everything Together

By default, Maya renders only the selected visible render layer. You can, however, tell Maya to test-render and show you all the layers composited together to give you a preview of what you’ll end up with when you composite all the layers together after batch-rendering the scene.

To test-render all the layers together, click the Options menu in the Layer Editor, as shown in Figure 11-49, and toggle on Render All Layers by clicking the check box if it isn’t already selected.

c11f049.tif

Figure 11-49: Turn on Render All Layers.

Now if you test-render a frame, Maya will render each layer separately and then composite them together. Test-render a frame with Render All Layers enabled, and you should notice that the foreground lemon is missing, as in Figure 11-50.

c11f050.tif

Figure 11-50: Rendering all the layers together

c11f051.tif

Figure 11-51: Reorder the render layers.

This is because the render layers in the Layer Editor need to be reordered so that columnPass is on the bottom, fruitPass is in the middle, and lemonPass is on top. This is the layer ordering for the composite. You can reorder the render layers by MMB+clicking a layer and dragging it up or down to its new location in the Layer Editor, as in Figure 11-51.

Now if you render the frame with Render All Layers enabled, you see the scene properly placed, as shown in Figure 11-52. Notice that shadows and reflections on the column’s tabletop are missing, however. For that, you will need to create render layer overrides to allow reflections and shadows of an object to render, but without the object itself rendering.

c11f052.tif

Figure 11-52: Now the lemon appears in the render.

Render Layer Overrides

Where are the shadows and reflections? If you recall from earlier in this chapter, this scene renders with shadows, and this scene should have reflections as well. However, the reflections and shadow-casting objects are on different layers than the column. Shadows and reflections can’t be cast from one layer onto another. In the following steps, you’ll use render layer overrides to set up your columnPass layer to have shadows and reflections from the fruit but not render the fruit on top of the column:

  1. Click to the columnPass render layer. In the Outliner, select all the fruit objects and add them to the layer (Figure 11-53).
    c11f053.tif

    Figure 11-53: Add the fruit back into the layer.

  2. If you render the layer now, it will render the fruit. To turn them off without removing them from the layer (and hence lose shadows and reflections), you’ll set render layer overrides for each of the fruit objects. Select the orange, and open the Attribute Editor.
    c11f054.tif

    Figure 11-54: Turn off Primary Visibility to set a render layer override for the orange on the columnPass layer.

  3. On the orangeShape tab in the Attribute Editor, click to open the Render Stats heading. Here you see switches allowing for different ways to render the object. You want the orange to cast reflections and shadows in the scene, without rendering itself, so uncheck the Primary Visibility box. It will turn orange to signify that there is now a render layer override on that attribute for the current render layer (columnPass) only (Figure 11-54).

    As a matter of fact, if you click the other render layers with the orange still selected, you will notice that the Primary Visibility setting for the orange turns back on and loses its orange color in the Attribute Editor on the other render layers. Render layer overrides work only on the layers in which they were created.

  4. Now select each fruit model down the list in the Outliner individually and turn off Primary Visibility one by one. You cannot select all the objects at once and turn off Primary Visibility in the Attribute Editor; it will register the action only for the last selected object and not them all.
  5. Turn off Render All Layers (in the Layer Editor, uncheck Options ⇒ Render All Layers). Render the columnPass layer, and you’ll see the top of the column is rendering with shadows and reflections but not the fruit! (See Figure 11-55.)
  6. Finally, you make the shadows look nicer by using raytrace shadows. Select spotLight1, and in the Attribute Editor, under the Shadows ⇒ Depth Map Shadow Attributes heading, turn off Use Depth Map Shadows. Scroll down a bit until you see the Raytrace Shadow Attributes heading; open it, and turn on Use Ray Trace Shadows.
  7. Repeat step 6 for spotLight3 and spotLight4. Render, and you’ll see sharp shadows now on the column (Figure 11-56).
    c11f055.tif

    Figure 11-55: The column is rendering with depth map shadows and reflections.

    c11f056.tif

    Figure 11-56: The raytraced shadows are clean but too sharp.

  8. Let’s enable soft shadows now for those three spotlights. Select spotLight1, and in the Raytrace Shadow Attributes, set Light Radius to 0.4 and Shadow Rays to 16. Repeat the procedure for spotLight3 and spotLight4. The shadows will look much more believable now.
  9. Turn on Render All Layers, and render a frame to see the entire composition (Figure 11-57). Once you verify everything is working and looking good, you can now render your scene into separate layers for better control in compositing.
    c11f057.tif

    Figure 11-57: The layers all rendered together with soft shadows and reflections

You can check your work against the file still_life_renderLayers_v02.mb from the scenes folder of the Lighting project on the book’s web page.

Batch Rendering with Render Layers

Now that you have everything separated into render layers, let’s talk about batch-rendering the scene to composite later. Make your selected render layers renderable by making sure the Renderable icon next to each render layer is enabled, as shown in Figure 11-58.

c11f058.tif

Figure 11-58: Check to make sure the layers you want to render are enabled.

In the Render Settings window, make sure Renderable Camera is set to camera1, as shown in Figure 11-59. Select your image file type and anything else you need to set in the Render Settings window. Then, in the main Maya window, choose Render ⇒ Batch Render to render the scene. Because render layers are enabled here, Maya renders the scene into different subfolders under the images folder of your current project. Each render layer gets its own folder in the images folder, as shown in Figure 11-60.

I have only begun to scratch the surface here. When you get the hang of rendering and as your CG needs begin to grow, you’ll find a plethora of options when rendering with layers and rendering with passes through mental ray. This section and the “Ambient Occlusion” section later in this chapter are here only to familiarize you with the basic workflow of render layers. You can find a wealth of information about rendering in layers and passes in the Maya online documentation under the Help menu.

c11f059.tif

Figure 11-59: Select camera1 as your renderable camera in the Render Settings window.

c11f060.tif

Figure 11-60: Render layers batch-render into subfolders in the images folder of your project.

Final Gather

Final Gather (FG) is a type of rendering with mental ray that includes a simple light bounce within the scene. Final Gather traces light as it reflects off surfaces to illuminate the scene for a nicely realistic render that takes into account color bleed of light from one surface to another. For example, a red wall casts a red hue on the surface right next to it. FG is an intricate dance of settings and numbers that lets you get perfect renders. It’s tough to cover in an introductory book such as this; however, this section will give you a primer to start using FG. In a follow-up section, you’ll use a combination of lights and HDRI with Final Gather to render the decorative box.

The basic premise is that FG uses the illumination in the scene from lights as well as objects with color and incandescence set in their shaders to create a soft natural light. Its base settings will give you nice results right from the start.

To render the still life fruit scene with FG, begin by creating a dome light, which evenly illuminates a scene from a dome around the scene. (The term dome light is a bit of a misnomer, because a dome light isn’t itself a light.) You’ll construct a simple NURBS sphere, cut it in half to create a dome, and give it an Incandescent shader to provide the light for the scene. This type of quick FG setup is extremely useful for rendering out soft lighting and shadows to show off a model or a composition.

To light and render with FG, follow these steps:

  1. Ensure that mental ray for Maya is loaded.
  2. Load the still life scene file still_life_mentalray_v01.mb from the Lighting project from the book’s web page. In the persp view panel (not the camera1 panel), create a polygonal sphere, and scale it up to enclose the entire scene. Select the bottom half faces of the sphere, delete them to cut the sphere in half, and name the object lightDome. Place the dome to fit over the scene, as shown in Figure 11-61.
  3. Add an Incandescent shader to the dome to give the scene some illumination through FG. To do so, in the Hypershade create a new Lambert shader. Turn up its incandescence to a medium light gray. Assign the new shader to the dome.
  4. Maya automatically creates a general default light in a scene that has no lights when you try to render it. This is so you can test-render your scene quickly. However, because this incandescent dome light should be the only light source in the FG render, you have to turn off the default light feature before you render. Open the Render Settings window and, under the Common tab’s Render Options heading (at the bottom of the Attribute Editor), turn off the Enable Default Light check box.
    c11f061.tif

    Figure 11-61: Create a hemisphere to act as a light dome.

  5. At the top of the Render Settings window, switch the Render Using attribute to mental ray. You can keep the settings on the Common tab to render at 640×480. Choose the Quality tab to access its settings. Set Sampling Mode to Unified Sampling, and leave Min and Max Samples at 1.0 and 100, respectively, but set a Quality value of 0.3. Check to make sure that raytracing is enabled under the Raytracing heading. Figure 11-62 shows the Quality tab of the Render Settings window.
  6. Click to open the Indirect Lighting tab and click the Final Gathering heading to expand its attributes. Turn on Final Gathering by checking the box. You can leave the settings at their defaults for your first render. Figure 11-63 shows the Indirect Lighting tab for the Render Settings window with Final Gathering turned on.
  7. You need to make sure the sphere you’re using as a dome light doesn’t render out in the scene. Select the sphere and, in its Attribute Editor under the Render Stats heading, turn off Primary Visibility. Since there are no render layers in the scene, it doesn’t turn orange like with the previous section’s exercise. Highlight the camera1 panel, and render the frame. Maya makes two passes at the scene and shows you something like Figure 11-64. You can control the brightness of the scene with the Incandescence attribute value of the dome’s shader—the whiter the incandescence, the brighter the scene.
    c11f062.tif

    Figure 11-62: The Quality tab

    c11f063.tif

    Figure 11-63: The Indirect Lighting tab accesses all the Final Gather settings.

    c11f064.tif

    Figure 11-64: The Final Gather render of the still life

You can adjust the level of lighting by increasing or decreasing the amount of incandescence on the light dome’s shader. The proximity of the sphere also affects the light amount, so moving the sphere closer or farther away will change the lighting level as well. You can also insert lights into the scene as you see fit.

You can improve the quality of the render by adjusting any of the following three settings on the Indirect Lighting tab under the Final Gathering section of the Render Settings window:

  1. Accuracy Increase this number for a more accurate render. Don’t increase it too much, however, because it will slow down your render. Earlier the still life was rendered with the default Accuracy setting of 100. In Figure 11-65, which uses a setting of 500, the soft shadows are noticeably smoother. Accuracy dictates the number of FG rays that are cast into the scene. The more rays, the better the quality of the render, although at a cost of rendering time.
    c11f065.tif

    Figure 11-65: Accuracy set at 500 increases the smoothness of the soft shadows. It’s hard to see here, but you’ll notice it in your own render.

  2. Primary Diffuse Scale Use this setting to adjust the overall lighting level globally in the scene. The higher the value of this color, the brighter the scene. You can type values greater than 1 in the Color Chooser.
  3. Secondary Diffuse Bounces Setting this attribute to 1 will add an additional bounce of light inside your scene, essentially brightening everything. Shadowed areas will pick up the biggest boost, and the scene lighting will be a bit softer overall.

The Point Density and Point Interpolation attributes, along with several other attributes in the Final Gathering section, optimize and further control the FG settings for optimum efficiency and results, especially with animated scenes. Consider using the basic settings shown in this chapter to become familiar with mental ray for Maya, and then use FG to crank out fast and elegant renders to show off your models until you get more comfortable with mental ray.

Final Gather is a tough nut to crack; it will take you some time to become proficient at rendering with FG in scene files and especially with animated scenes. Later in this chapter, you’ll try your hand at using FG, HDRI, and regular lights to render the decorative box from the previous chapters.

Ambient Occlusion

Ambient Occlusion is a special render pass that helps add depth and reality to a render. Ambient Occlusion goes by the premise that when two objects or surfaces are close to each other, they reduce the amount of light at the intersection. Ambient Occlusion passes make for great contact shadows and bring out the definition in surface creases and corners very nicely. Figure 11-66 shows an Ambient Occlusion pass for the living room scene from the PDF Global Illumination exercise included on the book’s web page.

c11f066.tif

Figure 11-66: The Ambient Occlusion pass is black and white and is used to darken areas of the original color render.

How the composite works is simple. Ambient Occlusion gives you a black-and-white pass of the same geometry you’ve already rendered. This pass is then multiplied over the color render. That means a brightness value of white (a value of 1) in the Ambient Occlusion pass won’t change the color of the original render (when the original color of the render is multiplied by 1, it stays the same color). The black areas of the ambient occlusion image (with a brightness value of 0) turn the same areas of the original render black (when the original color of the render is multiplied by 0, it goes to black). The gray points of the multiplying image darken the original render. It sounds confusing, but when you see it, it makes much better sense.

The Living Room

You’ll now take an existing render of a living room and add an Ambient Occlusion pass using render layers. Set your current project to the Livingroom project you copied from the web page, open the livingRoom_v2.mb file from the scenes folder, and follow these steps:

  1. Make sure mental ray is loaded, of course, and that Render Settings is set to Render Using mental ray. As you did earlier, you need to create a new render layer for the Ambient Occlusion. This layer requires all the objects in the scene but the lights to be assigned to it. In this scene, the only light is a single Directional light. In the Outliner, select all the top nodes of the scene, but leave out the light, as shown in Figure 11-67.
    c11f067.tif

    Figure 11-67: Select the scene objects for your Ambient Occlusion pass.

  2. Click the Render tab in the Layer Editor to switch to Render and then click the Create New Layer And Assign Selected Objects icon (c11g003.tif). Doing so creates a new layer (layer1) along with the preexisting masterLayer, as shown in Figure 11-68.
    c11f068.tif

    Figure 11-68: Create a new render layer.

  3. Click the new layer (layer1) to activate it. Everything in the scene should display as it did before, although the light disappears from view. Double-click layer1 and rename it ambientOcclusion.
  4. You’re going to use a preset to create a material override. This takes all the objects in the scene and assigns a single material to them, in this case an Ambient Occlusion shader that generates the Ambient Occlusion pass for the entire scene. RMB+click the ambientOcclusion layer, and select Attributes. In the Attribute Editor, click and hold down the Presets button. From the menu that appears, select Occlusion, as shown in Figure 11-69.
    c11f069.tif

    Figure 11-69: Setting an Occlusion preset for the layer

    If you’re in Shaded mode, everything should turn black in the view panels. This is normal, because everything now has the Ambient Occlusion Surface shader assigned, and that shader displays black in Maya panels. If you click the masterLayer, everything pops back into place.

    c11f070.tif

    Figure 11-70: The Ambient Occlusion shader in the Hypershade

  5. When you select Occlusion from the Presets menu, your Attribute Editor window should display a new shader called surfaceShader1. Figure 11-70 shows the new Ambient Occlusion shader that is assigned throughout the scene. Rename that shader to ambOccShader. Don’t worry if you don’t see the surfaceShader1 in your Attribute Editor; you’ll come back to it in later steps.
  6. While still in the ambientOcclusion layer, render a frame. You should see something like Figure 11-71. You needn’t worry about most of the settings in the Render Settings window; the layer preset takes care of it all. Well, almost all. It doesn’t turn off the Global Illumination pass that you used for the original color render in the PDF exercise (which you can find on the web page); you need to turn that off manually in the next step.
    c11f071.tif

    Figure 11-71: The first render from the Ambient Occlusion pass doesn’t look great—it’s too dark.

  7. In the Render Settings window, on the Indirect Lighting tab, you need to turn off Global Illumination, but just for the ambientOcclusion layer. With ambientOcclusion still selected in the Layer Editor, RMB+click the Global Illumination check box in Render Settings and choose Create Layer Override. The attribute lettering turns orange to signify that it’s being overridden for that render layer, just like you saw before. Uncheck the box. It doesn’t turn off GI for the masterLayer pass. You don’t have to spend the time calculating any GI for this pass.
  8. The render is mostly black, which darkens the original color render to black almost everywhere. You need the Ambient Occlusion shader to render mostly white with some darkening at the corners and where objects contact each other. You can adjust the Ambient Occlusion shader to fix this. Open the Hypershade window and click ambOccShader (or surfaceShader1, if you didn’t rename it earlier in step 5—rename it now).
  9. Notice that the Out Color attribute has a texture connection to it (signified by the c11g005.tif icon). Click this button to display the mib_amb_occlusion1 texture node in the Attribute Editor, as shown in Figure 11-72.
  10. Set the Max Distance attribute to 4.0, as shown in Figure 11-73, and render the frame again. Your Ambient Occlusion layer should look like Figure 11-74. It should have also taken less than half as long to render as the darker render from step 6.
    c11f072.tif

    Figure 11-72: The Ambient Occlusion shader attributes

    c11f073.tif

    Figure 11-73: Set Max Distance to 4.

    c11f074.tif

    Figure 11-74: The Ambient Occlusion layer pass looks much better, but you aren’t finished yet!

  11. Notice that the glass in the window and the glass on the coffee table have shadows on them. Because glass is clear, they shouldn’t have any Ambient Occlusion applied to them; it would look odd in the final composite. Select those pieces of geometry (Figure 11-75 shows the Outliner view for those pieces).
    c11f075.tif

    Figure 11-75: The Outliner view of the glass geometry in the scene

  12. With the glass geometry selected, select Display ⇒ Hide ⇒ Hide Selection. Now the glass won’t render in the Ambient Occlusion pass. But because you hid the objects only in this render layer, they still appear in the masterLayer; they will still render as glass in the color pass.
  13. Render the frame, and you should have something similar to Figure 11-76. This is the Ambient Occlusion pass you need to composite.
    c11f076.tif

    Figure 11-76: The Ambient Occlusion pass

Rendering the Results

You could save the image you just rendered in the Render View window to use in the composite and then render the masterLayer for the color pass in the Render View and save that frame as well. Instead, let’s batch-render the scene to show how Maya handles rendering with layers enabled. To batch-render the scene, follow these steps:

  1. Turn on the Renderable icon box (c11g006.tif) for the masterLayer, and make sure it’s on for the ambientOcclusion layer as well.
  2. Click to activate the masterLayer. Open the Render Settings window, and on the Common tab, verify all the settings to render a single frame (name.ext.# in the Frame/Animation Ext field) at 640×360 (which is half 720p HD resolution). Also, select camera1 as the renderable camera.
  3. If you batch-render (by choosing Render ⇒ Batch Render), Maya renders both render layers into the images folder of your project in separate folders, as shown in Figure 11-77.
    c11f077.tif

    Figure 11-77: Maya renders the layers into their own folders by default.

If for some reason your renders don’t show up in your project’s images folder, open the Script Editor window and look at the batch-render report. The render feedback shows you where the rendered images were saved, as shown in Figure 11-78. You may also want to make sure you set your project to the Livingroom project from the web page.

c11f078.tif

Figure 11-78: The Script Editor gives you feedback on the progress of the batch render.

Compositing the Results

Now that the two layers are rendered in their respective folders, load them into your favorite compositing package. You’ll layer the Ambient Occlusion pass over the color render using a Multiply Transfer mode. This exercise uses Adobe After Effects CS4 to demonstrate how the Ambient Occlusion pass is composited over the original color render.

Figure 11-79 shows After Effects with the masterLayer color pass loaded. Figure 11-80 shows the ambientOcclusion pass layered on top of the color layer. Finally, Figure 11-81 shows the ambientOcclusion pass changed to a Multiply Transfer mode (as it’s called in After Effects). Notice how the dark areas of the Ambient Occlusion pass help give contact shadows and depth to the color pass. Voilà!

This is a prime example of rendering different passes to achieve a more realistic result. Use different layers to put your final images together in composite.

You can see the difference Ambient Occlusion made to the living-room image in the Color Section of this book and on the web page.

c11f079.tif

Figure 11-79: The masterLayer render pass is loaded into After Effects.

c11f080.tif

Figure 11-80: The ambientOcclusion render pass is loaded into After Effects.

c11f081.tif

Figure 11-81: The ambientOcclusion pass is multiplied over the color pass and creates a more realistic image.

HDRI

As you saw in the Final Gather section, FG rendering is based on the illumination in the scene from lights as well as the brightness of objects in the scene, such as a light dome. In a previous section, you used an incandescent dome to light the still-life scene. But what if you were to use an image instead of just white for the light dome?

Furthermore, what if the image you used was a high dynamic range image (HDRI)? Several photos at varying exposures are taken of the same subject, ranging from very dark (low exposure), which highlight only the brightest parts of the scene, and going all the way up to very bright (overexposure), which capture the absolute darkest parts of the scene. When these images (usually five or seven images) are compiled into an HDR image, you get a fantastic range of bright to dark for that one subject.

How does this help you light? With image-based lighting (IBL), mental ray creates an environment sphere in your scene to which you assign an image, usually an HDRI. That environment sphere, much like the white dome in the Final Gather exercise earlier in the chapter, uses the brightness of its image to cast light in your Maya scene.

The best type of image to capture for an IBL is sometimes called a light probe. This is a picture of an environment, such as the office reflected in a chrome ball shown on the left of Figure 11-82 or the stitched-together panoramic stills compiled into a map shown on the right of Figure 11-82. The stitched panoramic on the right of Figure 11-82 was photographed at four 90-degree angles using a fish-eye camera lens capable of capturing a field of view of close to 180 degrees using a panoramic tripod attachment.

c11f082.tif

Figure 11-82: A light-probe photo of a desk is taken with a chrome ball (left) and a panoramic stitch (right).

Figure 11-82 shows the middle exposure of five exposures taken of the office and one of the four angles of the living room. Figure 11-83 shows five images in the range from underexposed (dark) to overexposed (bright) photos that were used to compile the HDRIs shown here. You will use an HDRI made from the living-room panoramic photos to light the decorative box in the next section.

c11f083.tif

Figure 11-83: Five exposures make up the HDRI of a desk using a chrome ball (left); and a living room using a panoramic stitch (right), which is to be used in the next section.

The living-room photos are taken at 90-degree intervals inside the living room and then stitched and compiled in an HDRI file using a photographic software package (shown in Figure 11-84). The HDRI file is called livingRoomPanoramic.hdr and is in the sourceimages folder of the TableLamp project on the web page for the next section’s IBL lighting exercise. You won’t be able to see the extensive range of the HDR because the great majority of computer displays are limited to a display of 8-bit color.

c11f084.tif

Figure 11-84: Fish-eye photos are taken at four angles of the living room, each with several exposures from light to dark (above). The fish-eye photos are then warped and stitched together using the handy software package PTGui and merged into an HDR image file (bottom).

The HDR will be mapped onto an IBL sphere. This is a large sphere that surrounds the environment in your Maya scene. The individual photos first need to be stitched together and converted to a rectangular image file, as shown in Figure 11-84. The full spherical panorama space captured in these photos and stitched together is laid out into a rectangular format that is suitable to project onto a sphere in Maya, just as if a geographic map on a school room globe was unwrapped into a rectangular sheet of paper.

Software such as HDRShop, available online for free, allows you to combine multiple images into an HDR. One useful program, PTGui from the Netherlands (available for a demo online at www.ptgui.com), allows you to stitch panoramas as well as merge HDR images, which makes it a fantastic tool for CG lighters and photographers. As long as the photos to be stitched were taken with enough overlap at the edges, PTGui is able to turn them into a large panoramic photo. And if the proper exposure ranges were also taken, PTGui creates a solid HDR as well. I won’t get into the details of creating the HDRI because it’s an advanced topic using Adobe Photoshop, PTGui, and/or other software; however, it’s good to know the origins of HDR images and how they come to be used in an IBL.

Displacement Mapping the Decorative Box

Before continuing with the lighting and rendering for the lamp and decorative box, let’s first address a need for detailing just the box by itself. Look at the photo of the box in Figure 3-21 (in Chapter 3, “The Autodesk® Maya® 2015 Interface”) and compare it to the renders of the box in Chapter 10 (Figure 10-65); you’ll see that the carved details in the CG box need more detail. Let’s start by taking a closer look at the box by itself.

  1. Make sure your project is set to the Plane project. Open the file planeLightingScene_v05.mb from the Plane project. An error may come up saying that the reference file cannot be found (if so, it will look like Figure 11-85). If that is the case, simply click Browse and navigate to where you have saved the Decorative_Box project’s scenes folder, where you will find the scene file boxDetail01.mb. Otherwise, the scene should open with no issues. There is a copy of the boxDetail01.mb file in the scenes folder for the plane project as well.
    c11f085.tif

    Figure 11-85: Oh no! Reference file not found!

  2. Select the top node of the toy plane (planeGroup) and create a new display layer called planeLayer. Turn off visibility for the planeLayer.
  3. In the Render Settings window, change the renderer to mental ray.
  4. Use the persp camera (not the renderCam) and line up a view of the box to match the box render shown in Figure 11-86.
    c11f086.tif

    Figure 11-86: The decorative box’s current look when you finished the lighting in Chapter 10

  5. Render a frame, and you should notice more closely the lack of definition in the box when compared to the real photo of the box (Figure 3-21 in Chapter 3).
  6. Save your work!

In the current render, the grooves are flat and shiny, whereas in the real box, they’re carved into the wood and aren’t glossy like the rest of the box. You will add definition to the model through textures next.

You can use the scene file planeLightingScene_v06.ma to catch up to this point or compare your camera angles.

Reflection Map

Just as you use a map to put color on the box, you can use similar maps to specify where and how much the box will reflect. Figure 11-87 shows the color map you used to texture the box in Chapter 7 side-by-side with a black-and-white map that shows only the carved regions of the box. This map was created with elbow grease and hard work to manually isolate just the carved areas of the box in Photoshop. See how much I do for you?

c11f087.tif

Figure 11-87: The black-and-white map on the right shows only the carved areas of the box.

You’ll first take the reflections out of the carved areas in the following steps:

  1. Set your project to the Decorative_Box project from the companion website.
  2. Open the boxDetail02.mb scene. This scene has the box set up with a few lights, a render camera and render settings preset, and a ground plane for you to focus on detailing just the box. Render a frame and study the outcome. Save it to the image buffer in the Render View window.
  3. Open the Hypershade. In the Create bar on the left, click 2D Textures under the Maya heading and choose File to open a new image file node (called file1). See Figure 11-88.
    c11f088.tif

    Figure 11-88: Create a new file node.

  4. Double-click the file node and navigate to find and choose the boxCarvings.jpg file in the sourceimages folder of the Decorative_Box project. See Figure 11-89.
    c11f089.tif

    Figure 11-89: Select the proper image file.

    c11f090.tif

    Figure 11-90: The swatch shows a thumbnail of the image you’re using.

  5. If the sample swatch at the top of the Attribute Editor for the file1 node doesn’t show the image you just selected, it is because the image is too large for Maya to create a thumbnail swatch automatically. If this is the case, the file node in the Hypershade would also be blank. RMB+click the file node and choose Refresh Swatch from the marking menu. Figure 11-90 shows the swatch with the black-and-white image as a thumbnail. This isn’t necessary, but it makes it easier for you to identify what file map is where.
  6. MMB+drag the phong1 node from the top of the Hypershade window down to the Work Area, alongside the file1 node.
  7. Double-click the phong1 node to open the Attribute Editor. MMB+drag the file1 node onto the Reflectivity attribute for the Phong1 shader, as shown in Figure 11-91.
  8. Notice the connection line in the Hypershade between the file1 and phong1 nodes. The white areas of the map tell the phong1 shader to have a reflectivity of 1, whereas the black areas have zero reflectivity. This effectively removes reflections from the box’s carvings. Render a frame of the box in the renderCam view and compare it to Figure 11-92.
    c11f091.tif

    Figure 11-91: Map the new image file to the Reflectivity attribute.

  9. In the Render View window, click the Keep Image icon (c11g007.tif) to store this render in the render buffer. Doing so allows you to easily compare renders to see the changes you make as you continue.
  10. The box’s reflections are now stronger all over, and the carvings still reflect. You need to turn on one switch. Select the file1 node and open the Color Balance heading in the Attribute Editor. Check the box for the Alpha Is Luminance attribute. This instructs Maya to use the luminance values (basically the brightness) of the image to output to the reflectivity attribute of the phong1 shader. The box renders properly, and the carvings have no reflections, as shown in Figure 11-93. Save this render into the render buffer with the Keep Image icon (c11g007.tif).
    c11f092.tif

    Figure 11-92: The reflections are stronger; the entire box looks like a mirror.

    c11f093.tif

    Figure 11-93: The carvings don’t reflect, but the rest of the box’s reflections are still too strong.

  11. You need to reduce the reflections on the rest of the box. Double-click the file1 node to open the Attribute Editor. In the Color Balance heading, set Alpha Gain to 0.4, as shown in Figure 11-94. This sets the brightest part of the reflections to be capped at 0.4 and not the previous 1.0. Render, and you see a much better reflection in the box and no reflections in the carvings. (See Figure 11-95.) Save this to the render buffer.
    c11f094.tif

    Figure 11-94: Set Alpha Gain to 0.4.

    c11f095.tif

    Figure 11-95: The reflections look much better now.

  12. Rename the file1 node to reflectionMap and the phong1 node to boxShader, and save your work to a new version.

You can open the scene file boxDetail03.ma from the scenes folder in the Decorative_Box project to catch up to this point or to check your work so far.

Displacement Mapping

Now that the reflections are set up, you’ll use the same image map to create displacements in the box to sink the carvings into the box. Isn’t that convenient?

  1. In the Hypershade, click to create a new file node, and select the boxCarvings.jpg file in the sourceimages folder again. You don’t want to reuse the same file node as you did for the reflections (reflectionMap node), because you need to change some of its attributes. Name the new file node displacementMap.
  2. Double-click the boxShader node to open the Attribute Editor and MMB+drag the shader to the Work Area of the Hypershade. Then, MMB+drag the new displacementMap node onto the boxShader node in the Hypershade’s Work Area and select Displacement Map from the context menu, as shown in Figure 11-96.
  3. A new node appears called displacementShader1, but there is no connection apparent to the boxShader. Select the boxShader and click the Input And Output Connections icon at the top of the Hypershade (c11g008.tif). The Hypershade shows you the entire shader network, including the displacement map connection, as shown in Figure 11-97. Notice that the displacement connects to the phong1SG node and not directly to the boxShader node. This is normal and how it’s always done.
    c11f096.tif

    Figure 11-96: Add the new image map to the Displacement Map attribute.

    c11f097.tif

    Figure 11-97: The shader network for the box

  4. Render the box, and see what happens now that you have a displacement map applied. Figure 11-98 shows how the box seems to have exploded!
    c11f098.tif

    Figure 11-98: The displacements seem to be wrong!

    Not to worry—this is to be expected. The values coming from the black-and-white map dictate how much of the geometry is displaced (moved). Obviously, you don’t have an image that works well for the amount of displacement, although it does look like the displacements are in the proper place to correspond to where the carvings are on the box.

  5. Double-click the displacementMap node. In the Attribute Editor, open the Effects heading, and click the Invert check box. This turns the background to black and the carvings to white. Set Alpha Gain to 0.03 in the Color Balance heading, and make sure Alpha Is Luminance is also checked. (See Figure 11-99.) The Alpha Gain value reduces the amount of displacement, and inverting the image lets the rest of the box outside of the carvings not be displaced.
    c11f099.tif

    Figure 11-99: Set the attributes for the displacement image.

  6. Render a frame, and compare it to Figure 11-100. It’s not looking very good. The box isn’t exploding anymore, and only the carvings are displacing, which is good. However, the carvings are sticking out, instead of in.
    c11f100.tif

    Figure 11-100: The carvings are displacing outward.

  7. Set the Alpha Gain attribute to –0.015 to push the carvings in a little instead of out. Render and compare to Figure 11-101. The carvings are set into the wood as they should be, but the render looks bad. The displacements are very jagged and ill-defined.
  8. The jagged look of the carvings has to do with the tessellation of the box—that is, the detail of the box’s polygonal mesh. There are advanced ways to address how mental ray deals with displacements; however, the most basic method is to adjust the detail of the box’s mesh. Figure 11-102 shows the current box’s mesh. Notice that the sides of the box are simply detailed. To increase the box’s faces to add detail, select the box, and then, in the Polygons menu set, choose Edit Mesh ⇒ Add Divisions optionbox.tif, under the FACE section. Set the options to Exponentially and Division Levels to 3, as shown in Figure 11-103. Click Add Divisions to execute.
    c11f101.tif

    Figure 11-101: The carvings are inset into the wood, but they don’t look good yet.

    c11f102.tif

    Figure 11-102: The current box’s mesh isn’t detailed enough.

  9. Figure 11-104 shows the newly tessellated box. It’s far more detailed in the mesh. When you render, it gives a result similar to Figure 11-105. You can compare your work to the scene file boxDetail04.ma in the scenes folder of the Decorative_Box project.
    c11f103.tif

    Figure 11-103: Set the Add Divisions values.

    c11f104.tif

    Figure 11-104: Added divisions

  10. Now that you have the detail you want in the box, you need to prepare the box’s scene file to be referenced back into your lamp lighting scene. Select the ground plane, the renderCam camera, and the three lights in the scene and delete them. Save your work to a new version.

Compare your work to the scene file boxDetail05.ma in the scenes folder of the Decorative_Box project.

c11f105.tif

Figure 11-105: The displacements render much better now.

Notice that the render times increased because you increased the detail on the mesh in step 8. This increase is normal, but it can become a problem if the mesh is too divided and has more faces than you need. This box has fairly detailed carvings, so the level to which you set Add Divisions in step 8 gives a good result without being too detailed. As your experience increases in Maya and mental ray rendering, you’ll learn how to use functions such as the mental ray Approximation Editor to keep the overall detail low on the mesh but with smooth displacement results when you render. This is an advanced technique, so I won’t cover it in this book. You’ve taken in quite a lot by this point already.

The next time you select the box and open the Attribute Editor, you’ll see a new tab called polySubdFace1. This is the node added with the Add Divisions function in step 8. Feel free to adjust the Subdivision Levels setting on that tab and render to see how the detail levels affect the final render. Also try better quality settings in Render Settings, as you did with the red wagon earlier in this chapter, to clean up the render to your satisfaction.

You’ll next add an IBL sphere and use the HDR image you saw earlier in the chapter.

Rendering the Scene with mental ray

You’re all grown up and ready to light a full scene using Final Gather, IBL with an HDRI, and regular lights to get the best bang for your buck out of mental ray rendering. In the previous chapter, you quickly lit the plane, candle, and decorative box with key, fill, and rim lights (the three-point lighting system) and set it to render with Maya Software raytracing. In this exercise, you’ll take this concept a few steps further and change the scene to best use mental ray, so take a deep breath, call your mother and tell her you love her, and let’s get started!

Set your project to the Plane project. Open the planeLightingScene_v06.ma file in the scenes folder. Remember that you turned off the plane’s display layer earlier, so the plane will not be seen when you load this file. This scene has the lights and soft shadows created in Chapter 10 and is set to render through mental ray with raytracing enabled already. Let’s take a critical look at the render from the earlier Figure 11-86.

Now that you have created a more detailed box, let’s update the reference in this scene. Choose File ⇒ Reference Editor. You are currently reading in boxDetail01.mb. Click boxDetail01.mb to select the entry and choose Reference ⇒ Replace Reference. Navigate to the Decorative_Box project’s scene folder and select boxDetail05.mb.

All your work detailing the box will now pop into the lamp lighting scene. Render a frame from the persp camera view. Figure 11-106 shows a comparison of the render from before (top) and the newly detailed box in the lamp lighting scene (bottom). The detailed box looks much nicer now, although you have to tweak the render quality settings in this scene later.

Adding an IBL

Here’s where things get fun. You’ll add an IBL node to the scene and add the living room HDR image to that IBL. First make sure you have mental ray selected as your renderer in the Render Settings window and then follow along with these steps:

  1. In your already open planeLightingScene_v06.ma scene, turn on the planeLayer visibility. Render a frame in the renderCam view, and save it to the buffer in the Render View window. You can also start moving around with your persp camera view again, since you’re no longer focusing on the box.
    c11f106.tif

    Figure 11-106: The render on the bottom shows all the added detail to the box missing from the render on the top.

  2. In the Render Settings window, click the Indirect Lighting tab. At the top, in the Environment heading, click the Create button for Image Based Lighting, as shown in Figure 11-107.
    c11f107.tif

    Figure 11-107: Click to create an IBL.

  3. The Attribute Editor opens to a view of the newly created IBL (named mentalrayIblShape1), as shown in Figure 11-108.
    c11f108.tif

    Figure 11-108: The Attribute Editor for the IBL node

  4. Click the folder icon (c11g010.tif) next to the Image Name attribute. Navigate to the sourceimages folder of the TableLamp project on your system, and select the file livingRoomPanoramic.hdr. You see in your view panes that a large yellow sphere is created in your scene. Set Hardware Exposure to 3 to lighten up the view of the HDR image in the view panels. The living-room panoramic HDR image is mapped. (See Figure 11-109.)
    c11f109.tif

    Figure 11-109: The IBL is in place and mapped to the office chrome ball HDRI.

  5. Use your persp camera to take a good look at the placement of the IBL sphere and the HDR image mapped to it. Select the IBL (you can click the IBL’s yellow wireframe lines or select mentalrayIbl1 in the Outliner), and rotate the IBL sphere to 80 in the Y-axis so that the bright sun in the window is behind the renderCam and the window faces the wing of the plane on the right side of the frame. Figure 11-110 shows the orientation of the IBL.
    c11f110.tif

    Figure 11-110: Rotate the IBL sphere in the Y-axis to 80.

  6. In the renderCam view, render a frame, and you’ll see that the lighting is largely unchanged from your earlier renders in step 1, though you should see more reflections in the plane and the candle’s glass. Next you need to enable Final Gather to take better advantage of the IBL and the HDRI mapped to it.
  7. On the Render Settings window’s Indirect Lighting tab, check the Final Gathering check box in the Final Gathering heading. Click the color swatch for Primary Diffuse Scale, and enter a V (value) of 1.5, as shown in Figure 11-111. This will boost the brightness of the HDRI and will therefore cast more light into the scene.
    c11f111.tif

    Figure 11-111: Enter a value of 1.5 to increase the brightness of the HDRI.

  8. Render a frame and compare it to the image in Figure 11-112. Save the image by clicking the Keep Image icon (c11g007.tif) and compare it to your earlier render before the IBL and before Final Gather. Also notice the bounced light on the redwood tabletop, which is a nice touch, albeit splotchy right now.

    The render is a little bright and quite noisy. You have three lights in the scene already and now an HDRI. Let’s get rid of all the lights and start fresh to convert this to an entire mental ray scene, shaders and all.

    c11f112.tif

    Figure 11-112: It’s a noisy and bright render.

  9. In the Outliner select the three lights in the scene, spotLight1, spotLight2, and directionalLight1. Press Ctrl+H to hide them, which will effectively turn them off in the scene. There’s no need to delete the lights; hiding them will do.
  10. Re-render the scene, and you’ll see only the HDRI contribution to the scene. The render will get more noisy, but you’ll tackle that noise a little later. You will now add some direct light with an Area light, which gives a much nicer lighting than the other lights you’ve used.
    c11f113.tif

    Figure 11-113: Create an Area light and place it as shown here.

  11. In the persp view panel, create an area light (Create ⇒ Lights ⇒ Area Light). Scale it to 3 in XYZ and place it to face the toy plane, as shown in Figure 11-113.
  12. Render the scene (it will take a few minutes), and you’ll see it’s brighter, of course, but the toy plane looks a little bright, like the light is too close as shown in Figure 11-114. Before you change the lighting, let’s re-create the materials with mental ray shaders. This will illustrate how shaders can affect lighting, and vice versa.
  13. Open the Hypershade and MMB+drag the yellow Blinn shader to the Work Area. You’ll start with changing this yellow Blinn to a yellow mia_material, a versatile mental ray shader. With the yellow Blinn selected, choose the Input and Output Connections icon (c11g008.tif) to see the connections for the Blinn shader.
    c11f114.tif

    Figure 11-114: Adding an Area light makes the toy airplane look a little too bright.

  14. In the left side of the Hypershade, click Mental Ray Materials and click to create a mia_material_x shader, as shown in Figure 11-115.
    c11f115.tif

    Figure 11-115: Create an mia_material_x shader.

  15. In the Work Area of the Hypershade, MMB+drag the noiseYellow texture node from the yellow Blinn to the new mia_material_x1 shader, as shown in Figure 11-116. When you release the middle mouse button, select Diffuse from the context menu that appears. This will connect the yellow noise pattern you created earlier to the color of the new mia material. Name the new material yellowMia.
  16. Now, let’s assign the new mia material yellow to the yellow parts of the plane. This is pretty easily done through the Hypershade. RMB+click the old yellow Blinn shader and select Select Objects With Material from the marking menu. This will select all the yellow parts of the plane. Next, RMB+click the yellowMia shader and select Assign Material To Selection. That’s it. See Figure 11-117.
  17. Select the yellowMia shader and notice that the attributes are a bit different from the shaders you’ve seen like Blinn or Phong. The Color attribute in the Diffuse section is the basic color of the shader; that’s where the yellow noise pattern is connected. You need to adjust the specular highlight to make the shader less glossy. Notice there are no specular controls. Instead, with this shader, the specular highlights are controlled in the Reflection section with the Reflectivity and Glossiness attributes. Set Glossiness to 0.35 to lessen the gloss on the yellow plastic and reduce Reflectivity to 0.20 to reduce the shine and reflection you’ll get once you render.
    c11f116.eps

    Figure 11-116: Connect the yellow texture to the new shader.

    c11f117.tif

    Figure 11-117: Assign the new yellowMia shader to the yellow parts of the plane.

  18. Repeat steps 13–17 for the old gray Blinn shader to make a new gray mia_material_x (call it greyMia). This way you can replace the gray parts of the plane with greyMia.
  19. Now that the toy plane has been converted to mental ray mia shaders, render the frame and compare it to your previous render with the Blinn shaders. Figure 11-118 shows the mia shader render of the plane. You can notice some subtle differences in how the mia_material is affected by light when compared to the Blinn render from Figure 11-114.
    c11f118.tif

    Figure 11-118: The mia material creates a more subtle look for the plane, though the scene is still too bright!

  20. Repeat steps 13–17 again to change the shader of the redwood tabletop to a mia material as well (call it floorMia). Except for the floor’s mia material, set Reflectivity to 0.4 and Glossiness to 0.70 to make it a bit shiny.
  21. Lastly, make another mia material. This time, set the Diffuse section’s Color to a medium gray and set Reflectivity to 0. This will be a matte material for the walls. Assign this new shader (call it wallsMia).
  22. Finally, select the Area light and set Intensity to 1.25 to bring down the brightness in the scene. Render and compare to previous renders and to Figure 11-119.

Lighting, rendering, and shading all go hand in hand, and as you can see from the previous exercise, you have to go back and forth to best achieve the look you want. Now you’re not done yet, there is quite a bit of noise in the renders. I’ll address that next. You can check your work (or skip to this point) against the scene file planeLightingScene_v07.ma from the scenes folder in the Plane project.

c11f119.tif

Figure 11-119: Rendering the mia materials on the plane, table top, and walls

Fixing Final Gather Noise

c11f120.tif

Figure 11-120: Using higher-quality settings for FG makes a big difference.

The render from the previous section looks nice, except that it’s noisy. Notice the blotches of light all over the floor. This is from having low-quality settings for FG. On the Render Settings’ Indirect Lighting tab, increase Accuracy to 750 under the Final Gathering heading and Point Interpolation to 80. Doing so dramatically increases the render time for the frame (perhaps even more than doubling the previous time); however, it makes the scene look much better—practically eradicating the blotchy nature of the previous renders. (See Figure 11-120.) Save the image to your Render View buffer.

You can open the scene file planeLightingScene_v08.ma from the scenes folder in the Plane project to catch up to this point or to check your work so far.

FG is a difficult beast to tame, especially with an IBL. It takes a lot of experience, patience, and practice to be able to use this powerful feature of mental ray successfully in scenes. Experiment with different HDR images that you can download from the Internet as well as adjusting the lights in the scene.

Fixing General Render Noise

You may have gotten rid of the blotchy Final Gather noise (mostly, at least), but if you take a close look at Figure 11-120, you can see there is some noise on the back wall. This is coming from the shadow being cast by theArea light in the scene. At first blush you may think to increase the overall Render Settings Quality slider to higher than the current 0.25. And that is not a bad instinct, but this noise is all in that back shadow. If the edges of the plane or decorative box or candle were jagged, then yes, the Quality slider would be your solution. This is all about the area light and its shadow, and for that there is a focused solution.

c11f121.tif

Figure 11-121: Cleaner shadow!

To fix the noisy shadow, go to the planeLightingScene_v08.ma scene and select the Area light. Since this is an Area light and it inherently has soft shadows, there is no Light Radius attribute to set the shadow softness. The softness of an Area light shadow corresponds to the size of the Area light. The larger the light, the softer its shadows will render. Our shadow seems too soft, so let’s make the Area light smaller first to sharpen the shadow a bit.

Select the Area light and reduce its scale to 1.75 in X, Y, and Z. Next, change Shadow Rays (in the Attribute Editor, under the Shadows ⇒ Raytrace Shadow Attributes section) to 12 and render to see the shadow render much cleaner than before. Compare the render in Figure 11-121 to Figure 11-120 where Shadow Rays was set to the default of 1 and the Area light was bigger. The shadow is a bit sharper, more defined, and much cleaner.

Adding Depth of Field

One last item of interest is adding a depth of field (DOF) to the image. This effect adds blur to the render for the areas of the image that may be out of the lens’s focal depth. It can greatly add to the photo-realism of a rendered image.

Select the renderCam and open the Attribute Editor. In the Depth Of Field heading, check the Depth Of Field attribute. Set Focus Distance to 11 and set F Stop to 4. The F Stop setting, like a real lens, sets how much is in focus around the focal distance. With a higher F Stop value, the focus runs deeper than with a low F Stop value. As you adjust your Focus Distance attribute, you can see the blurriness in the camera’s view panel—as long as you have Viewport 2.0 enabled, which it is by default. If not, in the view panel, choose Renderer ⇒ Viewport 2.0.

Figure 11-122 shows the final render of the scene with DOF enabled. Your render times will be longer, and if you want a better render than this one, which has some grain especially in the glass candle holder, you’ll likely need to increase your Quality value. This render can take quite some time, though.

c11f122.tif

Figure 11-122: The propeller is in focus! You’re finished!

The scene planeLightingScene_v09.ma from the scenes folder in the Plane project will take you to this point.

Notice from the render that the back of the toy plane is thrown out of focus, along with the candle, decorative box, and back walls. Experiment with varying focus distance and F Stop values to try different looks for your scene.

Depending on the need and the size of the render, you’ll have to set the sampling levels to suit your needs—but be warned that your rendering times will dramatically increase, easily tripling depending on the quality settings. There are several ways to create DOF in a render that are faster or more controllable than what I’ve covered here. You can render out a depth pass to use with a lens filter in a compositing package such as Nuke to keep render times down. There are also more accurate DOF methods in mental ray and its lens shaders that you can experiment with when you’ve comfortably grasped the overall workflow presented here.

Try also experimenting with the different sampling modes to see whether you can shave time off the render. Finally, adding an Ambient Occlusion pass isn’t absolutely necessary for this render, although it may enhance the look of the contact shadows.

Wrapping Up

When you’ve learned a lot more about lighting and gained confidence with the processes of lighting, rendering, and compositing, you’ll find a wealth of options when you render in several different layers. For example, if this plane, candle, and decorative box scene was a professional job, its render would most likely be split into a flat-color pass, a reflection pass, a specular highlight pass, a shadow pass, an Ambient Occlusion pass, a depth pass, and several different matte passes that separate parts of the scene to give the compositor the ultimate control in adjusting the image to taste.

You may not know what all those passes do right now, but understanding will come with time as long as you continue practicing your CG Kung Fu. Rendering your own color passes and Ambient Occlusions will give you some beautiful renders even without all the other passes. Keep in mind that small changes and additions can take you a long way toward a truly rich image.

Summary

In this chapter, you learned how to set up your scene for rendering. Starting with the Render Settings window and moving on to the different render engines available, you learned how to render your scene for a particular look. Then, I covered how to preview your render and how to use IPR for fast scene feedback. I moved on to cover how to render reflections and refractions, how to create and use cameras, and how to render with motion blur. You tested your skill on a wine bottle scene, and to batch-render it out into a sequence of images, you checked it in a program like FCheck. You also used Maya render layers, overrides, and rendering an Ambient Occlusion pass to make your renders more realistic. Finally, you applied this knowledge to rendering the toy plane, a glass candle holder, and the decorative box using Final Gather and an HDR of a living room.

Getting to this point in a scene can take some work, but when you see the results playing back on your screen, all the work seems more than worth it. Always allow enough time to ensure that your animations render properly and at their best quality. Most beginners seriously underestimate the time needed to complete this step properly in CG production.

After you create numerous scenes and render them, you’ll begin to understand how to construct your next scenes so that they render better and faster. Be sure to keep on top of your file management—rendering can produce an awful lot of files, and you don’t want to have them scattered all over the place.