Presentation is loading. Please wait.

Presentation is loading. Please wait.

Komputer Grafik 2 (AK045206) Shading 1/17 Realisme : Shading.

Similar presentations


Presentation on theme: "Komputer Grafik 2 (AK045206) Shading 1/17 Realisme : Shading."— Presentation transcript:

1 Komputer Grafik 2 (AK045206) Shading 1/17 Realisme : Shading

2 Komputer Grafik 2 (AK045206) Shading 2/17 Outline Shading Models : Direct Line –Flat Shading –Gouraud Shading –Phong Shading Shading Models : Indirect Line

3 Komputer Grafik 2 (AK045206) Shading 3/17 Shading Models (Direct lighting) Flat Shading –Compute Phong lighting once for entire polygon Gouraud Shading –Compute Phong lighting at the vertices and interpolate lighting values across polygon Phong Shading –Compute averaged vertex normals –Interpolate normals across polygon and perform Phong lighting across polygon

4 Komputer Grafik 2 (AK045206) Shading 4/17 The simplest approach, flat shading, calculates illumination at a single point for each polygon. We can refine it a bit by evaluating the Phong lighting model at each pixel of each polygon, but the result is still clearly faceted: To get smoother-looking surfaces we introduce vertex normals at each vertex –Usually different from facet normal –Used only for shading –Think of as a better approximation of the real surface that the polygons approximate Flat Shading

5 Komputer Grafik 2 (AK045206) Shading 5/17 Vertex normals may be –Provided with the model –Computed from first principles –Approximated by averaging the normals of the facets that share the vertex Flat Shading : Vertex Normal

6 Komputer Grafik 2 (AK045206) Shading 6/17 This is the most common approach –Perform Phong lighting at the vertices –Linearly interpolate the resulting colors over faces Along edges Along scanlines –This is what OpenGL does Gouraud Shading C1C1 C2C2 C3C3 c 1 + t 1 (c 2 -c 1 ) c 1 + t 2 (c 3 -c 1 ) c 1 + t 1 (c 2 -c 1 ) + t 3 (c 1 + t 2 (c 3 -c 1 )- c 1 + t 1 (c 2 -c 1 ))

7 Komputer Grafik 2 (AK045206) Shading 7/17 Artifacts –Often appears dull, chalky –Lacks accurate specular component If included, will be averaged over entire polygon Gouraud Shading C1C1 C2C2 C3C3 Can’t shade that effect!

8 Komputer Grafik 2 (AK045206) Shading 8/17 Artifacts –Mach Banding Artifact at discontinuities in intensity or intensity slope Gouraud Shading C1C1 C2C2 C3C3 C4C4 Discontinuity in rate of color change occurs here

9 Komputer Grafik 2 (AK045206) Shading 9/17 Phong shading is not the same as Phong lighting, though they are sometimes mixed up –Phong lighting: the empirical model we’ve been discussing to calculate illumination at a point on a surface –Phong shading: linearly interpolating the surface normal across the facet, applying the Phong lighting model at every pixel Same input as Gouraud shading Usually very smooth-looking results: But, considerably more expensive Phong Shading

10 Komputer Grafik 2 (AK045206) Shading 10/17 Phong Shading Linearly interpolate the vertex normals –Compute lighting equations at each pixel –Can use specular component N2N2 N3N3 N4N4 Remember: Normals used in diffuse and specular terms Discontinuity in normal’s rate of change is harder to detect

11 Komputer Grafik 2 (AK045206) Shading 11/17 Perspective Distortion         Z – into the scene Image plane Break up large polygons with many smaller ones Notice that linear interpolation in screen space does not align with linear interpolation in world space

12 Komputer Grafik 2 (AK045206) Shading 12/17 Z – into the scene Image plane Break up large polygons with many smaller ones Notice that linear interpolation in screen space does not align with linear interpolation in world space Perspective Distortion

13 Komputer Grafik 2 (AK045206) Shading 13/17 Interpolation dependent on polygon orientation  A D C B Interpolate between AB and AD  B A D C Interpolate between CD and AD Rotate - 90 o and color same point

14 Komputer Grafik 2 (AK045206) Shading 14/17 Problems at Shared Vertices Vertex B is shared by the two rectangles on the right, but not by the one on the left The first portion of the scanline is interpolated between DE and AC The second portion of the scanline is interpolated between BC and GH A large discontinuity could arise B A C E D F H G

15 Komputer Grafik 2 (AK045206) Shading 15/17 Polygonal silhouettes remain Shortcomings of Shading Gouraud Phong

16 Komputer Grafik 2 (AK045206) Shading 16/17 Shading Models (Indirect lighting) Ray Tracing Radiosity

17 Komputer Grafik 2 (AK045206) Shading 17/17 Referensi F.S.Hill, Jr., COMPUTER GRAPHICS – Using Open GL, Second Edition, Prentice Hall, 2001 CS 445/645 : Introduction to Computer Graphics, Slide-Presentation, Virginia University


Download ppt "Komputer Grafik 2 (AK045206) Shading 1/17 Realisme : Shading."

Similar presentations


Ads by Google