Rendering III : Radiosity

July 20, 1999 Motivational Film

✔More Bells and Whistles – Computer Graphics’ first music video

July 20, 1999 Logistics

✔Paper summaries on Radiosity – Any takers? ✔Projects – Updates due today – Sign up for presentations now open

July 20, 1999 Logistics

✔Many thanks to Max and Rob for taking over for me last week.

July 20, 1999 Photography and

pho•tog•ra•phy, n., the process or art of producing images of objects by the action of light on a sensitized surface, esp, a film in a camera.

Sure, we know, it’s all about light…

July 20, 1999 Computer Graphics as Virtual Photography

real camera photo Photographic Photography: scene (captures processing print light)

processing

Computer 3D camera tone synthetic Graphics: models model reproduction image (focuses simulated lighting) July 20, 1999 Today’s Class

✔Radiosity – Basics – The Radiosity Equation – Form Factors • What they are • The hemicube solution – Solving the Radiosity Equation – Rendering

July 20, 1999 Radiosity - Basics

✔The problem with ray tracing – Great for specular type reflections – Awful for diffuse reflections.

July 20, 1999 Radiosity - Basics

✔Based on the theory of ✔Calculate lighting in a steady state ✔Assumes that all surfaces are perfectly diffuse ✔Formulates a large systems of linear equations ✔Solution of these equations give you at each point July 20, 1999 Radiosity - Basics

✔Radiant exitance - radiant out

dΦ M = dA dA

July 20, 1999 Radiosity - Basics

✔Image is created by using calcuated radiant existance values in standard rendering process. – In essence, radiosity defines a “made to fit” texture mapping

July 20, 1999 Radiosity - Basics

✔Program Flow

July 20, 1999 Radiosity - Basics

✔View dependence vs view independence – Radiosity provides a view independent solution – Scene needs to be further rendered from a given view point.

July 20, 1999 Radiosity - Basics

✔Not points -- But patches – Scene is subdivided into patches – Radiant exitance will be calculated for each patch

July 20, 1999 Radiosity - Basics

✔Patches

July 20, 1999 Radiosity - Basics

✔Basic idea – Each patch will receive a certain amount of light from the environment – It will reflect fraction back into the environment – Keep track of amount of light reflected back – Continue till all light has been exhasted.

July 20, 1999 Radiosity - Basics

✔Key idea – Since all objects are perfectly diffuse, we can determine where light is coming from (and going) by simply considering the geometry of the scene.

– Calculation of radiant exitance per patch is given by the radiosity equation.

July 20, 1999 The Radiosity Equation

✔For each patch i, the RE gives you the radiant exitance of that patch. ✔All surfaces are perfectly diffuse (I.e. reflectivity is equal in all directions) ρ – for each patch is a constant I ✔ Geometry term Fi,j indicates the fraction of flux leaving patch i and arriving at patch j.

July 20, 1999 Radiosity Equation

