background preloader

Fluid Simulation for Games

Facebook Twitter

Fluid Simulation for Video Games (part 16) Downloads Download Fluid Simulation for Video Games (part 16) [PDF 770KB] Download MjgIntelFluidDemo16.zip [ZIP 682KB] Vortex Particle Method Meets Smoothed Particle Hydrodynamics The Vortex Particle Method (VPM) and Smoothed Particle Hydrodynamics (SPH) are both fluid simulation techniques that use particles to represent the fluid. Most articles in this series focus on VPM, which performs especially well for gaseous fluids because VPM retains filamentary detail without dissipating it. Part 15 describes a rudimentary SPH fluid simulation used to model a fluid in a container. SPH has a simpler boundary condition and so is well suited to viscous fluids in containers. Part 1 in this series summarized fluid dynamics; part 2 surveyed fluid simulation techniques. Mesh-free Gradients Previously, the simulations that accompanied these articles computed density gradient by transferring density to a uniform grid, then computing gradients using finite differences.

Figure 1. . ,” and Figure 2. Figure 3. Fluid Simulation for Video Games (part 17) By Dr. Michael J. Gourlay Downloads Fluid Simulation for Video Games (part 17) [PDF 916KB]MjgIntelFluidDemo17.zip [ZIP 3.4MB Fluid Surface Identification Liquids are fluids that have a free surface (that is, a surface whose shape is not defined by its container). Part 1 in this series summarized fluid dynamics; part 2 surveyed fluid simulation techniques. Indicator Function The fluid simulation keeps track of the distribution of density throughout the domain. Indicator function along a ray, passing through an object Figure 1. One problem: An indicator function does not lend itself well to tracking surfaces as they move. Figure 2. Although tracking surface motion using an indicator function creates more problems than it solves, it is still useful to identify surfaces in this way, at least initially. Finding Surfaces Using the Indicator Function The fact that you’re tracking a fluid surface implies that the fluid has at least two components—for example, air and water.

Figure 3. Figure 4. Blocks. Fluid Simulation for Video Games (part 15) By Dr. Michael J. Gourlay Downloads Download Fluid Simulation for Video Games (part 15) [PDF 1.2MB]Download MjgIntelFluidDemo15.zip [ZIP 4.1MB] Figure 1. Smoothed Particle Hydrodynamics Fluids come in a wide variety of forms, such as gas, liquid, and goo. Smoothed Particle Hydrodynamics (SPH) is a fluid simulation technique. This article—the 15th in the series—describes a rudimentary SPH fluid simulation used to model a fluid in a container. Discretization As part 2 described, every fluid simulation algorithm begins with discretization—breaking up the continuous fluid into chunks so that a computer can operate them. Representing Functions with Particles Say you want to know the value of some function at some point . Monte Carlo IntegrationSay you want to compute this integral Say you only know the values of at N random points .

Is the probability of a point being inside the volume element. Function Values from IntegralsSuppose is a Dirac delta function . Just becomes the value of the integrand . . Fluid Simulation for Video Games (part 14) By Dr. Michael J. Gourlay Downloads Download Fluid Simulation for Video Games (part 14) [PDF 1.1MB] Download MjgIntelFluidDemo14.zip [ZIP 3.8MB] Figure 1.

Containers Liquids are one phase of fluids in that that they take the shape of their container on all sides but one. This article-the 14th in a series-adds rudimentary containers to the fluid particle system described earlier. Inside-out Polytopes Detecting collisions between objects with arbitrary geometry requires sophisticated algorithms and mathematics, especially if you want to do that in real time. Part 13 described how to collide particles against convex polyhedral solids. Broad Phase: Bounding Sphere As in part 13, this article uses planes to create a half-space model of a convex polyhedron. Before jumping directly into computing the distance between points and the multiple planes that form a convex polytope, you should use a broad-phase bounding-volume test to avoid expensive computations. Figure 2. Contact Distance Figure 3. (where. Fluid Simulation for Video Games (part 13) By Dr. Michael J.

Gourlay Downloads Download Fluid Simulation for Games (part 13) [PDF 1.1MB] Download MjgIntelFluidDemo_Part13.zip [RAR 2.4MB] Figure 1. Convex Obstacles Video games are compelling because they are interactive. This article-the thirteenth in a series-describes how to augment the fluid particle system described earlier, interact with rigid bodies with any polyhedral shape, and generate a lift-like force on those bodies. Collision Detection Detecting collisions between objects first entails computing the distance between them.

The Math Behind Planes A plane is a two-dimensional surface in a three-dimensional space. And a distance, d. All points with coordinates that satisfy this equation lie within the plane. Has unit length ( ), d is the distance of the plane from the origin. Or The distance, D, of a point from the plane is: But wait a moment! And the plane with and d = 1. A plane divides all of space into two halves. Figure 2. Note: Technically, planes exist in other dimensions. . Fluid Simulation for Video Games (part 12) By Dr. Michael J. Gourlay Download Article and Source Code Download Fluid Simulation for Video Games (part 12) [PDF 1.65MB] Download MjgIntelFluidDemoPart12.rar [RAR 2.03MB] Figure 1. Comparison of particle paths for different velocity-from-vorticity methods.

The left side shows jerky paths from before this article. Jerkstrophy It comes down to sampling. Throughout this article series, I have explained the many liberties taken with simulation algorithms for the sake of speed. This article-the twelfth in a series-explains how improper sampling causes unwanted jerky motion and describes how to mitigate it. Note:Jerkstrophy is an Engreek portmanteau of the English jerk, meaning sudden uncontrolled movement, and the Greek strophy, meaning rotation. Determinism Determinism means that given the same input, the simulation generates the same output. Diagnosis What causes jerking in the vorton fluid simulation that these articles describe?

Figure 2. What cause this jerking? Figure 3. Figure 4. 1. Fluid Simulation for Video Games (part 11) By Dr. Michael J. Gourlay Download Article and Source Code Download Fluid Simulation for Video Games (part 11) [PDF 1.24MB]Download Fluid Simulation Source Code (part 11) [RAR 1.94MB] Figure 1. Combustion: Fuel + Oxygen + Heat -> Fire Combustion is a chemical reaction in which fuel oxidizes and releases heat. Visual effects traditionally model flames and smoke as different layers in a particle effect. Combustion Theory To understand combustion, you need to understand how chemicals move, how they interact with each other, and how they use and produce heat.

Whereas part 10 introduced the notion that a fluid can have variable density, this article introduces the notion that a fluid can have multiple constituents, also called chemical species. The following chemical equation models how a hydrocarbon fuel (Cx Hy) can combine with oxygen (O2) to produce exhaust (carbon dioxide,CO2, and water, H2O): where Previous articles already explained how to model advection and diffusion. Figure 2. Figure 3. Fluid Simulation for Video Games (part 10)

By Dr. Michael J. Gourlay Download Article and Source Code Download Fluid Simulation for Video Games (part 10) [PDF 1.1MB]Download Fluid Simulation Source Code (part 10) [787KB] Figure 1. "Hot Air Rises"-Well, Sort Of Heat transfers by contact during collisions at the molecular level, and air expands when it heats. A previous article (Part 8) already explained how a vortex-based fluid simulation can handle variable density in a fluid. This article-the tenth in a series-describes how density varies with temperature, how heat transfers throughout a fluid, and how heat transfers between bodies and fluid.

This article introduces features to simulation code presented in previous articles: Now, bodies immersed within the fluid heat or cool surrounding fluid (and vice versa), fluid can transfer heat within itself, and fluid density depends on its temperature. Thermal Effects Note: As mentioned in Part 8, the Boussinesq approximation has many limitations. Fluid density, or where . Leads to . Figure 2. Fluid Simulation for Video Games (part 9) By Dr. Michael J. Gourlay Download Article and Source Code Download Fluid Simulation for Video Games (part 9) [PDF 778KB]Download Fluid Simulation Source Code (part 9) [770KB] Archimedes' Principle: Body Buoyancy Any object wholly or partially immersed in a fluid is buoyed up by a force equal to the weight of the fluid displaced by the object.

This is Archimedes' Principle. This article-the ninth in a series-describes how to approximate buoyant and gravitational forces on a body immersed in a fluid with varying density. This article introduces features to simulation code presented in previous articles: Now, bodies immersed within the fluid float or sink depending on the mass of fluid the body displaces. The Weight of Fluid Displaced by an Object How do you express Archimedes' principle in a form usable by a simulation? This formula expresses the net force acting on a body immersed within a fluid with constant density: Here, is the mass of the body, is the acceleration caused by gravity, Results. Fluid Simulation for Video Games (Part 8)

By Dr. Michael J. Gourlay Download Article and Source Code Download Fluid Simulation for Video Games (Part 8) [PDF 1.2MB]Download Fluid Simulation Source Code (part 8) [764 KB] Baroclinicity: Fluid Buoyancy Heavier fluid sinks, and lighter fluid rises. This article, the eighth in a series, explains how a vortex-based fluid simulation handles variable density in a fluid. This article introduces features to the simulations presented in previous articles: The fluid flow includes motion because of buoyancy-heavier fluid sinks, and lighter fluid rises. Using Vortices to Push Heavy Fluid Below Light Fluid Remember that the simulation presented in these articles focuses on vorticity. Remember from Part 1 that by taking the curl of the momentum equation, you derive the vorticity equation: Figure 1. Boussinesq ApproximationNotice that the buoyancy term includes a density gradient ( ) and a pressure gradient ( ).

This equation obviates the need to compute pressure or its gradients. Figure 2. Figure 3. Fluid Simulation for Video Games (part 7) By Dr. Michael J. Gourlay Download PDF and Source Download Fluid Simulation for Video Games (part 7) [PDF 1.14MB] Download Fluid Simulation Source code (part 7) [720KB] Particle Operations for Fluid Motion This article, the seventh in a series, explains how to integrate a fluid simulation into a typical particle system.

This article introduces features to the simulations presented in previous articles: The fluid flow will include motion resulting from arbitrary external affectors (such as wind and forces), and the fluid simulation will work as particle operations that readily integrate into existing particle systems. Particle System Architecture Visual effects for video games consist of particle systems of screen-based filtering and compositing systems. Each effect in a particle system comprises of one or more particle collections (sometimes called groups or layers) and several particle operations (sometimes called actions). Figure 1. Position. Figure 2. Find bounding box. Figure 3. Fluid Simulation for Video Games (part 6) Download PDF and Source Download Download Fluid Simulation for Video Games (part 6) [PDF 953KB] Download Fluid Simulation Source code (part 6) [713KB] Differential Velocity Solvers This article, the sixth in a series, describes a radically different technique for computing velocity from vorticity, one of the cornerstones of the fluid simulation presented in these articles.

The first article summarized fluid dynamics; the second surveyed fluid simulation techniques; and the third and fourth presented a vortex-particle fluid simulation with two-way fluid-body interactions that runs in real time. The fifth article demonstrated how to obtain and use CPU usage profiling data to optimize and further parallelize the code so that it ran faster. This article describes a differential technique for solving velocity from vorticity and contrasts its results and performance with the integral treecode technique presented in Part 3. Velocity from Vorticity, Revisited from vorticity , where where: If . For any. Fluid Simulation for Video Games (part 5) Download PDF and Source Download Fluid Simulation for Video Games (part 5) [PDF 205KB]Download Fluid Simulation Source code (part 5) [651KB] Profiling and Optimization This article, the fifth in a series, describes the profiling and optimization of a fluid simulation, presented in the third and fourth articles.

The first article summarized fluid dynamics; the second surveyed fluid simulation techniques; and the third and fourth presented a vortex-particle fluid simulation with two-way fluid-body interactions, which runs in real time. This article exploits yet another feature of Intel® Threading Building Blocks (Intel® TBB) to spread more work across multiple threads. This article describes a process for profiling CPU usage and uses that information to optimize and further parallelize the code so that it runs faster. Much of the process of profiling and optimization described in this article mirrors the procedures described in The Software Optimization Cookbook. Benchmark Setup Profiling. Fluid Simulation for Video Games (part 4) - Intel® Software Network. Download PDF, Simulation Video, and Source Code Download Fluid Simulation for Video Games (part 4) [PDF 431KB]Video of three simulations (vortex ring, ball thru smoke, spinning ball) is available here (78.3MB)Download Fluid Simulation for Video Games (part 4) source code: MjgIntelFluidDemo.rar (425KB) Two-way Fluid-Body Interaction This article, the fourth in a series, augments a fluid simulation, presented in the third article, to include two-way fluid-body interaction.

The first article summarized fluid dynamics, the second surveyed fluid simulation techniques and the third presented a vortex-particle fluid simulation that runs in real time. The additions presented in this article allow the flow to interact with rigid bodies and vice versa. This simulation also exploits the embarrassingly parallel nature of the algorithms and uses Intel® Threading Building Blocks (TBB) to spread the work across multiple threads. Boundary Conditions Figure 1. At the contact point to the ambient flow field.

Fluid Simulation for Video Games (part 3) By Dr. Michael J. Gourlay Download PDF and Video Download Fluid Simulation for Video Games (part 3) [PDF 2.2MB]A video of three simulations (vortex ring, ball thru smoke, spinning ball) is available here (78.3MB) Vortex Particle Fluid Simulation This article, the third in a series, presents a fluid simulation implemented in C++ that runs in real time using modest and commonly available computer hardware. The first article summarized fluid dynamics; the second surveyed fluid simulation techniques. The simulation presented here uses vortex particles, called vortons by Novikov (1983), to represent the flow field and solves for velocity at each time. This simulation also exploits the embarrassingly parallel nature of the algorithms and uses Intel® Threading Building Blocks (Intel® TBB) to spread the work across multiple threads.

In the endeavor to achieve real-time fluid motion, some other fluid simulations exploit general-purpose computing on graphics processing unit (GPGPU). Discretization . . Fluid Simulation for Video Games (part 2) Fluid Simulation for Video Games (part 1)