Game Development Reference
In-Depth Information
rendering debugging objects such as bounding boxes, waypoints, markers,
and the like:
/ /
Untransformed ,
l i t
v e r t e x
s t r u c t
R e n d e r V e r t e x L
{
V e c t o r 3
p ;
/ /
3D p o s i t i o n
u n s i g n e d
a r g b ;
/ /
p r e l i t
c o l o r
(0xAARRGGBB)
f l o a t
u , v ;
/ /
t e x t u r e
mapping
c o o r d i n a t e s
} ;
The next example is a vertex used for lightmapped, bump-mapped ge-
ometry. It has basis vectors for lightmapping, and two sets of UVs, one
for the regular diffuse texture, and another for the lightmap, which stores
baked-in lighting that was calculated o ine:
/ /
Lightmapped ,
bump mapped
v e r t e x
s t r u c t
RenderVertexLtMapBump
{
V e c t o r 3
p ;
/ /
p o s i t i o n
V e c t o r 3
n ;
/ /
normal
V e c t o r 3
t a n g e n t ;
/ /
1 s t
b a s i s
v e c t o r
f l o a t
d e t ;
/ /
D e t e r m i n a n t
o f
t a n g e n t
space
/ /
t r a n s f o r m
( m i r r o r
f l a g )
f l o a t
u , v ;
/ /
r e g u l a r
c o o r d i n a t e s
f o r
d i f f u s e
and bump map
f l o a t
lmu , lmv ;
/ /
t e x t u r e
c o o r d s
i n t o
l i g h t m a p
} ;
Finally, here's a vertex that might be used for skeletal rendering. The
indices are stored in four 8-bit values, and the weights are stored as four
floats:
/ /
Lightmapped ,
bump mapped
v e r t e x
s t r u c t
R e n d e r V e r t e x S k i n n e d
{
V e c t o r 3
p ;
/ /
p o s i t i o n
V e c t o r 3
n ;
/ /
normal
V e c t o r 3
t a n g e n t ;
/ /
1 s t
b a s i s
v e c t o r
f l o a t
d e t ;
/ /
D e t e r m i n a n t
o f
t a n g e n t
space
/ /
t r a n s f o r m
( m i r r o r
f l a g )
f l o a t
u , v ;
/ /
r e g u l a r
c o o r d i n a t e s
f o r
d i f f u s e
and bump map
u n s i g n e d
b o n e I n d i c e s ;
/ /
bone
i n d i c e s
f o r
up
t o
4
bones
(8 b i t
/ /
v a l u e s )
V e c t o r 4
b o n e W e i g h t s ;
/ /
w e i g h t s
f o r
up
t o
4
bones
} ;
The preceding examples were all declared as struct s. As you can see,
the combinations can grow quite quickly. Dealing with this simply but
e ciently is a challenge. One idea is to allocate the fields as a structure of
arrays (SOA) rather than array of structures (AOS):
s t r u c t
V e r t e x L i s t S O A
{
V e c t o r 3
p ;
/ /
p o s i t i o n s
V e c t o r 3
n ;
/ /
n o r m a l s
V e c t o r 4
t a n g e n t D e t ;
/ /
xyz
t a n g e n t
+
d e t
i n w
Search WWH ::




Custom Search