The Basics of the Art of Lighting (part 3): Lighting and Shaders

By Audri Phillips

This third part of a series on lighting basics is devoted to the interrelationship between shaders/materials and lighting. It takes advantage of some features of Mental Ray to show you a quick and easy lighting setup that yields good results.

Object Materials and Textures

When considering the objects you are lighting, think about what kind of materials the objects are made of. Are they highly reflective and refractive? Do they create caustics? Do they have a shiny or matte finish? Are they bumpy or smooth? Object qualities influence the shader and lighting rig choices you make.

Every 3D program has a number of different shaders for simulating different types of materials. Think of shaders as containers for software instructions used mostly to calculate rendering. Different shaders contain different sets of instructions and attributes, and these attributes help define the look of the object. For example, ambient, diffuse, transparency, reflectivity, translucency, and bump settings are a few of the more common attributes.

Often, bitmapped images-commonly called textures-are added to a shader network for use with photographs, digital paintings, or analogue paintings that have been scanned in. Putting a texture into a shader network on a computer-generated (CG) object is called texture mapping. Assigning a shader to an object is also often called assigning a texture.

When trying to make something look photoreal, what could work better than starting with a photograph? I was a texture painter on the first Spiderman film. Most of the New York City that Spiderman was flying through was a totally digital creation. Photographs of the buildings were taken, and for the most part, we refit these photos back onto the CG buildings. We used the photographs as texture maps. Of course, that wasn't all that was done to make the CG buildings look right, but it was a good starting point.

When taking your own photographs to be used as textures, strive to have the image evenly lit. You want to create as few shadows and highlights as possible. You also want to make your photograph sharp and evenly in focus. Often, you then want to make your image seamless so that your texture can tile. You can do this easily in Adobe* Photoshop* using the offset filter and the clone brush.

Lighting, Texture, and Shaders

There is a marriage between the lights you use and the shaders that you assign to the objects you're lighting. The same lighting on an object can look very different if you place a new texture on it or there is a change in the shader you assigned. That is why lighters often have to wait for objects to be completely surfaced (shaders created and assigned to them) before they can make the final adjustments on their lighting. There is an especially big difference if the color values of the textures change radically from the start of the lighting process to the final look. There's a reason lighters are at the end of any pipeline.

Most of the shaders in Autodesk* Maya* contain a similar set of attributes, while many of the Mental Ray shaders are more specialized with fewer attributes. So, when using Mental Ray shaders, you can daisy chain a number of them together to get all of the attributes you need assigned to your objects. This specialization can give them their quality. In Figure 1, look at the attribute list for the basic Maya blinn shader in Autodesk* Maya* compare to the attribute list for the Mental Ray blinn shader.



Figure 1. The blinn shader in Autodesk* Maya* and Mental Ray

Using Specular Highlights to Distinguish Materials

One important attribute that you control both in lights and shaders is the specular highlight on an object. Note that when you talk about specular highlights, you're really talking once again about reflected light-light reflected from a surface. A specular highlight is light that is reflected from a surface but in a certain way, as shown in Figure 2. Notice that both blinn shaders in Figure 1 have the specular attribute. It is one of the defining attributes that let you know what kind of material an object is made of. It can be turned on or off in the light, as well. A softer material such as cloth generally causes no or little specular highlight, while a hard, smooth material one does. As a Maya Lambert shader has no specular highlight, you might use it for cloth or chalk or very matte finishes, while a Maya phong E shader, with its broader specular highlight, might well be used for a glossy plastic surface like certain bathroom moldings or car surfaces. You could use a Maya blinn shader for a metallic surface.



Figure 2. Different materials have different specular highlights. In general, the harder and smoother an object, the sharper the specular highlight; the softer and less smooth an object, the broader and softer the highlight. You may not be conscious of it, but you are always making decisions as to the material objects are made of by using the specular highlight.


Figure 3 shows common Maya shaders. These shaders are assigned to objects and give them their look.


Figure 3. Here are some of the most commonly used Maya shaders. Notice how the representation of their specular highlights is what differentiates one from another. The Lambert shader has no highlight at all.


What Is Specular Light?

Specular light is a light that has close to parallel rays. A specular highlight is really a mirror-like reflection of the specular light back from an object. The light comes in from a single direction and is reflected out again in a single direction, making the same angle with respect to the surface normal (Figure 4). This reflection makes the specular highlight view dependent. Walk around any surface that has a specular highlight and notice how the highlight is constantly changing.


