250 likes | 269 Views
In computer graphics, surfaces are represented by polygonal meshes, also known as wireframes. Learn about modeling shapes using polygons, normals, lighting effects, and shading techniques. Dive into barycentric coordinates for color determination on triangles. Explore smooth and flat shading for surface brightness. Understand the calculation of normals to enhance the realism of polygonal models.
E N D
Introduction to Meshes Lecture 22 Mon, Oct 20, 2003
Chapter 6 Modeling Shapes with Polygonal Meshes
Introduction to Solid Modeling with Polygonal Meshes • In computer graphics, we do not draw surfaces that are truly curved. • Instead, each surface consists of many small polygons connected in a mesh. • This is also called a wireframe. • If we fill the polygons in the mesh, then the surface looks solid.
Polygonal Faces • The simplest of all polygonal faces is the triangle. • Triangles have two major advantages. • All triangles are planar. • All triangles are convex.
R n P Q One Normal for the Face • The normal may be calculated from the vertices. • n = (Q – P) (R – P).
n2 n1 n3 One Normal for each Vertex • The normal at each vertex may be perpendicular to the face. • n1 = n2 = n3.
n2 n1 n3 One Normal for each Vertex • The normal at each vertex may point in a unique direction. • n1n2n3.
Lighting and Normals • When using a lighting model, the brightness and color of the surface are determined, in part, by the normals. • If there is one normal, the surface is of uniform brightness. • This is called flat shading.
Lighting and Normals • If each vertex has a distinct normal, then the brightness may vary over the surface. • This is called smooth shading.
Shading a Triangle • We will study lighting models later. • Lighting models determine how to color, or shade, a vertex. • For now, we will assume that each vertex has been assigned a shade. • Note: “shading” has nothing to do with shadows. It refers to the shade of color.
Shading a Triangle • Each point in the interior and on the boundary of a triangle can be expressed as a linear combination aP + bQ + cR of the three vertices of the triangle, where a + b + c = 1. • These are the barycentric coordinates.
Shading a Triangle • The coefficients a, b, c are used to determine the color of the point in the triangle. • The color of the point is the same linear combination of the colors of the vertices. • This is done for each pixel that is part of the triangle.
R(4, 8), color = (1, 0, 0) Q(12, 0) color = (0, 1, 1) P(0, 0) color = (1, 1, 0) Shading a Triangle • Consider this triangle.
R(4, 8), color = (1, 0, 0) Q(12, 0) color = (0, 1, 1) P(0, 0) color = (1, 1, 0) Shading a Triangle • What is the color of the outlined pixel?
Shading a Triangle • The coordinates are (3, 3). • Solve the system a(0, 0) + b(12 ,0) + c(4, 8) = (3, 3), a + b + c = 1. • The equations are 12b + 4c = 3, 8c = 3, a + b + c = 1.
Shading a Triangle • The solution is • a = 1/2. • b = 1/8. • c = 3/8. • Therefore, the color of the pixel is (1/2)(1, 1, 0) + (1/8)(0, 1, 1) + (3/8)(1, 0, 0) = (7/8, 5/8, 1/8).
R(4, 8), color = (1, 0, 0) color = (7/8, 5/8, 1/8) Q(12, 0) color = (0, 1, 1) P(0, 0) color = (1, 1, 0) Shading a Triangle
R(4, 8) Q(12, 0) P(0, 0) Shading a Triangle • The entire triangle