http://www.ugrad.cs.ubc.ca/~cs314/Vjan2013
Lighting/Shading
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2013 Tamara Munzner
2
Correction: W2V vs. V2W
- MV2W=(MW2V)-1
=R-1T-1
Mview2world = ux uy uz vx vy vz wx wy wz 1
- 1
ex 1 ey 1 ez 1
- =
ux uy uz e•u vx vy vz e• v wx wy wz e• w 1
- MV2W =
ux uy uz ex ux + ey uy + ez uz vx vy vz ex vx + ey vy + ez vz wx wy wz ex wx + ey wy + ez wz 1
- slide 26, Viewing
3
Recorrection: Perspective Derivation
x' y' z' w'
- =
E A F B C D 1
- x
y z 1
- y'= Fy + Bz, y'
w' = Fy + Bz w' , 1= Fy + Bz w' , 1= Fy + Bz z , 1= F y z + B z z , 1= F y z B, 1= F top (near) B, x'= Ex + Az y'= Fy + Bz z'= Cz + D w'= z x = left x /
- w = 1
x = right x /
- w =1
y = top y /
- w =1
y = bottom y /
- w = 1
z = near z /
- w = 1
z = far z /
- w =1
1= F top near B z axis flip! L/R sign error slide 91, Viewing
4
Reading for This Module
- FCG Chapter 10 Surface Shading
- FCG Section 8.2.4-8.2.5
- RB Chap Lighting
5
Lighting I
6
Rendering Pipeline
Geometry Database Model/View Transform. Lighting Perspective Transform. Clipping Scan Conversion Depth Test Texturing Blending Frame- buffer
7
Projective Rendering Pipeline
OCS - object/model coordinate system WCS - world coordinate system VCS - viewing/camera/eye coordinate system CCS - clipping coordinate system NDCS - normalized device coordinate system DCS - device/display/screen coordinate system
OCS O2W VCS CCS NDCS DCS
modeling transformation viewing transformation projection transformation viewport transformation perspective divide
- bject
world viewing device normalized device clipping W2V V2C N2D C2N WCS
8
Goal
- simulate interaction of light and objects
- fast: fake it!
- approximate the look, ignore real physics
- get the physics (more) right
- BRDFs: Bidirectional Reflection Distribution Functions
- local model: interaction of each object with light
- global model: interaction of objects with each other
9
Photorealistic Illumination
[electricimage.com]
- transport of energy from light sources to surfaces & points
- global includes direct and indirect illumination – more later
Henrik Wann Jensen 10
Illumination in the Pipeline
- local illumination
- only models light arriving directly from light
source
- no interreflections or shadows
- can be added through tricks, multiple
rendering passes
- light sources
- simple shapes
- materials
- simple, non-physical reflection models
11
Light Sources
- types of light sources
- glLightfv(GL_LIGHT0,GL_POSITION,light[])
- directional/parallel lights
- real-life example: sun
- infinitely far source: homogeneous coord w=0
- point lights
- same intensity in all directions
- spot lights
- limited set of directions:
- point+direction+cutoff angle
- z
y x
- 1
z y x
12
Light Sources
- area lights
- light sources with a finite area
- more realistic model of many light sources
- not available with projective rendering pipeline
(i.e., not available with OpenGL)
13
Light Sources
- ambient lights
- no identifiable source or direction
- hack for replacing true global illumination
- (diffuse interreflection: light bouncing off from
- ther objects)
14
Diffuse Interreflection
15
Ambient Light Sources
- scene lit only with an ambient light source
Light Position Not Important Viewer Position Not Important Surface Angle Not Important
16
Directional Light Sources
- scene lit with directional and ambient light
Light Position Not Important Viewer Position Not Important Surface Angle Important