Академический Документы
Профессиональный Документы
Культура Документы
Lecture 15 Slide 3 6.837 Fall 2001 Lecture 15 Slide 4 6.837 Fall 2001
1
Directional Light Sources Point Light Sources
All of the rays from a directional light source have a common The point light source emits rays in radial directions from its
direction, and no point of origin. It is as if the light source was source. A point light source is a fair approximation to a local
infinitely far away from the surface that it is illuminating. light source such as a light bulb.
Sunlight is an example of an infinite light source.
Lecture 15 Slide 7 6.837 Fall 2001 Lecture 15 Slide 8 6.837 Fall 2001
2
Lambert's Cosine Law Computing Diffuse Reflection
The angle between the surface normal and the incoming light
ray is called the angle of incidence and we can express a
intensity of the light in terms of this angle.
Ideal diffuse reflectors reflect light according to Lambert's cosine law, The Ilight term represents the intensity of the incoming light at
(there are sometimes called Lambertian reflectors). Lambert's law states
that the reflected energy from a small surface area in a particular direction the particular wavelength (the wavelength determines the
is proportional to cosine of the angle between that direction and the light's color). The kd term represents the diffuse reflectivity of
surface normal. Lambert's law determines how much of the incoming light the surface at that wavelength.
energy is reflected. Remember that the amount energy that is reflected in
In practice we use vector analysis to compute cosine term
any one direction is constant in this model. In other words the reflected
intensity is independent of the viewing direction. The intensity does indirectly. If both the normal vector and the incoming light
however depend on the light source's orientation relative to the surface, vector are normalized (unit length) then diffuse shading can be
and it is this property that is governed by Lambert's law. computed as follows:
Lecture 15 Slide 9 6.837 Fall 2001 Lecture 15 Slide 10 6.837 Fall 2001
3
Snell's Law Reflection
Reflection behaves according to Snell's law: Reflection is a very special case of Snell's Law where the
The incoming ray, the surface normal, incident light's medium and the reflected rays medium is the
and the reflected ray all lie in a same. Thus we can simplify the expression to:
common plane.
The angle that the reflected ray forms
with the surface normal is determined
θl = θr
by the angle that the incoming ray
forms with the surface normal, and
the relative speeds of light of the
mediums in which the incident and
reflected rays propagate according to
the following expression.
(Note: nl and nr are the indices of
refraction)
Lecture 15 Slide 13 6.837 Fall 2001 Lecture 15 Slide 14 6.837 Fall 2001
Lecture 15 Slide 15 6.837 Fall 2001 Lecture 15 Slide 16 6.837 Fall 2001
4
Effect of the nshiny coefficient Computing Phong Illumination
n shiny
( )
The diagram below shows the how the reflectance drops off in
a Phong illumination model. For a large value of the nshiny I specular = k s I light Vˆ ⋅ Rˆ
coefficient, the reflectance decreases rapidly with increasing
viewing angle.
The V vector is the unit vector in the direction of the viewer
and the R vector is the mirror reflectance direction. The vector
R can be computed from the incoming light direction and the
surface normal:
( )
R = 2 Nˆ ⋅ Lˆ Nˆ − Lˆ
Lecture 15 Slide 17 6.837 Fall 2001 Lecture 15 Slide 18 6.837 Fall 2001
Lecture 15 Slide 19 6.837 Fall 2001 Lecture 15 Slide 20 6.837 Fall 2001
5
Putting it all together Phong Illumination Model
Phong Illumination Model lights
n shiny
I total = k a I ambient
( ) (
+ I light k d Nˆ ⋅ Lˆ + k s Vˆ ⋅ Rˆ )
n shiny
i =1
( ) (
I total, λ = k aOλI ambient, λ + ∑ I i , λ k d Oλ Nˆ ⋅ Lˆ + k s Vˆ ⋅ Rˆ )
for each light Ii
for each color component I total, λ , O λ , I ambient, λ , I i , λ
reflectance coefficients kd, ks, and ka scalars between 0 and 1
shiny surfaces
notice that the specular component does not depend on the
object color O λ .
Lecture 15 Slide 21 6.837 Fall 2001 Lecture 15 Slide 22 6.837 Fall 2001
6
Facet Shading Vertex Normals
ni
Even when the illumination equation is applied at each point of If vertex normals are not provided
the faceted nature of the polygonal nature is still apparent. they can often be approximated by k
nv = ∑
averaging the normals of the facets
which share the vertex.
ni
ni
k
nv = ∑
i =1 n i i =1
This only works if the polygons
To overcome this limitation normals are introduced at each reasonably approximate the
vertex. underlying surface.
different than the polygon normal
A better approximation can be
for shading only (not backface culling or other
found using a clustering analysis of
computations) the normals on the unit sphere.
better approximates smooth surfaces
Lecture 15 Slide 25 6.837 Fall 2001 Lecture 15 Slide 26 6.837 Fall 2001
Lecture 15 Slide 27 6.837 Fall 2001 Lecture 15 Slide 28 6.837 Fall 2001
7
Transforming Surface Normals Normals Represent Tangent Spaces
By now you realize that surface normals are the most The fundamental problem with transforming normals is largely
important geometric surface characteristic used in computing a product of our mental model of what a normal really is. A
illumination models. They are used in computing both the normal is not a geometric property relating to points of of the
diffuse and specular components of reflection. surface, like a quill on a porcupine. Instead normals represent
geometric properties on the surface. They are an implicit
However, the vertices of a model do not transform in the same representation of the tangent space of the surface at a point.
way that surface normals do. A naive implementer might
consider transforming normals by treating them as points
offset a unit length from the surface. But even this approach
will not work. Consider the following two dimensional example.
8
Transforming Normals Normals of Curved Surfaces
This transformed tangent, t', must be perpendicular to the Not all surfaces are given as planar facets. A common example
transformed normal n‘: of such a surface a parametric surface. For a parametric
surface the three-space coordinates are determined by
n ′ = Qn
Let's solve for the transformation matrix Q that preserves the functions of two parameters u and v.
X (u ,v )
perpendicular relationship.
T S (u ,v ) = Y (u ,v )
n ′ ⋅ t 1′ = (Qn ) A ′t 1 = n TQ T A ′t 1 ,
Z (u ,v )
then n ′ ⋅ t 1′ = 0 iff Q T A ′ = I because n ⋅ t 1 = 0. The tangent vectors are computed with partial derivatives and
the normal with a cross product:
T ∂X ∂X
In other words Q = ( A ′−1 ) .
∂u
∂v
∂Y
∂Y
t1 = , t2 = , n = t 1 ×t 2
∂u ∂v
For what matrices A’ , would Q= A’ ? ∂Z ∂Z
∂u ∂v
Lecture 15 Slide 33 6.837 Fall 2001 Lecture 15 Slide 34 6.837 Fall 2001
Lecture 15 Slide 35 6.837 Fall 2001 Lecture 15 Slide 36 6.837 Fall 2001