Vous êtes sur la page 1sur 7

Wave Particles

Project Report for COMP-764B


Fahim Mannan
260 266 294
Abstract

This report presents an implementation of fluid simulation that was done based on [1]. Wave
particles, is a real-time fluid simulation technique that is stable and produces realistic effects.
Only the core part of the algorithm was implemented for this project. The implementation was
tested with different parameter settings. Timing results were also obtained with different number
of particles. The theory behind wave particles, the implementation details, and the results are
presented in this report.

1. Introduction

Fluid simulation has been of interest to the graphics community from the early 80s.
Before that it was mostly of interest to engineers working on fluid mechanics. One of the
main issues with fluid simulation especially for the case of interactive applications such
as games is its speed. Methods used in fluid mechanics aims for accuracy by precisely
solving equations representing the fluid model. As a result, there is high computation
cost. For graphics, the aim is mainly to make the simulation fast and realistic looking.
Therefore, simplification needs to be made to the equations to get approximate solutions.
Despite this trade off, the fluid mechanics based methods used in graphics are not
suitable for most interactive applications. Wave particles developed in [1], is a real-time
simulation approach that works very fast compared to other real-time wave simulation
algorithms. In this report, the theory behind it is first explained and then the
implementation details that are relevant to this project are discussed.

The report is organized as follows in section 2, a review of some of the related works is
presented. Section 3, gives an overview of wave particles as presented in [1]. In section 3,
the implementation done as part of this project is described. The results are shown in
section 4 and a summary of the work that has been done is given in section 5.

2. Related Works

Over the years, various approaches have been taken to simulate fluid. In this section,
some of the relevant approaches, mainly for simulating water are presented. Early works
have mostly concentrated on realistically rendering the appearance of water. Most of
these approaches use bump mapping, ray tracing or fourier synthesis [2]. However this
type of approach is not suitable for interacting with the fluid or for simulating realistic
but complex effects. For this, physically-based fluid simulation that uses models of fluid
dynamic is required. Most of the physically-based fluid simulators solve the Navier-
Stokes equations by either using Partial Differential Equation (PDE) solvers or by using
particle-based system. Simulations that rely on solving PDEs have the problem of being
unstable and slow in some cases. Whereas methods based on particle systems are stable
and faster ([3]). However tracking the particles and constructing the fluid surface
accurately is difficult. The work presented in [1] is related to particle-based approach to
fluid simulation.

Basically particle-based simulations can be categorized into those that uses simple
particle system and those with some form of particle-particle interaction ([3]). Simple
particle systems works for rendering effects like splashes or foam. But for doing
complete fluid simulation, interactive particle system needs to be used. An example of
this is Smoothed Particle Hydrodynamics (SPH) ([4]), which is an interpolation technique
for solving fluid equations using particle system. Wave particles is more related to
interactive particle based approach. However the interaction is not explicit but implicitly
implemented so that it runs in real-time.

3. Wave Particles

Wave particle essentially solves the second order wave equation. The fluid surface is
modeled as a height field and the objective is to determine the deviation of the field from
some base height. This deviation is determined by formulating an analytical solution to
the wave equation. The idea behind wave particles is to track a set of particles on the
water surface that are moving at the speed of wave and associate a deviation function
with each of the particles. There are several other quantities that are associated with wave
particles as well. Two of these that are necessary for rendering the height field are
radius of the particles and amplitude. The sum of the deviation functions forms the height
field which satisfies the second order wave equation. The deviation functions which
represents the waveform, corresponds to a bump or dent on the water surface. These are
modeled using sinusoids with a certain amplitude and defined over a certain spatial range.
The mathematical representation of the vertical deviation is given in eq. 1.
a x xi (t ) x xi (t )
Di ( x, t ) = i (cos( ) + 1) ( ) . (1)
2 ri 2ri
Here is the rectangular function. The equation basically means that the width of the
deviation function is twice the radius of the wave particle. This was chosen to get a
smooth wavefront. Besides vertical deviation, real surface waves have horizontal
deviations as well. To model that, an extended height field is formulated where the
surface deformation contains a vertical component and a horizontal local deviation
component. This is represented as follows
DiL ( x, t ) = Li (u i .( x xi )) Di ( x, t )
2u u
Li (u ) = sin u i
li li
Here, DLi is a vector combining the horizontal and vertical deviation. And u is the
velocity of the wave.

For surface wave simulation, one has to consider the wavefront expansion and
contraction as well. This is done by assigning a dispersion angle to each of the particles.
As the wavefront expands the distance between neighboring particles increase. This
causes the wavefront to become bumpy. To counter this problem, new particles are
generated whenever the distance between neighboring particles exceed some threshold
value. One final component that is considered is the effect of boundary. In the case of
closed container this is easily simulated by reflecting the wave particles when they hit the
boundary.

For realistic physically-based rendering the interaction between objects and fluid also has
to be considered. This interaction can be categorized into two classes 1) object to fluid
coupling and 2) fluid to object coupling. In the case of object to fluid coupling the
object causes new wave particles to be created based on the volume of fluid that is
displaced by the object. The sign of the amplitude which causes the bump or dent on
water surface is determined by whether a face of the object is pushing or pulling the
liquid. Finally, for the case of fluid to object coupling, the static and dynamic forces on
the object are computed.

4. Implementation

In the project, only the part related to wave particle generation and tracking has been
implemented. The authors provide the following steps that are executed in each time step.

TimeStep()
IterateWaveParticles()
ComputeObjectForces()
IterateObjects()
GenerateWaveParticles()
RenderHeightFields()

In the current implementation, only the IterateWaveParticles and


GenerateWaveParticles steps are implemented. In the GenerateWaveParticles step the
wave particles are generated assuming a sphere is dropped in the water. A number of
particles on the periphery of the sphere are generated in a way similar to what is shown in
figure 1. To determine the position of the particles, the dispersion angle is first computed
from the radius and the distance threshold value. Next, the particles are generated at the
computed dispersion angle.

Figure 1:Particle Generation on the Periphery of Obstacle


Besides computing the position and dispersion angles for the particles, the subdivision
time and the reflection times are also calculated. The frame number of these events are
determined using the speed of the particles in pixels. Finally, the event that would occur
first is stored in an event table which is implemented using hash map. The data structure
that is used is shown in figure 2. Here each entry in the table contains a list of particles
that has an event associated with them. The particles have a field called type which
stores the event that is going to occur. For the case of reflection event the particles
contain an additional variable which stores the wall that they are going to hit.

In the IterateWaveParticles step the reflection and subdivision events are handled for
each particle. First, the event list is checked to see if there is any event occurring in the
current frame. Then all the particles that have events associated with them are extracted
and the events are handled sequentially. For the subdivision event two new particles are
generated based on the dispersion angle and the distance threshold value. The amplitude
and dispersion angles are divided by three and the new particles birth frame is set to that
of the parent particle. For the reflection event, the particles birth position is changed to
the other side of the container and the direction is updated.

Event List

F1 P43 P59

F3 P10

F6 P25 P34 P39

Figure 2:Data Structure for Event Handling

Particle Table Particle


id
P8
type
wall
P10

P11

Figure 3:List of Particles and Particle Data Structure

In the rendering step, a loop runs through all the particles and draws them after
calculating the current location using the birth frame number and the current frame
number.
5. Results

Simulation was run using different parameter values. Some screenshots from running the
simulation are provided below.

Figure 4:Wave Particle Simulation

In the following, the result of wave form generation is shown. Figure 5(a) shows the
output of the wave particle simulation. This is convolved by the kernel defined in
equation 1. The kernel in 1D and 2D are shown in Figure 5(b) and (c). Since it is a
radially symmetric function, the convolution can be done separately. The result of
convolving in the x-direction and the y-direction are shown in Figures 5(d) and (e). The
final output shown in Figure 5(f) is achieved by first convolving in the x-direction and
taking the result and convolving that in the y-direction. The 3D visualization of this is
shown in Figure 6.

(a) (b) (c)

(d) (e) (f)


Figure 5:Waveform Generation
Figure 6:3D waveform

To evaluate the performance of the implementation, the time taken in each step of the
algorithm was recorded for different number of particles. The results for two different
runs are shown in Table 1 and 2. The simulation was run on 1.79GHz AMD Mobile
Athlon processor with 768MB RAM, and ATI Mobility Radeon 9200 with 32MB
memory.
Table 1:Timing results in ms. for Avg. Particles=202443 and Std=111082
Min Max Avg Std
IterateWaveParticles 0.0064254 122.341 1.53642 7.38092
GenerateWaveParticles 0.0061460 2.76013 0.0155382 0.0919103
Render 0.00810159 157.124 5.64986 16.2785
Frame Rate 0.0391111 219.26 7.23559 20.6597

Table 2:Timing results in ms. for Avg. Particles=2478600 and Std=446186


Min Max Avg Std
IterateWaveParticles 0.0064254 754.034 11.4068 50.1713
GenerateWaveParticles 0.0064254 4.39134 0.0428206 0.196139
Render 0.00754286 1219.27 34.9214 134.945
Frame Rate 0.0407873 1293.07 46.4086 177.015

From the above tables it can be seen that, GenerateWaveParticles takes the least amount
of time. This is because very simple objects are considered for this implementation and
also the dynamic motions of the objects are not considered. The second fastest routine is
IterateWaveParticles. This basically depends on the number of events that is going to
occur in a particular frame. If the maximum distance between particles threshold is small
then more subdivision events are going to occur and this will affect the runtime of the
routine. The slowest routine is Render. This is because it has to loop through all the
particles to draw them in their current position. And also the calls made to the graphics
API have some cost associated to them.

6. Conclusion

A subset of [1] has been implemented in the project. The focus has been mainly on the
algorithm for handling wave particle creation and events such as subdivision and
reflection. The waveform generation was done separately by convolving the output
generated by the simulation with the kernel defined in Equation 1. The time taken to
perform each step was measured for different number of particles.
Reference

[1] C. Yuksel, D. House, J. Keyser, "Wave Particles," ACM Transactions on Graphics


(proceedings of ACM SIGGRAPH), vol. 26, no. 3, article 99, 2007.
[2] A. Iglesias, Computer Graphics for Water Modeling and Rendering: A Survey,
Future Generation Computer Systems, vol. 20, no. 8, 2004, pp. 13551374.
[3] R. Bridson, M. Mller-Fischer, Fluid simulation: SIGGRAPH 2007 course notes,
In ACM SIGGRAPH 2007 Courses, pp. 1-81.
[4] M. Mller-Fischer, Particle-based fluid simulation for interactive applications, In
Proceedings of the 2003 ACM Siggraph/Eurographics Symposium on Computer
Animation, pp.154-159.

Vous aimerez peut-être aussi