tailieunhanh - 3D Graphics with OpenGL ES and M3G- P9

3D Graphics with OpenGL ES and M3G- P9:Mobile phones are the new vehicle for bringing interactive graphics technologies to consumers. Graphics that in the 1980s was only seen in industrial flight simulators and at the turn of the millennium in desktop PCs and game consoles is now in the hands of billions of people. This book is about the technology underpinnings of mobile threedimensional graphics, the newest and most rapidly advancing area of computer graphics. | 64 LOW-LEVELRENDERING CHAPTER 3 You can approximate a smooth unique vertex normal by averaging the normals of the adjacent triangles possibly weighted by the triangle areas n an i where a is the area of the triangle associated with ni and n again needs to be normalized. This gives a smooth look to the surface. A more involved approach would be to fit a smooth surface to the neighborhood of a vertex and to evaluate the surface normal at the vertex. A unique normal vector for each mesh vertex is useful for smooth objects but fails if we actually want to represent a sharp crease. The solution is to define the vertex as many times as there are different orientations around it. Similarly vertices need to be replicated if other properties such as material attributes should change abruptly between triangles. The simplest approach for determining the color of a primitive is to choose the coloring at one vertex and use it for the whole triangle this is called flat shading. More pleasing results can be obtained by interpolation however. There are two key approaches for such interpolation one could either first interpolate the normal vectors and then separately shade each pixel within a triangle Phong shading Pho75 or alternatively calculate the shading at the vertices and interpolate colors across the triangle Gouraud shading Gou71 . Phong shading produces visually better results than Gouraud shading. However Gouraud shading is much cheaper to calculate for two reasons. First linear interpolation of colors is less expensive than interpolation of orientations. Second assuming triangles typically cover several pixels the lighting equations have to be evaluated less often only at the vertices. For this reason OpenGL only supports Gouraud shading and all lighting happens at vertices. However we will see in Section that one can modulate both the colors and the apparent orientations within the triangles using texture and bump mapping. If the surface is transformed by .