radiosity mel slater department of computer science university college london

38
Radiosity Mel Slater Department of Computer Science University College London http://www.cs.ucl.ac.uk/staff/m.slater

Upload: allan-jackson

Post on 16-Dec-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Radiosity Mel Slater Department of Computer Science University College London

Radiosity

Mel Slater

Department of Computer Science

University College Londonhttp://www.cs.ucl.ac.uk/staff/m.slater

Page 2: Radiosity Mel Slater Department of Computer Science University College London

The Lab outside my office

Page 3: Radiosity Mel Slater Department of Computer Science University College London

The Lab outside my office!

Page 4: Radiosity Mel Slater Department of Computer Science University College London

Global Illumination Approacheshttp://www.dcs.shef.ac.uk/research/groups/graphics/msc/render/TOC.HTM

(a) Point light source(ray tracing),global illumination forspecular surfaces.(+ textures)

(b) global illuminationdiffuse surfaces (radiosity)...

(c) … showing colour bleeding(+ textures)

Watt A. Policarpo F. (1998)"The Computer Image"ACM Press/Addison-Wesley

Page 5: Radiosity Mel Slater Department of Computer Science University College London

Outline

• Radiosity Equations

• Form-factors and their computation

• Progressive Refinement

• Meshing

Page 6: Radiosity Mel Slater Department of Computer Science University College London

Radiosity Measure

• It is the name of a measure of light energy...

• ...and an algorithm:– Radiant energy (flux) = energy flow per unit

time across a surface (watts)– Radiosity = flux per unit area (a derivative of

flux with respect to area) radiated from a surface.

– These are wavelength-dependent quantities.

Page 7: Radiosity Mel Slater Department of Computer Science University College London

Types of Surface Reflectance

Specular-specular(ray tracing)

Diffuse-diffuse(radiosity)

Specular-diffuse(Monte Carlo)

Diffuse-specular(Monte Carlo)

Page 8: Radiosity Mel Slater Department of Computer Science University College London

Radiosity

• Models lighting in scenes for diffusely reflecting surfaces only.

• Assume polygonal scene– polygons divided into n small ‘patches’

– patch i has area Ai

– radiosity Bi

– Emits energy Ai*Ei

– Has surface reflectance pi (diffuse reflection)

Page 9: Radiosity Mel Slater Department of Computer Science University College London

Basic Equation

Energy (i) = Emitted Energy (i) + Reflected Energy (i) i = 1,2,…,n

Reflected Energy(i) = pi * (Total Energy in from Environment)

Total Energy In (i) = Sum of proportions of energy from all otherobjects that reach i

n

jjijj FBA

1Fji = proportion of energy from j

that reaches i per unit area of j(form-factor)

Page 10: Radiosity Mel Slater Department of Computer Science University College London

The Radiosity Equation

n

jjijjiiiii FBApEABA

1

Simplification:

n

jijjiii FBpEB

1

jijiji FAFA since

ni ,...,2,1

Page 11: Radiosity Mel Slater Department of Computer Science University College London

Solution of Equation

• The Bi are unknown

• Assume all else is known– false assumption for form-factors!

• Then can be rewritten as system of n linear equations in n unknowns.

• Hence patches can be rendered– ideally with smooth shading.

• One set of eqns for each wavelength!

Page 12: Radiosity Mel Slater Department of Computer Science University College London

The Radiosity Equation

FB E=

F

1 r1F

11– r

1F

12– ¼ r

1F

1n–

r2F

21– 1 r

2F

22– ¼ r

2F

2n–

¼ ¼ ¼ ¼r

nF

n1– r

nF

n2– ¼ 1 r

nF

nn–

=

B

B1

B2

¼B

n

and E

E1

E2

¼E

n

= =where

and

Page 13: Radiosity Mel Slater Department of Computer Science University College London

Form-factors

dAi

dAj

ai

aj

FdA idA j

i

cos j

cos

r2---------------=Differential

Form-factor

Patch ito patch j

Page 14: Radiosity Mel Slater Department of Computer Science University College London

