Game Development Reference
In-Depth Information
Real time lighting of a 3D model can be a time-intensive task, so when writing a
game we try to avoid doing so when possible in order to speed up rendering. If we
do not want to light a 3D model, there is no need to specify a normal stream; so, by
not lighting a model we save memory too.
There are a couple of points to bear in mind when specifying these additional streams.
Firstly, Marmalade expects the number of colors, UVs, and normals provided to
match the number of vertices provided. While you can specify streams of different
lengths, this will normally cause an assert to be fired and obviously it could yield
unexpected results when rendering.
Secondly, and perhaps most importantly, these additional streams may require us
to add extra copies of our vertices into the vertex stream since we can only provide a
single index stream.
Take the example of a cube where each vertex is a corner point of three different
faces of the cube. Since each face points in a different direction, we will need to
duplicate each vertex three times so it can be referenced in the index stream along
with the three different normal vectors.
We can also run into the same problem when the UV or color at a vertex varies
across each polygon that it forms a part of.
For each different combination of color, UV, and normal we encounter, we need to
provide an additional copy of each vertex, and therefore also an additional color, UV,
and normal value so that all the streams are the same length.
 
Search WWH ::




Custom Search