Anda di halaman 1dari 30

INTRODUCTION TO COMPUTER GRAPHIC S

Illumination

The slides combine material from Andy van Dam,


Spike Hughes, Travis Webb and Lyn Fong

Andries van Dam October 29, 2009 Illumination Models 1/30


INTRODUCTION TO COMPUTER GRAPHIC S

Outline
• Physical foundations of light
• Representing reflections
• The Rendering Equation
• Analytical intractability
• Formalizing our approximation
• Categories of illumination models
• Evaluating Illumination Models
• Shading models
• Beyond CS123

Andries van Dam October 29, 2009 Illumination Models 2/30


INTRODUCTION TO COMPUTER GRAPHIC S

How the World Works


What is Light?
• Electromagnetic Radiation
• Can be thought of as waves which
are defined by their wavelength
and amplitude
• We’re interested in wavelengths in
the visible spectrum

Andries van Dam October 29, 2009 Illumination Models 3/30


INTRODUCTION TO COMPUTER GRAPHIC S

How the World Works


What is Light?
• Can also be thought of as photons, or
packets of energy
• When an electron in an atom drops from a
higher to a lower orbital, a photon is
emitted
• When a photon strikes the atom, if it is
absorbed, electrons jump from a lower
orbital to a higher one
• Wavelength corresponds to change in
orbital and vice versa
• Properties of atoms cause different
absorption or emission, or sometimes
neither

Andries van Dam October 29, 2009 Illumination Models 4/30


INTRODUCTION TO COMPUTER GRAPHIC S

How the World Works


What is Light?
• Collections of atoms act in concert to
absorb or emit photons therefore
collections of atoms are compatible with a
wider range of wavelengths
• In metals for example electrons are not
attached to particular nuclei, but can
instead move about the material
• In other materials like carbon there are
also unattached electrons but they cannot
move freely so absorption induces the
atoms to vibrate a.k.a. heat up
• This further explains distinctions in
material properties such as color and
reflectance

Andries van Dam October 29, 2009 Illumination Models 5/30


INTRODUCTION TO COMPUTER GRAPHIC S

How the World Works


What is Light?
• Heat energy causes atoms to vibrate
• As materials become heated the become
better emitters of electromagnetic
radiation, i.e. they are more likely to emit
photons
• Heat energy as light energy
• This is why heated iron glows.

Andries van Dam October 29, 2009 Illumination Models 6/30


INTRODUCTION TO COMPUTER GRAPHIC S

Modeling Light
Representing Reflections
• Reflections can be thought of as absorption
and prompt remission of photons
• Light comes in, a fraction goes out towards
observer (remember conservation of energy)
• This is a function.
– it takes incoming intensity, incoming wavelength,
incoming angle, and outgoing angle of interest
– it returns outgoing intensity and wavelength
– we call this a BRDF or bidirectional reflectance
distribution function

A soybean field. Left: backscattering (sun behind observer). Right:


forwardscattering (sun opposite observer)

Andries van Dam October 29, 2009 Illumination Models 7/30


INTRODUCTION TO COMPUTER GRAPHIC S

Modeling Reflection
Lambertian Reflectance
• An example of such a function is the
Lambertian BRDF
• Lambertian surfaces appear to have the
same brightness no matter where you are
observing them from - look at the walls
around you
• Such a BRDF can be defined by Lambert’s
cosine law:
N — unit normal of A
I = Ip kd cos θ, i.e., L — unit vector in direction of light

I = Ip kd (N • L) kd — diffuse reflection coefficient;


specifies fraction of Ip reflected

I
p
θ
N
L

A
dA

Andries van Dam October 29, 2009 Illumination Models 8/30


INTRODUCTION TO COMPUTER GRAPHIC S

Modeling Reflection
Specular Reflectance
• Most materials are not perfectly diffuse
• This leaves us to define irregular BRDFs,
i.e., ones which are viewer-dependent
• We call this adding the specular property
of a material
• The value of this BRDF is greatest when
the outgoing angle is opposite the
incoming angle, as in a perfect mirror
• Think of a patch of water as it ripples

Andries van Dam October 29, 2009 Illumination Models 9/30


