# 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 16 Radiosity - continued.

## Presentation on theme: "1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 16 Radiosity - continued."— Presentation transcript:

2GR2-00 Calculating Form Factors n The calculation of: is difficult n In practice a hemicube is formed about the centre of the patch - projection on to flat planes is much easier F di-j = (cos i cos j ) /( r 2 ) dA j

3GR2-00 Hemicube Continuing our 2D cross section view: AiAi NiNi but imagine this in 3D as a hemicube centred on the centre of A i

4GR2-00 Hemicube - Pixels Divide the faces of the hemicube into small pixels - say 50x50 on top face AiAi NiNi

5GR2-00 Hemicube - Project patch j AiAi NiNi AjAj Project A j onto the hemicube, noting pixels which are covered. For these pixels, record patch (A j ) and its depth. If two patches project to same pixel, only record nearest since others are invisible to A i - this is the same idea as z-buffering.

6GR2-00 Hemicube - Form Factors AiAi NiNi AjAj We compute mini form factors for each pixel - say, F q, for pixel q. These can be pre-computed and stored in a look up table Then we get F i-j as: F i-j = F q where the summation is over all pixels q covered by the projection. See Watt or Foley, van Dam for how to calculate the mini form factors

7GR2-00 Radiosity - Summary n The basic radiosity method is: 1) decompose the scene into patches A i 2) compute the form factors F i-j using hemicubes 3) solve the radiosity system of equations to get B i for each patch i (for R,G,B) 4) render by feeding the B i values into a Gouraud interpolation renderer n Note: – 1) and 2) depend only on geometry – 3) depends on 1) and 2) plus reflection and emission values – 4) depends on 1),2),3) and view

8GR2-00 Radiosity - Further Examples Cornell group radiosity image, using progressive refinement approach 30,000 patches

9GR2-00 Radiosity - Further Examples Scene from the opera La Boheme by the Cornell group.

10GR2-00 Radiosity - Further Examples Museum drawn using radiosity by progressive refinement.

11GR2-00 Radiosity - Analysis n Radiosity algorithm is expensive in computation and storage n For accuracy we need to decompose into many small patches (typically N>1000) n But this means N 2 form factors that need to be computed and stored

12GR2-00 Progressive Refinement n Aim is to generate sequence of improving images n Basic algorithm works against this: – large initial start up in generating ALL the form factors (which need to be stored) – during one iteration of Gauss-Seidel, we generate B 1, B 2, etc so it takes a long time before we calculate B N - even if B N is significant, say a light source

13GR2-00 Revisit the Basic Algorithm n Basic equation for B i : – B i = E i + R i B j F i-j for each patch A i – each term of summation is patch j effect on patch i, ie – B i due to B j = R i B j F i-j gathers this gathers radiosity from all the other patches shoot n Different approach is to shoot radiosity from one patch to all other patches

14GR2-00 Shoot rather than Gather n So now: – B j due to B i = R j B i F j-i for all j – this shoots B i radiosity to each of the other patches in turn n But: different – F j-i for each j requires different hemicube calculation n So: – using reciprocity relationship (F j-i A j = F i-j A i ) – B j due to B i = R j B i F j-i = R j B i F i-j A i /A j for all j same – which uses same hemicube

15GR2-00 Progressive Refinement Algorithm n Algorithm works as follows: – Set initial radiosities B i and increments B i to E i – For each patch i do build hemicube, calculate form factors F i-j for each patch j do Radiosity = R j B i F i-j A i / A j B j = B j + Radiosity B i = 0 – Repeat until convergence

16GR2-00 Progressive Refinement Algorithm - Optimization n Initially the scene will be dark apart from light sources, then gets steadily lighter n For best effect: – start off with simple ambient illumination – at each stage, select patch i for shooting that has highest B i A i ie greatest unshot radiosity.

17GR2-00 Efficient Radiosity n Use shooting method to solve the radiosity equation, where increments are made to patches j from patch i n Choose patch i at each stage to achieve most effect n Add a (decreasing) ambient term in the early stages

18GR2-00 Issues in Radiosity n Artefacts in radiosity images occur due to: – approximations in hemicube method – using linear interpolation to reconstruct radiosity function across a patch – using a mesh structure which does not take into account variations in radiosity function

19GR2-00 Hemicube Approximations n Hemicube is divided into uniform set of pixels of finite size n … and it is assumed that each patch projects onto whole pixels - which is unlikely to be the case n An example of an aliasing effect - cf jagged lines in line drawing in 2D graphics

20GR2-00 Interpolation of Radiosity Function n Situation analogous to Gouraud shading… n … reflectance calculation assumes radiosity constant over patch n … radiosity at vertices found by averaging n … internal radiosity within patch found by linear interpolations n … causing Mach banding due to discontinuities of radiosity gradient