[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

### 5.8.3 Shading

Separating the ends of the cylinder sprite for texturing (see section Texturing) has a fortunate side effect. It separates the surface normals of the vertices as well as the texture coordinates.

Surface normals are used for shading the sprite. Light colors each vertex based on the average normal of all of the triangles that share that vertex. When all of the vertices in our sprite are shared, all of the edges look smooth--even the edges between the sides and the ends of the cylinder. With the ends separated, that edge is now sharply defined.

Unfortunately, we have also split one edge of the cylinder's sides, which creates a sharply defined edge where we don't want it. We could reconnect the shared vertices along that edge, but then we would have to texture the sides differently--the sides would either curve ackwardly or overlap.

We are stuck with an unwanted edge or a difficult texturing job until we can find a way to connect vertex normals without connecting skin vertices. One way we might be able to do this is by interfering with vertex normal calculation. We would simply mark certain vertices as needing to be blended together during or after vertex normal calculation. We would still have 98 vertex normals, but two pairs of them would be averaged together.

One way we might mark which vertices should be blended this way, would be to create a special frame in the 3D Sprite where all of the blended vertices are touching. In the case of our cylinder, the ends would be pulled away from the sides but the sides would form a complete loop so that vertices we split for texturing would be blended for shading.

The simplest way to apply the blending would be by averaging the vertex normals after vertex normal calculation. It would probably be more accurate to re-calculate the vertex normal by averaging the normals of all of the triangles connected to both vertices. Vertex normals can be pre-calculated-- especially if you are using pre-calculated vertex animation anyway. So the blending effect might only have to be applied once.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ]

This document was generated using texi2html 1.76.