Than Lwin Aung Introduction to 3D Graphic2We define the points of the triangle as vertices. In fact, a vertex stores more information than theposition of the point. In addition to the position of the point, it also stores color, normal vector at thepoint, and texture information. Therefore a vertex stores: position, color, normal and texture. Positioncan be represented with 3D vector <x,y,z>; color can be represented with RGBA (Red, Green, Blue andAlpha) ; normal can also be represented with 3D vector <x,y,z>; texture can be represent of 2D vector<x,y>.The question here is why we only need to define the color information only at the vertices of thetriangle. How about the points inside the triangle? Well, we interpolate the color and textureinformation for the points between vertices. For example, in the follow triangle, we only define thecolors at 3 vertices and the color is interpolated between 3 vertices.Therefore, it is pretty straightforward to understand the color information of the vertices. Next is thenormal information. The normal vector, in fact, represents the perpendicular vector of the trianglesurface. Since 3 vertices form a triangle surface, we can calculate the normal vector by performing cross-product between 2 positions vectors. For example:Normal = Vertex1 <x1,y1,z1>
Vertex2 <x2,y2,z2>Why do we need normal vector for the surface? Well, the answer is for a lot of things although theprimary purpose is to calculate light reflection, refraction and shading. We also need normal vector forcalculating the orientation of the surface.The last information each vertex store is the texture information. What is texture by the way? A texturein fact is nothing more an image. We use texture mapping to paste the image on the 3D surface. In fact,texture mapping saves us a lot of work for 3D modeling. How do we do texture mapping? It is in factsimple. Before going to the texture mapping, let me ask you a question. Are you familiar with the worldmap and the globe? The world map is 2D and the globe is 3D, right? How come? We in fact project the2D surface onto the 3D surface and vice versa. This is called texture mapping. Mathematically,<x,y,z> = R(<u,v>) , where R is a linear function which transform 2D (u,v) to 3D (x,y,z). There are variousfunctions of texture transformation depending on the surfaces.