Illumination and Light Transport Chapters 26, 29, 31, 33 Cornell box rendered

advertisement
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Cornell box rendered
using photon mapping
Illumination and Light Transport
Chapters 26, 29, 31, 33
Andries van Dam©
October 22, 2015
Photo credit: Ben Herila, 2010
1 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Outline

What is Light?

Local vs. Global Illumination

The Rendering Equation

Illumination vs. Shading

Computing Illumination

Modeling Reflectance

Illumination Models

Shading Models

Advanced Global
Illumination Techniques
Andries van Dam©
October 22, 2015
Animation source: http://upload.wikimedia.org/wikipedia/
2 of 56
commons/f/f5/Light_dispersion_conceptual_waves.gif
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
The Microscopic View of Light (see Chapter 26)






Light can be thought of as small packets of energy called photons
but it exhibits both wave and particle properties (see Slide 5)
For sound, wavelength determines pitch, with light it determines
color we see: red has longest and violet the shortest wavelength
Every atom has a nucleus which electrons orbit* at various levels
When an electron drops from a higher level orbit to a lower,
energy (photons) are emitted (Planck relation)
 E=hf (frequency of emitted light increases with energy, h is
Planck’s constant) – the higher the frequency, the more
energy (red vs. ultraviolet)
When an emitted photon strikes another atom and is absorbed,
electrons jump from a lower orbital to a higher one
The wavelength (color) of light emitted or absorbed corresponds
to change in orbital; The nature of atoms and their electrons
control type of light emission
E2
E1
*Note: The picture is greatly oversimplified. Electron orbits are quantum levels that
describe the probabilities of an electron’s location. And no, electrons don’t move in circles.
Andries van Dam©
October 22, 2015
3 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
The Microscopic View of Light

The different energy levels of
electrons allow for different
wavelengths of light to be reflected


Metals have “loose” electrons which
can move relatively freely and occupy
many different energy levels, which is
why they are more reflective
Insulators have more constrained
electrons which cannot change energy
levels as easily, so they convert more
absorbed light into heat instead of
reflecting it
Cloud Gate, Millenium Park, Chicago http://greghumphries.com/
Charcoal, source: http://budgetwarehouse.wordpress.com/party-needs/charcoal/
Andries van Dam©
October 22, 2015
4 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
The Macroscopic View of Light

Light is a type of electromagnetic radiation and can also be thought of as a continuous wave
(as opposed to discrete photons)

The particle description is best used to determine how energy is exchanged

The wave nature of light is best used to describe how light propagates or travels, at light
speed in space and air, but changes speed in different media as a function of indices of
refraction, hence the prism’s dispersion – violet w/ highest frequency/energy slows more
than red with lowest frequency/energy (Huygen’s Principle, Snell’s Law…)

Visible light has a wavelength between about 390nm – 700nm, a tiny portion of the entire
spectrum

Different wavelengths correspond to different colors; the 3 types of cones in retina react
(non-uniformly) to all wavelengths in visual spectrum but have max response in different
points on spectrum

See Tyson’s Cosmos’ “Hiding in the Light” about light (from the ancients to Newton to Fraunhofer)
Andries van Dam©
October 22, 2015
5 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
The Electromagnetic Spectrum

Full electromagnetic spectrum

Visible light has a wavelength between about 390nm – 700nm, a tiny portion
of the spectrum

We’re only interested in the visible spectrum – we define and group major
wavelength ranges, approximately red, green, and blue
Andries van Dam©
October 22, 2015
Vertical diagram: http://upload.wikimedia.org/wikipedia
/commons/2/25/Electromagnetic-Spectrum.svg
6 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Outline









What is Light?
Local vs. Global
Illumination
The Rendering Equation
Illumination vs. Shading
Computing Illumination
Modeling Reflectance
Illumination Models
Shading Models
Advanced Global
Illumination Techniques
Andries van Dam©
October 22, 2015
Photo source : http://www.overclock.net/artgraphics/251218-kerkythea-shaded-lightsource-test.html
7 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Illumination Models: Direct (non-global) Illumination

