Introduction to Physically-Based Illumination, Radiosity and ShadowComputations forComputer Graphics

Eugene Fiume Department of Computer Science University of Toronto

1CSC2522 LectureNotes January,2015 Overview

•physically-based illumination models for computer graphics are maturing.

•tutorial on concepts of physically-based models.

•introduction to transport (rendering equation).

•overviewofradiosity-based approach.

2CSC2522 LectureNotes January,2015 Solid Angle

r sin θ dθ dA r dω

θ

φ

Differential surface element dA on sphereofradius r: dA=(longitudinal arc length) × (latitudinal arc length) = (r dθ )(r sin θ dφ) =r2 sin θ dθ dφ. Differential solid angle dω (on sphere of radius 1): dA dω = = sin θ dθ dφ. r2

Solid angle (in ) requires (messy) contour integral.

3CSC2522 LectureNotes January,2015 Idon’t think this is very clear

The longitudinal arc is on a circle of radius r that slices through the sphere and includes the origin.

So, what’sthe arc length of part of a circle? Let’ssuppose that this circle is parameterised by X(θ ) =rsin θ , Y(θ ) =rcos θ . The arc length of a part of the circle described by angle ∆θ is θ + ∆θ 2 2 ∫ √  X˙+ Y˙ dθ . θ

But look at the integrand:

2 2 √ √  X˙+ Y˙ = √ r2(sin 2θ + cos 2θ ) =r.

So, the length of the longitidinal arc is just r dθ .

Remember the parametric definition of a sphere: x(θ , φ) =rsin θ sin φ, y(θ , φ) =rsin θ cos φ, z(θ ) =rcos θ .

Holding θ constant givesusalatitudinal circle of radius r sin θ in the z=r cos θ plane. So the length of the latititudinal arc is r sin θ dφ.

4CSC2522 LectureNotes January,2015 Solid Angle Properties Surface area of unit hemisphere = 2π steradians (sr). Surface area of unit sphere = 4π steradians (sr). Just do the integral: S 2π ∫ ∫ sin φ dφ dθ , 0 0 where S=π /2 for the hemisphere and π for the sphere.

Practical Solid Angle Computation

polygon P with area A r N θ

R

ω

1 O

Solid angle of P: projected area of P onto sphere in direction of O.

Approximation: if r << R so that projection of P on sphere is almost planar,then approximate solid angle def- inition by

A cos θ w= . R2

5CSC2522 LectureNotes January,2015 Geometry of Basic Projection

Suppose we have a beam of thickness L projecting onto a locally planar region with normal N. Assume the beam makehas an inci- dence angle of θ with the plane.

N cos θ = L / M L M L = M cosθ θ π/2−θ M = L / cosθ θ

Then we have the above relations.

6CSC2522 LectureNotes January,2015 Physical Lighting Terminology

What is this ‘‘intensity’’stuffanyway? Theyare all measures of power density w.r.t. solid angles and area (and power is a measure of energy density w.r.t. time).

Radiant power (Φ): Rate at which light energy is transmitted (energy/unit time, or , W). Physical term: flux.

Radiant Intensity (I): radiated onto a unit solid angle in a givendirection (W/sr). E.g., "intensity" of apoint light source.

Radiance (L): per unit projected surface area (W/(m2 ⋅ sr )). E.g., "intensity" of reflection of a surface.

Irradiance (E): Incident flux density on a locally planar area, in units of flux per unit surface area (W/m2). This is a direction-independent quantity.

Radiosity (B): Exitant flux density from a locally planar area, in units of flux per unit surface area (W/m2).

These are radiometric quantities, i.e., physical measurements of electromagnetic energy.There are comparable photometric quanti- ties corresponding to psychovisual measurement.

7CSC2522 LectureNotes January,2015 Relationships Between Radiometric Quantities

Radiant power: Φ.

Irradiance/Radiosity: dΦ E, B= , dA where

dΦ = ( ∫ L cos θ dω ) dA, Ω

Ω is the visible hemisphere, and

L is incoming or outgoing .

Radiant Intensity: dΦ I(ωω ) = . dω

Radiance:the quantity from which we construct the others. Call it L(x, ωω ), which is power per unit area radiated to point x along direction ωω .