INTRODUCTION TO COMPUTER GRAPHIC S

Modeling Reflections
Advanced Techniques
• There are many more complex and more
accurate BRDFs such as Blinn’s and
Anisotropic.
• There are even more complicated
distribution functions such as BSSDF or
bidirectional subsurface scattering function
• Furthermore researchers collect tables of
data for B*DFs of specific materials using
devices like the one pictured

Andries van Dam October 29, 2009 Illumination Models 10/30


INTRODUCTION TO COMPUTER GRAPHIC S

Modeling Light
The Rendering Equation
• Generalized rendering equation formulated
by Jim Kajiya, 1986:
 
L(i → j ) = G (i ↔ j )  Le(i → j ) + ∫ f (k → i → j ) L(k → i )dk 
 S 
• i.e.: Light energy traveling from point i to
j is equal to light emitted from i to j, plus
the integral over S (all points on all
surfaces) of reflectance from point k to i to
j, times the light from k to i, all attenuated
by a geometry factor.
– L(i → j ) is the amount of light traveling along the
ray from point i to point j.
– Le is the amount of light emitted by the surface
(luminance)
– f (k → i → j ) is the Bidirectional Reflectance
Distribution Function (BRDF) of the surface.
Describes how much of the light incident on the
surface at i from the direction of k leaves the
surface in direction of j.
– G (i ↔ j ) is a geometry term which involves
occlusion, distance, and the angle between the
surfaces
Andries van Dam October 29, 2009 Illumination Models 11/30
INTRODUCTION TO COMPUTER GRAPHIC S

Modeling Light
The Intractability
• The Universe has been simulating the
solution to the rendering equation since
the beginning of time so it would be
ridiculous if we could solve it. It is
provably unsolvable (left as an exercise to
the reader)
– this means we have to be clever in trying to
approximate the equation to trick the eye
– luckily the eye is easily fooled
• There are infinite possible wavelengths
– we will restrict our discussion to “red”, “green”,
and “blue” light because these 3 cover the
largest triangle (gamut) in the CIE space
• The world is, for our purposes, continuous,
while we need to display pixels
– this means we will compute samples of the world
at surface elements and translate them into pixel
data
• This leaves us with a discussion of how
best to make pretty pictures

Andries van Dam October 29, 2009 Illumination Models 12/30


INTRODUCTION TO COMPUTER GRAPHIC S

Formalizing our Approximation


Surface Elements
• A Surface Element is a differential area on
that surface
– most surfaces are curved and continuous
– approximate small regions with pieces of tangent
planes
– imagine breaking a surface up into a finite number
of very small pieces. Pieces are still curved, but if
they’re small enough, you can make them
arbitrarily close to being flat
• Surface normals have the same problem in
that they also vary continuously
– each tangent plane piece that defines a surface
element comes with a normal so we have no extra
work
– in Shapes, you broke the sphere up into triangles,
with each vertex having an associated normal.
The small area around a vertex is a surface
element used to calculate “illumination.”

Andries van Dam October 29, 2009 Illumination Models 13/30


INTRODUCTION TO COMPUTER GRAPHIC S

Formalizing our Approximation


Illumination
• Lighting, also called illumination or
reflection (at least in CS123), is
computing the intensity and wavelength
seen by a viewer, emitted by the surface
at a sample – it is a function of geometry
of the scene (including the model, the
lights, the viewer/camera) and material
properties
– Often computing lighting at every point is too
expensive so we interpolate
• Shading is faking data between samples
with known light information via
interpolation
• Illumination of a surface element
– defines the output of the illumination model
evaluated at that sample as seen by the camera

Andries van Dam October 29, 2009 Illumination Models 14/30


INTRODUCTION TO COMPUTER GRAPHIC S

Illumination Models
Local versus Global Models
• The rendering equation takes into account
non local information
– Thus the most realistic illumination
models try to take this global data into
account
– However purely local models can also
produce believable results for far
smaller costs

Andries van Dam October 29, 2009 Illumination Models 15/30


INTRODUCTION TO COMPUTER GRAPHIC S

Illumination Models
Local Illumination
• Take only direct lighting information into
account when computing a sample
• Local illumination is an approximation to
global illumination
• Usually involves an “ambient term” to set a
sort of minimum bar for object illumination

