Download presentation
Presentation is loading. Please wait.
Published byHendra Halim Modified over 6 years ago
1
CSE 470 Introduction to Computer Graphics Arizona State University
Lighting CSE 470 Introduction to Computer Graphics Arizona State University Dianne Hansford
2
Lighting Overview Elements of a lighting model
The Phong illumination model Application of the Phong model Shading methods: flat, Gouraud, Phong OpenGL aspects
3
Perception of an object influenced by:
light sources: number, type, color reflections material properties: reflection & absorption of light 3D feel – depth perception CG: approximate real-world lighting with a model
4
CG Lighting Models Local Single interaction of light & objects
Phong illumination model Global Multiple interaction of light & objects raytracing or radiosity
5
Elements of the Phong Model
Light Source Properties ambient light diffuse light specular light point source vs spotlight positional vs directional
6
Light Source Properties
ambient light scattered, no detectable direction backlighting in a room diffuse light directional, scatters once hits object, closest to the color of light specular light directed and bounces off object in preferred direction plays a role in shininess
7
Elements of the Phong Model
Material (object) properties influences interaction with light 1. reflectance of light a. ambient b. diffuse c. specular d. translucent (opaque) 2. surface normals 3. emissive color
8
Material Properties ambient reflectance amount of ambient light most visible where no direct light hits diffuse reflectance degree of scattering of light on surface matte vs flat paint finish specular reflectance degree of mirror-like quality
9
Light & Material Properties Examples
increasing diffuse increasing ambient increasing specular
10
Light & Material Properties
absorption/reflectance influence on color Example: red ball will reflect red light absorb green and blue light white light illuminating a red ball red ball green light illuminating a red ball black ball
11
Notation: Light Properties
Model is computed independently for red, green, blue components Light’s luminance represented by boldface vectors: La := ambient Ld := diffuse Ls := specular % of full intensity r g b Each vector takes form
12
Notation: Material Properties
Material’s properties represented by boldface vectors: ka := ambient kd := diffuse ks := specular % of reflection of light source’s corresponding property r % g % b % 0 <= r,g,b % <= 1 Each vector takes form
13
Math of the Phong Model Primary geometry v p point on surface
l light – p vector n normal to surface r reflection vector v viewpoint – p vector theta angle of incidence phi angle between v and r p Recall: angle of incidence equals angle of reflection All vectors normalized
14
Phong Model in OGL vertex color = material emission‡
+ (global ambient light scaled by material ambient property) + (ambient, diffuse, specular of lights, attenuated by material properties, viewer location and light position) ‡ at vertex
15
Diffuse Intensity Calculation
Lambert’s Law: light reflected is proportional to the cosine of the angle (theta) between surface normal n and light vector l theta is called the angle of incidence
16
Diffuse Intensity Calculation
Id := intensity of reflected diffuse light Id = kd x Ld x cos(theta) cos(theta) = l • n angles 0 90° Id = kd x Ld x (max{l • n, 0}) “x” is not cross product 3 separate scalar products “• “ is dot product Note: independent of viewer
17
Specular Intensity Calculation
Is := intensity of reflected specular light Basic idea: Is = ks x Ls x cos^s(phi) cos(phi) = v • r r = [2(l•n)]n - l phi = 0° full specular |phi| > 90° no specular (never compute angle directly) Focus of specular influenced by s Note: depends on viewpoint
18
Specular Intensity Calculation
s: Phong constant or “shininess” coefficient cos^s(phi) s=0.1 spread s=1 s=10 focus - 90° 90°
19
Specular Intensity Calculation
Blinn-Torrence modification – simplification for faster computation h = (l + v) / || l + v || “halfway” vector cos(alpha) = h • n alpha ~ ½ phi so good approximation
20
Specular Intensity Calculation
Is = ks x Ls x [max{h • n, 0}]^s if l • n < 0 then Is = 0 (no diffuse, no specular)
21
Attenuation Function For a positional light ...
d := distance of light source to vertex ogl choices for functions constant linear quadratic f(d) = 1/a f(d) = 1/(a + b*d) f(d) = 1/(a + b*d + c*d^2) inverse distance functions diminish intensity d increases for directional light, f(d) = 1
22
Spotlight Effect c Cone-shaped spotlight defined by: gamma c position
gamma “cut-off” angle d direction d sp := spotlight effect for a light source defined by angle between -l and d : cos(delta) = -l • d if delta > gamma sp = 0 else sp = (max{-l • d, 0})^p p influence similar to Phong constant; focus of intensity
23
Putting It All Together
Phong Model I := intensity at a vertex e := emission intensity at a vertex Ma := ambient intensity for the entire model I = e + (ka x Ma) + for each light { [f(d) * sp * (ka*La + Id + Is)] } Remember: boldface indicates r,g,b values
24
Shading Methods Phong model color of vertex
Shading methods color of triangle Methods: Flat shading Gouraud (smooth) shading Phong‡ Shading in ogl Recall: triangle normal .vs. averaged vertex normal ‡ confusing, but different from Phong illumination model
25
Flat Shading One normal per triangle
Simulates viewer and light source distant then v, n, l same over triangle one shading calculation
26
Gouraud (smooth) Shading
One normal per vertex Lighting calculation made at each vertex I1, I2, I3 Lighting at any point p within triangle v1, v2, v3 I = b1*I1 + b2*I2 + b3* I3 where b1, b2, b3 are the barycentric coordinates of p wrt v1, v2, v3 p = b1*v1 + b2*v2 + b3*v3 (b1 + b2 + b3 = 1)
27
Phong Shading One normal per vertex ... however
a normal is calculated for each rendered point p in triangle vertex normals n1, n2, n3 p = b1*v1 + b2*v2 + b3*v3 n = b1*n1 + b2*n2 + b3*n3 Calculate intensity at p wrt n
28
Resources Many figures for these slides were taken from Pascal Vuytsteker’s website: Delphi3d’s Phong for dummies
29
Material Properties
30
Material Properties
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.