Use radiance to denote light carried by a ray in a ray tracer.(NO inverse square lawinnon-participating media.)

Use radiant intensity to denote energy distributions of light sources. (Follows inverse square law.)

8CSC2522 LectureNotes January,2015 Incident Irradiance

ω Suppose incoming radiance from differential solid angle d i along ωω direction i is Li.

L i ω L d i r N

θ i θr

φ i φ r

Then incident irradiance is θ ω Ei =Li cos i d i

Bidirectional Reflectance Distribution Function To characterise arbitrary reflection functions, write down an expression that relates incident irradiance to outgoing radiance in ωω direction r : Lr fi→r = Ei or ωω θ φ θ φ Lr ( r ) =fi→r ( i, i, r , r ) Ei, so bidirectional reflectance distribution function (BRDF) fi→r is ωω proportion of incident irradiance that is reflected in direction r .

9CSC2522 LectureNotes January,2015 BRDF and Reflectance

Units of BRDF are sr−1,and givesdensity of flux per .

BRDF is always positive,and is in fact a true distribution (and really should only be used under an integral).

But it is possible for a BRDF to be an "impulse", meaning perfect specular reflection in one direction.

Reflectivity or the Reflectance

Reflectance acts likeaBRDF,but is instead a unitless proper frac- tion in [0,1]. It is defined as

reflected flux dΦ ρ r = = Φ . incoming flux d i

The region of integration givesdifferent kinds of canonical reflectances.

Of particular interest to us is this fact: if the surface is Lambertian or diffuse,meaning that incoming light is equally likely to be scat- tered in all directions, then the hemispheric reflectance is

ρ π d = fi→r , or ρ d f → = . i r π

Another nice fact:

B ρ = . d E

10 CSC2522 LectureNotes January,2015 Physically-Plausible Reflectance Models

The use of BRDF allows specification of

•anisotropic reflection models: fixing i and r butrotating the surface will change directional reflectance. •fully plausible, energy-conserving, empirically validated illu- mination models. •models that are really really expensive tocompute. Really!

Howdoes this sit with traditional illumination models? In fact, it’snot that hard to makecurrent models more plausible. Traditionally,local illumination models have been defined as intensity at a point = ambient + diffuse ++specular .

That is,

IP =ka Ia +kd Id +ks Is.

As a first step, to translate to physical models, use radiance, and define BRDF as

ρ ρ ρ =kd d +ks s, kd +ks = 1,

ρ ρ where d is Lambertian reflector and s is your favourite specular reflection function this week. Leave ambient component ad hoc. So, ρ ρ Lr =ka La + (kd d +ks s)Ei ρ ρ θ ω =ka La + (kd d +ks s) Li cos i d i

Sum or integrate as appropriate overall light sources.

11 CSC2522 LectureNotes January,2015 Rendering Equation (Kajiya and Hanrahan)

Characterise all interactions of light from anypoint x on anysur- face s with a point x′ on a surface.

The result is an outgoing radiance value.

The rendering equation describes a two-point (i.e., one-bounce) light transport.

Multi-point transport is got by cascading the equation to get full ray transport problem.

Based on radiance.

ωω ωω ′ ′ ωω ′ ′ ′ ′ L(x, ) =Le(x, ) + ∫ f (x ; x) L(x , ) G(x, x ) V(x, x )dA , S where

S is all surfaces, and dA′ is a differential element of S ,

′ ωω ′ Le(x , )isself-emission, V(x, x′)is1if x is visible to x′,and is 0 otherwise,

G(x, x′)isageometric scale factor,

f (x′; x)isBRDF (actually depends on all angles): light reflected about x from x′.

Notice that radiance to be computed appears on LHS and under integral.

Kajiya proposed some (theoretically) nice ways to compute the equation (including Monte Carlo path tracing and a series expan- sion).

12 CSC2522 LectureNotes January,2015 Radiosity Equation

Under Lambertian assumption, the BRDF is independent of incom- ing, outgoing directions, and can be taken out of the integral.

Furthermore, outgoing radiance is direction independent, so we can work with irradiance/radiosity instead.

In fact,

B(x) L(x, ωω ) = ,(*) π so we can rewrite the rendering equation as a radiosity equation:

ρ (x) B(x) =E(x) + d ∫ B(x′) G(x, x′) V(x, x′)dA′ π S

Notes: •This reformulation in terms of radiosity/irradiance can be eas- ily got by multiplying rendering equation by π and changing units. ρ •Notice the change from BRDF f to reflectance d.

So far,sogood, but notice again that radiosity appears on LHS and under integral.

From nowon, we will bury the visibility term V and 1/π into geo- metric term G. G will resurface as the integrand for a form factor.

13 CSC2522 LectureNotes January,2015 Discretisation of the Radiosity Equation

Even the radiosity equation is intractable (let alone the rendering equation), so work with that first.

Break all surfaces up into patches or elements and makeassump- tions about the nature of radiosity.Let there be n patches Ai, i= 1, ..., n.(By convention, areas of the patches will have same name −−ouch!)

The easiest assumption is that radiosity is constant across a sur- face. If we can solvefor radiosities, then, each element i will have constant radiosity Bi. In that case, we get

n ρ Bi =Ei + i Σ B j Fij. j=1

To makethe derivation clearer,multiply through by Ai,which is allowed because Ai >0:

n ρ Bi Ai =Ei Ai + i Σ B j Fij Ai. j=1

Physically,what this does is turn an equation in flux density to an equation in flux.

We’llsee whythis is useful on the next slide, when we talk about Fij,the form factor.

14 CSC2522 LectureNotes January,2015 Form Factors

dA i θi

Pi r V(x,x’) θ j

dA j

A j

The term Fij is a form factor and denotes the fraction of energy leaving Ai and arriving at A j:

1 cos θ cos θ F = ∫ ∫ i j V dA dA . ij π 2 ij j i Ai r Ai A j

That means that

Ai Fij =Aj F ji, so that

Ai F ji =Fij . A j

This is called form-factor reciprocity.

15 CSC2522 LectureNotes January,2015 The Radiosity System of Equations

Folding form factors back into the radiosity equation, we see that since

n ρ Bi Ai =Ei Ai + i Σ B j Fij Ai. j=1 n ρ =Ei Ai + i Σ B j F ji A j. j=1

Dividing through by Ai again givesus

n A ρ j Bi =Ei + i Σ B j F ji j=1 Ai n ρ =Ei + i Σ B j Fij. j=1

This expression states that the radiosity (i.e., outgoing flux density) of element i is an accumulation from the emitted flux density of this element, and of contributions of flux radiated onto element i from all other elements.

Now, the Ei (initial emissions) are the knowns, so rewrite equation in terms of knowns and unknowns in matrix form:

− ρ ⋅ ⋅ − ρ E1   1 1 F11 1 F1n  B1  E   − ρ F ⋅ ⋅ − ρ F  B   2  =  2 21 2 2n   2  ...   ......  ...  − ρ ⋅ ⋅ − ρ En   n Fn1 1 n Fnn  Bn 

16 CSC2522 LectureNotes January,2015 Moreproblems than solutions

•matrix is O(n2)insize, where n,the number of patches, is usu- ally much larger than number of polygons.

•restricted to closed polyhedral environments.

•norefraction, specularity,translucency.

•form-factor computation is very costly,and must be redone wheneverasingle object moves(butnot in principle when the camera moves).

•how are patches chosen?

•how toscale up geometric complexity?

•extension to curved surfaces?

•how toreconstruct continuous tone images from constant-radios- ity patches.

•costly visibility computations.

•vast amounts of aliasing.

•fast shadows?

But solution is viewindependent (?), and independent of initial emissions Ei.

17 CSC2522 LectureNotes January,2015 Partial Solutions

Matrix Size 1. Use iterative methods to solvesystem row-wise (i.e., for each Bi). Corresponds to gathering radiosity from other patches.

2. Still costly,solook at system in another way.

Think instead about distributing radiosity from Bi out to other patches in proportion to form factor.

In fact, this turns out to solvethe system column-wise (incre- mentally), because for each iteration, i is fixed, correspond- ing to a column of the radiosity matrix.

Corresponds to shooting radiosity.

After each iteration, a valid (though incomplete) image can be rendered, so this technique is called progressive refine- ment.

Afull radiosity matrix is not needed (only the current col- umn, assuming form factors are cheap to compute).

