illumination models and shading
TRANSCRIPT
![Page 1: Illumination Models and Shading](https://reader031.vdocuments.us/reader031/viewer/2022022415/5865df141a28abd75a8c5c1f/html5/thumbnails/1.jpg)
Illumination Models and ShadingFoley & Van Dam, Chapter 16
![Page 2: Illumination Models and Shading](https://reader031.vdocuments.us/reader031/viewer/2022022415/5865df141a28abd75a8c5c1f/html5/thumbnails/2.jpg)
Illumination Models and Shading• Light Source Models• Ambient Illumination• Diffuse Reflection• Specular Reflection• Polygon Rendering Methods• Flat Shading• Gouraud Shading • Phong Shading
![Page 3: Illumination Models and Shading](https://reader031.vdocuments.us/reader031/viewer/2022022415/5865df141a28abd75a8c5c1f/html5/thumbnails/3.jpg)
Illumination Models• Motivation: In order to produce realistic images, we must simulate the appearance of surfaces under various lighting conditions
• Illumination Model: Given the illumination incident at a point on a surface, quantifies the reflected light
![Page 4: Illumination Models and Shading](https://reader031.vdocuments.us/reader031/viewer/2022022415/5865df141a28abd75a8c5c1f/html5/thumbnails/4.jpg)
Illumination Model Parameters• Lighting effects are described with models that consider the interaction of light sources with object surfaces
• The factors determining the lighting effects are:– The light source parameters:
• Positions• Electromagnetic Spectrum• Shape
– The surface parameters• Position• Reflectance properties• Position of nearby surfaces
– The eye (camera) parameters• Position• Sensor spectrum sensitivities
![Page 5: Illumination Models and Shading](https://reader031.vdocuments.us/reader031/viewer/2022022415/5865df141a28abd75a8c5c1f/html5/thumbnails/5.jpg)
Illumination Models and Rendering
• An illumination model is used to calculate the intensity of the light that is reflected at a given point on a surface• A rendering method uses intensity calculations from the illumination model to determine the light intensity at all pixels in the image
![Page 6: Illumination Models and Shading](https://reader031.vdocuments.us/reader031/viewer/2022022415/5865df141a28abd75a8c5c1f/html5/thumbnails/6.jpg)
Light Source Models• Point Source (a): All light rays originate at a point and
radially diverge. A reasonable approximation for sourceswhose dimensions are small compared to the object size
• Parallel source (b): Light rays are all parallel. May bemodeled as a point source at infinite distance (the sun)
• Distributed source (c): All light rays originate at a finitearea in space. It models a nearby source, such as a fluorescent light
ab
c
![Page 7: Illumination Models and Shading](https://reader031.vdocuments.us/reader031/viewer/2022022415/5865df141a28abd75a8c5c1f/html5/thumbnails/7.jpg)
Illumination Models• Simplified and fast methods for calculatingsurfaces intensities, mostly empirical
• Calculations are based on optical propertiesof surfaces and the lighting conditions (no reflected sources nor shadows)
• Light sources are considered to be point sources
• Reasonably good approximation for most scenes
![Page 8: Illumination Models and Shading](https://reader031.vdocuments.us/reader031/viewer/2022022415/5865df141a28abd75a8c5c1f/html5/thumbnails/8.jpg)
Ambient Illumination• Assume there is some non-directional lightin the environment (background light)
• The amount of ambient light incident oneach object is constant for all surfaces andover all directions
• Very simple model, not very realistic
• OpenGL default
![Page 9: Illumination Models and Shading](https://reader031.vdocuments.us/reader031/viewer/2022022415/5865df141a28abd75a8c5c1f/html5/thumbnails/9.jpg)
Ambient Illumination• The reflected intensity Iamb of any point on the
surface is:
Ia - ambient light intensityKa ∈ [0,1] - surface ambient reflectivity
• In principle Ia and Ka are functions of color, so wehave IRamb, IGamb and IBamb
Iamb = Ka Ia
![Page 10: Illumination Models and Shading](https://reader031.vdocuments.us/reader031/viewer/2022022415/5865df141a28abd75a8c5c1f/html5/thumbnails/10.jpg)
Ambient Illumination• Example:
![Page 11: Illumination Models and Shading](https://reader031.vdocuments.us/reader031/viewer/2022022415/5865df141a28abd75a8c5c1f/html5/thumbnails/11.jpg)
Diffuse Reflection• Diffuse (Lambertian) surfaces are rough or grainy,like clay, soil, fabric
• The surface appears equally bright from all viewing directions
• The brightness at each point is proportional to cos(θ)
θNL
![Page 12: Illumination Models and Shading](https://reader031.vdocuments.us/reader031/viewer/2022022415/5865df141a28abd75a8c5c1f/html5/thumbnails/12.jpg)
Diffuse Reflection• Brightness is proportional to cos(θ) because a
surface (a) perpendicular to the light direction ismore illuminated than a surface (b) at an obliqueangle
a b
θNL
![Page 13: Illumination Models and Shading](https://reader031.vdocuments.us/reader031/viewer/2022022415/5865df141a28abd75a8c5c1f/html5/thumbnails/13.jpg)
Diffuse Reflection• The reflected intensity Idiff of a point on the
surface is:
Ip - the point light intensity. May appear as attenuated source fatt(r)IPKd ∈ [0,1] - the surface diffuse reflectivityN - the surface normal L - the light direction
NOTE: If N and L have unitary length: cos(θ) = N ⋅ L
Idiff = Kd Ipcos(θ) = Kd Ip(N⋅L)
![Page 14: Illumination Models and Shading](https://reader031.vdocuments.us/reader031/viewer/2022022415/5865df141a28abd75a8c5c1f/html5/thumbnails/14.jpg)
Diffuse Reflection• Example:
![Page 15: Illumination Models and Shading](https://reader031.vdocuments.us/reader031/viewer/2022022415/5865df141a28abd75a8c5c1f/html5/thumbnails/15.jpg)
Diffuse Reflection• Example: diffuse reflection from differentlight directions
![Page 16: Illumination Models and Shading](https://reader031.vdocuments.us/reader031/viewer/2022022415/5865df141a28abd75a8c5c1f/html5/thumbnails/16.jpg)
Diffuse Reflection• Commonly, there are two types of light sources:
– A background ambient light– A point light source
• The equation that combines the two models is:
• Note this is the model for one color and it shouldbe replicated for each channel: IR, IG and IB
I = Idiff + Iamb = Kd Ip N⋅L + Ka Ia
![Page 17: Illumination Models and Shading](https://reader031.vdocuments.us/reader031/viewer/2022022415/5865df141a28abd75a8c5c1f/html5/thumbnails/17.jpg)
Diffuse Reflection• Example:
0 0.3 0.6
0.3
0.5
0.7
Ka
Kd
![Page 18: Illumination Models and Shading](https://reader031.vdocuments.us/reader031/viewer/2022022415/5865df141a28abd75a8c5c1f/html5/thumbnails/18.jpg)
Specular Reflection• Models shiny and glossy surfaces (like metal,plastic, etc..) with highlights
• Reflectance intensity changes with reflected angle• An ideal specular surface (mirror) reflects light exclusively in one direction: R
• Glossy objects are not ideal mirrors and reflect in the immediate vicinity of R
θ θ
NL R
θ θ
NL Rφ
V
Ideal specular surface Non-ideal specular surface
![Page 19: Illumination Models and Shading](https://reader031.vdocuments.us/reader031/viewer/2022022415/5865df141a28abd75a8c5c1f/html5/thumbnails/19.jpg)
Specular Reflection• The Phong Model: reflected specular intensity
falls off as some power of cos (φ):
Ks - the surface specular reflectivityn – specular reflection parameter, determining
the deviation from ideal specular surface(for a perfect mirror n=∞)
Ispec = Ks Ipcosn(φ) = Ks Ip(R⋅V)n
θ θ
NL Rφ
V
Specular surface
![Page 20: Illumination Models and Shading](https://reader031.vdocuments.us/reader031/viewer/2022022415/5865df141a28abd75a8c5c1f/html5/thumbnails/20.jpg)
Specular Reflection• The Phong Model: plots of cosn(φ) for three
values of the specular parameter n
-2 -1.5 -1 -0.5 0 0.5 1 1.5 20
0.2
0.4
0.6
0.8
1
n=1n=8
n=64
θ θ
NL Rφ
V
Specular surface
![Page 21: Illumination Models and Shading](https://reader031.vdocuments.us/reader031/viewer/2022022415/5865df141a28abd75a8c5c1f/html5/thumbnails/21.jpg)
Specular Reflection• The illumination equation combined with diffuse reflection is:
• If k light sources are present in the scene:
I = Iamb+Idiff+Ispec=Ka Ia + Ip (Kd N⋅L + Ks (R⋅V)n)
I= Iamb+Σk (Ikdiff+Ikspec)
![Page 22: Illumination Models and Shading](https://reader031.vdocuments.us/reader031/viewer/2022022415/5865df141a28abd75a8c5c1f/html5/thumbnails/22.jpg)
Specular Reflection• Example:
0.2 0.5 0.8
0
0.3
0.7
Kd
Ks
![Page 23: Illumination Models and Shading](https://reader031.vdocuments.us/reader031/viewer/2022022415/5865df141a28abd75a8c5c1f/html5/thumbnails/23.jpg)
Specular Reflection• Example: effects of the specular parameter n
n=50
n=10
n=3
![Page 24: Illumination Models and Shading](https://reader031.vdocuments.us/reader031/viewer/2022022415/5865df141a28abd75a8c5c1f/html5/thumbnails/24.jpg)
Specular Reflection• Example:
Ambient Illumination
Ambient + Diffuse
Ambient + Diffuse + Specular
![Page 25: Illumination Models and Shading](https://reader031.vdocuments.us/reader031/viewer/2022022415/5865df141a28abd75a8c5c1f/html5/thumbnails/25.jpg)
Composing Light Sources• Example:
![Page 26: Illumination Models and Shading](https://reader031.vdocuments.us/reader031/viewer/2022022415/5865df141a28abd75a8c5c1f/html5/thumbnails/26.jpg)
Polygon Rendering Methods• A freeform surface can be approximatedby polyhedra
• Rendering: calculate the illumination at each surface point
• Applying the illumination model at eachsurface point is computationally expensive
![Page 27: Illumination Models and Shading](https://reader031.vdocuments.us/reader031/viewer/2022022415/5865df141a28abd75a8c5c1f/html5/thumbnails/27.jpg)
Flat Shading• A single intensity is calculated for each surfacepolygon
• Fast and simple method• Gives reasonable result only if all of the followingassumptions are valid:
– The object is a polyhedron– Light source is far away
from the surface so that N•L is constant over each polygon
– Viewing position is far away from the surface so that V•R is constant over each polygon
![Page 28: Illumination Models and Shading](https://reader031.vdocuments.us/reader031/viewer/2022022415/5865df141a28abd75a8c5c1f/html5/thumbnails/28.jpg)
Gouraud Shading• Renders the polygon surface by linearly interpolating intensity values across the surface
Gouraud Shading Algorithm:1. Determine the normal at each polygon vertex2. Apply an illumination model to each vertex to
calculate the vertex intensity3. Linearly interpolate the vertex intensities over
the surface polygon
![Page 29: Illumination Models and Shading](https://reader031.vdocuments.us/reader031/viewer/2022022415/5865df141a28abd75a8c5c1f/html5/thumbnails/29.jpg)
Gouraud Shading• The normal Nv of a vertex is an average of all neighboring normals:
∑
∑=
kk
kk
V
N
NN
![Page 30: Illumination Models and Shading](https://reader031.vdocuments.us/reader031/viewer/2022022415/5865df141a28abd75a8c5c1f/html5/thumbnails/30.jpg)
Gouraud Shading• Interpolation of the vertex intensities
221
411
21
244 I
yyyyI
yyyyI
−−
+−−
=
223
533
23
255 I
yyyyI
yyyyI
−−
+−−
=
545
4p4
45
p5p I
xxxx
Ixxxx
I−−
+−−
=
I1
I2
I3
I4 I5scan line
y
x
IP
![Page 31: Illumination Models and Shading](https://reader031.vdocuments.us/reader031/viewer/2022022415/5865df141a28abd75a8c5c1f/html5/thumbnails/31.jpg)
Gouraud Shading• Example: Gouraud shading of a sphere
![Page 32: Illumination Models and Shading](https://reader031.vdocuments.us/reader031/viewer/2022022415/5865df141a28abd75a8c5c1f/html5/thumbnails/32.jpg)
Phong Shading• A more accurate method for rendering a polygonsurface is to interpolate normal vectors, and thenapply the illumination model to each surface point
Phong Shading Algorithm:1. Determine the normal at each polygon vertex2. Linearly interpolate the vertex normals over
the surface polygon3. Apply the illumination model along each scan
line to calculate intensity of each surface point
![Page 33: Illumination Models and Shading](https://reader031.vdocuments.us/reader031/viewer/2022022415/5865df141a28abd75a8c5c1f/html5/thumbnails/33.jpg)
Phong Shading• Example: Phong shading of a sphere
![Page 34: Illumination Models and Shading](https://reader031.vdocuments.us/reader031/viewer/2022022415/5865df141a28abd75a8c5c1f/html5/thumbnails/34.jpg)
Polygon Rendering Methods• Example:
Flat
Gouraud
Phong
![Page 35: Illumination Models and Shading](https://reader031.vdocuments.us/reader031/viewer/2022022415/5865df141a28abd75a8c5c1f/html5/thumbnails/35.jpg)
Polygon Rendering Methods• Example:
Flat
Gouraud
Phong
![Page 36: Illumination Models and Shading](https://reader031.vdocuments.us/reader031/viewer/2022022415/5865df141a28abd75a8c5c1f/html5/thumbnails/36.jpg)
Polygon Rendering Methods• Example:
Flat Gouraud
Phong