Phong
Phong
Phong
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
Illumination Models
Simplified and fast methods for calculating surfaces intensities, mostly empirical Calculations are based on optical properties of surfaces and the lighting conditions (no reflected sources nor shadows) Light sources are considered to be point sources Reasonably good approximation for most scenes
Ambient Illumination
Assume there is some non-directional light in the environment (background light) The amount of ambient light incident on each object is constant for all surfaces and over all directions Very simple model, not very realistic OpenGL default
Ambient Illumination
The reflected intensity Iamb of any point on the surface is:
Iamb = Ka Ia
Ia - ambient light intensity Ka [0,1] - surface ambient reflectivity In principle Ia and Ka are functions of color, so we have IRamb, IGamb and IBamb
Ambient Illumination
Example:
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()
L
Diffuse Reflection
Brightness is proportional to cos() because a surface (a) perpendicular to the light direction is more illuminated than a surface (b) at an oblique angle a b
Diffuse Reflection
The reflected intensity Idiff of a point on the surface is:
Diffuse Reflection
Example:
Diffuse Reflection
Example: diffuse reflection from different light directions
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:
I = Idiff + Iamb = Kd Ip NL + Ka Ia
Note this is the model for one color and it should be replicated for each channel: IR, IG and IB
Diffuse Reflection
Example:
0 0.3 0.6
Kd
0.3
0.5
0.7
Ka
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
N L R L N R V
Specular Reflection
The Phong Model: reflected specular intensity falls off as some power of cos ():
Specular surface
Specular Reflection
The Phong Model: plots of cosn() for three values of the specular parameter n
1
n=1
0.8
n=8 n=64 L
N R V
0.6
0.4
0.2
Specular surface
0 -2
-1.5
-1
-0.5
0.5
1.5
Specular Reflection
The illumination equation combined with diffuse reflection is:
I= Iamb+k (Ikdiff+Ikspec)
Specular Reflection
Example:
0 0.2 0.5 0.8
Ks
0.3
0.7
Kd
Specular Reflection
Example: effects of the specular parameter n
Specular Reflection
Example:
Ambient Illumination
Ambient + Diffuse
Flat Shading
A single intensity is calculated for each surface polygon Fast and simple method Gives reasonable result only if all of the following assumptions are valid: The object is a polyhedron Light source is far away from the surface so that NL is constant over each polygon Viewing position is far away from the surface so that VR is constant over each polygon
Gouraud Shading
Renders the polygon surface by linearly interpolating intensity values across the surface Gouraud Shading Algorithm: 1. Determine the normal at each polygon vertex 2. Apply an illumination model to each vertex to calculate the vertex intensity 3. Linearly interpolate the vertex intensities over the surface polygon
Gouraud Shading
The normal Nv of a vertex is an average of all neighboring normals:
N
V
N N
Gouraud Shading
Interpolation of the vertex intensities
y
I3 I1 IP I4 I2
y y
y y
I5
y y
y y
scan line
I4 =
I5 =
4 1
y y
y y
2 2
I1 +
I3 +
1 1
y y
y y
x
4 2
I2
5 2
4 4
5 3
5 5
2 2
p 4
3 3
p 5
I2
Ip =
x x
x x
I4
x + x
x x
I5
Gouraud Shading
Example: Gouraud shading of a sphere
Phong Shading
A more accurate method for rendering a polygon surface is to interpolate normal vectors, and then apply the illumination model to each surface point Phong Shading Algorithm: 1. Determine the normal at each polygon vertex 2. Linearly interpolate the vertex normals over the surface polygon 3. Apply the illumination model along each scan line to calculate intensity of each surface point
Phong Shading
Example: Phong shading of a sphere
Phong
Phong
Flat
Gouraud
Phong