Andries van Dam October 29, 2009 Illumination Models 16/30


INTRODUCTION TO COMPUTER GRAPHIC S

Illumination Models
Global Illumination
• Simulates what happens when other objects
and scene elements affect light reaching a
surface element
• Lights and shadows
– most light striking a surface element comes directly
from emissive light sources in the scene (direct
illumination)
– sometimes light from a source is blocked by other
objects
– surface element is then in “shadow” from that light
source
• Inter-object reflection
– light bounces off other objects toward our surface
element
– when that light reaches our surface element, it
brightens it (indirect illumination)

object
eye

direct illumination indirect illumination


light object light
object

Andries van Dam October 29, 2009 Illumination Models 17/30


INTRODUCTION TO COMPUTER GRAPHIC S

Illumination Models
Local versus Global Models
• Local models concentrate on light from
direct sources
– pro: scene can be rendered fast
– con: pay a price in lost realism; lose interesting
effects of light transport because we ignore
effects of all other objects in the scene when
considering a particular surface element
• Global models concentrate on capturing
the all illumination information
– pros: shadows, inter-object reflection, refraction,
i.e. bending of light at translucent surfaces,
volumetric effects of participating media such as
air, water, and fog
– cons: slow

Andries van Dam October 29, 2009 Illumination Models 18/30


INTRODUCTION TO COMPUTER GRAPHIC S

Computing Illumination Models


• Polygon Rendering
– Evaluates at several samples and shade
everywhere in between to produce pixels
in final image
• Light Transport Simulation
– Evaluate at enough samples to produce
final image without any guessing
• Note: the BRDF is often implicit in simple
illumination models because they are so
faked out and there is no conception of units,
just dials to adjust results to look good

Andries van Dam October 29, 2009 Illumination Models 19/30


INTRODUCTION TO COMPUTER GRAPHIC S

Illumination Models
Phong
• Simple, NOT physically-based
• Does attempt to simulate some of the
most important observable effects of
common light interactions
• Specifies characteristics of surfaces
– ambient component: accounts for non-specific
global light
– diffuse component: accounts for the color of the
object under normal conditions using lamberts
cosine law I = Ip kd (N • L)
– specular component: accounts for highlights on
shiny objects
• Specular reflection proportional (R • V)n
– as n increases, highlight is more concentrated,
surface appears glossier

Andries van Dam October 29, 2009 Illumination Models 20/30


INTRODUCTION TO COMPUTER GRAPHIC S

Illumination Models
Computing Results
• Variables
– λ = color component (e.g. R, G, and B)
– i = intensity of light as measured at surface
– ia= the amount of ambient light used in the scene
– k = material's efficiency at reflecting light (attenuation
coefficient)
– ka is the ambient attenuation coefficient for this object's
material (we would expect ka ~ kd)
– O = innate color of object's material at specific point on
surface
• Ambient component
– effect on surface constant regardless of orientation, no
geometric information
– total hack (crudest possible approximation to inter-
object reflection), but makes all objects a little visible
• Diffuse component
– uses Lambert's diffuse-reflection cosine law
– idir (light's intensity) and ℓ (light's direction) vary for
each light source
– kd is the diffuse attenuation coefficient
– Od = innate color of object's diffuse material property at
specific point on surface
 
I λ = iaλ k a Od λ + ∑ idir k d Od (N • L )
lights

Andries van Dam October 29, 2009 Illumination Models 21/30


INTRODUCTION TO COMPUTER GRAPHIC S

Illumination Models
Computing Results
• We can add a specular hack to increase
“accuracy”
• Energy from a single light reflected by a
single surface element can be computed
Iλ = IaλkaOdλ + fattIpλ[kdOdλ(N • L) + ksOsλ(R • V)n]

ks - specular coefficient, fraction of light reflected


Osλ - object specular color (not necessarily the
same as Odλ)
• For multiple point lights, simply sum
contributions
next slide
    n
I λ = I aλ k a Odλ + ∑m f att I pλ [k d Odλ ( N • L ) + k S OSλ ( R • V ) ]