Figure 4. Specular highlights are view dependent, because they are based on the light source.


The image you see in a mirrored surface such as a still lake reflecting the sky or a mirror reflecting your face is also a specular reflection, but it is a specular reflection of one object into another, so more than one light bounce is involved. The light ray comes from the light source, hits the reflective object, reflects off it, then hits the reflective surface and bounces off of it.

A diffuse reflection is caused by light that reflects from the surface in multiple directions. A diffuse reflection-sometimes called a glossy reflection-can result when light hits a bumpy surface, causing the light to be more scattered as it bounces back. Some surfaces, such as most cloth materials, scatter the light so much that there will be no specular reflection at all. That is, it's a less spread out diffuse reflection. You can also generate blurry reflections this way.

This is where the more specialized Mental Ray shaders come into play. Different Mental Ray shaders have different parameters and attributes to refine and control how an object reflects light. Using the Mental Ray shader dgs_material with the attributes glossy specular and shiny and adjusting the parameters, you can control the look of the highlight (see Figure 5).


Figure 5. Both spheres have Mental Ray shader dgs_material applied to them. The specular highlight is different on the two spheres, with the difference mostly being created by the shiny attribute settings. The left sphere has the shiny attribute set to 39.454, while the sphere on the right has a shiny setting of 8.366. The dgs_material shader is often used to simulate mirrors, glossy paint, or plastic.


Toon Shaders

There are many types of shaders, some very specialized. Toon shaders are no exception. At one end of the spectrum from photorealism are the toon shaders that are often used in games. Toon shaders were developed to simulate the look in a 3D animation of a 2D cartoon made traditionally in cel-based animation. Although a variety of toon shaders are available, most essentially assign a light value to each pixel, then map those values to a small number of discrete values-values usually on a texture map or some form of ramp texture. In this way, the colors and shading become distinct, hard-edged shapes.

You can create the black outlines in a variety of ways. For your lighting, you would also want little or no specular highlights: In 2D cell animation, the highlight will stay where it is painted. I used toon shaders when I was art directing a ride film. Then, I used the 3D program Lightwave and set up an even, ambient light over the whole scene and had one key light casting the shadows (see Figure 6).


Figure 6. Image courtesy of Jennifer Hachigian, who was one of the artists on the ride film (see resources)


Bringing In HDRI

You may decide that you want a look that is a bit more photorealistic than tune shading. A popular method for creating photorealistic imagery is incorporating high-dynamic-range imaging (HDRI)-also known as image-based lighting-maps into a global illumination system. An HDRI image contains extra information, a wider dynamic range, and can be used by 3D programs to create very realistic lighting and reflections. This wider dynamic range allows for the image to contain the whole range of intensity levels-for example, from the brightest sunlight to the dimmest light bulb or far-away star. So, an HDRI image often looks very dreamy, surreal, and oversaturated because of the wide range of exposure levels in it.

You create HDRI images either from computer renderings or by capturing a view of a scene with multiple photographs and multiple exposures taken using exposure bracketing. These multiple images and exposures are then merged into one HDR image. You can even use Adobe* Photoshop* CS2 to merge your images. To do so, in the File menu under the Automate drop-down list, click Merge to HDR.


A Quick and Rewarding Way to Set Up Lighting

I thought it would be good to close this article to show you a lighting setup to use in Autodesk* Maya* that employed image-based lighting with the mentalrayIblShape ray in combination with painting with lights and final gather. I always get good results fairly effortlessly with this setup. In short, the mentalrayIblShape is a Mental Ray for Maya plug-in node that simulates light emitted from an infinitely distant sphere. You can use this sphere to light your scene and map the texture of your choice onto it. Using it alone without having final gather turned on, it acts like a spherical area light. You can map a texture map that has been generated from a real environment or your CG environment onto the sphere.

Earlier, I mentioned using HDRI images: Here is where you can be one. Such an image would be especially useful if you want to try to match the lighting of the scene the HDRI image was created from. In this case, I just take a sky image that is not an HDRI image and map it onto the sphere. When using this sphere, I turn on final gather and accept the default settings for it. The falloff start and stop settings of 0 for final gather mean that Mental Ray is calculating your scene size for you. It will take into account your mentalrayIblShape and give you the best computational values for your final gather rays reaching the sphere and picking up its colors.

