0% found this document useful (0 votes)
4 views9 pages

Lecture16 - Lights

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views9 pages

Lecture16 - Lights

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Lecture 16 --- 6.837 Fall '00 Lecture 16 --- 6.

837 Fall '00

Illumination and Shading - Part 1 Two Components of Illumination


Light Sources

● Emittance Spectrum (color)


● Light Sources
● Geometry (position and direction)
● Directional Attenuation
● Empirical
Illumination
Surface Properties
● Reflectance Spectrum (color)
● Shading
● Geometry (position, orientation, and micro-structure)
● Absorption
● Transforming
Normals
Simplifications used by most computer graphics systems:
● Only the direct illumination from the emitters to the reflectors of the scene
● Project #4
● Ignore the geometry of light emitters, and consider only the geometry of reflectors

Lecture 16 Slide 1 6.837 Fall '00 Lecture 16 Slide 3 6.837 Fall '00

http://graphics.lcs.mit.edu/classes/6.837/F00/Lecture16/Slide01.html [11/9/2000 2:58:30 PM] http://graphics.lcs.mit.edu/classes/6.837/F00/Lecture16/Slide03.html [11/9/2000 2:58:36 PM]

Lecture 16 --- 6.837 Fall '00 Lecture 16 --- 6.837 Fall '00

Illumination Models Ambient Light Source


Even though an object in a scene is not directly lit it will still be visible. This is because light
Computer Graphics Jargon: is reflected indirectly from nearby objects. A simple hack that is commonly used to model
this indirect illumination is to use of an ambient light source.
● Illumination - the transport of
luminous flux from light sources
between points via direct and indirect
paths
● Lighting - the process of computing
the luminous intensity reflected from a
specified 3-D point
Ambient light has no spatial or directional characteristics. The amount of ambient light
● Shading - the process of assigning incident on each object is a constant for all surfaces in the scene. An ambient light can have
colors to pixels a color.
The amount of ambient light that is reflected by an object is independent of the object's
Illumination Models: position or orientation. Surface properties are used to determine how much ambient light is
reflected.
● Empirical - simple formulations that approximate observed phenomenon
● Physically-based - models based on the actual physics of light's interactions with matter

Lecture 16 Slide 2 6.837 Fall '00 Lecture 16 Slide 4 6.837 Fall '00

http://graphics.lcs.mit.edu/classes/6.837/F00/Lecture16/Slide02.html [11/9/2000 2:58:35 PM] http://graphics.lcs.mit.edu/classes/6.837/F00/Lecture16/Slide04.html (1 of 4) [11/9/2000 2:58:38 PM]


Lecture 16 --- 6.837 Fall '00 Lecture 16 --- 6.837 Fall '00

Directional Light Sources Other Light Sources


All of the rays from a directional light source have a common direction, and no point of Spotlights
origin. It is as if the light source was infinitely far away from the surface that it is
illuminating. ● Point source whose intensity falls off away from a
given direction
Sunlight is an example of an infinite light source.
● Requires a color, a point, a direction, parameters
that control the rate of fall off

Area Light Sources


The direction from a surface to a light source is important for computing the light reflected
from the surface. With a directional light source this direction is a constant for every surface. ● Light source occupies a 2-D area (usually a
polygon or disk)
A directional light source can be colored.
● Generates soft shadows

Extended Light Sources


● Spherical Light Source
● Generates soft shadows

Lecture 16 Slide 5 6.837 Fall '00 Lecture 16 Slide 7 6.837 Fall '00

http://graphics.lcs.mit.edu/classes/6.837/F00/Lecture16/Slide05.html [11/9/2000 2:58:39 PM] http://graphics.lcs.mit.edu/classes/6.837/F00/Lecture16/Slide07.html [11/9/2000 2:58:42 PM]

Lecture 16 --- 6.837 Fall '00 Lecture 16 --- 6.837 Fall '00

Point Light Sources Ideal Diffuse Reflection


The rays emitted from a point light radially diverge from the source. A point light source is a First, we will consider a particular type of surface called an ideal diffuse reflector. An ideal
fair approximation to a local light source such as a light bulb. diffuse surface is, at the microscopic level, a very rough surface. Chalk is a good
approximation to an ideal diffuse surface. Because of the microscopic variations in the
surface, an incoming ray of light is equally likely to be reflected in any direction over the
hemisphere.