Analytic Form Factors

FdAiA j

i

cos j

cos

r2---------------------------- A

jd

Aj

=

Fij1

Ai-----

icos

jcos

r2

---------------------------- Ajd A idA

j

A

i

×=

jijiji FAFA

From a differential to a patch

From patch to patch

this follows.

In practice form factorscannot be derived analytically!

Must also take into account visibility between patches!

Page 15: Radiosity Mel Slater Department of Computer Science University College London

Form-Factor Computation

• Nusselt Analog• Proportion of projected

area on circular base = FdAiAj

• Note - all patches with the same projected area have same form-factor.

Page 16: Radiosity Mel Slater Department of Computer Science University College London

Hemi-cube ApproximationStart with patch i

Place a hemi-cube on its centre.

Project all other patches ontothis hemi-cube.

The hemi-cube is ‘pixelised’, with a pre-computed for each grid and stored in a look-up table

Use z-buffer for each face - storingwhich patches remain visible.

qF

Page 17: Radiosity Mel Slater Department of Computer Science University College London

Delta Form-Factors

Consider (eg) the top face.

The exact form factor between a ‘pixel’ to the origin can bederived analytically.

Same is true for all such pixels.

The form-factor is approximated bysum of all delta form-factors of pixels covered by j.

1

x2 y2 1+ + 2-------------------------------------

Page 18: Radiosity Mel Slater Department of Computer Science University College London

Delta Form-Factors

x

yr

y

xj

i

Ar

F jiq

2

coscos

1

1coscos

22

yxr

zji

1

x2 y2 1+ + 2-------------------------------------

Page 19: Radiosity Mel Slater Department of Computer Science University College London

Problems with Hemi-Cube

• Crude sampling method– more ideal would be a uniform subdivision of

the hemisphere around a patch centre• more computationally intensive (has been tried).

• Leads to aliasing - depending on size of ‘pixels’.

• Gives form-factors (and hence radiosities) at patch centers - not ideal for smooth shading.

Page 20: Radiosity Mel Slater Department of Computer Science University College London

Use Ray Casting

source

receiver

Take a sample of npoints on a source patch.

Trace rays to a vertex onreceiver patch.

Sum the contributionsof all visible rays.

Page 21: Radiosity Mel Slater Department of Computer Science University College London

Advantages of Ray Casting

• Can easily obtain the form-factors and radiosities at the vertices (smooth shading)

• Can vary the sampling scheme

• Visibility naturally taken into account.

• See notes for the derivation and nature of the approximation.

Page 22: Radiosity Mel Slater Department of Computer Science University College London

Matrix Solution Impractical

• Have been assuming the full matrix solution - impractical!

• Suppose there are 10,000 polygons.– Each divided into 10 patches (say).– n = 100,000– n2 = 10,000,000,000– Each form factor 4 bytes (at least)– 40,000,000,000 bytes = 40Gb for the matrix.

Page 23: Radiosity Mel Slater Department of Computer Science University College London

Progressive Refinement (PR)

• Solve the equation row by row, without ever storing the full matrix.

• Consider again:

n

jijjiii FBpEB

1

Bi due to B

jr

iB

jF

ij=

A single term determinesinfluence of j on i.

Page 24: Radiosity Mel Slater Department of Computer Science University College London

Progressive Refinement...

jijiji FAFA Using

Bj due to B

ir

jB

iF

jir

jB

iF

i j

Ai

Aj

-----= =

and swapping i with j:

For all patches j: Bj due to B

ir

jB

iF

ij

Ai

Aj

-----=

Page 25: Radiosity Mel Slater Department of Computer Science University College London

Shooting

• We ‘shoot’ light out from patch i, allowing it to make a contribution to all other patches j

– adjusting the radiosities of each of these other patches.

• Note that the form-factors needed (Fij) are all from the ith row of the matrix - e.g., one hemicube.

Page 26: Radiosity Mel Slater Department of Computer Science University College London

