{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

CG-lecture13 - Introduction to Computer Graphics Lecture 13...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Introduction to Computer Graphics Lecture 13 Shading How to shading pixels with illumination model? (1) Ray-tracing and Radiosity: Non-Classic Ray-tracing pipeline; can handle pixel well; still need shading method to improve shading (1) Classic pipeline: Only compute the vertexes Classic reflection; interpolate other pixels reflection; Applying Illumination We have an illumination model for a point on a We surface surface Assuming that our surface is defined as a mesh of Assuming polygonal facets, which points should we use? which Keep in mind: Keep • It’s a fairly expensive calculation • Several possible answers, each with different implications Several for the visual quality of the result for Applying Illumination With polygonal/triangular models: • Each facet has a constant surface normal • If the light is directional, the diffuse reflectance is constant If across the facet. Why? Why? Flat Shading The simplest approach, flat shading, calculates The flat illumination at a single point for each polygon: illumination If an object really is faceted, is this accurate? If is Is flat shading realistic for faceted object? No: • For point sources, the direction to light varies across the For facet facet – For specular reflectance, direction to eye varies across the facet Flat Shading We can refine it a bit by evaluating the Phong We lighting model at each pixel of each polygon, but the result is still clearly faceted: but Barycentric Coordinates Barycentric coordinates (Möbius, 1827) (Möbius, Barycentric • Consider a triangle defined by (A1, A2, A3) – These points are defined relative to world origin – A point within triangle could also be defined as (x, y, z) point relative to world origin relative • A point can be defined as (t1, t2, t3) corresponding to its corresponding position with respect to A1, A2, A3. position Barycentric Coordinates Solve for (t1, t2, t3) such that – t1 + t2 + t3 = 1 – t1A1 + t2A2 + t3A3 = P A1+t2(A2-A1)+t3(A3-A1)=P mathworld.com Gouraud Shading This is the most common approach • Perform Phong lighting at the vertices • Linearly interpolate the resulting colors over faces – Along edges – Along scanlines c1 + t1(c2-c1) C1 – This is what OpenGL does q C3 Does this eliminate the facets? C2 c1 + t1(c2-c1) + t3(c1 + t2(c3-c1)- c1 + t1(c2-c1)) c1 + t2(c3-c1) Gouraud Shading Artifacts • Often appears dull, chalky • Lacks accurate specular component – If included, will be averaged over entire polygon C1 C3 C2 Can’t shade that effect! Gouraud Shading q Artifacts – Mach Banding s Artifact at discontinuities in intensity or intensity slope C1 C4 C3 C2 http://www.edcenter.sdsu.edu/slides/GA/visteacher/sld048.htm Discontinuity in rate of color change occurs here Vertex Normals To get smoother-looking surfaces we introduce vertex normals at each we vertex vertex • Usually different from facet normal • Used only for shading Used only for • Think of as a better approximation of the real surface that the real polygons approximate polygons Vertex Normals Vertex normals may be Vertex • Provided with the model • Approximated by Approximated averaging the normals of the facets that share the vertex share Phong Shading Phong shading is not the same as Phong lighting, not though they are sometimes mixed up though • Phong lighting: the empirical model we’ve been discussing to calculate illumination at a point on a surface to • Phong shading: linearly interpolating the surface normal across the facet, applying the Phong lighting model at every pixel every – Same input as Gouraud shading – Usually very smooth-looking results: – But, considerably more expensive Phong Shading Linearly interpolate the vertex normals • Compute lighting equations at each pixel • Can use specular component N1 N4 I total = k a I ambient + N3 N2 #lights ∑ i =1 ( ) ( ˆˆ ˆˆ I i k d N ⋅ Li + k s V ⋅ Ri ) Remember: Normals used in diffuse and specular terms Discontinuity in normal’s rate of change is harder to detect nshiny Shortcomings of Shading Polygonal silhouettes remain Gouraud Phong Perspective Distortion Linear interpolation in image space is Image plane not accurate sampling of 3D n space n n n n n nn n n Break up large polygons with many smaller ones Polygon n n Z – into the scene Notice that linear interpolation in screen space Nonlinear color shift from does not align with(left) tointerpolation in world space blue linear red (right) Perspective Distortion Image plane Break up large polygons with many smaller ones Z – into the scene Notice that linear interpolation in screen space does not align with linear interpolation in world space Interpolation dependent on polygon orientation A Rotate -90o and color same point B C Interpolate between AB and AD C A 1 D B D Interpolate between CD and AD Problems at Shared Vertices D C B E A H Vertex B is shared by the two rectangles on the right, but not by the one on the left G The first portion of the scanline is interpolated between DE and AC F The second portion of the scanline is interpolated between BC and GH A large discontinuity could arise Bad Vertex Averaging Shading Models (Direct lighting) Flat Shading • Compute Phong lighting once for entire polygon Gouraud Shading • Compute Phong lighting at the vertices and interpolate Compute lighting values across polygon lighting Phong Shading • Interpolate normals across polygon and perform Phong Interpolate lighting across polygon lighting ...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online