260 likes | 393 Views
GR2 Advanced Computer Graphics AGR. Lecture 15 Radiosity. Review. First a review of the two rendering approaches we have studied: Phong reflection model ray tracing. I( ) = K a ( )I a ( ) + ( K d ( )( L . N ) + K s ( R . V ) n ) I*( ) / dist. Phong Reflection Model.
E N D
GR2Advanced Computer GraphicsAGR Lecture 15 Radiosity
Review • First a review of the two rendering approaches we have studied: • Phong reflection model • ray tracing
I() = Ka()Ia() + ( Kd()( L . N ) + Ks( R . V )n ) I*() / dist Phong Reflection Model • This is the most common approach to rendering • objects represented as polygonal faces • intensity of faces calculated by Phong local illumination model • polygons projected to viewplane • Gouraud shading applied with Z buffer to determine visibility
Phong 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
Ray 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
Ray 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
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
Radiosity • 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 diffuse reflectors and are represented as sets of rectangular patches Ai
Radiosity - 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,..N j light leaving light emitted light reflected Ei is the light energy emitted by Ai per unit area Ri is the fraction of incident light reflected in all directions Fj-i is the fraction of energy leaving Aj that reaches Ai
Radiosity - Pictorial Definition Form factor Fj-i is fraction of energy leaving Aj that reaches Ai. It is determined by the relative orientation of the patches and distance r between them Aj j r Nj Ni Form factors are hard to calculate! Let’s assume for now we can do it. i Ai Bi Ai = Ei Ai + Ri (Fj-i Bj Aj) j
Simplifying the Equation Bi Ai = Ei Ai + Ri (Fj-i Bj Aj) ie Bi Ai = Ei Ai + Ri (Bj Fj-i Aj) j j There is a reciprocity relationship: Fj-i Aj = Fi-jAi Hence: Bi Ai = Ei Ai + Ri (Bj Fi-j Ai) j So the radiosity of patch Ai is given by: Bi = Ei + Ri ( Bj Fi-j ) j
B1 = E1 + R1 ( Bj F1-j ) j 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?
Solving 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
Solving 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 Jacobi iterative method • An improved method is Gauss-Seidel iteration • this always uses best available values • eg B1(1) (rather than B1(0) ) used to calculate B2(1), etc
Rendering • 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 BiRED, BiGREEN, BiBLUE • We get vertex intensities by averaging the intensities of surrounding faces • Then we can pass to Gouraud renderer code for interpolated shading
Pause 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
Form 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
Form Factors - Notation Form factor Fdi-dj gives the fraction of energy reaching dAj from dAi. Aj dAj Nj j Ni r i Ai r is distance between elements Ni, Nj are the normals i, j are angles made with normals by line joining elements dAi
Aj dAj Ai dAi 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 all directions from dAi * form factor Fdi-dj is fraction of energy reaching dAj from dAi
Aj dAj dAi Form Factor Calculation : 2D Cross Section View We begin calculation by * projecting dAj onto the surface of the hemisphere (blue) * this resulting area is (cos j / r2 ) dAj Nj j r This gives us the relative area of light energy reaching dAj from dAi
Aj dAj dAi Form Factor Calculation : 2D Cross Section View But we need a measure per unit area of Ai so need to adjust for orientation of Ai This gives a ‘corrected’ area as: ( cos i cos j / r2 ) dAj i
Form Factor Calculation : 2D Cross Section View Total energy comes from integrating over whole hemisphere - this comes to Hence form factor is given by: Fdi-dj = ( cos i cos j ) / ( r2 )dAj dAi
Aj Ai dAi 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
Aj Ai dAi Form Factor Calculation Strictly speaking, we should now integrate over all dAi. In practice, we take Fdi-j as representative of Fi-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.