Lighting is a bit more complicated than the primitive color and vertex color processes, since the following two changes are required:
List 2-3 | |
|
The Vtx union for storing vertex information is used as type Vtx_t when setting vertex color, and as type Vtx_tn when setting normal vectors.
The only difference between type Vtx_t and type Vtx_tn is that one holds "the vertex color RGB components" and the other holds "the normal vector x,y,z components." All other elements are common to both.
The thing you need to be aware of is that when treating them as normal vector component values, each element becomes a signed 8bit number. Also, the normal vectors need to be normalized.
In other words, you must scale so that either of the following conditions is met: