O'Reilly logo

GPU PRO 3 by Wolfgang Engel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

2
IV
Depth Rejected Gobo Shadows
John White
2.1 Introduction
This chapter describes a technique to provide soft shadows using a single tex-
ture sample in environments where the objects casting shadows and the objects
receiving shadows are disjoint. This is common in games where the lighting on
the static environment is prebaked into lightmaps and dynamic objects are later
combined into the world.
Note that the soft shadows using this technique will only be cast onto prelit
environment surfaces and not on themselves (i.e., self shadowing) or from one dy-
namic object to another. In these cases you need to use standard soft-shadowing
techniques such as percentage closest filtering (PCF), variance [Donnelly and
Lauritzen 06] or exponential shadows maps [Salvi 08]; otherwise the object will
receive nonfiltered blocky shadows.
2.2 Basic Gobo Shadows
Before we discuss the technique, it is worthwhile to take a step backwards and
describe a very simple technique for soft shadows using gobo projected textures.
A gobo is a theatrical term that refers to a cutout shape that can be placed in
front of a spotlight light bulb. When the spotlight is turned on, the gobo cutout
will partially block some light and the resultant shape will be projected onto the
scene.
In games we can apply the same trick by applying a similar black or white
texture to a projected light. The result is a soft image that casts onto the world.
This texture can therefore be used to fake a shadow from an object. A common
example of this in games is to have the light source in a wired cage; the gobo is
then used to fake the shadow from the cage onto the world. As in the theater,
the trick relies on the fact that any moving objects cannot move in between the
light source and the world object from which the gobo is used to fake shadows
(see Figure 2.1).
243
244 IV Shadows
Figure 2.1. A gobo texture and its projection.
In games, this gobo can be generated upfront and loaded in and used statically.
It can also be generated per frame by rendering the objects using a black shader
onto a white surface, and then applying a blur filter afterwards to smooth the
edges to fake the penumbra from the area light source.
Figure 2.2. A correct and an incorrect projection.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required