Crudest hack: take only direct lighting
information from light sources into
account when computing a sample

Usually involves an “ambient term” to set a
sort of minimum bar for inter-object
reflection and thus light up visible surfaces

Used in OpenGL <3.0, most traditional
hardware pipelines (“fixed function” as
opposed to programmable shader- driven
pipelines on modern GPUs)
The fixed-function pipeline is deprecated in OpenGL 3.0, and removed in 3.1+
Andries van Dam©
October 22, 2015
Nancy Tom’s Sceneview scene,
rendered using OpenGL with only
local illumination (2001).
8 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Illumination Models: Global Illumination

Simulates how other objects affect light reaching a surface element

Lights and shadows


most light striking a surface element comes directly from emissive light sources

sometimes light from a source to a surface element is blocked by other objects; surface
element is then in “shadow” from that light source, the blocker/occluder

classical h/w pipeline doesn’t account for blockers since each triangle is considered
purely by itself
from Pixar’s “Luxo Jr.”
Inter-object reflection (indirect illumination)

light bounces off other objects toward our surface element, to add to direct illumination;
diagram shows only a single specular ray out of a potentially infinite number of rays
eye
indirect illumination
object
direct illumination
light
Andries van Dam©
object
October 22, 2015
object
light
9 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Global Illumination
Direct illumination
Andries van Dam©
+
Indirect illumination
October 22, 2015
=
Total illumination
10 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Diffuse Interreflection
Total illumination
(normal image)
Andries van Dam©
October 22, 2015
11 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Diffuse Interreflection
Direct illumination
Andries van Dam©
October 22, 2015
12 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Diffuse Interreflection
Indirect illumination
(diffuse
interreflection)
Andries van Dam©
October 22, 2015
13 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Human face
Total illumination
(normal image)
Andries van Dam©
October 22, 2015
14 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Human face
Direct illumination
Andries van Dam©
October 22, 2015
15 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Human face
Indirect illumination
Andries van Dam©
October 22, 2015
16 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Video
S. Nayar, G. Krishnan, M. Grossberg, and R. Raskar. “Fast Separation of Direct and
Global Components of a Scene using High Frequency Illumination,” SIGGRAPH ‘06
http://www.cs.columbia.edu/CAVE/projects/separation/videos/Separation.mov
Andries van Dam©
October 22, 2015
17 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
How to separate direct and indirect components (1/3)

Use a high frequency illumination
pattern


For example a checkerboard pattern of lit
and unlit patches
Each patch i that is not directly
illuminated by the pattern should be lit
due only to indirect illumination

This gives an estimate for indirect
illumination on patch i
Algorithm Attribution:
S. Nayar, G. Krishnan, M. Grossberg, and R. Raskar. “Fast Separation of
Direct and Global Components of a Scene using High Frequency
Illumination,” SIGGRAPH ’06 (Full Paper)
Andries van Dam©
October 22, 2015
18 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
How to separate direct and indirect components (2/3)

Then how do we estimate indirect illumination for patches that fall in a
directly illuminated region?




Light scene by complement of original illumination pattern
e.g., all lit squares in checkerboard become unlit, and all unlit squares
become lit
Light on unlit squares is indirect component
Obtain estimate for direct illumination by subtracting the estimate for
indirect illumination
Andries van Dam©
October 22, 2015
19 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
How to separate direct and indirect components (3/3)



In theory, a high frequency pattern and its complement are sufficient for separation.
In practice, however, a series of images are used, each with the illumination pattern
shifted slightly. This is because lit and unlit areas still have brightness variations due
to inaccuracies in the projector
This technique can be applied to real life scenes



Different illumination patterns can be used


use a projector to cast a shifting high frequency pattern and take multiple photographs
is a technique from computer vision since we are processing data captured from the real
world
checkerboard, sinusoidal pattern, line occluder passes a narrow linear shadow across the
scene
Can produce impossible images which cannot be observed in the real world— adjust
the blending ratio between indirect and direct illumination components
Andries van Dam©
October 22, 2015
20 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
The Rendering Equation (Kajiya, Immel et al, 1986)

