Game Development Reference
In-Depth Information
of dynamic lights, and a second lightmap for objects further away. This means
that when objects are far from the player, a lightmap is used to illuminate the
surface and the painted shadows are used. Objects closer to the player use the
second lightmap, but also make use of dynamic shadows. What is so cool about
this is that Unity will dynamically transition from one lightmap to the other, and
from not using dynamic shadows to making them visible. This allows for very
sophisticated lighting schemes to be baked into the scene, yet allow dynamic
elements to move and cast realistic moving shadows when close to the camera.
Warnings and Pitfalls
For a sunny day where
the shadows are crisp,
shifting to real-time
lighting can be a really
nice solution. However,
in the steps to follow,
we will be taking a lot
of care to try and make
sure that the shadows
are all sorts of soft. If the
real-time lighting kicks in,
suddenly the nice softly
baked shadows transition
into unsightly crisp ones
(even with Soft Shadows
turned on). So in some
cases, like the foggy day,
if you are using Unity Pro,
make sure the Rendering
Path is set to Forward.
There are a couple of conditions that must be met to make use of this
though. The first is that when baking, both lightmaps must be created. In the
Lightmapping window, the very first option is Mode, which (by default) is set
to Dual Lightmaps. Changing this to Single Lightmaps will speed the baking
process, but means dynamic lighting will not be employed.
The second condition is that the Rendering Path must be set to Deferred. The
way to set this is via Edit>Project Settings>Player. Look to the Other Settings
section and change Rendering Path to Deferred.
Figure 7.27 shows dual lightmaps in action. This is not an optimal setup,
because it is never preferable to have the player see the two maps swapping
out (as we can here); but it shows how as the player gets closer, the one
lightmap is fading into the other.
To change the distance from the camera that this transition takes place,
either change the Shadow Distance setting in the Quality Settings
(Editor>Project Settings>Quality) or, when the Lightmapping window is
open (Window>Lightmapping), look to the bottom-right corner of the Scene
window for the Lightmap Display window ( Figure 7.28 ). There the Shadow
Figure 7.27 Dual lightmaps in action
(with a Shadow Distance setting of 5).
Figure 7.28 Lightmap Display window present at the bottom right of the Scene window when the
Lightmapping window is active.
Search WWH ::




Custom Search