1gr2-00 gr2 advanced computer graphics agr lecture 15 radiosity

25
1 GR2-00 GR2 Advanced Computer Graphics AGR Lecture 15 Radiosity

Upload: nathan-waddell

Post on 28-Mar-2015

224 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 15 Radiosity

1GR2-00

GR2Advanced Computer

GraphicsAGR

GR2Advanced Computer

GraphicsAGR

Lecture 15Radiosity

Page 2: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 15 Radiosity

2GR2-00

ReviewReview

First a review of the two rendering approaches we have studied:– Phong reflection model– ray tracing

Page 3: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 15 Radiosity

3GR2-00

Phong Reflection ModelPhong Reflection Model

This is the most common approach to rendering– objects represented as polygonal faces– intensity of faces calculated by Phong

locallocal illumination model

– polygons projected to viewplane– Gouraud shading applied with Z buffer

to determine visibility

I() = Ka()Ia() + ( Kd()( L . N ) + Ks( R . V )n ) I*() / dist

Page 4: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 15 Radiosity

4GR2-00

Phong Reflection ModelPhong Reflection Model

Strengths– simple and efficient– models ambient, diffuse and specular

reflection Limitations

– only considers light incident from a light source, and not inter-object reflections - ie it is a local illumination method (ambient term is approximation to global illumination

– empirical rather than theoretical base– objects typically have plastic appearance

Page 5: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 15 Radiosity

5GR2-00

Ray TracingRay Tracing

Ray traced from viewpoint through pixel until first object intersected

Colour calculated as summation of:– local Phong reflection at that point– specularly reflected light from

direction of reflection– transmitted light from refraction

direction if transparent

Page 6: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 15 Radiosity

6GR2-00

Ray TracingRay Tracing

This is done recursively Colour of light incoming along

reflection direction found by:– tracing ray back until it hits an

object– colour of light emitted by object is

itself summation of local component, reflected component and transmitted component

– and so on

Page 7: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 15 Radiosity

7GR2-00

Ray Tracing - Strengths and Weaknesses

Ray Tracing - Strengths and Weaknesses

Advantages– increased realism through ability to

handle inter-object reflection Disadvantages

– much more expensive than local reflection

– still empirical– only handles specular inter-object

reflection– entire calculation is view-dependent

Page 8: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 15 Radiosity

8GR2-00

RadiosityRadiosity

Based on the physics of heat transfer between surfaces

Developed in 1980s at Cornell University in US (Cohen, Greenberg)

Determine energy balance of light transfer between all surfaces in an enclosed space– equilibrium reached between emission of

light and partial absorption of light Assume surfaces are opaque, are perfect

diffusediffuse reflectors and are represented as sets of rectangular patches Ai

Page 9: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 15 Radiosity

9GR2-00

Radiosity ExamplesRadiosity Examples

Page 10: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 15 Radiosity

10GR2-00

Radiosity - DefinitionRadiosity - Definition

Radiosity defined as:– energy (Bi ) per unit area leaving a

surface patch (Ai ) per unit time

Bi Ai = Ei Ai + Ri ( Fj-i Bj Aj) i=1,2,..Nj

Ei is the light energy emitted by Ai per unit areaRi is the fraction of incident light reflected in all directionsFj-i is the fraction of energy leaving Aj that reaches Ai

lightemitted

lightreflected

lightleaving

Page 11: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 15 Radiosity

11GR2-00

Radiosity - Pictorial Definition

Radiosity - Pictorial Definition

Ai

Aj

r

Ni

Nj

i

j

Bi Ai = Ei Ai + Ri (Fj-i Bj Aj)

Form factor Fj-i is fraction ofenergy leaving Aj that reachesAi. It is determined by therelative orientation of thepatches and distance rbetween them

Form factors arehard to calculate!Let’s assume for nowwe can do it.

j

Page 12: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 15 Radiosity

12GR2-00

Simplifying the EquationSimplifying the Equation

Bi Ai = Ei Ai + Ri (Fj-i Bj Aj)ieBi Ai = Ei Ai + Ri (Bj Fj-i Aj)

There is a reciprocity relationship:Fj-i Aj = Fi-jAi

Bi Ai = Ei Ai + Ri (Bj Fi-j Ai)

Hence:

Bi = Ei + Ri ( Bj Fi-j )

So the radiosity of patch Ai is given by:

j

j

j

j

Page 13: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 15 Radiosity

13GR2-00

Creating a System of Equations

Creating a System of Equations

We get one equation for each patch– assume we can calculate form factors

– then N equations for N unknowns B1,B2,..BN

First equation is:

(1-R1F1-1)B1 - (R1F1-2)B2 - (R1F1-3)B3 - .. - (R1F1-N)BN = E1

..and we get in all N equations like this. Generally Fi-i will be zero - why? Most of the Ei will be zero - why?

B1 = E1 + R1 ( Bj F1-j )j

Page 14: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 15 Radiosity

14GR2-00

Solving the EquationsSolving the Equations

Equations are solved iteratively - ie a first guess chosen, then repeatedly refined until deemed to converge

Suppose we guess solution as:B1

(0), B2(0), .. BN

(0)

Rewrite first equation as:B1 = E1 + (R1F1-2)B2 + .. + (R1F1-N)BN

Then we can ‘improve’ estimate of B1 by:B1

(1) = E1 + (R1F1-2)B2(0) + .. + (R1F1-N)BN

(0)

.. and so on for other Bi

Page 15: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 15 Radiosity

15GR2-00

Solving the EquationsSolving the Equations

This gives an improved estimate:B1

(1), B2(1), .. BN

(1)

and we can continue until the iteration converges.

This is known as the JacobiJacobi iterative method

An improved method is Gauss-SeidelGauss-Seidel iteration– this always uses best available values

– eg B1(1) (rather than B1

(0) ) used to calculate B2

(1), etc

Page 16: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 15 Radiosity

16GR2-00

RenderingRendering

What have we calculated? The Bi are the intensities of light

emanating from each patch– the form factors do not depend on

wavelength , but the Ri do

– thus Bi depend on , so we need to calculate Bi

RED, BiGREEN, Bi

BLUE

We get vertex intensities by averaging the intensities of surrounding faces

Then we can pass to Gouraud renderer code for interpolated shading

Page 17: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 15 Radiosity

17GR2-00

Pause at this stagePause at this stage

Number of equations can be very large

Calculation is not view dependent

Only diffuse reflection We still have not seen how to

calculate the form factors! Their calculation dominates

Page 18: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 15 Radiosity

18GR2-00

Form FactorsForm Factors

The calculation of the form factors is unfortunately quite hard

We begin by looking at the form factor between two infinitesimal areas on the patches

Page 19: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 15 Radiosity

19GR2-00

Form Factors - NotationForm Factors - Notation

Ai

Ni

dAi

Nj

Aj

dAj

i

j

Form factor Fdi-dj gives the fractionof energy reaching dAj from dAi.

r

r is distance between elementsNi, Nj are the normalsi, j are angles made with normalsby line joining elements

Page 20: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 15 Radiosity

20GR2-00

Form Factor Calculation : 2D Cross Section View

Form Factor Calculation : 2D Cross Section View

Draw in 2D but imagine this in 3D:* create unit hemisphere with dAi at centre* light emits/reflects equally in alldirections from dAi * form factor Fdi-dj is fraction of energyreaching dAj from dAi

dAi

Aj

dAj

Ai

Page 21: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 15 Radiosity

21GR2-00

Form Factor Calculation : 2D Cross Section View

Form Factor Calculation : 2D Cross Section View

We begin calculation by* projecting dAj onto the surfaceof the hemisphere (blue)* this resulting area is (cos j / r2 ) dAj

This gives us the relative area of light energy reaching dAj from dAi

dAi

Aj

dAj

j

r

Nj

Page 22: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 15 Radiosity

22GR2-00

Form Factor Calculation : 2D Cross Section View

Form Factor Calculation : 2D Cross Section View

But we need a measure perunit area of Ai so need to adjustfor orientation of Ai

This gives a ‘corrected’ area as:( cos i cos j / r2 ) dAj

dAi

Aj

dAj

i

Page 23: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 15 Radiosity

23GR2-00

Form Factor Calculation : 2D Cross Section View

Form Factor Calculation : 2D Cross Section View

dAi

Total energy comes from integratingover whole hemisphere - this comes to this comes to

Hence form factor is given by:Fdi-dj = ( cos i cos j ) / ( r2 )dAj

Page 24: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 15 Radiosity

24GR2-00

Form Factor Calculation : 2D Cross Section View

Form Factor Calculation : 2D Cross Section View

Finally we need to sum up for ALL dAj. This means integrating over the whole of the patch:Fdi-j = (cos i cos j ) /( r2 ) dAj

dAi

Aj

Ai

Page 25: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 15 Radiosity

25GR2-00

Form Factor CalculationForm Factor Calculation

dAi

Aj

Ai

Strictly speaking, we should nowintegrate over all dAi. In practice,we take Fdi-j as representative ofFi-j and this assumption:

Fi-j = Fdi-j

works OK in practice.

However the calculation of the integral (cos i cos j ) /( r2 ) dAj

is extremely difficult. Next lecture will discuss an approximation.