Computing light transport in a scene with both direct light sources (emitters) and indirect sources, i.e., interobject reflection – basically an energy balance: the radiance (energy) leaving a point is the sum of emitted and
reflected light from other sources

We compute integrals of the recursive form
L 𝑃, 𝜔𝑜 = 𝐿𝑒 𝑃, 𝜔𝑜 +
2
𝑤𝑖 ∈𝑺+
(𝑝)
𝐿 𝑃, −𝜔𝑖 𝑓𝑟 (𝑃, 𝜔𝑖 , 𝜔𝑜 ) 𝜔𝑖 ∙ 𝒏𝑝 𝑑𝜔𝑖

𝐿 𝑃, 𝜔 is the radiance at surface point P in direction 𝜔

𝑺 +2 is the + hemisphere of all incoming directions to P. 𝜔𝑖 is one of those directions

𝐿𝑒 𝑃, 𝜔𝑜 represents the amount of light emitted from the material at point P (zero for most objects)

𝑓𝑟 (𝑃, 𝜔𝑖 , 𝜔𝑜 ) represents the BRDF term which is covered in more detail later in this lecture

(𝜔𝑖 ⋅ 𝒏𝑝 ) accounts for diminished intensity per unit area as a function of angle to the normal

This equation is the foundation of almost all rendering algorithms (radiosity, photon mapping, path tracing…)

It doesn’t handle subsurface scattering, phosphorescence and fluorescence; Also, the terms should include
additional parameters for wavelength and time
Andries van Dam©
October 22, 2015
Image courtesy of: http://en.wikipedia.org/wiki/Rendering_equation
21 of 56
−𝜔𝑖
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
An Alternate Formulation of the Rendering Equation
L 𝑃, 𝜔𝑜 = 𝐿𝑒 𝑃, 𝜔𝑜 +
2
𝑤𝑖 ∈𝑺+
(𝑝)
𝑒
𝐿 𝑃, −𝜔𝑖 𝑓𝑟 (𝑃, 𝜔𝑖 , 𝜔𝑜 ) 𝜔𝑖 ∙ 𝒏𝑝 𝑑𝜔𝑖
j
S
𝐿 𝑖 → 𝑗 = 𝐿 𝑖 → 𝑗 + 𝐿𝑟 (𝑖 → 𝑗)
𝐿𝑟 𝑖 → 𝑗 =

𝐿 𝑘 → 𝑖 𝑓𝑟 (𝑘 → 𝑖 → 𝑗)𝐺 𝑘 ↔ 𝑖 𝑑𝑘
i
Light energy traveling from point i to j = light emitted from i to j (direct term), plus indirect term, light
reflected from i to j. It is the integral over S of the value of the BRDF for every point k reflecting to i and
from there to j times light energy L from k to i, all attenuated by a geometry factor G
𝑘∈𝑺

𝐿 𝑖 → 𝑗 is the total amount of light (radiance) potentially traveling along the ray from point i to point j; occlusion not
taken into account

𝐿𝑒 (𝑖 → 𝑗) is the direct term, the amount of light emitted by the surface at point i (luminance)

𝐿𝑟 (𝑖 → 𝑗) is the light reflected from i to j, this corresponds to the recursive integral of all indirect energy reflected from i
𝑓𝑟 (𝑘 → 𝑖 → 𝑗) is the Bidirectional Reflectance Distribution Function (BRDF) of surface at i. Describes fraction of light
incident on surface at i from direction of k that leaves surface in direction of j – it is an attenuation factor between 0 and
1, and is a function of the reflection characteristics of the material. It can be measured for real materials
𝐺 𝑘 ↔ 𝑖 is a geometry term which involves occlusion, distance, and angle between vectors; often 0 because of an
occluder