The direction of the light to each point on a surface changes when a point light source is
used. Thus, a normalized vector to the light emitter must be computed for each point that is
illuminated.

Lecture 16 Slide 6 6.837 Fall '00 Lecture 16 Slide 8 6.837 Fall '00

http://graphics.lcs.mit.edu/classes/6.837/F00/Lecture16/Slide06.html [11/9/2000 2:58:40 PM] http://graphics.lcs.mit.edu/classes/6.837/F00/Lecture16/Slide08.html [11/9/2000 2:58:43 PM]


Lecture 16 --- 6.837 Fall '00 Lecture 16 --- 6.837 Fall '00

Lambert's Cosine Law Diffuse Lighting Examples


We need only consider angles from 0 to 90 degrees. Greater angles (where the dot product is
negative) are blocked by the surface, and the reflected energy is 0. Below are several
examples of a spherical diffuse reflector with a varying lighting angles.

Ideal diffuse reflectors reflect light according to Lambert's cosine law, (these are sometimes
called Lambertian reflectors). Lambert's law states that the reflected energy from a small
surface area in a particular direction is proportional to the cosine of the angle between that
direction and the surface normal. Lambert's law determines how much of the incoming light
energy is reflected. Remember that the amount of energy that is reflected in any one
direction is constant in this model. In other words, the reflected intensity is independent of
the viewing direction. The intensity does, however, depend on the light source's orientation Why do you think spheres are used as examples when shading?
relative to the surface, and it is this property that is governed by Lambert's law.

Lecture 16 Slide 9 6.837 Fall '00 Lecture 16 Slide 11 6.837 Fall '00

http://graphics.lcs.mit.edu/classes/6.837/F00/Lecture16/Slide09.html [11/9/2000 2:58:44 PM] http://graphics.lcs.mit.edu/classes/6.837/F00/Lecture16/Slide11.html [11/9/2000 2:58:49 PM]

Lecture 16 --- 6.837 Fall '00 Lecture 16 --- 6.837 Fall '00

