Fast Photorealistic Techniques to Simulate Global Illumination in Videogames and Virtual Environments
Total Page:16
File Type:pdf, Size:1020Kb
Universitat Polit`ecnica de Catalunya Departament de Llenguatges i Sistemes Inform`atics Fast Photorealistic Techniques to Simulate Global Illumination in Videogames and Virtual Environments Alex` M´endez Feliu Ph. D. dissertation Advisor: Mateu Sbert Casasayas Girona April, 2007 Preface This document is the Ph. D. dissertation entitled Fast Photorealistic Techniques to Simulate Global Illumination in Videogames and Virtual Environments, pre- sented by Alex` M´endez i Feliu to the Universitat Polit`ecnica de Catalunya to obtain the doctorate degree. Abstract To compute global illumination solutions for rendering virtual scenes, physically accurate methods based on radiosity or ray-tracing are usually employed. These methods, though powerful and capable of generating images with high realism, are very costly. In this thesis, some techniques to simulate and/or accelerate the computation of global illumination are studied. The obscurances technique is based on the supposition that the more occluded is a point in the scene, the darker it will appear. It is computed by analyzing the geometric environment of the point and gives a value for the indirect illumination for the point that is, though not physically accurate, visually realistic. This technique is enhanced and improved in real-time environments as videogames. It is also applied to ray- tracing frameworks to generate realistic images. In this last context, sequences of frames for animation of lights and cameras are dramatically accelerated by reusing information between frames. Just a Tale It was the end of 2001 and I was in Mexico. One Sunday, few weeks after tragic September 11th and exactly the day U. S. A. attacked Afghanistan, my ex-teacher and friend Isaac Rudom´ın and I joined for breakfast. We had not seen in months and many things had happened during that time. 2001 was not really a good year for me, at least professionally. I arrived to Mexico in January with the only objective to be close to my girlfriend, but I never imagined how hard it is to be a foreigner in a strange land, even when they speak your own language. I did not find a job in six months and when I found it, it was in substitution for a pregnant secretary. I answered phone calls and wrote faxes to customers and suppliers: an awful job for a shy programmer with the dream to work in computer graphics. Meanwhile my friend Isaac had been traveling through Europe, gone to con- ferences and met people. Among the people he met, there was Roel Mart´ınez and Mateu Sbert from the Universitat de Girona. That Sunday, in a beautiful all-you-can-eat restaurant in the middle of the Naucalpan Gardens, he told me about Girona Graphics Group and the things i they were doing. Then I devised the idea of coming back to my country to do what I always wanted to do and it looked fascinating. I contacted Mateu and a few months later I came to Girona. There was only one problem to solve, but it had an easy solution: soon my girlfriend had to become my wife, but that is another story... Funding My work in this dissertation has been possible thanks to grant FPI number BES-2002-1570 from the Ministerio de Ciencia y Tecnolog´ıa from the Spanish Government. This research has also been supported by projects TIC2001-2416-C03 and TIN2004-07451-C03-01 from the Spanish Government, GameTools Project from the VIth Framework Program from the European Union, 2001/SGR/00296 and ACI2002-52 projects from the Catalan Government, Spanish-Austrian joint- action HU2000-0011 and Hungarian-Spanish Joint Action HH2004-0001. Acknowledgements Thanks to all the people that in any way has been involved with this work. To my advisor Mateu Sbert, for his brain is a source of ideas that feeds all our research, for his patience and for his support. To Isaac Rudom´ın, for increasing my passion for this field and to Roel Mart´ınez, for being the link to Mexico from Girona, and viceversa. To L´aszl´o Szirmay-Kalos, for his kindness, his knowledge and his support during my stay in Budapest and all the chances we have had to meet in the past and hopefully in the future. To L´aszl´o Neumann, for his colors and his ideas. Thanks to Coloroid Ltd. and to professor Antal Nemcsics for his kind permission to use the Color Harmony Designer software. To my other co-authors, Jordi Cat`a, Nicolau Sunyer and Sergi Funtan´e, aquesta tesi us deu m´es coses del que sembla. The kitchen, aircraft and stairs model is courtesy of LightWork Design Ltd. Margarita Garc´ıa and Astrid Southon helped with programming obscurances within RenderPark. Thanks to Janne Kontkanen, Simon Premoˇze and Per Christensen for their kind permission to use their images. Als meus companys. Al Carles i a l'Albert, per tots aquests caf`es. A la Marit´e i al Narc´ıs, per omplir-nos els caps de setmana. A la quitxalla, l'Isma, el Fran i la Tere, molts `anims, que teniu molt de futur. Al Gus, per cuidar-nos a tots. Als meus amics, al Roberto, al Joan i, especialment, al Paco, pel que hem compartit i el que ens queda per fer junts. A la meva fam´ılia. Als meus pares, a les meves germanes, a les iaies i a la tieta, que sovint no han acabat d'entendre per qu`e he seguit aquest cam´ı a la vida, per`o sempre m'han fet suport. A la petita Ariadna, la meva neboda, la nova estrella que il.lumina la fam´ılia, i primera de les que han de venir. A l'Estela, la meva llum i les meves ombres, la meva vida. El meu m´on real. Alex` M´endez i Feliu Girona, 24 d'Abril del 2007 ii Contents Preface i Contents iii List of figures vii 1 Introduction 1 1.1 Motivation . 1 1.2 Objectives . 2 1.3 Scope of the problem . 2 1.4 Overview . 3 1.4.1 Chapter 2: Background . 3 1.4.2 Chapter 3: From obscurances to ambient occlusion: A survey . 3 1.4.3 Chapter 4: Improving obscurances . 3 1.4.4 Chapter 5: Obscurances in diffuse environments: videogames 4 1.4.5 Chapter 6: Obscurances in non-diffuse environments . 4 1.4.6 Chapter 7: Animations: reuse of information between frames . 4 1.4.7 Chapter 8: Conclusions and future work . 5 1.5 Summary . 5 2 Background 7 2.1 Monte Carlo techniques . 7 2.1.1 How does it work? . 7 2.1.2 Error in Monte Carlo integration . 8 2.1.3 Importance Sampling . 8 2.1.4 Multiple importance sampling . 8 2.1.5 Quasi-Monte Carlo . 9 2.2 Physics of the light . 9 2.3 Programming the light: local and global illumination . 11 2.3.1 Local illumination and global illumination . 11 2.3.2 The ray . 11 2.3.3 The color . 11 2.3.4 BRDFs and BTDFs . 11 2.3.5 The rendering equation . 12 2.4 Radiosity . 13 2.4.1 Radiosity equation . 13 2.4.2 Form factors . 13 2.4.3 Solving the radiosity matrix . 16 2.4.4 Cornell Box . 17 iii 2.5 Ray-tracing . 17 2.5.1 The concept . 18 2.5.2 Algorithm: recursive ray-tracing . 18 2.5.3 Acceleration techniques . 19 2.6 Path-tracing . 20 2.6.1 The rendering equation and random walks . 20 2.6.2 The algorithm . 20 2.6.3 Direct and indirect illumination . 21 2.6.4 Termination conditions: Russian Roulette . 21 2.6.5 Some discussion . 21 2.7 Other Global illumination techniques . 22 2.8 Reuse of paths . 22 2.8.1 Reuse of gathering paths in path-tracing . 23 2.8.2 Reuse of shooting light paths . 23 2.8.3 Reuse of hits for neighbor eyes . 24 2.9 Summary . 24 3 From obscurances to ambient occlusion: A survey 25 3.1 Introduction . 25 3.2 Previous work . 26 3.2.1 Shading particle systems . 26 3.2.2 Accessibility . 26 3.2.3 Extended Ambient Term . 27 3.3 Theoretical basis . 27 3.3.1 Observing reality . 27 3.3.2 The obscurances illumination model . 28 3.3.3 Ambient occlusion as a simplification for obscurances . 29 3.3.4 Comparisons . 31 3.4 Computing methods . 32 3.4.1 Ray-casting . 32 3.4.2 Keeping the values . 33 3.4.3 GPU . 33 3.5 Advanced features . 35 3.5.1 Color bleeding . 35 3.5.2 Moving objects . 35 3.5.3 Deformable objects . 35 3.5.4 Trees and plants . 36 3.5.5 Volumetric vicinity shading . 36 3.5.6 Light animation and frame optimization . 36 3.5.7 Non-diffuse features . 37 3.5.8 Monte Carlo optimization . 37 3.5.9 Bent normal and environment mapping . 38 3.6 Comparison tables . 38 3.6.1 Where is the value computed and saved . 38 3.6.2 Object and scene consideration . 39 3.6.3 GPU and dynamics . 40 3.6.4 Optimizations . 41 3.6.5 Add-ons . 42 3.7 Impact . 43 3.7.1 Software packages . 43 3.7.2 Movies and TV . 44 3.7.3 Videogames . 45 iv 3.8 Summary . 45 4 Improving obscurances 47 4.1 Adding color bleeding . 47 4.1.1 Modifying the formulas . 47 4.1.2 Results . 48 4.2 The different ρ functions . 49 4.3 The maximum distance (parameter dmax) . 49 4.4 Important secondary reflectors problem . 52 4.5 Noise reduction using different sampling techniques .