Andries van Dam©
October 22, 2015
22 of 56
k
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Examples of Global Models

The rendering equation takes into account global information of both
direct (from emitters) and indirect illumination (inter-object reflections)


Many different approximations with advantages and disadvantages, and their
own resource requirements – in general, more computation gives better results
Even purely local model is a zero’th order approximation to rendering eqn.
Direct illumination + specular reflection
Ray trace
Andries van Dam©
+ soft shadows and caustics
Ray trace + caustic photon map
October 22, 2015
+ diffuse reflection (color bleeding)
Ray trace + caustic and diffuse photon maps
http://graphics.ucsd.edu/~henrik/images/global.html
23 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Illumination Models: Non-global vs. Global Models

Non-global models concentrate on light from direct
sources



Global models concentrate on capturing all
illumination information



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
pro: shadows, inter-object reflection, refraction, i.e.
bending of light at translucent surfaces, caustics,
volumetric effects of participating media such as air,
water, fog, etc.
con: slow
Note that top image is darker because diffuse interobject reflection is not counted, so no color
bleeding. “Ambient” hack compensates for this
difference
Andries van Dam©
October 22, 2015
Direct (diffuse +
specular) lighting +
indirect specular
reflection via
recursive ray tracing
Full global
model using
stochastic
simulation for
diffuse
interreflections
(color bleeding)
Ray tracing +
Light cache +
Irradiance map
http://www.spot3d.com/vray/help/200R1/examples_GI.htm 24 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Illumination Models: Non-global vs. Global Models
Direct (diffuse + specular) lighting
+ indirect specular reflection
Andries van Dam©
October 22, 2015
Full global illumination
25 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Illumination and Shading

Lighting, or illumination, is the process of computing the intensity and color of a
sample point in a scene as seen by a viewer


Shading is the process of interpolation of color at points in-between those with
known lighting or illumination, typically vertices of triangles in a mesh


lighting is a function of the geometry of scene (including the model, lights and camera,
and their spatial relationships) and material properties (reflection, absorption,…)
used in many real time graphics applications (e.g., games) since calculating illumination
at a point is usually expensive. In ray-tracing only do lighting for samples (based on
pixels or sub-pixel samples for super-sampling), no shading rule
On the GPU processing triangles, lighting is calculated by a vertex shader, while
shading is done by a fragment or pixel shader

the term shader is ambiguous, unfortunately, and also not to be confused with shadows
Andries van Dam©
October 22, 2015
26 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Outline

What is Light?

Local vs. Global Illumination

The Rendering Equation

Illumination vs. Shading

Computing Illumination

Modeling Reflectance

Illumination Models

Shading Models

Advanced Global
Illumination Techniques
Andries van Dam©
October 22, 2015
27 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Illumination Models: Computing Illumination

Illumination can be computed by:


Light transport simulation: Evaluate illumination with enough samples to produce a final
image without any guessing / shading, both for direct and for indirect components

often used for high quality renderers, e.g., those used in FX movies

some implementations can run in real time on the GPU, but more complex lighting models that
are difficult to parallelize for GPUs are still run on the CPU

renders of highest quality can take days for a single frame, even on modern distributed CPU
render farms and/or GPU render farms

Many simulations use stochastic sampling: path tracing, photon mapping, Metropolis light
transport
Polygon rendering: Evaluate illumination at several samples, and shade (using a shading
rule) in between to produce pixels in the final image

often used in real-time applications such as computer games, done in GPU

lower quality than light transport simulation, but can obtain satisfactory results with various
additions such as maps (bump, displacement, environment), covered in upcoming lecture
Andries van Dam©
October 22, 2015
28 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Light Transport: Inverse Square Law



In Ray assignment, account for light attenuation (affects all models)
Amount of light that illuminates an object decreases with square of distance between them
For a given 3D angle (solid angle), the area it covers grows with the square of the distance


Intensity of light per unit area falls off with the inverse square
Conversely, for a fixed area, the angle it covers decreases with the square of the distance

Slide 45 shows a hack that produces better results
Andries van Dam©
October 22, 2015
29 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Outline

What is Light?

Local vs. Global Illumination

The Rendering Equation

Illumination vs. Shading

Computing Illumination

Modeling Reflectance

Illumination Models

Shading Models

Advanced Global
Illumination Techniques
Andries van Dam©
October 22, 2015
Bubble Mathematics, by tlindenbaum
30 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Modeling Reflectance: The BRDF (1/2)

Light arriving at a surface can scatter in many directions



The direction of scattering is determined by the material
Intensity at a given outgoing direction is dependent on incoming direction and material
properties (how much energy it absorbs, how much it reflects diffusely vs. specularly, etc.)
Model or measurement of reflectance is called the
bidirectional reflectance distribution function (BRDF): for any incoming light ray
how much energy is reflected for any outgoing light ray
+
Diffuse Reflections
=
Specular Reflections
Total Scattering Distribution (BRDF)
BRDF for simple model of diffuse + specular reflection, e.g., the Phong Lighting Model
Andries van Dam©
October 22, 2015
31 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Modeling Reflectance: The BRDF (2/2)



When light hits a surface, it can be reflected, refracted, absorbed, or
otherwise scattered (e.g., subsurface scattering)
BRDF represents material properties of an object and how it reflects light
Given an incoming direction, outgoing direction, incident point on object,
and properties of lights, BRDF provides how much light reflects off surface



can be measured with equipment or estimated based on some model
Note that the BRDF is often implicit in simplest illumination models, and a
few parameters (typically diffuse and specular reflection coefficients) are
adjusted experimentally until desired visual outcome is achieved
For this course, primarily concern ourselves with simple reflectance models
Andries van Dam©
October 22, 2015
32 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Simple Reflectance Models

Some of these models you have seen before in OpenGL

Lambertian

Diffuse
light scatters equally (output radiance is equal) in all
outgoing directions (i.e. viewer independent)
light scatters (possibly unevenly) in all outgoing
directions, e.g., rug, paper, unvarnished wood
ωr = ω - 2 ω ⋅ 𝐧 𝐧
n
ωr
ω
n
ω- 𝜔⋅𝐧 𝐧
ω

Mirror
Specular

Glossy

Andries van Dam©
𝜔⋅𝐧 𝐧
light scatters in a single direction, 𝜔𝑟 = 𝜔 − 2 𝜔 ⋅ 𝐧 𝐧
light scatters tightly around a particular direction
(shiny objects with sharp highlights)
light scatters weakly around a particular direction
October 22, 2015
33 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Modeling Reflectance: Lambertian (1/2)

Lambertian surfaces have uniform, diffuse-only
scattering;
same apparent brightness independent of view
direction and incoming light direction

Most materials are not perfectly Lambertian;
most BRDFs are viewer dependent

Lambert’s cosine law:
As angle between light and normal increases ,
light’s energy spreads across a larger area
𝐼 = 𝑖𝑑𝑖𝑟 cos(𝜃) = 𝑖𝑑𝑖𝑟 (𝒏 ⋅l)
𝑖𝑑𝑖𝑟 is intensity
(light’s color) of
directional light
(rays parallel to l)
Andries van Dam©
3D visualization: hemisphere represents equal
magnitude of reflected intensity for any outgoing
vector. Real surfaces will have asymmetric BRDFs.
October 22, 2015
34 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Modeling Reflectance: Lambertian (2/2)


Several lighting models attempt to approximate these phenomena
Models you have seen before– no physical foundation, but looks okay


Phong Model
Blinn-Phong Model
Some more complicated models are
physically based



Cook-Torrance Model
Oren-Nayer Model
Which model we use largely depends
on our application
 Usually a performance vs. accuracy tradeoff

Andries van Dam©
October 22, 2015
Image credit:
http://wiki.blender.org/index.php/File:Manual-Shaders-Lambert.png 35
of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Modeling Reflectance: Specular