Andries van Dam October 29, 2009 Illumination Models 22/30


INTRODUCTION TO COMPUTER GRAPHIC S

Attenuating Light With Distance


• Density of energy (light) decreases by
inverse square of the distance from the
surface , due to spherical
  radiation pattern
1
I = f att * (Ip kd )(N • L ), where f att =
2
(d L )
dL—path length from light to object
• This makes surfaces with equal kd ( N • L )
vary in appearance if they are at different
distances from the light—important if two
surfaces overlap:
N
N

• Formula often creates harsh effect – we do


not often see objects illuminated by point
lights!
1
fatt = min( ,1)
• Instead use: c1+c2dL + c3( d L)2
where c1, c2, c3 are experimentally-defined
constants. This is a heuristic! (nice word for
a hack)
Andries van Dam October 29, 2009 Illumination Models 23/30
INTRODUCTION TO COMPUTER GRAPHIC S

Blinn-Phong Illumination Model


• Variation on Phong specular term that is
computationally more efficient
– uses half angle between viewer and light instead of
angle between surface normal and light
– half angle requires a square root
– normal to light angle requires a different computation
for each triangle in the scene
– Take your pick!
• Blinn-Phong yields different results, but the
units are bogus anyway and it is easier to use
it to produce visually pleasing images

l +e
h=
l +e
Specular term
δ
e = viewpoint
r = reflected image of light source
ℓ = vector from the light source
n = surface normal
h = the half vector, i.e., average of vectors e and -ℓ
δ = angle between h and n
n = specular coefficient
Andries van Dam October 29, 2009 Illumination Models 24/30
INTRODUCTION TO COMPUTER GRAPHIC S

Illumination Models
Computing Results
• Look closely at the specular term:
  n
k S OSλ ( R • V )
• We can compute this term recursively
– shoot a ray from eye through a pixel on the screen
– calculate intersection of ray with a primitive in the
scene
– shoot a ray from the intersection point to calculate
the contribution of other objects in the lighting
– applying our simple illumination model at
intersection point
– can even be done in hardware thanks to modern
gpus
• We call this Ray Tracing
• Ray tracing is a pseudo global model that
you will be implementing soon (in software)

Andries van Dam October 29, 2009 Illumination Models 25/30


INTRODUCTION TO COMPUTER GRAPHIC S

Shading Models
Flat
• We define a normal at each polygon (not
at the vertices)
• Lighting: Evaluate the BRDF the center of
each polygon using the associated normal
• Shading: Every sample point on that
polygon is taken to have that result

Andries van Dam October 29, 2009 Illumination Models 26/30


INTRODUCTION TO COMPUTER GRAPHIC S

Shading Models
Gouraud
• We define a normal at each vertex
• Lighting: Evaluate the BRDF at each
vertex using the associated normal
• Shading: For every sample point on the
polygon we interpolate the color values at
vertices of the polygon computed in the
lighting step

Andries van Dam October 29, 2009 Illumination Models 27/30


INTRODUCTION TO COMPUTER GRAPHIC S

Shading Models
Phong
• We define a normal at each vertex
• Lighting: Evaluate the BRDF at each
vertex using the associated normal
• Shading: For every sample point on the
polygon we interpolate the normals at
vertices of the polygon and compute the
color using the BRDF which we use to
determine the color (explained in
polygonal rendering lecture soon)

Andries van Dam October 29, 2009 Illumination Models 28/30


INTRODUCTION TO COMPUTER GRAPHIC S

Advanced Techniques
Photon Mapping
• Photon mapping is a more accurate
approximation of the rendering equation
that uses statistical methods to improve
sampling
• Balances accuracy and speed
• Henrik Wann Jensen wrote the book on it.
Literally (as you will find out if you take
CS224)

Andries van Dam October 29, 2009 Illumination Models 29/30


INTRODUCTION TO COMPUTER GRAPHIC S

Advanced Techniques
Others
• Metropolis Light Transport
– the most accurate feasible technique
– too slow for most purposes
• Radiosity
– Make sure to come to lecture on Novemeber 12th

Andries van Dam October 29, 2009 Illumination Models 30/30

Anda mungkin juga menyukai