n = + ρ {M i M{oi {i ∑ M j Fij = exitance init flux out reflectance 1j 421 43 light from other surface

July 20, 1999 Radiosity Equation

✔Radiosity vs Rendering Equation ε I(x, x′) = g(x, x′)[(x, x′) + ∫ ρ(x, x′, x′′)I(x′, x′′)dx′′] S

n = + ρ M i M oi i ∑ M j Fij j=1

July 20, 1999 Radiosity System of Equations

✔Rearrange terms a bit

n = + ρ M i M oi i ∑ M j Fij j=1

n = − ρ M oi M i i ∑ M j Fij j=1

July 20, 1999 Radiosity System of Equations

✔ Expandρ this out ρ = − ρ + ρ +L+ ρ M o1 M1 ( 1M1F11 1M 2F12 nM n F1n ) = − ρ + +Lρ+ M o2 M 2 ( 2M 2 F21 2M 2 F22 nM n F2n ) Kρ = − + +L+ ρ M on M n ( n1M1Fn1 n M 2Fn2 n M n Fnn )

July 20, 1999 Radiosity System of Equations ρ ✔Put into matrixρ formρ ρ ρ    − − L −   M o1 1 1F11 1F12 1F1n M1    ρ ρ   M − F 1− F L − F M  o2  =  2 21 2 22 2 2n  2   L   L ρL L L  L       − − L − ρ M on   n Fn1 n Fn2 1 n Fnn M n 

July 20, 1999 Radiosity System of Equations

✔Put in matrix notation = − M o (I T )M

Mo = initial n x 1 exitance vector I = n x n identity matrix M = final n x 1 exitance vector ρ T = n x n matrix whose i,j element is iFij

July 20, 1999 Radiosity System of Equations

✔ We have Mo ✔We have I ✔ ρ We have I ✔We’re solving for M ✔ We need this Fij -- Form Factor

✔Any questions?

July 20, 1999 Radiosity - Form Factors

✔Form factors are a geometric term:

– Given the radiant exitance of a patch Ei, what fraction of its flux is received by

another patch Ej. – Remember: All patches are Lambertian surfaces and distribute flux equally in all directions.

July 20, 1999 Radiosity - Form Factors

✔ Flux emitted by Ei: = Ei M i Ai ✔ Flux arriving at Ej Φ = Φ ij Fij i Φ F = ij ij Φ i July 20, 1999 Radiosity - Form Factors

✔Physically based geometry – Points are actually areas – Rays are actually solid angles.

July 20, 1999 Radiosity - Form Factors

✔Solid angles

ω = A r 2

July 20, 1999 Radiosity -- Form Factors

d 2Φ L = dωdAcosθ

July 20, 1999 Radiosity -- Form Factor

✔ Flux leaving Ei in direction of Ej

Φ = θ θ ω ij 1L2(3i )cos idAid radiance July 20, 1999 Radiosity - Form Factors

✔ Solid angle of ray as seen by Ei

ω = θ 2 d cos j dAj / r

July 20, 1999 Radiosity - Form Factor

✔ Flux leaving Ei towards Ej

L cosθ cosθ dA dA Φ = i i j i j ij 2 July 20, 1999 r Radiosity - Form Factor

✔Recall: Form Factor is the fraction of total flux given off by one patch that arrives at another. ✔We have the amount of flux from i to j Φ ( ij) ✔What we need is total amount of flux Φ emitted by i ( i)

July 20, 1999 Radiosity - Form Factor

✔Recall: Patch i is Lambertian Φ = = π i M idAi LidAi

Note: it can be shown by integration of L over a hemisphere that M = πL for a Lambertian surface

July 20, 1999 Radiosity - Form Factor

✔Calculating the fraction

Φ L cosθ cosθ dA dA F = ij = i i j i j ij Φ π 2 LidAir

cosθ cosθ dA F = i j j ij πr 2

July 20, 1999 Radiosity - Form Factor

✔Calculating the fraction

cosθ cosθ dA Depends ONLY on geometry! F = i j j ij πr 2 July 20, 1999 Radiosity - Form Factor

✔But wait, there’s more…. – Patches are not points nor are they differential areas – Must integrate over each patch.

July 20, 1999 Radiosity - Form Factor

✔Integration over patches

July 20, 1999 Radiosity - Form Factors

✔The final expression!

1 cosθ cosθ F = ∫∫ i j dA dA ij A πr 2 i j i AAij

July 20, 1999 Radiosity - Form Factors

✔Fun Facts about form factors – Solution first developed in 1760 by Lambert

– AiFij = AjFji – Form Factor assumes a nonparticipating medium (like air or vacuum)

July 20, 1999 Radiosity - Form Factors

✔So how do we solve this thing? – There is an analytic solution. But it is very ugly and impractical (note: discovered in 1993) – Classic solution: The Hemicube method

– Any questions before we move on?

July 20, 1999 Radiosity - Form Factors

✔Nusselt’s Analogy

July 20, 1999 Radiosity - Form Factors

✔Nusselt’s Analogy

– Project Ej onto plane of surface – Form factor is fraction of projected surface area with respect to projected area of a hemisphere.

July 20, 1999 Radiosity - Form Factors

✔Result from Nusselt’s Analogy

July 20, 1999 Radiosity - Form Factors

✔Hemicube – Replace hemisphere with hemicube. – Hemicube is divided into cells. – Can determine form factor for each cell (delta form factors). – Form factor for a patch is the sum of delta form factors for cells that the projection of the patch covers.

July 20, 1999 Radiosity - Form Factors

✔Hemicube

July 20, 1999 Radiosity - Form Factors

✔Hemicube - Delta Form Factors – Gives an approximation of form factor for a cell on the hemicube.

θ θ cos i cos j F − ≈ ∆A dEi E j πr 2 j

July 20, 1999 Radiosity - Form Factors

✔Hemicube - delta form factor (top side)

July 20, 1999 Radiosity - Form Factors

✔Hemicube - Delta Form Factors – If we conveniently choose r to be 1 then

r = u 2 + v2 +1 – and θ 1 cos = cosθ = i j r

July 20, 1999 Radiosity - Form Factors

✔So...

π cosθ cosθ ∆A ∆F ≈ i j ∆A = top top r 2 top π (u 2 + v2 +1)2

July 20, 1999 Radiosity - Form Factors

✔Similarly, it can be shown

π cosθ cosθ n∆A ∆F ≈ i j ∆A = side side r 2 side π (u 2 + n2 +1)2

July 20, 1999 Radiosity - Form Factors

✔Fun Facts about Hemicube – Delta Form Factors can be precomputed once then applied to each patch – Accuracy depends on hemicube resolution. – Most popular means of calculating form factors

July 20, 1999 Radiosity

✔Let’s recap – Divided ourρ scene into n patches – Set up thisρ systemρ of n equations: ρ ρ    − − L −   M o1 1 1F11 1F12 1F1n M1    ρ ρ   M − F 1− F L − F M  o2  =  2 21 ρ 21 22 21 2n  2   L   L L L L  L       − − L − ρ M on   n Fn1 n2 Fn2 1 n1Fnn M n 

July 20, 1999 Radiosity

✔Recap continued – For each i,j combination, calculate the form

factor Fij – Now need to solve the radiosity equation

July 20, 1999 Radiosity

✔Recap

July 20, 1999 Radiosity

✔Solving the Radiosity Equation – Use Numerical Techniques (Jacobi / Gauss-Sidel method) • Calculates full radiosity solution • O (n2) – Progressive Refinement • Approximate solution • Better solution with each iteration.

July 20, 1999 Radiosity - Progressive Refinement

✔Progressive Refinement – Based on Flux left to be distributed in scene. – At each iteration only consider patch with most flux to give – Continue until flux left to be distributed falls below a threshold – Limit…threshold = 0 is equivalent to full solution. July 20, 1999 Radiosity - Progressive Refinement

✔Shooting flux into environment

July 20, 1999 Radiosity - Progressive Refinement

✔For each patch I we keep track of:

– Mi - current amount of radiant exitance ∆ – Mi - current amount of radiant exitance gained since last iteration ∆ unsent – Mi - amount of unsent radiant exitance since last iteration ✔Munsent - Total amount of unsent flux = ∆ unsent Mi Ai

July 20, 1999 Radiosity - Progressive Refinement

✔ ∆ ∆ unsent Initialize Mi, Mi, Mi = Moi ✔ While Munsent > Threshold ∆ unsent – Find element i with greatest Mi Ai – For each other element j

• Calculate form factor Fij ∆ ∆ unsent • Calculate M, change of M due to Mi Ai • Update ∆Munsent for element j • Update Total M for element j – Set ∆Munsent for element I to 0

July 20, 1999 Radiosity - Progressive Refinement

✔Solution gets progressively better with each iteration ✔Later iterations contribute less to total solution than earlier iterations ✔Limit is equivalent to complete solution.

July 20, 1999 Radiosity

✔Okay, so where are we?

July 20, 1999 Radiosity

✔Finally! Rendering – Radiosity Solution gives us a view independent solution – “Made to fit” texture mapping – Use traditional rendering to get view dependent image • flat / Gouraud shading • Non-recursive ray tracing – We are done! July 20, 1999 Radiosity - examples

✔Cornell Box

July 20, 1999 Radiosity Examples

July 20, 1999 Radiosity

✔Based on physically based energy transfer ✔Calculates steady state solution ✔Assumes diffuse surfaces ✔Computationally intensive

July 20, 1999 Radiosity

✔Summary

July 20, 1999 Radiosity

✔One thing we didn’t discuss – Meshing strategies • How do we efficiently divide scene into patches • Adaptive Subdivision – see Ashdown, Chapter 7

July 20, 1999 Radiosity

✔Further Reading – Ashdown,Perspective Radiosity: A Programmer’s

– Cohen/Wallace,Image Synthesis Radiosity and Realistic

– papers on reserve

✔Any questions

July 20, 1999 Next Class

✔Advanced Rendering – Two pass method • Radiosity + ray tracing - Best of both worlds – REYES

July 20, 1999 Remember

✔Class Web Site: – http://www.cs.rit.edu/~jmg/virtualPhoto

July 20, 1999