Copyright is owned by the Author of the thesis. Permission is given for a copy to be downloaded by an individual for the purpose of research and private study only. The thesis may not be reproduced elsewhere without the permission of the Author. GPU Accelerated Particle Methods for Simulating and Rendering Fire and Water Effects A thesis presented in partial fulfillment of the requirements for the degree of Doctor of Philosophy in Computer Science at Massey University, Albany New Zealand. Timothy Lyes 2015 Abstract Thesimulationofcomplexnaturalphenomenasuchasfireandwaterisacomplicatedproblem and with the surge in popularity of video games and other interactive media, it has become an area of interest in computer graphics to be able to simulate these phenomena in real-time. Thechallengeexistsnotonlytosimulateasaccuratelyaspossibleforthebestdegreeofvisual realism,butalsotouseamethodwhichallowsforthisreal-timeinteraction. In this thesis, the use of particle systems as a method for simulating fire and water effects is explored, as well as the rendering methods used to visualize them. Particle systems are well suited to this type of problem as they can be parallelized and provide many methods of behavioural customization in order to produce a wide range of different effects. Realistic lookingresultscanbeachievedwhenasufficientnumberofparticlesareabletobesimulated withinanadequatetimeframe. It can be shown that particle system methods such as Smoothed Particle Hydrodynamics and Velocity-Vortex methods are able to simulate these phenomena well. These methods are implemented using NVIDIA CUDA to parallelize the governing algorithms on the graphics processor, and with the use of spatial grid division techniques to reduce the computational complexity,theyareabletorunatreal-timeinteractiverates. Additionally, when utilizing point-based approaches for rendering fire, and a surface gen- eration approach using the Marching Cubes algorithm for rendering water, it can be shown that these particle systems are able to be rendered with realistic-looking visualizations while maintaininginteractivity. Combiningboththecomputationalaspectsoftheparticlesystemand the rendering aspects directly on the graphics device produces good quality rendered fire and watereffectsatspeedsfastenoughtobeusedwithinteractivemediaapplications. Acknowledgements I would like to thank everyone who has supported me. In particular I would like to thank my parents,JoannaandRex,andmytwosisters,AmyandSusannah,whohavecontinuedtolove and support me during this endeavour. I would also like to thank my supervisors, Dr. Arno Leist,Dr. DanielPlayneandProf. KenHawickfortheirguidanceandexpertise,aswellasall mycolleaguesatMasseyUniversityfortheircamaraderieandencouragement. CONTENTS ListofFigures 6 ListofTables 9 1 Introduction 11 1.1 AimandResearchMethodsoftheThesis . . . . . . . . . . . . . . . . . . . . 13 1.2 KeyContributionsoftheThesis . . . . . . . . . . . . . . . . . . . . . . . . . 14 1.3 StructureoftheThesis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 2 IntroductiontoParticleSystems 17 2.1 ParticleSystemsOverview . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 2.2 FluidFlowandHydrodynamics . . . . . . . . . . . . . . . . . . . . . . . . . 20 2.3 OtherRelatedParticleModels . . . . . . . . . . . . . . . . . . . . . . . . . . 23 2.3.1 Agent-BasedModels . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 2.3.2 Spring-MassModels . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 2.3.3 OtherNotableWork . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 2.4 RenderingEffects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 2.5 NumericalMethodsandIntegration . . . . . . . . . . . . . . . . . . . . . . . 27 2.5.1 EulerIntegrationMethod . . . . . . . . . . . . . . . . . . . . . . . . . 27 2.5.2 Euler-CromerMethod . . . . . . . . . . . . . . . . . . . . . . . . . . 28 2.5.3 Runge-Kutta(2ndOrder) . . . . . . . . . . . . . . . . . . . . . . . . . 29 2.5.4 Runge-Kutta(4thOrder) . . . . . . . . . . . . . . . . . . . . . . . . . 29 2.5.5 LeapfrogMethod . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 2.6 ComputationalComplexity . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 2.7 IntroductiontoParallelization . . . . . . . . . . . . . . . . . . . . . . . . . . 32 3 IntroductiontoParallelization 35 3.1 CUDAProgrammingModel . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 3.2 KeplerArchitecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 4 CONTENTS 3.3 CUDAMemory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 3.4 ParallelizationofParticleMethods . . . . . . . . . . . . . . . . . . . . . . . . 42 3.5 CUDALibraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 3.5.1 Thrust . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 3.5.2 CURANDRandomNumberGeneration . . . . . . . . . . . . . . . . . 45 3.6 GraphicsCards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 3.7 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 4 ParticleSystemModels 47 4.1 Non-interactingParticleModel . . . . . . . . . . . . . . . . . . . . . . . . . . 48 4.2 Spring-MassModel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 4.3 SmoothedParticleHydrodynamics . . . . . . . . . . . . . . . . . . . . . . . . 52 4.3.1 Navier-StokesFluidFlow . . . . . . . . . . . . . . . . . . . . . . . . 53 4.3.2 SPHEquations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 4.4 Velocity-VortexModel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 4.4.1 Rigid-BodyInteraction . . . . . . . . . . . . . . . . . . . . . . . . . . 61 4.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 5 SpatialGridandIntegrationMethods 63 5.1 SpatialGridAlgorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 5.1.1 SpatialGrid-basedCollisionDetection . . . . . . . . . . . . . . . . . 64 5.1.2 SortingConsiderations . . . . . . . . . . . . . . . . . . . . . . . . . . 67 5.1.3 SpatialGridImplementation . . . . . . . . . . . . . . . . . . . . . . . 68 5.2 NumericalIntegration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 5.2.1 IntegrationImplementation . . . . . . . . . . . . . . . . . . . . . . . . 70 5.2.2 IntegrationMethodComparison . . . . . . . . . . . . . . . . . . . . . 74 5.3 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 6 Implementation 85 6.1 FireIntroduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 6.2 Non-interactingFireImplementation . . . . . . . . . . . . . . . . . . . . . . . 86 6.3 PlasmaImplementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 6.3.1 PlasmaSystemOverview. . . . . . . . . . . . . . . . . . . . . . . . . 91 6.3.2 Plasma-specificSpatialGridAnalysis . . . . . . . . . . . . . . . . . . 93 6.3.3 InteractionProcessing . . . . . . . . . . . . . . . . . . . . . . . . . . 98 6.4 Velocity-VortexFireImplementation . . . . . . . . . . . . . . . . . . . . . . . 98 6.4.1 FireSystemInitialization . . . . . . . . . . . . . . . . . . . . . . . . . 101 6.4.2 DynamicSpatialGrid . . . . . . . . . . . . . . . . . . . . . . . . . . 101 6.4.3 VorticityDynamics . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 6.4.4 BuoyancyHandling . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 6.4.5 AdvectionStepandBodyCollision . . . . . . . . . . . . . . . . . . . 107 6.4.6 FirePerformanceComparison . . . . . . . . . . . . . . . . . . . . . . 108 CONTENTS 5 6.5 WaterImplementation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 6.5.1 Spring-MassSystemImplementation . . . . . . . . . . . . . . . . . . 110 6.5.2 SmoothedParticleHydrodynamicsImplementation . . . . . . . . . . . 113 6.5.3 SPHvsSpring-MassComparison . . . . . . . . . . . . . . . . . . . . 117 6.6 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 7 Rendering 121 7.1 RenderingIntroduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 7.2 Point-BasedRenderingMethod . . . . . . . . . . . . . . . . . . . . . . . . . . 123 7.3 FireVisualComparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 7.4 VolumetricRendering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 7.5 SurfaceGeneration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 7.5.1 IsosurfaceIntroduction . . . . . . . . . . . . . . . . . . . . . . . . . . 132 7.5.2 MarchingCubes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 7.5.3 Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 7.5.4 ImplementationOverview . . . . . . . . . . . . . . . . . . . . . . . . 138 7.5.5 CellClassificationApproaches . . . . . . . . . . . . . . . . . . . . . . 138 7.5.6 GeneratingtheSurface . . . . . . . . . . . . . . . . . . . . . . . . . . 142 7.6 SurfaceRendering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 7.6.1 SurfaceRendering . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 7.6.2 CubemappingandFresnelReflection . . . . . . . . . . . . . . . . . . 146 7.7 ResultsDiscussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 7.8 RealismComparisons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156 7.9 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 8 DiscussionsandConclusions 161 8.1 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 8.1.1 NumericalIntegrationandSpatialPartitioning . . . . . . . . . . . . . 162 8.1.2 ChoicesinFireandWaterSimulationModels . . . . . . . . . . . . . . 163 8.1.3 SurfaceGenerationandRendering . . . . . . . . . . . . . . . . . . . . 165 8.2 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166 8.3 FutureWork . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
Description: