11

A hierarchical subdivision algorithm for stochastic radiosity methods

  • Upload
    tuwien

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

A Hierarchical Subdivision Algorithm for StochasticRadiosity MethodsRobert F. Tobler, Martin Feda, Werner Purgathofer, and Alexander WilkieTechnical University of Viennae-mail: [email protected] radiosity methods have become a standard tool for generating global illumina-tion solutions for very large scenes. Unfortunately, these methods need scene descriptionsthat are premeshed to a very �ne resolution, in order to compute an adequate solution ofthe global illumination. The algorithm proposed in this paper uses a stochastic Galerkinapproach to incrementally calculate the illumination function. By tracking the illumina-tion function at di�erent levels of resolution it is possible to get a measure for the qualityof the representation, and thus adaptively subdivide in places with inadequate accuracy.With this technique a hierarchical mesh is generated, that is based on the stochasticevaluation of global illumination.Keywords: radiosity, stochastic, Monte Carlo, hierarchical, Galerkin, density estimation1 IntroductionCalculating the global illumination for a given scene is a very time-consuming task. Inorder to speed up the calculation, stochastic methods have been introduced to calculatean approximate solution. The �rst description of a Monte Carlo method for solving theglobal illumination problem was done by Kajiya [Kaj86]. Shirley [Shi90][Shi91b] adaptedthe Monte Carlo method for solving the radiosity equation system. Pattanaik and Mudur[PM92] introduced particle tracing, which simulates the propagation of `photons' withina scene. The Stochastic Ray Method [NPT+95] explored a stochastic reformulation of theJacobi iteration, in order to speed up the simulation process. The main drawback of allthese stochastic radiosity methods is that they need a scene that is meshed to the desiredresolution in order to obtain adequate results. Creating an adequate a-priori mesh fora scene is a di�cult task, since the accuracy of the radiosity computation depends onthe light transport within the scene, and thus on the inter-patch visibility and the lightdistribution.For non-stochastic methods, a number of approaches exist, that adaptively subdividethe patches in the original scene, in order to gain accuracy in places of high illuminationgradients. Among these, the most prominent method is the hierarchical radiosity algo-rithm [HSA91]. Later the hierarchies in these approaches were extended beyond the scope

2 R.F. Tobler, M. Feda, W. Purgathofer, and A. Wilkieof single patches, thus clustering objects together [Sil95]. Although these methods some-times use stochastic methods to calculate form factors, they are based on non-stochastic,and form factor calculating algorithms and therefore have di�culties dealing with thecalculation of non-lambertian interre ection.Originally all radiosity methods [CG85][CGIB86][CCWG88] used the constant radios-ity assumption, i.e. the radiosity was assumed to be constant over the area of each patch.In order to deal with radiosity gradients, the surfaces had to be split into a large numberof subpatches, sometimes called `elements'. The Galerkin method [Zat93] overcame thisproblem by representing the radiosity function as a weighted sum of basis functions. Inorder to calculate these weights, the form factor needed to be expanded to a matrix ofcoupling coe�cients. Calculating these coe�cients is a very time-consuming task, sincethe time complexity of the algorithm scales with O(K4) if K is the order of the func-tional basis. Feda [Fed96] introduced a stochastic integration method for these couplingcoe�cients that reduces the time complexity to O(K2).This paper presents a new method, that is based on Feda's stochastic calculation ofthe Galerkin coe�cients. Due to the hierarchical nature of the new approach, it obviatesthe need for generating an a-priori mesh of the scene. The new method is demonstratedusing a standard Monte Carlo type simulation of global interre ection that is basedon Pattanaik and Mudurs method [PM92]. A few tests and examples demonstrate theadvantages of the new method.2 Stochastic Galerkin RadiosityIn most stochastic radiosity methods, one of the problems that have to be solved is thereconstruction of the radiosity function over a surface based on a set of random samplesacross this surface. The samples can be viewed as particles or photons that have reachedthe surface at the current stage of the simulation, and the photon density function encodesthe radiosity function. Thus the reconstruction of the radiosity function can be viewedas a density-estimation problem. Shirley et al. [SWH+95] proposed a solution which isbased on the idea of splatting, i.e. the photons leave their energy not only in the formof delta-spikes, but in the form of a kernel function that describes the deposition of thephoton's energy on the surface.A completely di�erent approach can be derived from the Galerkin method [Zat93].Feda [Fed96] has shown that the Galerkin method can be adapted to stochastic methodsusing a Monte Carlo evaluation of the kernel integral. This section will give a shortdescription of the method.We start with the parametric form of the radiosity equation, with suitable parametricextensions of all quantities involved:Bi(s;t) = Ei(s;t) +Xj ZZ Kij(s;t;u;v) �Bj(u;v) dv du (1)The kernel function Kij(s;t;u;v) subsumes the re ection coe�cient, the form factor (in-cluding visibility), and the area function:Kij(s;t;u;v) = �i(s;t) � FdAidAj (s;t;u;v) � Aj(u;v) (2)

A Hierarchical Subdivision Algorithm for Stochastic Radiosity Methods 3The area function Aj(u;v) can be expanded in terms of the surface geometry xj(u;v):Aj(u;v) = ��������@xj(u;v)@u � @xj(u;v)@v �������� (3)Using a suitable de�nition of the inner product, the radiosity function of a surface ican be approximated using a set of orthonormal basis functions Nk and an associatedweighting function W :Bj(u;v) �Xk Bkj �Nk(u;v) where Bkj = hBj j NkiW (4)Expanding this equation using the de�nition of the inner product over the parameterinterval [a;b] � [c;d] we get:hBj j NkiW = Z baZ dc Bj(u;v) �Nk(u;v) �W (u;v) dv du (5)This integral can be solved numerically using Monte Carlo quadrature in the followingway: hBj j NkiW � (b� a) � (d� c)m mXi=1 Bj(�i) �Nk(�i) �W (�i) (6)where the �i are uniformly distributed over the parameter interval.This equation cannot be directly used to calculate the coe�cients for the basis func-tion, since the radiosity function Bj(�i) is not known in advance. The density of thesampling points, as provided by the radiosity simulation, corresponds to the radiosityfunction. This fact can be used to modify the method: equation (6) is based on a uniformsampling strategy. It is, however, very easily changed to non-uniform sampling, by intro-ducing a probability density function (PDF ) fj . For non-uniform sampling we thereforeget: hBj j NkiW � 1mj mjXi=1 Bj(�i) �Nk(�i) �W (�i)fj(�i) (7)where the samples �i are distributed according to fj , for short: �i � fj . The energy uxfunction is transformed to the PDF fj by normalization:fj(u;v) = Bj(u;v) � Aj(u;v)R ba R dc Bj(s;t) � Aj(s;t) dt ds � Bj(u;v) �Aj(u;v)mj � � (8)Heremj is the number of photons that are re ected and emitted on the surface j, and � isthe energy ux carried by each photon. Note that the denominator of the �rst formulationof equation 8 is the total outgoing energy, which can be written as the energy carried byall outgoing photons. Combining equations (7) and (8) we �nd that the inner productcan be evaluated byhBj j NkiW � � � mjXi=1 Nk(�i) �W (�i)Aj(�i) where �i � fj (9)The stochastic evaluation of the Galerkin integral is therefore reduced to a weighted sumof the basis functions evaluated at the points where photons are emitted or re ected.

4 R.F. Tobler, M. Feda, W. Purgathofer, and A. Wilkie3 Hierarchical Stochastic Radiosity3.1 Incremental Calculation of the Radiosity FunctionThe incremental calculation of the radiosity function can be easily derived from theMonte Carlo evaluation of the Galerkin integral as given in the previous section. Whilein the conventional non-incremental approach the quantities stored with each patch areeither powers or radiosities, in the incremental approach only `photon counters' remainat each surface. The actual scaling to radiosities or powers is done at the very end, whenthe surfaces need to be displayed. Of course this can be extended to Galerkin radiositymethods as well. In this case, the coe�cients of the basis functions are stored as relativevalues, so that the �nal radiosity function is only calculated for display purposes.3.2 Tracking the Radiosity Function on Multiple LevelsThe main idea of the subdivision algorithm is to simultaneously track the functionalrepresentation of the radiosity function at di�erent levels of resolution. By comparingthe functional representation at a coarser resolution level with the representation at a�ner level the error in the coarser representation can be estimated by some appropriatedi�erence-measure between these two representations. Of course, this measurement isonly meaningful if a statistically signi�cant population of samples (photons) has beengathered. At that point the quality of the functional representation is estimated bycomparing it with the representation at a higher resolution. If the di�erence exceeds somethreshold value (the value of which has to be determined experimentally, but should notdepend on the scene) the coarser level of resolution is deemed inadequate for capturingthe radiosity function, and a higher resolution level is needed.There is, however, a problem: at the higher resolution level each patch will get less pho-tons than a patch at the coarser resolution level. Therefore the variance of the radiosity-function at the higher resolution level will be higher than on the coarser resolution level.In order to perform a meaningful comparison, it is necessary to introduce a kind of stabil-ity measure for each node in the hierarchy, that indicates the usefulness of the coe�cientsof its radiosity function. Only if the stability of a node at the higher resolution level ishigher than a certain threshold parameter, we perform comparisons of its radiosity func-tion with the function of the node at the coarser resolution level. The exact nature ofthis stability measure will be explained in section 3.4.3.3 The HierarchyThe new algorithm builds a tree-structure (e.g. a quadtree) over each surface. Each nodestores the coe�cients for a functional representation of the radiosity function over itspart of the surface. At each point in time, a speci�c set of tree nodes that represents thewhole surface contains the piecewise functional representation of the complete radiosityfunction. This is the `current' level of representation. Some levels down, at a higherresolution the `preview' level is maintained to estimate the quality of the functionalrepresentation. As new samples are taken, they are classi�ed with respect to the nodesof the tree, and the functional representations of all the nodes containing the sample are

