CS 445 / 645 Introduction to Computer GraphicsRay Tracing AssignmentSlide 3Barycentric CoordinatesSlide 5Barycentric coordinatesSlide 7Applying IlluminationSlide 9Flat ShadingIs flat shading realistic for faceted object?Slide 12Vertex NormalsSlide 14Gouraud ShadingSlide 16Slide 17Phong ShadingSlide 19Shortcomings of ShadingPerspective DistortionSlide 22Interpolation dependent on polygon orientationProblems at Shared VerticesBad Vertex AveragingShading Models (Direct lighting)CS 445 / 645Introduction to Computer GraphicsLecture 18Lecture 18ShadingShadingLecture 18Lecture 18ShadingShadingRay Tracing AssignmentDeadline extended until Tuesday the 13thDeadline extended until Tuesday the 13thDeadline extended until Tuesday the 13thDeadline extended until Tuesday the 13thRay Tracing AssignmentBarycentric coordinates Barycentric coordinates (M(Mööbius, 1827)bius, 1827)•Consider a triangle defined by (AConsider a triangle defined by (A11, A, A22, A, A33))–These points are defined relative to world originThese points are defined relative to world origin–A point within triangle could also be defined as (x, y, z) A point within triangle could also be defined as (x, y, z) relative to world originrelative to world origin•A point can be defined as (tA point can be defined as (t11, t, t22, t, t33) corresponding to its ) corresponding to its position with respect to Aposition with respect to A11, A, A22, A, A33..Barycentric coordinates Barycentric coordinates (M(Mööbius, 1827)bius, 1827)•Consider a triangle defined by (AConsider a triangle defined by (A11, A, A22, A, A33))–These points are defined relative to world originThese points are defined relative to world origin–A point within triangle could also be defined as (x, y, z) A point within triangle could also be defined as (x, y, z) relative to world originrelative to world origin•A point can be defined as (tA point can be defined as (t11, t, t22, t, t33) corresponding to its ) corresponding to its position with respect to Aposition with respect to A11, A, A22, A, A33..Barycentric CoordinatesSolve for (tSolve for (t11, t, t22, t, t33) such that) such that–tt11 + t + t22 + t + t3 3 = 1= 1–tt11AA11 + t + t22AA22 + t + t33AA33 = P = PSolve for (tSolve for (t11, t, t22, t, t33) such that) such that–tt11 + t + t22 + t + t3 3 = 1= 1–tt11AA11 + t + t22AA22 + t + t33AA33 = P = Pmathworld.comBarycentric CoordinatesAn observationAn observation•tt11, t, t22, and t, and t3 3 are weights such are weights such that when they are used to that when they are used to represent the mass at the represent the mass at the vertices of the triangle, P is vertices of the triangle, P is at its center of massat its center of mass•tt11, t, t22, and t, and t33 are weights that represent the ratio of the area of are weights that represent the ratio of the area of each of the three subtriangles to the area of the wholeeach of the three subtriangles to the area of the wholeAn observationAn observation•tt11, t, t22, and t, and t3 3 are weights such are weights such that when they are used to that when they are used to represent the mass at the represent the mass at the vertices of the triangle, P is vertices of the triangle, P is at its center of massat its center of mass•tt11, t, t22, and t, and t33 are weights that represent the ratio of the area of are weights that represent the ratio of the area of each of the three subtriangles to the area of the wholeeach of the three subtriangles to the area of the wholeBarycentric coordinatesThe cross product computes a triangle’s areaThe cross product computes a triangle’s area•|| (A|| (A2 2 - A- A11) x (A) x (A33-A-A11) || = (area of A) || = (area of A11AA22AA33)) * 2* 2Where || x || = the area of the triangle x… the cross productWhere || x || = the area of the triangle x… the cross productThe cross product computes a triangle’s areaThe cross product computes a triangle’s area•|| (A|| (A2 2 - A- A11) x (A) x (A33-A-A11) || = (area of A) || = (area of A11AA22AA33)) * 2* 2Where || x || = the area of the triangle x… the cross productWhere || x || = the area of the triangle x… the cross producttkAAP kkAAAktkAAP kkAAAktkAAP kkAAAkBarycentric CoordinatesAll points of triangle are unique, all points in All points of triangle are unique, all points in space can be represented with barycentric space can be represented with barycentric coordinatescoordinates•AA11, A, A22, and A, and A33 form an affine space form an affine space•If 0 If 0 ≤ t≤ t11, t, t22, t, t33 ≤ 1, the point is in the triangle ≤ 1, the point is in the triangleAll points of triangle are unique, all points in All points of triangle are unique, all points in space can be represented with barycentric space can be represented with barycentric coordinatescoordinates•AA11, A, A22, and A, and A33 form an affine space form an affine space•If 0 If 0 ≤ t≤ t11, t, t22, t, t33 ≤ 1, the point is in the triangle ≤ 1, the point is in the triangleApplying IlluminationWe have an illumination model for a point on a We have an illumination model for a point on a surfacesurfaceAssuming that our surface is defined as a mesh of Assuming that our surface is defined as a mesh of polygonal facets, polygonal facets, which pointswhich points should we use? should we use? Keep in mind:Keep in mind:•It’s a fairly expensive calculationIt’s a fairly expensive calculation•Several possible answers, each with different implications Several possible answers, each with different implications for the visual quality of the resultfor the visual quality of the resultWe have an illumination model for a point on a We have an illumination model for a point on a surfacesurfaceAssuming that our surface is defined as a mesh of Assuming that our surface is defined as a mesh of polygonal facets, polygonal facets, which pointswhich points should we use? should we use? Keep in mind:Keep in mind:•It’s a fairly expensive calculationIt’s a fairly expensive calculation•Several possible answers, each with different implications Several possible answers, each with different implications for the visual quality of the resultfor the visual quality of the resultApplying IlluminationWith polygonal/triangular models:With polygonal/triangular models:•Each facet has a constant surface normalEach facet has a constant surface normal•If the light is directional, the
View Full Document