Note: Because the sphere is infinitely distant, scaling it will have no effect on the environment. However, rotating the sphere will, as your colors will be placed in a different relationship to your scene. Some advantages this sphere has over your creating-say-a nurbs or poly sphere and mapping a texture onto it is that I don't have to set the distance my sphere is away from my scene. In addition, a real piece of geo would slow down the render more.

Setting Up the Lighting To set up the lighting, perform the following steps:

    1. Open the Render Settings window.
    2. In the Render Using drop-down list, select mental ray.
    3. Click the Indirect Lighting tab (see Figure 7).

      Figure 7. Make sure that you select the Final Gathering check box, but leave the Final Gathering default settings. The attribute editor for the environmental sphere (mentalraylblShape1) opens.


    1. In the Image Name field, browse to your image file.

      You can also choose to load your file in as a texture (choose Texture as the type instead of Image File), and then browse to the image. This might give you better results, because if you choose an image file as the type, Autodesk* Maya* down-filters the image file, but the texture will be point sampled. See Figure 8.



      Figure 8. Note that for Type, you could also choose Texture, and then load the file as a texture.


  1. Pull back in your camera panel window far enough to see the environmental sphere (mentalraylblShape1) (see Figure 9).

    Note: You will have to increase the default setting for the camera clipping plane.



    Figure 9. Notice that in the render stats, primary visibility can be off or on. If it's off, the sphere still works as a light and color source, but it does not render.

Test Renders

I set up a test scene and will be rendering it in several different ways. In this first version of the scene-shown in Figure 10-I render it with just one directional light.


Figure 10. This is the scene lit only with one direct light. The sphere is in the scene, but all of its render attributes except primary visibility have been turned off. The one directional light, which is meant to emulate the sun, has ray tracing turned on.

Figure 11 shows the same scene, but now the render attributes of the sphere have been turned on.


Figure 11. You can see that the sphere is essentially acting as a big colored area light. In this image, you can also notice the softness of the ray-traced shadows.

In Figure 12, final gathering has been enabled as well.


Figure 12. This is the same scene but with final gathering turned on.

You can see how final gathering picks up the colors of the sky. In brief, final gathering is a global illumination system in which the area surrounding every point in a scene is sampled. Rays are sent out from each point to do this sampling, and you set the distance the rays travel to perform this sampling. The rays travel out to the mentalraylblShape and sample it, but every object in the scene becomes a light source.

In the render shown in Figure I3, I added a Mental Ray Dgs_material shader onto one of the spheres.


Figure 13. I've added a Mental Ray Dgs_material shader to one of the spheres. You can see the specular highlights and reflections on it.

In the final render shown in Figure 14, I put in a volume primitive to create some low fog and a Mental Ray depth of field shader on the camera.


Figure 14. This is the final render, in which I added a volume primitive and a Mental Ray depth of field shader on the camera. The shapes were added to help show the depth of field and fog.


Conclusion

This article explored the relationship between lights and shaders. You will often hear the term color and lighting as referring to both lights and shaders. Often, the CG programmers have used real-world physics principles as to how light and materials interact in our 3D programs. I picked out specularity as one example of this, which is important in simulating a material, and it is controlled both in the lighting and the shader. The global illumination system I demonstrated also attempted to emulate real-world lighting. Future articles will talk more about shaders and how to simulate different materials as well as more about global illumination systems.


Resources

http://www.celshader.com/ - View more animation and artwork by Jennifer Hachigian



About the Author

Audri Phillips is a Los Angeles–based artist currently working and exhibiting in a variety of media ranging from computer animation and motion graphics to her more personal work-oil paintings and video art (visual poetry). She has worked for more than 25 years as an artist/digital artist in the entertainment industry in Los Angeles at such studios as Disney Feature Animation, Sony Imageworks, DreamWorks Feature Animation, Rhythm and Hues, Digital Domain, and Electronic Arts as well as a number of small design boutiques. Her production experience includes art direction, design, visual development, storyboards, and color and lighting. Examples of her work are available at http://www.audri.com, http://www.alternatesight.com, http://visualmusic.ning.com/profile/AudriPhillips?xg_source=profiles_memberList, http://www.absolutearts.com, and http://www.lynda.com.

For more complete information about compiler optimizations, see our Optimization Notice.
Categories: