You are on page 1of 34

Chapter 11: Lighting: Tutorial

By Roland Hess

While lighting is extremely important to the quality of a final render,[KM] and good setups can run the gamut
from basic to complex, Blender's lighting tools themselves are simple to use.

Open the scene called "Lighting Tutorial.blend" that is found in the "lightingexamples" folder of the included
CD.

The "lighting tutorial.blend" file when first opened.

If you were to render this scene right now (F12), you would get nothing but a completely blank image.
Although the models and textures are complete, nothing will render without lamps.

Use the toolbox (Spacebar) to add a standard Lamp to the scene.


The toolbox adding a lamp.

Like any other Blender object, new lamps are created at the current location of the 3D cursor. They can be
moved (G-key) or rotated (R-key), with the transform manipulators and mouse gestures working as well.
salthough scaling should be avoided. In fact, scaling Lamps in Blender can create serious problems with
your scenes., as dDistance, energy and shadow settings can be sensitive to the scene's overall scale of a
scene, and using the Scale tools on them can lead to unexpected results. The transformation manipulators
and mouse gestures will also work with lamps.

With the new Lamp selected, find the Lamps subcontext of the Shading context, commonly referred to as
the Lamp buttons. In the example file, the buttons window is already set to the Lamp buttons.
The lamp buttons.

The type of lamp we you[KM] have added to our your[KM] scene is often referred to as a "point lamp,"[KM],
although that term is not used in the Blender interface. A point lamp casts light equally in all directions, using
the lamp's location as the light source.
Lamp with arrows showing to how it lightsThe arrows show how light shines in all directions from the
standard lamp.

Try a render (F12) to see what the scene looks like with a single point lamp at default settings.

Note: You can also use the Shift-P preview panel that was demonstrated in Chapter 2 to get a quick faster
idea of how your lamps affect the scene.
render without shadowsRendering without shadows makes the vase seem to float.

One thing you'll notice about the render is that while the objects are illuminated on the side facing the lamp
and dark on the side facing away, there are no cast shadows. You would think that light sources should
always cast shadows like they do in the real world. Shadows, however, require extra calculations at render
time, which can slow things down. In addition, some scenes may have complex lighting setups using dozens
of lamps, not all of which need to show shadows for the scene to be believable. For those these[KM]
reasons, shadows in most CG programs, Blender included, can be enabled or disabled.

Let's turn on shadowing for our your[KM] point lamp. In the Shadow and Spot panel, press the "Ray
Shadow" button. Now re-render. That's all there is to using a point lamp.

Note: If no shadows are rendered after enabling clicking "Ray Shadow,"[KM], be sure that the "Ray" button
is enabled in the Render panel of the Render buttons (F10).
render with shadowsThe vase now looks like it makes contact with the tiles.

From a top view (Numpad-7), press Shift-D to duplicate the point lamp and move it to the other side of the
scene.

If you have added the wrong kind of lamp to your scene and would like a different kind, you don't need to
delete it and create a new one. The Lamps panel in the Lamp buttons lets you switch the actively selected
lamp into a different type. Change the duplicated lamp into a Sun lamp by pressing the "Sun" button on the
Preview panel.

A Sun lamp has the same set of options as a standard Lamp in the Lamp buttons, but works a little
differently in the 3D view and has a very different effect on a render. Recall that the standard Lamp
broadcasts light in all directions from it's[KM] location. A sun lamp does not shine light from a single location,
regardless of where the lamp is located in the scene. It creates uniform lighting coming from a single
direction.
sun lamp in 3D view with arrows showing how light comes from itAll light from a sun lamp flows in the same
direction.

The direction is controlled by the rotation of the lamp in the 3D view, visualized by the dashed line attached
to the lampit. All of the light generated by a Sun lamp will shine parallel to this line. To see the difference
between the parallel shading and shadows of a Sun lamp and a standard Lamp, move the lamp fairly close
to the vase and orient rotate the lamp's direction tolamp to face it.
sun lamp close to vase, pointed toward it.[no text]

Render the scene. With the Render view still up, press the J-key. This will switch the render out to themove
the render to an alternate render buffer, so we you[KM] can easily compare it to the next step.

Back in the 3D view, change the Sun lamp back tointo a stand standard[KM] lamp and render again.

When the render is finished, you can press the J-key several times to toggle between the two versions of the
render. It's quite obvious when doing this how the light sources differ greatly in their effect, even though their
controls are mostly the same.
render of scene as sun lamp and as standardThe sun lamp render is on the left. Even though the lamp is
nearly touching the vase, notice the parallel shadows it casts.

Now that we've introduced you to[KM] the absolute basics of lamps (creation, positioning and shadow
activation), we'll you'll[KM] create two different lamp setups, one each on a different layer, to learn the rest of
the lamp controls.

Three Point Lighting

The discussion section of this chapter talks about some of the weaknesses of this very traditional method,
common in studio lighting, but using it will give us you[KM] a good chance to learn some additional
techniques.

Three point lighting makes use of... three lamps!. Surprise. One lamp provides a direct light[KM], to show the
details of the subject (the vase in our the[KM] example). Another lamp shines from a different direction and
fills in the areas that are cast into shadow by the first lamp. A third lamp shines from behind and above,
throwing a bright rim of light around the back and top edges of the subject.

We'll You'll[KM] start by creating the first light, called the "key" light. Select and delete (X-key) the two lamps
that are already in our your[KM] scene.

Add a new Spot lamp at about the location shown in the illustration. We've split our 3D view into two
separate views so you can better see the placement of the lamps.
spot lamp added for key lightThe 3D cursor positioned before the creation the Spot lamp.

Using either the hotkeys, the manipulators or mouse gestures, rotate the spot lamp until its central targeting
line passes through the vase.
spot lamp with line passing through vase.[no text]

Spot lamps have quite a few more controls than the other types of lamps we've you've[KM] seen so far.
Almost all of those settings are related to shadows, and we'll examine them in a moment. For now, duplicate
the Spot lamp twice with Shift-D and position and rotate the two new lamps as shown in the next illustration.
three spot lamps in 3 point lighting configurationSee if you can get close to this lamp configuration.

A render with this setup produces bland results.


three lamp render without adjustmentsThree point lighting with three identical lamps.

What we you[KM] need to do is to adjust the intensities of the lamps to give the image better contrast. Select
Spot number 1, the key light, and adjust the value of the Energy slider on the Lamp panel to around 2. Also,
change the R and G values in the RGB sliders to 0.6. As you can see in the color swatch below the sliders
and in the Preview panel, this will change the key lamp to a light blue.
lamp panel showing energy=2 and rg=.6[no text]

Spot number 2 is called the "Fill" lamp, because it fills in the areas that are not illuminated by the key lamp. It
should be a more subtle light, so turn its energy down to 0.60, and reduce its Blue slider to 0.5.
lamp panel for fill light[no text]

Finally, select Spot 3, the "Back" light, so called because of it's placement behind the subject. It will give the
vase a bright rim around its upper edges. Leave the color alone (R, G and B all stay at 1.0), but change its
Energy slider to 5.0.
render with energies and colors adjustedA much more interesting render.

There are a couple of ugly things that are ugly in about this render that can need to be fixed. First, the
specular highlighting from both the fill and back lamps looks bad on the wooden frame of the base, as well
as on the highlight on the left side of the vase. We You[KM] don't want it to lose the highlights from the key
lamp, though, so we you[Km] can't just turn off specularity in the vase's material. Blender allows you to
enable and disable both specular and diffuse shading on a lamp-by-lamp basis.

Select the fill lamp (number 2), and click the "No Specular" button on the Lamps panel. Do the same for the
back lamp (number 3). You can re-render to see the effects.

Another problem is the shadow being generated by the back lamp. If you examine it closely in your render
window, you can see that it becomes pixelated (boxy) around the edgededges[KM]. In our first experiments,
we enabled the "Ray Shadow" button on the standard and Sun lamps. That type of shadow generation
always results in sharp, accurate shadows with no user configuration. Those shadows come at the cost of
speed. In contrast, the default shadowing method for Spot lamps is called "buffered shadows."[KM].

Each time an image is rendered using a lamp that has a buffered shadow, a special mini-render is done of
the scene from the point of view of the spot lamp. An image is created of how far the objects in the scene
are from the lamp. This kind of image is called a "shadow map."[KM]. When the final render is done, that
shadow map is used to decide if there is anything between the part of the object being render rendered[KM]
and the[KM] lamp, creating shadows.
If you're thinking ahead, you may already realize why the shadow being generated by the back lamp looks
pixelated. . It's because the shadow map, being an image, doesn't have enough resolution (enough pixels)
to cover the area of the scene it is being asked to cover.

We You[KM] can control the size of the shadow map with the "ShadowBufferSize" spinner in the Shadow
and Spot panel. Select the back lamp and set its ShadowBufferSize to 2000. Re-render to see the shadow
from the back lamp with a much nicer edge this time.

There is one other huge problem with the shadow from that back lamp, one you may not have even noticed:
there seems to be light leaking through the vase!

fixed shadowbuff size, but highlighting light leakSome problems have been cleaned up, but light is bleeding
through the vase.

Where is that coming from? Without being too technical, we'll just say that at some point during the creation
of the shadow map, the wall of the vase was too thin to be detected. The result is an inaccurate map and a
bad render. To fix problems like this, turn the Bias setting on the Shadow and Spot panel to 0.3. Re-render,
and the problem has gone away.
fixed render.Much better.

You might be thinking at this point that tweaking buffered shadows is a pretty big pain and wondering why
you shouldn't just use ray shadows all the time. The first reason is speed, and the second is flexibility. If you
like, note your render time for using buffered shadows on the Render window. Then, switch each of the
lamps to use ray shadows, re-render and see the time difference. On my the[KM] test computer for this
simple scene, the difference is that buffered shadows are almost 20% faster than ray shadows.

The second advantage, and probably the most important, is flexibility. Buffered shadows allow you to easily
create blurred shadows, which can give an image a softer, more realistic look. To show this effect, set the
Soft value of the back lamp to 10 and re-render. To increase the quality of the softening calculations, you
can raise the Sample value.
soft shadowingThe back light's shadow, softened.

Callout: When working with buffered shadows, there are several things to watch out for:
- PIxelated Pixelated[KM] (blocky) shadows can be fixed by raising the ShadowBufferSize.
- Light leaks in a shadow, as well as a shadow not quite meeting the bottom of the shadow- casting[KM]
object, can be fixed by reducing the Bias value.
- Buffered shadows can be blurred by raising the Soft value.

There are two more things we you[KM] can do to increase the quality of our your[KM] buffered shadow. The
first is to adjust the Spot lamp's cone that you can seeappears in the 3D view. The cone that emanates from
the lamp shows the area of light that is projected. Nothing outside of this cone receives any light from the
lamp. You Your[KM] goal as a lighting technician in Blender is to get that cone to be as small as possible,
while still encompassing the objects in your scene.

Adjust the area the spotlight covers by reducing the SpotSi (Spot Size) slider on the Shadow and Spot
panel. In the case of our the[KM] example, I waswe were[KM] able to reduce it to 15.00. Note in the
illustration how much smaller the cone is than before.
smaller light coneTry to achieve the tightest light cone that will cover your objects.

The second adjustment that can assist with spot quality deals with something called clipping. Clipping is just
another way to limit what the shadow buffer creator creation process sees. The defaults that you can see at
the bottom of the Shadow and Spot panel are 0.50 for ClipSta (Clip Start) and 40.00 for ClipEnd. This
means that Blender will create a shadow map for objects that are between 0.50 and 40.00 units from the
lamp. Nothing outside of that range will be able to cast a shadow. Like the size of the Spot lamp's cone, we
you[KM] want to keep this range as small as possible while still encompassing all of the objects that need to
be included.

The newest version of Blender allows you to set this the clipping values automatically. To do so, click the
"Automobile" button (Get it? Auto?) to the left of each Clip spinner on the panel.

In a rudimentary scene like our this[KM] example, none of these optimizations make much of a difference to
rendering speed or quality. It is when scenes grow in complexity, to hundreds of thousands of faces, and are
rendered thousands of times for an animation that these controls really begin to prove their worth.

One final word about buffered shadows. If all of these settings seem overwhelming, but you want the speed
of buffered shadows, you are in luck. In addition to the default method of buffered shadow creation (called
"Classic-Halfway" for technical reasons), there is another method called "Irregular."[KM].

Select the key lamp (number 1) and change the drop down menu below the "Buf. Shadow" button to
"Irregular."[KM]. The ShadowBufferSize and several other controls disappear. Irregular shadow buffers give
very nice edges without the downsides of raytracing. Adjust the Bias on this lamp to 0.300 and turn on Auto
clipping for both ClipSta and ClipEnd.

Final render with 3 three point lighting setup.

That's a decent lighting setup for our your[KM] scene. We'd like you[KM] to make one more, but we've
you've[KM] spent so much time on this one that it seems wrong to completely discard it. Rather, we'd just
like you[KM] to get it out of the way. Select all three lamps, then press the M-key, which, if you remember for
from the Object chapter, will bring up the Layers palette.

Use the mouse, or press the 2-key, to put the lamps on Layer 2. Unless they are on a visible layer, lamps
will not add light to a scene. Therefore, using layers to hold different sets of lamps is a great way to manage
different lighting setups.

With those lamps sent to Layer 2, let's create a new lamp directly above the scene. This time, select the
"Hemi" style of lamp from the toolbox. If you create the lamp in a top view, it will be facing directly downward.
If it isn't, use Alt-R to remove any rotations.
new hemi lamp, arrowsThe Hemi lamp illuminates from an imaginary hemisphere.

The purpose of a Hemi lamp is to light every object in the scene as though it were in the middle of a giant,
glowing hemisphere. Hemi lamps are like Sun lamps in that their location doesn't matter -[KM]-- only their
orientation. Hemi lamps do not cast shadows.

Here is a render of the scene with the Hemi lamp's default settings.
hemi lit scene. The scene lit with a single Hemi lamp.

Obviously, Hemi lamps aren't really suitable by themselves. They are good, however, for adding a little bit of
light to a scene whose shadowed areas appear too dark, or to give an overall color cast.

Since we'll you'll[KM] be using it as a sort of background illumination, let's reduce it's Energy slider to around
0.4, and turn off specularity by pressing the "No Specular" button.

Now, we'll you'll[KM] add the last kind of lamp:[KM], an Area lamp. Create one with the toolbox, and position
it as shown in the illustration.
area lamp added[no text]

Area lamps are directional, so we you[KM] will need to point it at the vase. The fastest way to do this is to
first select the Lamp, then Shift-RMB select the vase and press Ctrl-T. Choose "TrackTo Constraint" from
the menu that pops up. Ctrl-T tells the selected object to point toward the Active object, regardless of where
it is. A lamp that is tracked this way will even automatically follow an animated object.

With the Area lamp as the Active object again, enable "Ray Shadow" in its Shadow and Spot panel. Turn
"Samples" up to 4 once Ray Shadow is on. Set Energy to 0.25.
area lamp settings[no text]

When you render, you should see something like this:


area lamp render[no text]

Notice the softening shadows? Although it uses raytracing to calculate the shadows, they aren't sharp. Why
not? An Area lamp simulates what would happen of if[KM] you had a grid of ray-traced Sun lamps. The
Sample spinner tells the Lamp how many raytraced lamps to include in its calculations. In this case, the
value we you[Km] assigned, 4, told it to make a grid that was 4 lamps by 4 lamps, giving a total of sixteen
lamps.
faked sun lamps, with renderThe render from a grid of Sun lamps is similar to that of the Area lamp.

Here, you can see a real Sun lamp arrayed on a 4x4 grid. The resulting render looks much the same as the
one from the Area lamp.

Area lamps can give a realistic effect with respect to shading and shadowing, but it comes at a cost.
Because it istheytheir shadows are[KM] raytraced, it rendering[KM] can be slow. As the Samples value
increases, quality goes up, but speed suffers.

Another issue with Area lamps is that distance from the subject can be important. They are tuned for optimal
lighting conditions at the distance noted in their Dist control on the Lamp panel. This value is shown by the
central targeting line extending from the lamp in the 3D view. Moving a lamp much closer or further from the
subject than its distance value suggests can result is drastically increased and reduced energy levels,
respectively.

