The lighting that we looked at last term was aimed at lighting for a Playblast. In this lecture we're going to look at lighting for rendering. This splits into two distinct sections:
Render-only light types
Get a new scene, and create some primitives scattered in the centre of a plain. Now create a spotlight, and point it at the objects. Turn ray-traced shadows on, and do a quick render.
Take a closer look at the shadows, and you'll notice that they are very sharp. Perfectly sharp, in fact. This is because the light comes from a single point in space, and thus an object has to either block the light or not block it. All of the lights that we looked at last time produce sharp shadows: spot lights, point lights, directional lights and ambient lights. The first light that we're going to look at today produces much softer shadows: area lights can be partially blocked by an object, as shown by the stolen image on the right.
In the attribute editor of the spot light, change its
Area Light. We will not be able to see this accurately in the viewport, so you might want to flip back to
Use Default Lighting (press
5). When we do a render of this, we get a rather messy image. We can see that the intention is correct, but the image is very speckly. In order to reduce this unwanted patterning, we have to increase the number of
Shadow Rays on the light source. Go into the attribute editor, and under
Shadows / Raytrace Shadow Attributes change the
Shadow Rays value to
20. While we're here, turn the intensity down to 0.5, so that the image isn't so over-exposed. The softness of the shadows can be adjusted by changing the size of the area light: the smaller the light, the sharper the shadow (hence a point light casts infinitely sharp shadows).
You may have noticed when we rendered this image that it took a surprisingly long time for a scene that only contains four primitives and one light: area lights are very computationally expensive. There is a much cheaper way to soften your shadows, but it is less accurate. Change the light to a point light, and turn depth map shadows on. Now scroll down in the attribute editor: just after the depth map shadows check box, there is a
Dmap Filter Size slider. Change the value to 10, and see the effect on the render. The shadows are softer, but the effect is considerably less realistic than that of the area light. The difference is greatly exaggerated when an object casts a shadow on another that is very close: when the two objects are further apart, the shadows tend to look better.
Confusingly, a volume light is not the 3D equivalent of an area light. Instead, it is a light that only affects objects in a certain volume of space. Have a go now: change our light to a volume light (turn the
Dmap Filter Size back down to
1), and situate it as in the image on the left. Turn the intensity up to 10, and do a quick render. You'll see that the light doesn't affect anything outside of its sphere. The type of falloff can be changed by adjusting the
Color Range section of attributes. This sort of light is very well suited, for example, to creating the light from a candle on nearby objects: any objects that are outside its sphere of influence will not be affected, thus reducing the required computation. The shape affected doesn't have to be a sphere: it can be changed from the
Light Shape drop down, and also using the
The light comes from a single point in the default case, but there are a couple of other options: in the
Volume Light Dir drop down box, we can choose
Outward (the default),
Down Axis works like a bounded directional light,
Outward (as we've seen) works like a bounded point light, but
Inward is a bit confusing. It is not a way of simulating a spherical area light pointing inwards; the light still comes from the point in the centre, but it is travelling in the opposite direction. The light still illuminates the same objects as the
Outwards option, but the opposite side of them (for example, in the set up shown above, it would be illuminating the inside of the primitives).
So far, we have only been considering direct illumination: an object will be illuminated if and only if there is a direct line of sight between it and a light source. This works fine in situations with strong light sources, such as stage lighting or direct sunlight, but in other circumstances it doesn't. Imagine we have an anglepoise lamp on a desk, and that it is the only source of light in the room. We will still get illumination of the entire room, despite the fact that the anglepoise is pointing at the desk surface. We will even get light under the desk, though less than in the rest of the room. This is known as indirect illumination. The oldest and cheapest way to fake indirect illumination is to use what's called the "ambient colour" of an object. This is the colour that an object appears on screen, even when no light is shining on it. This creates a very washed out and flat look, as there is no shading depending on the angle of the faces: there are many better ways to simulate this natural phenomenon.
Before we start with diffuse interreflection, though, we are going to look at using caustics. Caustics are the light patterns produced when, for example, is refracted through a crystal ball, or reflected off a gold ring. Maya (via the mental ray renderer) can simulate caustics using a mechanism known as photons.
Create a new scene. Now create a simple ring on a plane, by whatever methods you like. Delete its history, and give it a shiny texture (I'm going to use silver / chrome like). Give the plane a nice texture too, and put a simple (one colour) sky sphere in if you have time. You should end up with something that looks more or less like mine.
Now select the spotlight, and find the
mental ray section in the attribute editor. Since we want this light to create caustics, we will turn on
Emit Photons. Now bring up the render globals (make sure the renderer is set to
mental ray), and find the
Caustics and Global Illumination section, and turn on
This creates our caustics, but not quite the way I intended them: I was thinking a bit more well defined, and not quite as bright. In order to make the photon calculations more accurate, we can do two things: we can either increase the number of photons emitted from the light source (I've turned mine up to 100,000), or we can increase the Caustic Accuracy value in the Render Globals. Both of these routes dramatically increase the render times, so use with care. To reduce the brightness, simply turn the Photon Intensity slider (in the light source) down (to about 2,000).
Note that we can do the same thing with refraction. Try creating a refractive sphere in place of our ring: you shouldn't need to change any other settings to get the "magnifying glass" effect.
Global illumination in Maya is again implemented using photons. For a more (read: very) in-depth description about photons, have a flick through Henrik Wann Jensen's 2001 book1: it is jam-packed full of terrifying maths and I wouldn't recommend buying it unless you're sure you're going to need it for one reason or another. I have a copy in PG15 if you want to have a quick look.
To explain global illumination, get a new scene with a white box for a room (delete one face so we can see in easily) and a vividly coloured sphere on the floor. Create a spot light that is pointing directly down onto the sphere, and turn shadows on (note: turn on the
Shadow Map check box in the mental ray section, not the normal Maya section).
Now turn on
Emit Photons on the light, and
Global Illumination in the render globals. If you press render, you'll discover what many have discovered before you: global illumination doesn't work right first time, it usually takes a lot of tweaking.
The blotches are caused by us being able to see individual photons, so let's increase the number of photons (to 200,000) and also increase the accuracy to 256 in the render globals. The image is less blotchy now, but, as I said, global illumination takes a lot of tweaking to get it just right.
Notice the blue colour on the floor: this is known as colour bleeding, and is a result of the diffuse interreflection I was talking about earlier.
Global illumination and final gathering are often used together, but here we're going to try them separately. First, turn off photons on the light and global illumination in the render globals, and turn on the
Final Gather check box in the render globals. This should add a little diffuse interreflection, but this method doesn't use the lights themselves (we just turned photons off), it looks at the brightness of the object (which can be affected by the lights). Add some incandescence to the blue sphere, and see how this affects the outcome. Then turn the intensity of the light down to zero. Because of the incandescence, the sphere still lights up the floor. Notice that we can turn the V value (of HSV) higher than 1, and the result will be that the object is even brighter, and will light the environment better.
Now we are going to try replicating "Construction in Wood, A Daylight Experiment", a sculpture by John Ferren. The original sculpture, the visible surfaces of which were entirely white, was placed in front of an open window. The sculpture works by having bright colours on the faces pointing towards the light (i.e. away from the viewer), which then "bleed" onto the white faces which are pointing towards the viewer. To replicate this in CG we have to use some form of indirect illumination.
Open up the scene
The sculpture should be viewed from the side opposite the spot light. Use either global illumination, final gathering or both to bleed the colours from the back to the front. In the example shown here I used global illumination.
1JENSEN, H. W., 2001. Realistic image synthesis using photon mapping. Natick: A K Peters, Ltd.