Game Development Reference
In-Depth Information
Blending and output. Finally, at the very bottom of the render
pipeline, we have produced a color, opacity, and depth value. The
depth value is tested against the depth buffer for per-pixel visibility
determination to ensure that an object farther away from the camera
doesn't obscure one closer to the camera. Pixels with an opacity that
is too low are rejected, and the output color is then combined with
the previous color in the frame buffer in a process known as alpha
blending.
The pseudocode in Listing 10.10 summarizes the simplified rendering
pipeline outlined above.
/ /
F i r s t ,
f i g u r e
how
t o
view
t h e
s ce ne
s e t u p T h e C a m e r a ( ) ;
/ / C l e a r t h e z b u f f e r
c l e a r Z B u f f e r ( ) ;
/ /
S e t u p
e n v i r o n m e n t a l
l i g h t i n g
and
f o g
s e t G l o b a l L i g h t i n g A n d F o g ( ) ;
/ /
g e t
a
l i s t
o f
o b j e c t s
t h a t
a r e
p o t e n t i a l l y
v i s i b l e
p o t e n t i a l l y V i s i b l e O b j e c t L i s t
=
h i g h L e v e l V i s i b i l i t y D e t e r m i n a t i o n ( s c e n e ) ;
/ /
Render
e v e r y t h i n g
we found
t o
be
p o t e n t i a l l y
v i s i b l e
f o r
( a l l
o b j e c t s
i n
p o t e n t i a l l y V i s i b l e O b j e c t L i s t )
{
/ /
P e r f o r m
lower l e v e l
VSD
u s i n g
bounding
volume
t e s t
i f
( ! o b j e c t . i s B o u n d i n g V o l u m e V i s i b l e ( ) )
c o n t i n u e ;
/ /
F e t c h
o r
p r o c e d u r a l l y
g e n e r a t e
t h e
geometry
t r i M e s h
=
o b j e c t . g e t G e o m e t r y ( )
/ /
C l i p
and
r e n d e r
t h e
f a c e s
f o r
( each
t r i a n g l e
i n
t h e
g e o m e t r y )
{
/ /
T r a n s f o r m
t h e
v e r t i c e s
t o
c l i p
space ,
and
p e r f o r m
/ /
v e r t e x l e v e l
c a l c u l a t i o n s
( run
t h e
v e r t e x
s h a d e r )
c l i p S p a c e T r i a n g l e
=
t r a n s f o r m A n d L i g h t i n g ( t r i a n g l e ) ;
/ /
C l i p
t h e
t r i a n g l e
t o
t h e
view
volume
c l i p p e d T r i a n g l e
=
c lip ToVi ewV olu me ( c l i p S p a c e T r i a n g l e ) ;
i f
( c l i p p e d T r i a n g l e . i s E m p t y ( ) )
c o n t i n u e ;
/ /
P r o j e c t
t h e
t r i a n g l e
onto
s c r e e n
space
s c r e e n S p a c e T r i a n g l e
=
c l i p p e d T r i a n g l e . p r o j e c t T o S c r e e n S p a c e ( ) ;
/ /
I s
t h e
t r i a n g l e
b a c k f a c i n g ?
i f
( s c r e e n S p a c e T r i a n g l e . i s B a c k F a c i n g ( ) )
c o n t i n u e ;
/ /
R a s t e r i z e
t h e
t r i a n g l e
f o r
( each
p i x e l
i n
t h e
t r i a n g l e )
{
/ /
S c i s s o r
t h e
p i x e l
h e r e
( i f
t r i a n g l e
was
/ /
n o t
c o m p l e t e l y
c l i p p e d
t o
t h e
f r u s t u m )
i f
( p i x e l
i s
o f f s c r e e n )
c o n t i n u e ;
Search WWH ::




Custom Search