for each iteration {sort in descending order of Bi Bi ;for each patch i { /*in the descending order*/

compute the form factors Fij using a hemi-cube at i;for each patch ji {

Rad = pj * Bi * Fi j * (Ai/Aj) ;Bj = Bj + Rad;Bj = Bj + Rad;

}Bi = 0;

}/*render scene here if desired*/

}/*until convergence of the Bi */

Bi , Bi = 0 for all non-light sources

Bi , Bi = Ei for sources. unshot radiosity Bi

Page 27: Radiosity Mel Slater Department of Computer Science University College London

Ambient Term in PR

• Initially images are very dark due to large amount of un-shot energy

• Un-shot energy is approximated and used in an ambient term

• Purely for display, does not contribute to the final solution

Page 28: Radiosity Mel Slater Department of Computer Science University College London

Ambient Term

• Average un-shot energy:

n

ii

n

iii

A

ABU

0

0

• Average reflectance:

n

ii

n

iii

avg

A

A

0

0

rr

• Take account for infinite inter-reflections:

avgavgavgavgavgR

rrrrr

1

1...1 432

Page 29: Radiosity Mel Slater Department of Computer Science University College London

Ambient Term

RUAmbient

AmbientBB iii r'

• The ambient term is computed as:

• For the display adjust the radiosities:

• As the accuracy solution improves with each iteration, the ambient will decrease and tend to zero

Page 30: Radiosity Mel Slater Department of Computer Science University College London

Meshing

• Choosing a mesh for the patches is the most problematic aspect of radiosity.

• Too coarse, and sharp gradients (shadows) are missed, and the effects are blocky.

• Too fine - increases time/space and oversamples for relatively low gradients.

• Uniform meshing is simplest, suffers from above.

Page 31: Radiosity Mel Slater Department of Computer Science University College London

Adaptive Meshing• Only the receivers of light need to be finely

subdivided– and only where there is a sharp radiosity gradient.

• Use an adaptive subdivision scheme:– Subdivide patch into elements– if radiosity for the elements are slowly changing,

finish– else subdivide the elements and repeat.

Page 32: Radiosity Mel Slater Department of Computer Science University College London

Substructuring

• Create a coarse patch mesh.

• Compute radiosity on patch mesh.

• Find areas of high radiosity gradient.

• Subdivide patches into elements.

• Compute radiosity values on elements from the patch radiosity values.

Patch boundariesElement boundaries

Page 33: Radiosity Mel Slater Department of Computer Science University College London

Substructuring

• Patch to patch form factor is

Fiqj= form factor between element q of patch i and j

Aiq = Area of element q of patch i

R = Number of elements for patch i

• Radiosity of element q of patch i

Biq is radiosity of element q of patch i

R

qiji

iij qq

AFA

F0

1

n

jjjiiii BFEB

qqqq0

r

Page 34: Radiosity Mel Slater Department of Computer Science University College London

Substructuring

• Radiosity is shot only from patches, but is computed at elements.

• Only NxM form factor computations (instead of MxM) where N is the number of patches and M the number of elements.

• Although the obtained solution is comparable to a MxM solution.

Page 35: Radiosity Mel Slater Department of Computer Science University College London

Meshing: Cornell Box

Example using the hemi-cube method.Does not use smooth shading.

Page 36: Radiosity Mel Slater Department of Computer Science University College London

Rendering

• Radiosity is a view-independent solution.

• Could flat shade each patch with colour depending on radiosity at the center (bad solution!)

• Instead obtain radiosities at the vertices of the polygons– use Gouraud smooth shading (interpolation)– Available very cheaply on graphics hardware.

Page 37: Radiosity Mel Slater Department of Computer Science University College London

Radiosity vs Ray-Tracing

• In RT rays are send through each image pixel and followed as they reflect off objects in scene– Mostly specular surfaces– View dependent

• Radiosity is based on exchange of energy between object surfaces– Diffuse surfaces– View independent– Finite elements – discreet representation of scene

(mesh)

Page 38: Radiosity Mel Slater Department of Computer Science University College London

Resource and Potential Assignment

www.cs.ucl.ac.uk/teaching/GMV/Exercises/radiosity/readme.html