« Sponsored Video: Getting The Most Out Of Your Game With Integrated Graphics | Main | Sponsored Video: Behind the Scenes at Project Offset »

Implementing Fluid Effets

Simulating convincing fluids in computer games is not only computationally expensive, but often mentally expensive as well, with even introductory papers on the subject requiring the reader have math skills at least at the undergraduate calculus level. In his technical article originally printed in Game Developer magazine, Neversoft co-founder Mick West explains how fluid effects work without using advanced equations, providing example code and explaining how to simulate fluids without expensive iterative diffusion and projection steps.

West begins by describing the two common styles for simulating the motion of fliuds - grid methods and particle methods. When the grid method style, he explains, "The fluid is represented by dividing up the space a fluid might occupy into individual cells and storing how much of the fluid is in each cell. In a particle method, the fluid is modeled as a large number of particles that move around and react to collisions with the environment, interacting with nearby particles. Let's focus first on simulating fluids with grids."

He then notes that the simplest way to discuss the grid method is in respect to a regular two-dimensional grid: "At the most basic level, to simulate fluid in the space covered by a grid you need two grids: one to store the density of liquid or gas at each point and another to store the velocity of the fluid."

In addition to the two grids, programmers can use any number of other matching grids that store various attributes: "Each will be stored as a matching array of floats, which can store factors such as the temperature of the fluid at each point or the color of the fluid (whereby you can mix multiple fluids together). You can also store more esoteric quantities such as humidity, for example, if you were simulating steam or cloud formation."

About

This specially written weblog combines Gamasutra and Intel knowhow to present and deconstruct the latest happenings in visual computing and game technology.

Editor: Eric Caoili

Recent Comments