3. Hierarchical Approaches. Observethat not all patches (via form factors and radiosity matrix) affect each other at the same scale.

Create a hierarchyofinteractions by grouping together patches with respect to a scale-preserving distance criterion.

Related to clustering algorithms for n-body systems in applied physics.

Can have O(n)convergence.

18 CSC2522 LectureNotes January,2015 Form Factor Computations

1. Use aprojection technique called the Nusselt analogue. Use it to discretise the hemisphere into a hemicube.Can have substantial approximation error.

2. Analytic form factor techniques for simple polygons. Mathematically very nice, especially for a reference model, butthe functions involved are quite expensive tocompute (complexdilogarithm).

3. Ray tracing approaches: used differential form factor com- putations (area/point to point) to approximate area-area form factors.

4. Hierarchical radiosity techniques reduce the number of form-factors to compute at anytime.

Optical Phenomena Beyond Diffuse Reflection

1. Some work on participating media: light interacts with environment (e.g., dust, smoke, mist) producing scattering effects.

2. Multipass Algorithms: Do a first-pass radiosity step and use the result likeanenvironment map in a subsequent specular (ray-tracing) pass.

19 CSC2522 LectureNotes January,2015 Decomposition into Patches−Meshing

•extremely difficult problem.

•originally,meshing was done by hand and not talked about.

•trade-offbetween view-dependence and the creation of meshes that were far to fine.

•current approaches nowinv olvetracking discontinuities in radiance function due to shadowboundaries and polygon edges. Very active research area. (See video).

•adaptive meshing, mesh filtering to reduce mesh size.

Aliasing and Approximation Error

• constant radiosity syndrome has nowbeen cured.

•patch elements are nownolonger assumed to carry constant radiosity.Infinite element terminology,constant radiosity assumption means that order 1 elements are used.

•now,patches are assumed to carry variable radiosity.A polynomial basis (usually degree 1 or 2 lagrange basis) is imposed overpatch, permitting subsampling of radiosity overpatch.

•improvesthe approximation, avoids ad hoc reconstruction techniques, and avoids some aliasing error.

20 CSC2522 LectureNotes January,2015 ShadowComputations for Area Light Sources

•possibly the hardest problem of them all.

•needed for discontinuity meshing.

•extensive geometric computations.

•use of aspect graphs to accelerate computation. An aspect graph characterises the parts of a scene that have topologically similar ‘‘view’’ofanarea light source.

•can exploit this structure to ‘‘scan convert’’apenumbral shadow.

•most substantial progress in this area is by U of Toronto!

21 CSC2522 LectureNotes January,2015 Most Recent Work at U of Toronto

•accelerated shadowcomputations (twopapers at SIGGRAPH ’94).

•structured sampling techniques for occluded and unoccluded environments (award winning paper at Eurographics ’93).

•nonuniform radiant intensity distributions for area light sources (CVGIP GMIP ’93).

•illumination in the presence of participating media (SIG- GRAPH ’93,95).

•discontinuity meshing (Graphics Interface ’86, TVCG 1997).

•incremental visibility.

Cast of researchers on illumination at UofT includes: Eugene Fiume Sherif Ghali Marc Ouellette Michiel van de Panne James Stewart JeffTupper

22 CSC2522 LectureNotes January,2015 References

The last word on (including light):

Robert Siegel and John Howell, Thermal Heat Trans- fer,Third Edition, Hemisphere Publishing Corporation, 1992.

One recent book on this material (despite the backward title): Michael Cohen and John Wallace, Radiosity and Realistic Image Synthesis,Academic Press, 1993.

Amore unified and clearer treatment: Francois Sillion and Claude Puech, Radiosity and Global Illumi- nation,MorganKaufmann, 1994.

Amodern treatment of physically based light transport: Matt Pharr and GregHumphreys Physically Based Rendering: Fr omTheory to Implementation,Second Edition, MorganKauf- mann, 2010.

And of course the basic literature.

23 CSC2522 LectureNotes January,2015 Discussion/Open Questions

•Isthe radiosity-based technique worth the trouble?

•What does a physically-plausible illumination model add to my animated toothpaste commercial?

•Doshadows really need to be computed precisely?

24 CSC2522 LectureNotes January,2015