30
I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam October 29, 2009 Illumination Models 1/30 Illumination The slides combine material from Andy van Dam, Spike Hughes, Travis Webb and Lyn Fong

Illumination - University of Southern Mississippiorca.st.usm.edu/~jchen/courses/graphics/lectures/Illumination.pdf · Andries van Dam October 29, 2009 Illumination Models 14/30 Formalizing

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Illumination - University of Southern Mississippiorca.st.usm.edu/~jchen/courses/graphics/lectures/Illumination.pdf · Andries van Dam October 29, 2009 Illumination Models 14/30 Formalizing

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S

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

Illumination

The slides combine material from Andy van Dam, Spike Hughes, Travis Webb and Lyn Fong

Page 2: Illumination - University of Southern Mississippiorca.st.usm.edu/~jchen/courses/graphics/lectures/Illumination.pdf · Andries van Dam October 29, 2009 Illumination Models 14/30 Formalizing

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S

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

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

Page 3: Illumination - University of Southern Mississippiorca.st.usm.edu/~jchen/courses/graphics/lectures/Illumination.pdf · Andries van Dam October 29, 2009 Illumination Models 14/30 Formalizing

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S

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

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

Page 4: Illumination - University of Southern Mississippiorca.st.usm.edu/~jchen/courses/graphics/lectures/Illumination.pdf · Andries van Dam October 29, 2009 Illumination Models 14/30 Formalizing

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S

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

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

Page 5: Illumination - University of Southern Mississippiorca.st.usm.edu/~jchen/courses/graphics/lectures/Illumination.pdf · Andries van Dam October 29, 2009 Illumination Models 14/30 Formalizing

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S

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

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

Page 6: Illumination - University of Southern Mississippiorca.st.usm.edu/~jchen/courses/graphics/lectures/Illumination.pdf · Andries van Dam October 29, 2009 Illumination Models 14/30 Formalizing

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S

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

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.

Page 7: Illumination - University of Southern Mississippiorca.st.usm.edu/~jchen/courses/graphics/lectures/Illumination.pdf · Andries van Dam October 29, 2009 Illumination Models 14/30 Formalizing

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S

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

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)

Page 8: Illumination - University of Southern Mississippiorca.st.usm.edu/~jchen/courses/graphics/lectures/Illumination.pdf · Andries van Dam October 29, 2009 Illumination Models 14/30 Formalizing

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S

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

θ

dA

Ip

A

N L

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:

I = Ip kd cos θ, i.e., I = Ip kd (N • L)

N — unit normal of A

L — unit vector in direction of light

kd — diffuse reflection coefficient;

specifies fraction of Ip reflected

Page 9: Illumination - University of Southern Mississippiorca.st.usm.edu/~jchen/courses/graphics/lectures/Illumination.pdf · Andries van Dam October 29, 2009 Illumination Models 14/30 Formalizing

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S

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

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

Page 10: Illumination - University of Southern Mississippiorca.st.usm.edu/~jchen/courses/graphics/lectures/Illumination.pdf · Andries van Dam October 29, 2009 Illumination Models 14/30 Formalizing

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S

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

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

Page 11: Illumination - University of Southern Mississippiorca.st.usm.edu/~jchen/courses/graphics/lectures/Illumination.pdf · Andries van Dam October 29, 2009 Illumination Models 14/30 Formalizing

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S

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

Modeling Light The Rendering Equation

•  Generalized rendering equation formulated by Jim Kajiya, 1986:

•  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. –  is the amount of light traveling along the

ray from point i to point j. –  is the amount of light emitted by the surface

(luminance) –  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.

–  is a geometry term which involves occlusion, distance, and the angle between the surfaces

Page 12: Illumination - University of Southern Mississippiorca.st.usm.edu/~jchen/courses/graphics/lectures/Illumination.pdf · Andries van Dam October 29, 2009 Illumination Models 14/30 Formalizing

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S

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

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

Page 13: Illumination - University of Southern Mississippiorca.st.usm.edu/~jchen/courses/graphics/lectures/Illumination.pdf · Andries van Dam October 29, 2009 Illumination Models 14/30 Formalizing

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S

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

•  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.”

Formalizing our Approximation Surface Elements

Page 14: Illumination - University of Southern Mississippiorca.st.usm.edu/~jchen/courses/graphics/lectures/Illumination.pdf · Andries van Dam October 29, 2009 Illumination Models 14/30 Formalizing

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S

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

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

Page 15: Illumination - University of Southern Mississippiorca.st.usm.edu/~jchen/courses/graphics/lectures/Illumination.pdf · Andries van Dam October 29, 2009 Illumination Models 14/30 Formalizing

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S

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

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

Page 16: Illumination - University of Southern Mississippiorca.st.usm.edu/~jchen/courses/graphics/lectures/Illumination.pdf · Andries van Dam October 29, 2009 Illumination Models 14/30 Formalizing

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S

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

•  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

Illumination Models Local Illumination

Page 17: Illumination - University of Southern Mississippiorca.st.usm.edu/~jchen/courses/graphics/lectures/Illumination.pdf · Andries van Dam October 29, 2009 Illumination Models 14/30 Formalizing

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S

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

•  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)

eye

light light

direct illumination indirect illumination

object object

object

Illumination Models Global Illumination

Page 18: Illumination - University of Southern Mississippiorca.st.usm.edu/~jchen/courses/graphics/lectures/Illumination.pdf · Andries van Dam October 29, 2009 Illumination Models 14/30 Formalizing

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S

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

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

Page 19: Illumination - University of Southern Mississippiorca.st.usm.edu/~jchen/courses/graphics/lectures/Illumination.pdf · Andries van Dam October 29, 2009 Illumination Models 14/30 Formalizing

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S

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

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

Page 20: Illumination - University of Southern Mississippiorca.st.usm.edu/~jchen/courses/graphics/lectures/Illumination.pdf · Andries van Dam October 29, 2009 Illumination Models 14/30 Formalizing

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S

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

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

Page 21: Illumination - University of Southern Mississippiorca.st.usm.edu/~jchen/courses/graphics/lectures/Illumination.pdf · Andries van Dam October 29, 2009 Illumination Models 14/30 Formalizing

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S

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

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

Page 22: Illumination - University of Southern Mississippiorca.st.usm.edu/~jchen/courses/graphics/lectures/Illumination.pdf · Andries van Dam October 29, 2009 Illumination Models 14/30 Formalizing

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S

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

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

•  For multiple point lights, simply sum contributions

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λ)

Page 23: Illumination - University of Southern Mississippiorca.st.usm.edu/~jchen/courses/graphics/lectures/Illumination.pdf · Andries van Dam October 29, 2009 Illumination Models 14/30 Formalizing

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S

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

•  Density of energy (light) decreases by inverse square of the distance from the surface , due to spherical radiation pattern

dL—path length from light to object •  This makes surfaces with equal

vary in appearance if they are at different distances from the light—important if two surfaces overlap:

•  Formula often creates harsh effect – we do not often see objects illuminated by point lights!

•  Instead use: where c1, c2, c3 are experimentally-defined constants. This is a heuristic! (nice word for a hack)

kd ( N • L )

) 1 , 2) ( 3 2 1

1 min( L d c L d c c att f

+ + =

2 ) (

1 where , ) )( ( *

L d att f L N d k p I att f I = • =

Representing Lights

Page 24: Illumination - University of Southern Mississippiorca.st.usm.edu/~jchen/courses/graphics/lectures/Illumination.pdf · Andries van Dam October 29, 2009 Illumination Models 14/30 Formalizing

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S

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

•  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 –  Computing the half angle requires a square root –  Computing the 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

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

δ

Blinn-Phong Illumination Model

Page 25: Illumination - University of Southern Mississippiorca.st.usm.edu/~jchen/courses/graphics/lectures/Illumination.pdf · Andries van Dam October 29, 2009 Illumination Models 14/30 Formalizing

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S

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

Illumination Models Computing Results

•  Look closely at the specular term:

•  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)

Page 26: Illumination - University of Southern Mississippiorca.st.usm.edu/~jchen/courses/graphics/lectures/Illumination.pdf · Andries van Dam October 29, 2009 Illumination Models 14/30 Formalizing

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S

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

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

Page 27: Illumination - University of Southern Mississippiorca.st.usm.edu/~jchen/courses/graphics/lectures/Illumination.pdf · Andries van Dam October 29, 2009 Illumination Models 14/30 Formalizing

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S

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

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

Page 28: Illumination - University of Southern Mississippiorca.st.usm.edu/~jchen/courses/graphics/lectures/Illumination.pdf · Andries van Dam October 29, 2009 Illumination Models 14/30 Formalizing

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S

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

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)

Page 29: Illumination - University of Southern Mississippiorca.st.usm.edu/~jchen/courses/graphics/lectures/Illumination.pdf · Andries van Dam October 29, 2009 Illumination Models 14/30 Formalizing

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S

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

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)

Page 30: Illumination - University of Southern Mississippiorca.st.usm.edu/~jchen/courses/graphics/lectures/Illumination.pdf · Andries van Dam October 29, 2009 Illumination Models 14/30 Formalizing

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S

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

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