Before we move on to the final method of lighting a scene, we'll add one more trick to our your[KM] lamp
knowledgelook at one more technique. Although we'll you'll[KM] do this to the Area lamp, it will work for any
of Blender's lamp types.
The Lamp tTexture and iInput panel.

On the Texture and Input panel in the Lamp buttons, use the menu selector below the Add New button to
find the texture called "Branches."[KM]. Then click on the "View" button below the texture selector to change
the way the texture maps with the light. Lamps can have standard Blender textures attached to them., and
tThose textures can be used to change the color of the light. One of the best uses for this is to fake the way
that light filters through a tree's branches and leaves.

Of course, you could also model an actual tree with leaves, and have the lamp shine through it, casting real
shadows. But most times, going to such trouble will not be worth the difference in the resulting renders.

Render again, and see how the Branches texture affects the light.
branches renderThe branch pattern of the image texture is cast from the lamp.

The Branches texture was already created for you, but you can use any of the texturing tools reviewed in the
Materials and Texturing chapter to create textures for your lamps. They can be layered, just like Materials,
and their scales and offsets adjusted and animated separately. For example, if you wanted to make a fairly
convincing animation of a branch shadow pattern moving in the wind, you could create three different branch
textures, stack them, and animate them each to move in a slightly different way. While that probably wouldn't
hold up if it were the featured portion element of a scene, it would certainly suffice for background work.

At this point, you can push the Clear button to remove the texture from the lamp.

In addition to lamps, Tthere is one more method of adding light to a scene. It produces excellent results, but
can be slow. Do you see a trend here?

Ambient Occlusion

Select and delete the Hemi lamp we you[KM] created earlier. Select the Area lamp and send it to Layer 3 to
get it out of the way for a moment.

Find the World buttons (F8), which are another subcontext of the Shading buttons, like Lamps. Click on the
"Amb Occ" tab to bring it to the front. Ambient Occlusion refers to a technique that raytracing renderers can
use that causes faces that are both near and pointing at toward other faces to appear darker, and faces that
are far, or pointing away from, other faces to appear lighter. To see the effect in practice, click on the
"Ambient Occlusion" button in the Amb Occ tab, then render.
amb occ tab with settingsDefault Ambient Occlusion settings.

The render is grainy, but notice how the tiles under the vase have a subtle shading to them, which makes it
look like the vase is casting a slight shadow. Also, the lower portion of the vase is darker than the top, as its
lower[KM] faces are pointing toward the tiles, while the faces on the upper part are facing the "sky."[KM].
And all of this with no lamps! This method of lighting a scene can be excellent when you want believability
with very little configuration and have rendering time to burn.
amb occ render with default settingsA render lit only with Ambient Occlusion.

Raising the Samples value for Ambient Occlusion smoothes out the graininess, but, of course, takes longer.
It's quite common to work on a scene that will include Ambient Occlusion with a very low sample value, like
2, to enhance speed for[KM] while you get things as you want themtweak the rest of the scene. After that,
you can turn it up to 10 or so for your final render and get yourself a cup of coffee.

To demonstrate how believability in an image can be significantly enhanced by using Ambient Occlusion
(often usually referred to as "AO"), let's bring back our Area lamp. Enable Layer 3 (by Shift-LMB on the
Layer 3 button on the 3D header, or by using Shift-3), and render). Since the AO is already adding a
significant amount of light to the scene, turn the Area lamp's Energy slider even further down to 0.1. Render.

The result is a softly lit scene with a high degree of believability. If you would like to really remove the grain
in the render, change the AO samples to 10 and check the new result. AO samples can be set as high as
16, but excellent results are usually achievable without going that far.
final renderThe final render.

Conclusion

Lighting is an art form in itself. Large CG companies have artists on staff who do nothing but lighting. It is a
complex topic , one that can make or break a scene. While we've shown you the mechanics of using
Blender's lighting tools in this tutorial, we encourage you to work through the discussion section of this
chapter, and to seek out other resources to enhance your artistic abilities.