Most materials are not perfectly
Lambertian; most BRDFs are viewer
dependent

this is the specular property of the material

BRDF value is greatest when 𝜔𝑜 = 𝜔𝑖 (when
the outgoing angle is opposite the incoming
angle ), like a perfect mirror or rippling water
Andries van Dam©
October 22, 2015
36 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Modeling Reflection: BSSRDF



All of these models model light when it
hits a surface directly and then scatters
Light may also be scattered/absorbed
while traveling through participating
media (e.g., fog)
The BRDF can be generalized to model
transmission through an object
(i.e. refraction) and sub-surface
scattering by defining other terms, such
as the bidirectional scattering surface
Image: No scattering
reflectance distribution function
(top) vs. with BSSRDF
scattering (bottom).
(BSSRDF)
Andries van Dam©
Image credit:
October 22, 2015 http://graphics.ucsd.edu/~henrik/images/subsurf.html 37 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Modeling Reflectance: Subsurface Scattering

Some surfaces may also reflect light internally a little before letting the
light escape again (subsurface scattering)


marble, skin, wax, hair, milk and other fluids
More complex models are needed to approximate these interactions
Andries van Dam©
October 22, 2015
38 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Modeling Reflectance: Measuring B*DFs

Researchers collect tables of data for B*DFs of specific materials using devices like the
one pictured

The basic idea is to vary a light source around a hemisphere and measure the intensity
at that direction.
Image credit: Chuck Moidel
Andries van Dam©
October 22, 2015
39 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Outline

What is Light?

Local vs. Global Illumination

The Rendering Equation

Illumination vs. Shading

Computing Illumination

Modeling Reflectance

Illumination Models

Shading Models

Advanced Global
Illumination Techniques
Andries van Dam©
October 22, 2015
40 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Illumination Models: Phong (1/5) (Review)


Simple model (not physically based)
Splits illumination at a surface into three components



Ambient – Non-specific constant global lighting (hack)
Diffuse – Color of object under normal conditions using Lambert’s model
Specular – Highlights on shiny objects (hack)

Proportional to 𝑹 ⋅ 𝐕
glossier object
Andries van Dam©
𝛼
so a larger 𝛼 results in a more concentrated highlight and
October 22, 2015
41 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Illumination Models: Phong (2/5) (Review)
𝐼𝜆 = 𝑖𝑎𝜆 𝑘𝑎 𝑂𝑎𝜆 +
𝑖𝑑𝑖𝑟𝜆 𝑘𝑑 𝑂𝑑𝜆 (𝒏 ∙ 𝒍)
𝑙𝑖𝑔ℎ𝑡𝑠

Variables







λ = color component (approximated by just using three eqn’s for 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
kd is the diffuse attenuation coefficient for this object’s material (expect ka ≃ kd)
O = innate color of object's material at specific point on surface
(equivalent to C in the OpenGL3D lecture)
Andries van Dam©
October 22, 2015
42 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Illumination Models: Phong (3/5) (Review)
𝐼𝜆 = 𝑖𝑎𝜆 𝑘𝑎 𝑂𝑎𝜆 +
𝑖𝑑𝑖𝑟𝜆 𝑘𝑑 𝑂𝑑𝜆 (𝒏 ∙ 𝒍)
𝑙𝑖𝑔ℎ𝑡𝑠

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
𝑖𝑑𝑖𝑟 (light's intensity) and ℓ (light's direction) vary for each light source
ka and kd are ambient and diffuse attenuation coefficients – typically the same
𝑂𝑑 = innate color of object's diffuse material property at specific point on surface
𝑂𝑎 = innate color of the object’s ambient material property at specific point on surface, typically
same as 𝑂𝑑
Both k and O are non-physical, dimensionless fractions between 0 and 1 – could combine them
Andries van Dam©
October 22, 2015
43 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Illumination Models: Phong (4/5) (Review)

The full Phong model is a combination of ambient, Lambertian and
specular terms (summing over all the lights)
𝑓𝑎𝑡𝑡 𝑖𝑑𝑖𝑟𝜆 𝑘𝑑 𝐧 ⋅ 𝒍 𝑂𝑑𝜆 + 𝑘𝑠 𝐑 ⋅ 𝐕 𝛼 𝑂𝑠𝜆
𝐼𝜆 = 𝑖𝑎𝜆 𝑘𝑎 𝑂𝑎𝜆 +
𝑚∈𝑙𝑖𝑔ℎ𝑡𝑠


Subscript 𝑠 represents specular (so 𝑘𝑠 ) is specular coefficient
𝑹 is the reflected direction of the light ray about the surface normal


the smaller the angle δ between V and R, the brighter reflection
𝑓𝑎𝑡𝑡 is the lighting attenuation function

function of distance from the light
Note: for a directional light, l is
simply a directional vector. For a
point light, l must be computed
from the light’s positions and the
surface point.
Andries van Dam©
October 22, 2015
44 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Illumination Models: Phong (5/5) (Review)

By the inverse square law, density of light
energy decreases by the inverse square
of the distance from the surface, due to
spherical radiation pattern, so
𝐼 = 𝑓𝑎𝑡𝑡 𝑖𝑑𝑖𝑟 𝑘𝑑 𝒏 ⋅ 𝒍 , where 𝑓𝑎𝑡𝑡 =

1
2
𝑑𝑙𝑖𝑔ℎ𝑡
This will attenuate the light intensity
according to distance, so farther objects
appear darker, i.e. surfaces with equal
𝑘𝑑 𝒏 ⋅ 𝒍 vary in appearance if they are
at different distances from the light –
important if two surfaces overlap
Andries van Dam©
October 22, 2015

But this doesn’t look good – objects
illuminated by point lights will look as if they
were very harshly lit (things get dark too fast)

Instead, use the following heuristic (hack)
𝑓𝑎𝑡𝑡 = min
1
2
𝑐1 + 𝑐2 𝑑𝑙𝑖𝑔ℎ𝑡 + 𝑐3 𝑑𝑙𝑖𝑔ℎ𝑡
,1
where c1, c2, c3 are experimentally-defined
constants
45 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Illumination Models: Blinn-Phong

Variation on Phong model which modifies the specular term to be more computationally
efficient

The new specular term uses the half angle between the viewer and the light (not a
function of the orientation/normal) instead of the angle between the reflected light ray
and the viewer
𝑖𝑑𝑖𝑟 𝑘𝑠 𝑂𝑠 𝐧 ⋅ 𝐡 𝛼
𝑚∈𝑙𝑖𝑔ℎ𝑡𝑠

-
𝐡 is the half angle
ℎ=
𝒍+𝑽
𝒍+𝑽

l is normalized direction from point to light,
V is normalized vector to viewer

Use Blinn-Phong or Phong?

Doesn’t matter, they look slightly different but they’re both hacks
Andries van Dam©
October 22, 2015
46 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Illumination Models: Computing Results – sneak peak
at Recursive Ray Tracing


Look closely at the specular term: 𝑘𝑠 𝑂𝑠𝜆 𝐑 ⋅ 𝐕
We can compute this term recursively







𝛼
shoot a ray from eye through a pixel on the screen
calculate intersections of ray with all primitives in the scene, pick
the closest one
shoot a specular reflection ray (equal and opposite angle) from the
intersection point to closest object to calculate its specular
contribution. Spawn a secondary specular ray, etc.
apply our simple illumination model at every intersection point,
accounting for direct contribution from non-occluded lights, and
indirect specular contributions from nearest objects
can even be done realtime in hardware thanks to modern GPU’s
Simple global model that only computes specular interobject reflection, but can be extended for diffuse effects
You will be implementing the simple RRT soon; see next
lecture
Andries van Dam©
Images: http://www.ignorancia.org/en/index.php?page=Patio
October 22, 2015http://www.247-lasereyesurgery.info/wp-content/uploads/2013/08/img_3.jpg
47 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Outline

What is Light?

Local vs. Global Illumination

The Rendering Equation

Illumination vs. Shading

Computing Illumination

Modeling Reflectance

Illumination Models

Shading Models

Advanced Global
Illumination Techniques
Andries van Dam©
October 22, 2015
48 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Shading Models – Flat/Constant (Review)

We define a normal at each polygon (not
at each vertex)

Lighting: Evaluate the lighting equation
at the center of each polygon using the
associated normal

Shading: Each sample point on the
polygon is given the interpolated lighting
value at the vertices (i.e., a total hack)
Andries van Dam©
October 22, 2015
49 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Shading Models – Gouraud (Review)

Define a normal vector at each vertex

Lighting: Evaluate lighting equation at each
vertex using associated normal vector

Shading: Each sample point’s color on
polygon is interpolated from color values at
polygon’s vertices
An issue with Gouraud shading is that specular
highlights appear to “jump” as the object
rotates. Simple fix is to increase polygon count,
at cost of much more computation.
Andries van Dam©
October 22, 2015
50 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Shading Models – Phong (Review)

Each vertex has an associated normal vector

Lighting: Evaluate lighting equation at each
vertex using associated normal vector

Shading: For every sample point on polygon
we interpolate normals at vertices of the
polygon and compute color using lighting
equation with the interpolated normal at each
interior pixel – more accurate representation
of true surface normal at each point (and we
don’t get moving specular highlights)
Andries van Dam©
October 22, 2015
51 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Outline

What is Light?

The Rendering Equation

Illumination vs. Shading

Local vs. Global Illumination

Computing Illumination

Modeling Reflectance

Illumination Models

Shading Models

Advanced Global
Illumination Techniques
Andries van Dam©
October 22, 2015
52 of 56
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Advanced Global Illumination Techniques

In practice, calculating global illumination for a scene is a very complex
and computationally intensive task


Real time


Many algorithms (both real time and non real time) have been developed to
calculate or approximate global illumination
Ambient occlusion, image based lighting, path tracing
Not (yet) real time

Radiosity, Metropolis light transport, photon mapping, point based color
bleeding
Andries van Dam©
October 22, 2015
53 of 56
Advanced GI
Advanced Global
Techniques
Illumination Techniques
Photon
Real TimeMapping
Global Illumination
SnowdropRay
Renderer
Mental
Renderer
Tom Clancy’s2The Division
Bioshock
Uses Deferred Radiance Transfer
Determine
amount of
Volumes and Volumetric lighting to
light
at a point by
create real time global illumination ,
sending
packets of
including shadows, light filtering
energy
(photons) from
through bullet holes, and changes in
each
light source out
environmental light sources due to
into
the scene and
player actions.
counting
how many are
Technology
around
that point.
Trailer
Andries van Dam©
54 of 56
Advanced Global
Illumination Techniques
Ray Bundling
Hyperion Renderer
Big Hero 6
At each step of raytracing, bundle
similar rays into groups and treat
them as a wave of rays. This reduces
the computation of each step, and
allows for many more iterations,
creating better illuminated scenes.
Technology
Andries van Dam©
Advanced GI
Techniques
Point-Based Color Bleeding
Renderman Renderer
Up!
First generates a direct
illumination point cloud.
Uses the point cloud for
lookup during rendering
to approximate diffuse
light bounces by adding up
the contribution from
other points in the cloud.
55 of 56
Advanced Global
Illumination Techniques
Voxel Global Illumination
Advanced GI
Techniques
(VXGI)
Image Based Lighting
Maxwell Renderer
Sunflow Renderer
Shiny Aliens
Break scene into voxels using
an algorithm similar to an
octree. Rather than using
original geometry, voxel
approximation can be used to
efficiently calculate ambient
occlusion and interreflections.
Plot an image onto a
dome or sphere, using
the lighting properties of
this surface to determine
global illumination when
rendering the scene.
Technology
More Images
Andries van Dam©
56 of 56
Download