Game Development Reference
In-Depth Information
V e c t o r 2
uv0 ;
/ /
f i r s t
c h a n n e l
mapping
c o o r d s
V e c t o r 2
uv1 ;
/ /
second
c h a n n e l
mapping
V e c t o r 2
l t M a p ;
/ /
l i g h t m a p
c o o r d s
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
u n s i g n e d
a r g b ;
/ /
v e r t e x
c o l o r
} ;
In this case, if a value was not present, the array pointer would simply
be NULL .
Another idea is to use a raw block of memory, but declare a vertex
format class with accessor functions that do the address arithmetic to locate
a vertex by index, based on the variable stride, and access a member based
on its variable offset within the structure.
10.10.3
Vertex-Level Operations
After mesh data has been submitted to the API, a wide range of vertex-
level computations are performed. In a shader-based renderer (as opposed
to a fixed-function pipeline), this happens in our vertex shader. The input
to a vertex shader is essentially one of the struct s that we described in the
previous section. As discussed earlier, a vertex shader can produce many
different types of output, but there are two basic responsibilities it must
fulfill. The first is that it must output, at the very minimum, a clip-space
(or in some circumstances screen-space) position. The second responsibility
is to provide to the pixel shader any inputs that are needed for the pixel
shader to perform the shading calculations. In many cases, we can simply
pass through vertex values received from the input streams, but other times,
we must perform calculations, such as transforming raw vertex values from
modeling space to some other coordinate space in which we are performing
lighting or generating texture coordinates.
Some of the most common operations that are done in a vertex shader
are
Transforming model-space vertex positions into clip space.
Performing skinning for skeletal models.
Transforming normals and basis vectors into the appropriate space
for lighting.
Calculating vectors needed for lighting ( l and h ) and transforming
them into the appropriate coordinate space.
Computing fog density values from the vertex position.
Search WWH ::




Custom Search