Computing Diffuse Reflection Specular 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.
A second surface type is called a specular reflector. When we look at a shiny surface, such
as polished metal or a glossy car finish, we see a highlight, or bright spot. Where this bright
spot appears on the surface is a function of where the surface is seen from. This type of
reflectance is view dependent.
At the microscopic level a specular reflecting surface is very
smooth, and usually these microscopic surface elements are
oriented in the same direction as the surface itself. Specular
reflection is merely the mirror reflection of the light source in a
The Ilight term represents the intensity of the incoming light at the particular wavelength (the surface. Thus it should come as no surprise that it is viewer
wavelength determines the light's color). The kd term represents the diffuse reflectivity of the dependent, since if you stood in front of a mirror and placed your
surface at that wavelength. finger over the refelection of a light, you would expect that you
could reposition your head to look around your finger and see the
In practice we use vector analysis to compute cosine term indirectly. If both the normal light again. An ideal mirror is a purely specular reflector.
vector and the incoming light vector are normalized (unit length) then diffuse shading can be
computed as follows: In order to model specular reflection we need to understand the
physics of reflection.

Lecture 16 Slide 10 6.837 Fall '00 Lecture 16 Slide 12 6.837 Fall '00

http://graphics.lcs.mit.edu/classes/6.837/F00/Lecture16/Slide10.html [11/9/2000 2:58:46 PM] http://graphics.lcs.mit.edu/classes/6.837/F00/Lecture16/Slide12.html [11/9/2000 2:58:50 PM]


Lecture 16 --- 6.837 Fall '00 Lecture 16 --- 6.837 Fall '00

Snell's Law Phong Illumination


Reflection behaves according to Snell's law which states: One function that approximates this fall off is called the Phong Illumination model. This
model has no physical basis, yet it is one of the most commonly used illumination models in
● The incoming ray, the surface normal, and the computer graphics.
reflected ray all lie in a common plane.

● The angle that the reflected ray forms with the


surface normal is determined by the angle that the The cos φ term is maximum when the surface is viewed from the mirror direction and falls
incoming ray forms with the surface normal, and off to 0 when viewed at 90 degrees away from it. The nshiny term controls the rate of this fall
the relative speeds of light of the mediums in which
the incident and reflected rays propogate according off.
to the following expression.

(Note: nl and nr are the indices of refraction)

Reflection is a very special case of Snell's Law where the incident light's medium and the
reflected rays medium is the same. Thus we can simplify the expression to:

Lecture 16 Slide 13 6.837 Fall '00 Lecture 16 Slide 15 6.837 Fall '00

http://graphics.lcs.mit.edu/classes/6.837/F00/Lecture16/Slide13.html [11/9/2000 2:58:51 PM] http://graphics.lcs.mit.edu/classes/6.837/F00/Lecture16/Slide15.html [11/9/2000 2:58:53 PM]

Lecture 16 --- 6.837 Fall '00 Lecture 16 --- 6.837 Fall '00

Non-ideal Reflectors Effect of nshiney


Snell's law, however, applies only to ideal mirror reflectors. Real The diagram below shows the how the Phong reflectance drops off based on the viewer's
materials, other than mirrors and chrome tend to deviate angle from the reflected ray for various values of nshiny.
significantly from ideal reflectors. At this point we will introduce
an empirical model that is consistent with our experience, at least
to a crude approximation.
In general, we expect most of the reflected light to travel in the
direction of the ideal ray. However, because of microscopic
surface variations we might expect some of the light to be reflected just slightly offset from
the ideal reflected ray. As we move farther and farther, in the angular sense, from the
reflected ray we expect to see less light reflected.

Lecture 16 Slide 14 6.837 Fall '00 Lecture 16 Slide 16 6.837 Fall '00

http://graphics.lcs.mit.edu/classes/6.837/F00/Lecture16/Slide14.html [11/9/2000 2:58:52 PM] http://graphics.lcs.mit.edu/classes/6.837/F00/Lecture16/Slide16.html [11/9/2000 2:58:54 PM]


Lecture 16 --- 6.837 Fall '00 Lecture 16 --- 6.837 Fall '00

Computing Phong Illumination


The cos term of Phong's specular illumination using the following relationship. Phong Examples
The following spheres illustrate specular reflections as the direction of the light source and
the coefficient of shineyness is varied.

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 as shown below.

The following figure illustrates this relationship.

Lecture 16 Slide 17 6.837 Fall '00 Lecture 16 Slide 19 6.837 Fall '00

http://graphics.lcs.mit.edu/classes/6.837/F00/Lecture16/Slide17.html [11/9/2000 2:58:55 PM] http://graphics.lcs.mit.edu/classes/6.837/F00/Lecture16/Slide19.html [11/9/2000 2:58:58 PM]

Lecture 16 --- 6.837 Fall '00 Lecture 16 --- 6.837 Fall '00

Blinn & Torrance Variation Putting it all together


Jim Blinn introduced another approach for computing Phong-like illumination based on the Our final empirical illumination model is:
work of Ken Torrance. His illumination function uses the following equation:

Notes:
In this equation the angle of specular dispersion is computed by how far the surface's normal
is from a vector bisecting the incoming light direction and the viewing direction. ● The Phong Lighting model
● Once per light
● Once per color component
● Reflectance coefficients, ka, kd,
and ks may or may not vary
with the color component
If they do, you need to be
careful.

On your own you should consider how this approach and the previous one differ.
Lecture 16 Lecture 16 Slide 20 6.837 Fall '00
Slide 18 6.837 Fall '00

http://graphics.lcs.mit.edu/classes/6.837/F00/Lecture16/Slide18.html [11/9/2000 2:58:57 PM] http://graphics.lcs.mit.edu/classes/6.837/F00/Lecture16/Slide20.html [11/9/2000 2:58:59 PM]


Lecture 16 --- 6.837 Fall '00 Lecture 16 --- 6.837 Fall '00

Where do we Illuminate? Facet Shading


To this point we have discussed how to compute an illumination model at a point on a Even when the illumination equation is applied at each point of the faceted nature of the
surface. But, at which points on the surface is the illumination model applied? Where and polygonal nature is still apparent.
how often it is applied has a noticable effect on the result.
Illuminating can be a costly process involving the computation of and normalizing of vectors
to multiple light sources and the viewer.
For models defined by collections of polygonal facets or triangles:
● Each facet has a common surface normal
● If the light is directional then the diffuse contribution is constant across the facet
● If the eye is infinitely far away and the light is directional then the specular contribution
is constant across the facet To overcome this limitation normals are introduced at each vertex.
● Usually different than the polygon normal
● Used only for shading (not backface culling or other geometric computations)
● Better approximates the "real" surface
❍ Assumes the polygons were a piecewise approximation of the real surface (C0)
❍ Normals provide information about the tangent plane at each point (C1)
Lecture 16 Slide 21 6.837 Fall '00 Lecture 16 Slide 23 6.837 Fall '00

http://graphics.lcs.mit.edu/classes/6.837/F00/Lecture16/Slide21.html [11/9/2000 2:59:00 PM] http://graphics.lcs.mit.edu/classes/6.837/F00/Lecture16/Slide23.html [11/9/2000 2:59:03 PM]

Lecture 16 --- 6.837 Fall '00 Lecture 16 --- 6.837 Fall '00

Flat Shading Vertex Normals


The simplest shading method applies only one illumination calculation for each primitive. If vertex normals are not
This technique is called constant or flat shading. It is often used on polygonal primitives. provided they can often be
approximated by averaging the
normals of the facets which
share the vertex.

Issues: This only works if the polygons


reasonably approximate the
● For point light sources, the direction to the light source varies over the facet underlying surface.
● For specular reflections, the direction to the eye varies over the facet
Nonetheless, often illumination is computed for only a single point on the facet. Which one?
Usually the centroid. For a convex facet the centriod is given as follows: A better approximation can be found using a clustering
analysis of the normals on the unit sphere.

Lecture 16 Slide 22 6.837 Fall '00 Lecture 16 Slide 24 6.837 Fall '00

http://graphics.lcs.mit.edu/classes/6.837/F00/Lecture16/Slide22.html [11/9/2000 2:59:02 PM] http://graphics.lcs.mit.edu/classes/6.837/F00/Lecture16/Slide24.html [11/9/2000 2:59:04 PM]


Lecture 16 --- 6.837 Fall '00 Lecture 16 --- 6.837 Fall '00

Gouraud Shading Transforming Surface Normals


The Gouraud Shading shading method applies the illumination model on a subset of surface By now you realize that surface normals are the most important geometric surface
points and interpolates the intensity of the remaining points on the surface. In the case of a characteristic used in computing illumination models. They are used in computing both the
polygonal mesh the illumination model is usually applied at each vertex and the colors in the diffuse and specular components of reflection.
triangles interior are linearly interpolateded from these vertex values.
Hit Ctrl-Shift-S to rotate teapot
However, the vertices of a model do not transform in the same way that surface normals do.
A naive implementer might consider transforming normals by treating them as points offset
The linear interpolation can be accomplished using the plane equation method discussed in a unit length from the surface. But even this approach will not work. Consider the following
the lecture on rasterizing polygons. two dimensional example.
Notice that facet artifacts are still visible.

The problem with transforming normals occurs when objects undergo an anisotropic scaling
(scaling that is not uniform in all directions). Such scaling results only from affine modeling
transforms (Why not Euclidean transforms?).

Lecture 16 Slide 25 6.837 Fall '00 Lecture 16 Slide 27 6.837 Fall '00

http://graphics.lcs.mit.edu/classes/6.837/F00/Lecture16/Slide25.html [11/9/2000 2:59:05 PM] http://graphics.lcs.mit.edu/classes/6.837/F00/Lecture16/Slide27.html [11/9/2000 2:59:08 PM]

Lecture 16 --- 6.837 Fall '00 Lecture 16 --- 6.837 Fall '00

Phong Shading Normals Represent Tangent Spaces


In Phong shading (not to be confused with Phong's illumination model), the surface normal The fundamental problem with transforming normals is largely a product of our mental
is linearly interpolated across polygonal facets, and the Illumination model is applied at model of what a normal really is. A normal is not a geometric property relating to points of
every point. the surface, like a quill on a porcupine. Instead normals represent geometric properties on
the surface. They are an implicit representation of the tangent space of the surface at a point.
A Phong shader assumes the same input as a Gouraud shader, which means that it expects a
normal for every vertex. The illumination model is applied at every point on the surface
being rendered, where the normal at each point is the result of linearly interpolating the
vertex normals defined at each vertex of the triangle.

In three dimensions the tangent space at a point is a plane. A plane can be represented by
Phong shading will usually result in a very smooth appearance, however, evidence of the
either two basis vectors, but such a representation is not unique. The set of vectors
polygonal model can usually be seen along silhouettes.
orthogonal to such a plane is, however unique and this vector is what we use to represent the
tangent space, and we call it a normal.

Lecture 16 Slide 26 6.837 Fall '00 Lecture 16 Slide 28 6.837 Fall '00

http://graphics.lcs.mit.edu/classes/6.837/F00/Lecture16/Slide26.html [11/9/2000 2:59:06 PM] http://graphics.lcs.mit.edu/classes/6.837/F00/Lecture16/Slide28.html [11/9/2000 2:59:09 PM]


Lecture 16 --- 6.837 Fall '00 Lecture 16 --- 6.837 Fall '00

Triangle Normals Transforming Normals


Now that we understand the geometric implications of a normal it is easy to figure out how This transformed tangent, t', must be perpendicular to the transformed normal, n'. Let's solve
to transform them. for the transformation, Q that maintains this relationship.
On a faceted planar surface, vectors in the tangent plane can be computed using surface
points as follows.

All that we need to do is find a value for the Q matrix so that the transformed normal and the
Normals are always orthogonal to the tangent space at a point. Thus, given two tangent transformed tangent are still orthogonal. This can be accomplished by letting
vectors we can compute the normal as follows:

which gives

This normal is perpendicular to both of these tangent vectors.


Thus the transform that must be applied to normals so that they remain perpendicular to the
tangent space of transformed points is:

Is there a class of matrices where (A'-1)T = A?


Lecture 16 Slide 29 6.837 Fall '00 Lecture 16 Slide 31 6.837 Fall '00

http://graphics.lcs.mit.edu/classes/6.837/F00/Lecture16/Slide29.html [11/9/2000 2:59:10 PM] http://graphics.lcs.mit.edu/classes/6.837/F00/Lecture16/Slide31.html [11/9/2000 2:59:13 PM]

Lecture 16 --- 6.837 Fall '00 Lecture 16 --- 6.837 Fall '00

Transforming Tangents Normals of Nonplanar Surfaces


The following expression shows an affine transformation of a tangent vector. Not all surfaces are given as planar facets. A common example of such a surface is called a
parametric surface. For a parametric surface the three-space coordinates are determined by
functions of two parameters, u and v in our case.

For parametric surfaces two vectors in the tangent plane can be found by computing partial
derivitives as follows.
If we multiply this out we get

And the normal is computed as before:

Lecture 16 Slide 30 6.837 Fall '00 Lecture 16 Slide 32 6.837 Fall '00

http://graphics.lcs.mit.edu/classes/6.837/F00/Lecture16/Slide30.html [11/9/2000 2:59:12 PM] http://graphics.lcs.mit.edu/classes/6.837/F00/Lecture16/Slide32.html [11/9/2000 2:59:14 PM]


Lecture 16 --- 6.837 Fall '00

Discuss Project #4
Rule Changes:
● Project is due midnight Monday (11/20/00)
● You are required only to implement an ambient and a directional light source
● Parser for input files:
❍ Comments - # the rest of the line after a pound sign is ignored
❍ Eye Position - eye x y z
❍ Look-at Position - look x y z
❍ World-space up vector - up x y z
❍ Horizontal field-of-view - fov angle_in_degrees
❍ Ambient Light Source - la r g b # color intensities range from 0 to 1
❍ Directional Light Source - ld r g b x y z # x y z is a vector from the light to the
surface
❍ Polygon Vertex - v x y z
❍ Polygon Facet - f i1 i2 i3 i4 ... in # index to vertex 0-based
❍ Surface Parameters - surf r g b ka kd ks nshiney
Lecture 16 Slide 33 6.837 Fall '00

http://graphics.lcs.mit.edu/classes/6.837/F00/Lecture16/Slide33.html [11/9/2000 2:59:15 PM]

Lecture 16 --- 6.837 Fall '00

Next Time

Physically-Based Illumination Models


Lecture 16 Slide 34 6.837 Fall '00

http://graphics.lcs.mit.edu/classes/6.837/F00/Lecture16/Slide34.html [11/9/2000 2:59:18 PM]

You might also like