0% found this document useful (0 votes)
126 views30 pages

CS 445 / 645 Introduction To Computer Graphics: Shading

This document discusses different shading models used in computer graphics including flat shading, Gouraud shading, Phong shading, and global illumination techniques like ray tracing and radiosity. Flat shading calculates lighting at one point per polygon, while Gouraud and Phong shading interpolate lighting or normals across polygons. Ray tracing recursively casts rays to calculate direct and indirect lighting effects. Radiosity models diffuse interreflection of light between surfaces.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
126 views30 pages

CS 445 / 645 Introduction To Computer Graphics: Shading

This document discusses different shading models used in computer graphics including flat shading, Gouraud shading, Phong shading, and global illumination techniques like ray tracing and radiosity. Flat shading calculates lighting at one point per polygon, while Gouraud and Phong shading interpolate lighting or normals across polygons. Ray tracing recursively casts rays to calculate direct and indirect lighting effects. Radiosity models diffuse interreflection of light between surfaces.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 30

CS 445 / 645

Introduction to Computer Graphics


Lecture 15
Shading
Lighting Review
Lighting Models
• Ambient
– Normals don’t matter
• Lambert/Diffuse
– Angle between surface normal and light
• Phong/Specular
– Surface normal, light, and viewpoint
Applying Illumination
We now have an illumination model for a point on
a surface
Assuming that our surface is defined as a mesh of
polygonal facets, which points should we use?
Keep in mind:
• It’s a fairly expensive calculation
• Several possible answers, each with different implications
for the visual quality of the result
Applying Illumination
With polygonal/triangular models:
• Each facet has a constant surface normal
• If the light is directional, the diffuse reflectance is constant
across the facet. Why?
Flat Shading
The simplest approach, flat shading, calculates
illumination at a single point for each polygon:

If an object really is faceted, is this accurate?


Is flat shading realistic for faceted
object?

No:
• For point sources, the direction to light varies across the
facet

– For specular reflectance, direction to eye


varies across the facet
Flat Shading
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
Vertex Normals
Vertex normals may be
• Provided with the model
• Computed from first principles
• Approximated by
averaging the normals
of the facets that
share the vertex
Gouraud Shading
This is the most common approach
• Perform Phong lighting at the vertices
• Linearly interpolate the resulting colors over faces
– Along edges
c1 + t1(c2-c1) C1
– Along scanlines

– This is what OpenGL does


 Does this eliminate the facets? C3

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
 Artifacts
– Mach Banding
 Artifact at discontinuities in intensity or intensity slope C1

C4
C3

C2

Discontinuity in rate
of color change
occurs here
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
Phong Shading
Linearly interpolate the vertex normals
• Compute lighting equations at each pixel
• Can use specular component
N1
   
#lights

 I i  kd Nˆ  Lˆi  k s Vˆ  Rˆi 
nshiny
I total  ka I ambient 
i 1  

N4 Remember: Normals used in


N3 diffuse and specular terms

N2 Discontinuity in normal’s rate of


change is harder to detect
Shortcomings of Shading
Polygonal silhouettes remain

Gouraud Phong
Perspective Distortion

Image
plane
Break up large polygons
with many smaller ones
i
i
i
i
i
i
uu u u u u
Z – into the scene

Notice that linear interpolation in screen space


does not align with linear interpolation in world space
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
B
and color
i same point C
B D A

D
C
Interpolate between Interpolate between
AB and AD CD and AD
Problems at Shared Vertices
Vertex B is shared by the two
rectangles on the right, but not by the
D C H one on the left

The first portion of the scanline


B G is interpolated between DE and AC

The second portion of the scanline


is interpolated between BC and GH
E F
A
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 lighting values
across polygon
Phong Shading
• Compute averaged vertex normals
• Interpolate normals across polygon and perform Phong lighting across
polygon
Global Illumination

We’ve glossed over how light really works


And we will continue to do so…
One step better

Global Illumination
• The notion that a point is illuminated by more than light from local
lights; it is illuminated by all the emitters and reflectors in the
global scene
The ‘Rendering Equation’
Jim Kajiya (Current head of Microsoft Research) developed this in
1986

 
I  x, x'  g  x, x'e  x, x'   r  x, x' , x' 'I  x' , x' 'dx' '
 S 

I(x, x’) is the total intensity from point x’ to x


g(x, x’) = 0 when x/x’ are occluded and 1/d2 otherwise (d = distance
between x and x’)
e(x, x’) is the intensity emitted by x’ to x
r(x, x’,x’’) is the intensity of light reflected from x’’ to x through x’
S is all points on all surfaces
The ‘Rendering Equation’
The light that hits x from x’ is the direct
illumination from x’ and all the light reflected by
x’ from all x’’
To implement:
• Must handle recursion effectively
• Must support diffuse and specular light
• Must model object shadowing
Shading Models (Indirect lighting)

Ray Tracing Radiosity


Recursive Ray Tracing
Cast a ray from the
viewer’s eye through
each pixel
Compute intersection of
this ray with objects
from scene
Closest intersecting
object determines
color
Recursive Ray Tracing
Cast a ray from intersected object to
light sources and determine
shadow/lighting conditions
Also spawn secondary rays
• Reflection rays and refraction rays
• Use surface normal as guide (angle of
incidence equals angle of reflection)
• If another object is hit, determine the light it
illuminates by recursing through ray tracing
Recursive Ray Tracing
Stop recursing when:
• ray fails to intersect an object
• user-specified maximum depth is reached
• system runs out of memory
Common numerical accuracy error
• Spawn secondary ray from intersection point
• Secondary ray intersects another polygon on same object
Recursive Ray Tracing
Still producing PhD’s after all these years
Many opportunities to improve efficiency and
accuracy of ray tracing
• Reduce the number of rays cast
• Accurately capture shadows caused by non-lights (ray
tracing from the light source)
• Expensive to recompute as eyepoint changes
Image Synthesis Class
Prof. Humphreys is looking for students
Modeled after Stanford course (let’s beat ‘em)
• See: http://graphics.stanford.edu/courses/cs348b-competition/
Radiosity

Ray tracing models specular


reflection and refractive transparency, but
still uses an ambient term to account for
other lighting effects
Radiosity is the rate at which energy is
emitted or reflected by a surface
By conserving light energy in a volume,
these radiosity effects can be traced

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy