Komputer Grafik 2 AK 045206 Realisme Shading 1

  • Slides: 17
Download presentation
Komputer Grafik 2 (AK 045206) Realisme : Shading 1

Komputer Grafik 2 (AK 045206) Realisme : Shading 1

Komputer Grafik 2 (AK 045206) Outline • Shading Models : Direct Line – Flat

Komputer Grafik 2 (AK 045206) Outline • Shading Models : Direct Line – Flat Shading – Gouraud Shading – Phong Shading • Shading Models : Indirect Line Shading 2

Komputer Grafik 2 (AK 045206) Shading Models (Direct lighting) • Flat Shading – Compute

Komputer Grafik 2 (AK 045206) 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 Shading 3

Komputer Grafik 2 (AK 045206) Flat Shading • The simplest approach, flat shading, calculates

Komputer Grafik 2 (AK 045206) Flat Shading • 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 Shading 4

Komputer Grafik 2 (AK 045206) Flat Shading : Vertex Normal • Vertex normals may

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

Komputer Grafik 2 (AK 045206) Gouraud Shading • This is the most common approach

Komputer Grafik 2 (AK 045206) 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 – This is what Open. GL does C 1 c 1 + t 1(c 2 -c 1) C 3 c 1 + t 2(c 3 -c 1) C 2 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)) Shading 6

Komputer Grafik 2 (AK 045206) Gouraud Shading • Artifacts – Often appears dull, chalky

Komputer Grafik 2 (AK 045206) Gouraud Shading • Artifacts – Often appears dull, chalky – Lacks accurate specular component • If included, will be averaged over entire polygon C 1 C 3 C 2 Can’t shade that effect! Shading 7

Komputer Grafik 2 (AK 045206) Gouraud Shading • Artifacts – Mach Banding • Artifact

Komputer Grafik 2 (AK 045206) Gouraud Shading • Artifacts – Mach Banding • Artifact at discontinuities in intensity or intensity slope C 1 C 4 C 3 C 2 Discontinuity in rate of color change occurs here Shading 8

Komputer Grafik 2 (AK 045206) Phong Shading • Phong shading is not the same

Komputer Grafik 2 (AK 045206) Phong Shading • 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 Shading 9

Komputer Grafik 2 (AK 045206) Phong Shading • Linearly interpolate the vertex normals –

Komputer Grafik 2 (AK 045206) Phong Shading • Linearly interpolate the vertex normals – Compute lighting equations at each pixel – Can use specular component N N 4 3 N 2 Remember: Normals used in diffuse and specular terms Discontinuity in normal’s rate of change is harder to detect Shading 10

Komputer Grafik 2 (AK 045206) Perspective Distortion Image plane Break up large polygons with

Komputer Grafik 2 (AK 045206) Perspective Distortion Image plane Break up large polygons with many smaller ones i i i uu u u Z – into the scene Notice that linear interpolation in screen space does not align with linear interpolation in world space Shading 11

Komputer Grafik 2 (AK 045206) Perspective Distortion Image plane Break up large polygons with

Komputer Grafik 2 (AK 045206) 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 Shading 12

Komputer Grafik 2 (AK 045206) Interpolation dependent on polygon orientation • Interpolation dependent on

Komputer Grafik 2 (AK 045206) Interpolation dependent on polygon orientation • Interpolation dependent on polygon orientation A i D C Interpolate between AB and AD Shading B C A i B Rotate 90 o and color same point D Interpolate between CD and AD 13

Komputer Grafik 2 (AK 045206) Problems at Shared Vertices Vertex B is shared by

Komputer Grafik 2 (AK 045206) Problems at Shared Vertices Vertex B is shared by the two rectangles on the right, but not by the on the left D C H B E G F A 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 Shading 14

Komputer Grafik 2 (AK 045206) Shortcomings of Shading • Polygonal silhouettes remain Gouraud Shading

Komputer Grafik 2 (AK 045206) Shortcomings of Shading • Polygonal silhouettes remain Gouraud Shading Phong 15

Komputer Grafik 2 (AK 045206) Shading Models (Indirect lighting) Ray Tracing Radiosity Shading 16

Komputer Grafik 2 (AK 045206) Shading Models (Indirect lighting) Ray Tracing Radiosity Shading 16

Komputer Grafik 2 (AK 045206) Referensi • F. S. Hill, Jr. , COMPUTER GRAPHICS

Komputer Grafik 2 (AK 045206) 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 Shading 17