Game Development Reference

In-Depth Information

that should be treated normally and those that should be extruded to infinity by

using 4D homogeneous coordinates. A
w
coordinate of 1 is assigned to the un-

modified vertices and a
w
coordinate of 0 is assigned to the extruded vertices.

The vertex program performing the extrusion utilizes the information stored in

the
w
coordinate to perform the appropriate vertex modifications.

Before we examine the extrusion method, we must prepare the appropriate

quad list or triangle list (depending on whether we are using a point light or infi-

nite directional light). We need to make sure that the vertices of each extrusion

primitive are wound so that the face's normal direction points out of the shadow

volume. Suppose that a silhouette edge
E
has endpoints
A
and
B
. The edge-

finding code presented in Listing 10.1 associates the triangle for which the verti-

ces
A
and
B
occur in counterclockwise order as the first triangle sharing the edge

E
. Thus, if the first triangle faces toward the light source, then we want the verti-

ces
A
and
B
to occur in the opposite order for the extruded primitive so that its

vertices are wound counterclockwise. If the first triangle faces away from the

light source, then we use the vertices
A
and
B
in the same order for the extruded

primitive. Table 10.1 lists the vertices of the extrusion of the edge
E
for point

light sources and infinite directional light sources for the cases that the first trian-

gle associated with the edge
E
faces toward or away from the light source.

Facing of First

Triangle

Point Light Source

(Extrusion is a list of

quads)

Infinite Light Source

(Extrusion is a list of tri-

angles)

=

BBB

,

,

,1

=

BBB

,

,

,1

V

V

1

x

y

z

1

x

y

z

=

,

AA

,

,1

=

,

AA

,

,1

Toward light

source

V

A

V

A

2

x

y

z

2

x

y

z

=

,

AA

,

, 0

=

0, 0, 0, 0

V

A

V

3

x

y

z

3

=

BBB

,

,

, 0

V

4

x

y

z

=

,

AA

,

,1

=

,

AA

,

,1

V

A

V

A

1

x

y

z

1

x

y

z

Away from light

source

=

BBB

,

,

,1

=

BBB

,

,

,1

V

V

2

x

y

z

2

x

y

z

=

BBB

,

,

, 0

=

0, 0, 0, 0

V

V

3

x

y

z

3

=

,

AA

,

, 0

V

A

4

x

y

z

Table 10.1.
Given a silhouette edge
E
having endpoints
A
and
B
, this table lists the ob-

ject-space vertices of the extruded shadow volume face corresponding to
E
. The first tri-

angle associated with the edge
E
is the triangle for which the vertices
A
and
B
occur in

counterclockwise order.

Search Nedrilad ::

Custom Search