A Hierarchical Subdivision Algorithm for Stochastic Radiosity Methods 5updated. If a statistically meaningful number of samples have been taken for a node of thepreview representation, the quality of the corresponding current level can be estimated,and if it is deemed inadequate, it is split (i.e. the functional representation at the nextlevel below this node becomes the current representation and a new preview level isestablished). The preview levels are mainly used for the subdivision oracle, only if theyhave an adequately low variance (i.e. if they are `stable'), they are used for rendering.Since the nodes of the tree-structure are not created at the same time, it is possiblethat the current level has received more photons than the preview level. In order tocompensate for this fact, it is necessary to scale the coe�cients of the preview levelaccordingly. The easiest way to do this, is to view the propagation of a photon down thehierarchy as a series of `shooting' steps. Each node maintains the number of photons ithas received preceived, and the number of photons that have been propagated down thehierarchy or `shot', pshot. If we need to retrieve the radiosity value for a node, we canthen calculate the radiosity per photon Bp (as opposed to the radiosity per patch, B) ateach level on the way down the hierarchy. At level l+ 1 the radiosity per photon can beeasily calculated from the radiosity per photon at the previous level l:B(l+1)p = B(l)p � p(l)receivedp(l)shot � A(l)A(l+1) (10)Of course, the ratio of the areas of the nodes at the di�erent levels A(l)�A(l+1) has to betaken into account as well. See �gure 1 for a graphical representation.preceived node at

level l

nodes atlevel l+1

pshot

preceivedpshotFig. 1. The propagation of photons down the hierarchy (note that some photons landed on theupper level, before the lower level was created).As previously mentioned each node maintains the coe�cients of the radiosity func-tion at its level. Whenever a photon is propagated down the hierarchy these coe�cientsare updated according to the photon's radiosity contribution in each color band. In theconstant case this reduces to simply adding the photon's contribution to the single setof coe�cients that represents the radiosity of the node. For higher order Galerkin repre-sentations, the incremental version of equation (9) as described in section 3.1, needs tobe used to update the coe�cients.

6 R.F. Tobler, M. Feda, W. Purgathofer, and A. Wilkie3.4 Node StabilityAs we need to compare the functional representations of the radiosity function at dif-ferent levels of the hierarchy, and all these representations have been generated using astochastic algorithm, we need a measure for the variance of the radiosity function. Con-sidering equation (10), it can be seen, that the radiosity per photon, Bp, for a node isinversely proportional to the number of photons that have been shot at the node, pshot.In order to set a threshold to the variance of a node, we could specify a maximum forBp, since each future photon can change the radiosity value of a node maximally bythis value. This agrees with the results of Shirley [Shi91a], and can be interpreted in thefollowing way: in order to keep the variance of the radiosity for all nodes the same, weneed to ensure that that the expected number of rays that hit each node is the same.Therefore we consider a node `stable', if the number of photons that have been shotat it is larger than a certain threshold value, and we can then compare its radiosityfunctions with the radiosity function at another level. Of course this is a simpli�cation,since the contribution of each photon to a patch may be di�erent, if di�erent estimatorsfor the radiosity simulation are used, but it serves as a good �rst-order approximation,since for all stochastic methods a large proportion of photons in realistic scenes have thesame, or a similar weight, as they carry direct illumination and have not lost any powerdue to re ections.3.5 Comparing Radiosity FunctionsAn important part of the hierarchical subdivision algorithm is the necessity of compar-ing radiosity functions at di�erent levels of resolution. Although there are a number ofdi�erence measures available, there is no adequate di�erence measure available that in-corporates the human perceptual system. Therefore we opted for a very simple schemethat just calculates the maximal di�erence of all stable subnodes, as compared to thenode at the current level. This maximal di�erence is then divided by the level of radiosityof the current node, in order to get a relative di�erence measure.By using a relative measure here, we try to incorporate at least one aspect of thehuman perceptual system: in dark parts of a scene the human eye is more sensitive todi�erences in radiosity than in bright parts of a scene.3.6 Performance ConsiderationsIn order to compare the new hierarchical approach with a standard non-hierarchicalMonte Carlo algorithm, we consider an a-priori mesh of the same resolution as the small-est adaptively generated hierarchy nodes. The hierarchical node at the highest resolutionwill only be generated after all the nodes above it have been found inadequate for therepresentation of the radiosity function, and have therefore been split. If we assume a(completely unrealistic) worst case for the hierarchical algorithm, namely that all sub-nodes always get very similar numbers of photons, we have a nearly balanced tree. If wecalculate the number of photons, p, that have to be shot to make all the nodes in thistree stable we get the following sum over the photons received at each level p(l):p = mXl=1 p(l) (11)

A Hierarchical Subdivision Algorithm for Stochastic Radiosity Methods 7where m is the highest resolution level. In order to get the same variance at the highestresolution level, a non-hierarchical algorithm needs to shoot p(m) photons. Thus theoverhead of the hierarchical method can be approximated by the sum of the geometricseries with the factor q being the fanout of the subdivision method: 1=(1� 1q ). Dependingon the fanout of the hierarchy we get a di�erent overhead: in our examples we used aquadtree (with a fanout of 4) and therefore the overhead in the number of photons thathave to be shot is maximally 33%.3.7 Comparison with the Non-Hierarchical ApproachThe hierarchical approach has a few advantages when compared with a non-hierarchicalMonte Carlo simulation:{ There is no need to generate an a-priori mesh without any knowledge about theillumination function on the surfaces.{ A stable solution can be displayed at any point in the simulation. This type ofintermediate solution is based on a coarser mesh resolution, but it does not displaythe typical Monte Carlo noise.But there are also drawbacks:{ The subdivision oracle that compares the functional representations of di�erent levelsof resolution is blind with respect to certain repeating patterns. This is an aliasinge�ect of the quadtree nodes with the radiosity function, and it cannot be completelyavoided, since we try to predict the behaviour of the radiosity function for a higherresolution based on a evaluation at a lower resolution.{ At the time, when a node of the current level is split, we throw away some informationof previously gathered photons, since some photons will have been counted in theprevious level and not in the newly generated one. Since the photons counted atthe previous level have been counted at a lower resolution, they are useless for theradiosity function at a higher resolution and need to be discarded.Although these disadvantages cannot be completely avoided, their e�ect can be relievedby using adequate heuristics: in order to tune the subdivision oracle various parameterscan be added that serve as hints for subdivision. These could include things like mini-mal subdivision level, and forced subdivision if additional geometric information can beobtained.4 ResultsThe new method was implemented in C++ using the VEGA [TLP95] and Babel[TLGP96] libraries. We added the hierarchical subdivision algorithm to a particle tracersimilar to the one of Pattanaik and Mudur [PM92]. In order to store the radiosities atdi�erent levels of resolution, each patch is the root of a local quadtree. In our currentimplementation we use square patches and always split in the middle of a node, so thatall subnodes are of equal area. The algorithm can, however, be easily modi�ed to includetriangular patches as well.

8 R.F. Tobler, M. Feda, W. Purgathofer, and A. WilkieBefore testing the method with a full radiosity method, we used a simple test setup: asquare patch of unit area was illuminated in only one region, including a linear transitionfrom the non-illumiated to the fully illuminated part. The square patch is initially notsubdivided, and the new method is used to build a hierarchical representation of theradiosity function.

Fig. 2. Constant and linear radiosity on a partly illuminated square patch. The nodes that passthe stability criterion are shown.Figure 2 shows the result of throwing 106 photons on the patch using constant andlinear radiosity. The new method does a good job of detecting the shadow boundarieson the patch. In places with very little illumination, the nodes at the preview level donot get enough photons for a meaningful comparison and therefore no subdivision isperformed. In places with very strong illumination, the comparison takes place, but onlyin places with a very high gradient a di�erence between the current level and the previewlevel is detected, and the current node is subdivided. The linear solution needs even lesssubdivision to obtain an adequate result, since the graduated part of the illuminated areacan be approximated using comparatively large nodes.Figure 3 shows the result of a small constant radiosity simulation using Pattanaik andMudurs methodwith 8 million particles. As a comparisonwe used the same scene without

A Hierarchical Subdivision Algorithm for Stochastic Radiosity Methods 9

Fig. 3. Non-hierarchical and hierarchical constant radiosity solution with the respective meshes(see color plates at the end).hierarchical subdivision, the same number of particles, and a mesh resolution that is equalto the �nest resolution of the hierarchical solution. Again the hierarchical algorithm doesa good job of detecting the places with high radiosity gradients. In addition to that, alot less variance is visible in the hierarchical solution.One of the problems is, however, also visible. The subdivision of the right wall indi-cates, that the preview misses the small shadow cast be the table in the back. Thereforethe lower part of the wall is not meshed to an adequate resoution and a visible shadowleak occurs. Similarly another shadow leak occurs at the back of the same table.5 Conclusion and Future WorkWe presented a new approach for adaptively generating a hierarchical subdivision of ascene, based on a stochastic calculation of the global illumination. This new methodobviates the need to use a premeshed scene for calculating the radiosity solution withstochastic methods. It has been shown that the adaptive subdivision is very well suitedto �nd the places of high radiosity gradients, that need to be represented at a higherresolution level.

10 R.F. Tobler, M. Feda, W. Purgathofer, and A. WilkieIt is possible to combine this new method with di�erent types of subdivision strategies(e.g. symmetric vs. unsymmetric), or di�erent functional representations (e.g. constant,linear, quadratic, aso.). The only necessary requirement for the representation is thepossibility of incremental calculation of the representation using stochastic samples.The functional representations can also be based on a wavelet basis similar as inwavelet radiosity [GSCH93]. In this case the wavelets with smaller bases could be used asfunctional representation of the preview level. Although this may lead to a more compactscheme for storing the coe�cients for the functional representation, it will probablyhave an adverse e�ect on the generality of the scheme: with independent functionalrepresentations on each level, it is a lot easier to compare the representations even if theydo not use the same mesh as a support.We will further investigate some variants of the new hierarchical approach as indicatedabove, and explore the possibilities of combining it with bidirectional methods [VG95]and importance driven methods [SAS92], as these algorithms yield additional informationon the necessary mesh resolution in di�erent parts of the scene.We will also investigate the combination of the presented algorithmwith discontinuitymeshing algorithms similar to the method introduced by Lischinski et al. [LTG93], inorder to prevent the well known artifacts of light and shadow leaks.AcknowledgementsWe would like to thank Helwig L�o�elmann, Peter Stieglecker, Christoph Traxler for theirhelp and their valuable comments. This work was partly sponsored by the \Fonds zurF�orderung der wissenschaftlichen Forschung" (FWF) under project number 09639-MAT.References[CCWG88] Michael F. Cohen, Shenchang Eric Chen, John R. Wallace, and Donald P. Green-berg. A progressive re�nement approach to fast radiosity image generation. Com-puter Graphics (SIGGRAPH '88 Proceedings), 22(4):75{84, August 1988.[CG85] Michael F. Cohen and Donald P. Greenberg. The Hemi-Cube: A radiosity solu-tion for complex environments. Computer Graphics (SIGGRAPH '85 Proceedings),19(3):31{40, August 1985.[CGIB86] Michael Cohen, Donald P. Greenberg, Dave S. Immel, and Philip J. Brock. Ane�cient radiosity approach for realistic image synthesis. IEEE Computer Graphicsand Applications, 6(3):26{35, March 1986.[Fed96] Martin Feda. A Monte Carlo approach for Galerkin radiosity. to appear in TheVisual Computer, 12, 1996.[GSCH93] Steven J. Gortler, Peter Schroder, Michael F. Cohen, and Pat Hanrahan. Waveletradiosity. Computer Graphics (SIGGRAPH '93 Proceedings), pages 221{230, 1993.[HSA91] Pat Hanrahan, David Salzman, and Larry Aupperle. A rapid hierarchical radiosityalgorithm. Computer Graphics (SIGGRAPH '91 Proceedings), 25(4):197{206, July1991.[Kaj86] James T. Kajiya. The rendering equation. Computer Graphics (SIGGRAPH '86Proceedings), 20(4):143{150, August 1986.

A Hierarchical Subdivision Algorithm for Stochastic Radiosity Methods 11[LTG93] Daniel Lischinski, Filippo Tampieri, and Donald P. Greenberg. Combining hierar-chical radiosity and discontinuity meshing. Computer Graphics (SIGGRAPH '93Proceedings), pages 199{208, 1993.[NPT+95] L�aszl�o Neumann, Werner Purgathofer, Robert F. Tobler, Attila Neumann, PavolEli�a�s, Martin Feda, and Xavier Pueyo. The stochastic ray method for radiosity.In P. Hanrahan and W. Purgathofer, editors, Rendering Techniques '95, pages 206{218. Eurographics, Springer-Verlag, June 1995.[PM92] S. N. Pattanaik and S. P. Mudur. Computation of global illumination by MonteCarlo simulation of the particle model of light. In Proceedings of the Third Euro-graphics Workshop on Rendering, pages 71{83, Bristol, UK, May 1992.[SAS92] Brian E. Smits, James R. Arvo, and David H. Salesin. An importance-driven ra-diosity algorithm. Computer Graphics (SIGGRAPH '92 Proceedings), 26:273{282,July 1992.[Shi90] Peter Shirley. A ray tracing method for illumination calculation in di�use-specularscenes. In Proceedings of Graphics Interface '90, pages 205{212, May 1990.[Shi91a] P. Shirley. Time complexity of monte carlo radiosity. In Werner Purgathofer, editor,Eurographics '91, pages 459{465. North-Holland, September 1991.[Shi91b] Peter Shirley. Radiosity via ray tracing. In James Arvo, editor, Graphics Gems II,pages 306{310. Academic Press, San Diego, 1991.[Sil95] Francois X. Sillion. A uni�ed hierarchical algorithm for global illumination withscattering volumes and object clusters. IEEE Transactions on Visualization andComputer Graphics, 1(3):240{254, September 1995.[SWH+95] Peter Shirley, Bretton Wade, Philip Hubbard, David Zareski, Bruce Walter, andDonald P. Greenberg. Global illumination via density estimation. In P. Hanrahanand W. Purgathofer, editors, Rendering Techniques '95, pages 219{230. Eurograph-ics, Springer-Verlag, June 1995.[TLGP96] Robert F. Tobler, Helwig L�o�elmann, Thomas Galla, and Werner Purgathofer. BA-BEL: A generic data structure for geometric modeling. In Proceedings of the FourthWinter School of Computer Graphics, pages 359{366, Plzen, Czech Republic, Febru-ary 1996.[TLP95] Robert F. Tobler, Helwig L�o�elmann, and Werner Purgathofer. VEGA: Viennaenvironment for graphics applications. In Proceedings of the Third Winter Schoolon Computer Graphics, pages 323{328, Plzen, Czech Republic, February 1995.[VG95] Eric Veach and Leonidas J. Guibas. Optimally combining sampling techniques formonte carlo rendering. Computer Graphics (SIGGRAPH '95 Proceedings), pages419{428, August 1995.[Zat93] Harold R. Zatz. Galerkin radiosity: A higher order solution method for global illu-mination. Computer Graphics (SIGGRAPH '93 Proceedings), pages 213{220, 1993.