Top Banner

of 47

Real Time Interactive Water Waves

Apr 06, 2018

Download

Documents

jagan2003
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 8/2/2019 Real Time Interactive Water Waves

    1/47

  • 8/2/2019 Real Time Interactive Water Waves

    2/47

  • 8/2/2019 Real Time Interactive Water Waves

    3/47

    Abstract

    In this master thesis report a new method for simulating waters surfacewaves is presented. The method is well adapted for real-time applica-tions and has been developed with computer games in mind. By sim-ulating the water surface at several different resolutions simultaneouslyusing a construction similar to Laplacian Pyramids dispersion is handledapproximately resulting in a complex behaviour. The simulation is alsoextended with a dynamic level of detail method and phenomenologicalmodels for boundaries and high frequency waves. This method is pro-totyped inside the Frostbite engine developed at EA DICE andruns at 3 ms per time step on a single core of a Intel Xeon processorwith high quality results.

  • 8/2/2019 Real Time Interactive Water Waves

    4/47

    Referat

    Interaktiva vattenvgor i realtid

    Denna rapport presenterar resultaten fr ett examensarbete om simu-lering av vattenvgor. En ny metod fr att simulera vattenvgor pre-senteras. Denna metod r anpassad fr realtids-tillmpningar och harutvecklats med datorspel i tanke. Genom att simulera en vattenyta medflera upplsningar samtidigt i en pyramidstruktur hanteras dispersionapproximativt. Simuleringen varierar dynamiskt upplsning beroendep avstnd till observatren och fr att ka detaljnivn finns ett feno-menologiskt detaljsystem. En prototyp har utvecklats inuti spelmotorn

    Frostbitesom utvecklats av EA DICE. Prototypen simulerar ettsteg p 3 ms men en krna hos en Intel Xeno-processor med braresultat.

  • 8/2/2019 Real Time Interactive Water Waves

    5/47

    Contents

    1 Introduction 1

    2 Background 3

    2.1 The Height Field Model . . . . . . . . . . . . . . . . . . . . . . . . . 32.1.1 Linear Wave Theory . . . . . . . . . . . . . . . . . . . . . . . 42.1.2 The Shallow Water Equations . . . . . . . . . . . . . . . . . . 42.1.3 Turbulence . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

    2.2 Related Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.2.1 Height Field Methods . . . . . . . . . . . . . . . . . . . . . . 52.2.2 Control and Detail . . . . . . . . . . . . . . . . . . . . . . . . 62.2.3 Interaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

    3 Overview 9

    3.1 Variable Wave Speed . . . . . . . . . . . . . . . . . . . . . . . . . . . 93.2 Level of Detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103.3 Interaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

    4 Theory and Techniques 13

    4.1 Dispersion as Convolution . . . . . . . . . . . . . . . . . . . . . . . . 134.2 Laplacian Pyramids . . . . . . . . . . . . . . . . . . . . . . . . . . . 144.3 Approximating L . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144.4 Interaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164.5 Bandpass Filtered Ellipses . . . . . . . . . . . . . . . . . . . . . . . . 174.6 Level of Detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

    4.7 Phenomenological Generation of Details . . . . . . . . . . . . . . . . 194.8 Phenomenological Boundary Conditions . . . . . . . . . . . . . . . . 21

    5 Implementation 23

    5.1 Update method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235.2 Parallelism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

    5.2.1 Vectorization . . . . . . . . . . . . . . . . . . . . . . . . . . . 245.2.2 Processor parallelism . . . . . . . . . . . . . . . . . . . . . . . 24

    5.3 Algorithm Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . 255.4 Client and Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

  • 8/2/2019 Real Time Interactive Water Waves

    6/47

    5.5 Rendering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

    5.6 Physics Interaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

    6 Results 27

    6.1 Octave Implementation . . . . . . . . . . . . . . . . . . . . . . . . . 276.2 Frostbite Implementation . . . . . . . . . . . . . . . . . . . . . . . . 31

    7 Discussion 33

    7.1 Design Choices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337.1.1 Linear Wave Theory . . . . . . . . . . . . . . . . . . . . . . . 337.1.2 Wave decomposition . . . . . . . . . . . . . . . . . . . . . . . 337.1.3 Approximation ofL . . . . . . . . . . . . . . . . . . . . . . . 33

    7.1.4 Level of Detail . . . . . . . . . . . . . . . . . . . . . . . . . . 347.1.5 Interaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347.1.6 Phenomenological boundaries and details . . . . . . . . . . . 34

    7.2 Future Research . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347.2.1 Different approximations of L . . . . . . . . . . . . . . . . . . 347.2.2 Hybrid Methods . . . . . . . . . . . . . . . . . . . . . . . . . 347.2.3 Level of Detail . . . . . . . . . . . . . . . . . . . . . . . . . . 347.2.4 Rendering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357.2.5 Interaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357.2.6 Boundary Conditions . . . . . . . . . . . . . . . . . . . . . . 357.2.7 Performance Comparisons . . . . . . . . . . . . . . . . . . . . 35

    7.2.8 Other uses . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

    Bibliography 37

  • 8/2/2019 Real Time Interactive Water Waves

    7/47

    List of Figures

    3.1 Level of Detail. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103.2 Example of Object Interaction. . . . . . . . . . . . . . . . . . . . . . . . 11

    4.1 Laplacian Pyramid Algorithm. . . . . . . . . . . . . . . . . . . . . . . . 154.2 Example Decomposition. . . . . . . . . . . . . . . . . . . . . . . . . . . . 154.3 Approximation ofL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164.4 Bandpass Filtered Edges. . . . . . . . . . . . . . . . . . . . . . . . . . . 194.5 Propagation of Detail Waves. . . . . . . . . . . . . . . . . . . . . . . . . 20

    5.1 Vectorization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245.3 Algorithm Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255.2 Border sizes for Different Grid Resolutions. . . . . . . . . . . . . . . . . 26

    6.1 Sum of eight bandpass filtered functions. . . . . . . . . . . . . . . . . . . 27

    6.2 Bandpass Decomposition. . . . . . . . . . . . . . . . . . . . . . . . . . . 286.3 Measured wave speed. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296.4 Height-field Results Comparison. . . . . . . . . . . . . . . . . . . . . . . 296.5 Grids in the Pyramid. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

  • 8/2/2019 Real Time Interactive Water Waves

    8/47

    List of Tables

    4.1 Approximation ofL: Values for B and A1 . . . . . . . . . . . . . . . . . 16

    6.1 Time Measurements for 8 Connected Pyramids. . . . . . . . . . . . . . . 316.2 Time Measurements for Various Pyramid Configurations. . . . . . . . . 31

  • 8/2/2019 Real Time Interactive Water Waves

    9/47

    Chapter 1

    Introduction

    Simulating water realistically is of greatinterest in computer graphics since it issuch an important part of our world. It isalso a very complex problem. Today re-alistic computer generated water is seenin many movies. This not the case forcomputer games. The simulations usedin movies are not computed in real-timeand a single frame may take several min-utes or hours to compute (24 frames are

    needed per second) and may use a clusterof computers. In video games this is notpossible, instead the simulation has to becomputed in real-time on a single com-puter or video game console. Because ofthis only a 1/24th of a second is avail-able per frame to achieve 24 frames persecond. Also only a fraction of a the com-puters or the consoles processing poweris available since to rest of the game hasto be run at the same time. This is a dif-

    ference of several orders of magnitude.Because of this water is rarely simulatedin games today and when it is in a verysimple fashion.

    In this thesis we will focus on surfacewaves on water that as a whole is in rest.Examples of this are ponds, lakes andpools. The goal is to investigate how ac-curately this can be done in a real time

    context and find a method that is us-able in games on this generation of con-soles. The method should be easy to con-trol from a user perspective: an artistshould be able to tweak as much as pos-sible for artistic use in a computer game.It should also be predictable in perfor-mance. In games consistent performanceis more important than simulation ac-curacy: keeping the frame-rate is more

    important than keeping the simulationphysical. Another important area of fo-cus is level of detail. In order to effi-ciently use the computing power resolu-tion should be adapted to the distance tothe observer. Waves far away need lessresolution than waves close since theywill occupy less screen space. Paralleliza-tion is also important to utilize the paral-lel nature of modern computer processorsand video game consoles.

    An important area of research is in-vestigating what simplification are use-ful and provide realistic results. In thisthesis we limit our investigation to lin-ear wave theory since it accounts forimportant properties of water such aswave speed dependency on wavelengthand water height. It is also an inter-esting starting point since several com-

    1

  • 8/2/2019 Real Time Interactive Water Waves

    10/47

  • 8/2/2019 Real Time Interactive Water Waves

    11/47

    Chapter 2

    Background

    One of the hardest problems in com-puter graphics is fluid-simulation. Largescale (millions of particles) offline fluidsimulations have not been possible un-til recently with software such as Re-alFlow [rea]. Large scale real-time simu-lations are still not feasible. To simulatefluid dynamics Navier-Stokes equationshave to be solved. Usually simulation isrestricted to incompressible Newtonian

    fluids. This yields the incompressibleNavier-Stokes equations (2.1) and thevolume conservation equation(2.2):

    v

    t+ v v

    = p + 2v + f

    (2.1)

    v = 0 (2.2)Where v is the flow velocity, is the

    fluid density, p is the pressure, isthe dynamic viscosity and f representsbody forces such as gravity. These equa-tions are usually solved with smoothed-particle hydrodynamics (SPH) for fluidsand 3D grid-based methods for gases.For real time solvers only modest particlenumbers (e.g.. 65 000 [Gre08]) and gridsizes (e.g.. 128x128x32 grid [KID10]) canbe solved. These results are from simula-

    tions utilizing the full processing powerof a high-end PC. In real-time applica-tions such as games only a fraction of thecomputing power is available: simulationsize has to be even less. In order to simu-late more detailed fluids in real-time vastsimplifications have to be made.

    2.1 The Height Field

    Model

    One way of simplifying the simulation isto only consider the surface of the fluidand to model it as a height field. Thismeans that the surface height (h) is mod-eled as a function of horizontal spatialcoordinates (x, y). This effectively re-duces the problem size by a dimension.A height field correctly represents waveson for example an ocean surface, a pond,

    a river etc as long as the waves are fairlysmall. Splashes and breaking waves cannot be represented however since they vi-olate the height field assumption. Never-theless this is a useful representation andheight field approach will be the focus ofthis paper.

    There has been a lot of research onthis description of water surfaces. Wewill focus on the results of linear wave

    3

  • 8/2/2019 Real Time Interactive Water Waves

    12/47

  • 8/2/2019 Real Time Interactive Water Waves

    13/47

  • 8/2/2019 Real Time Interactive Water Waves

    14/47

    CHAPTER 2. BACKGROUND

    duce the wave particles, particles repre-

    senting a small disturbance of the watersurface, and use them to solve a simplewave equation. The particles are splat-ted to a height field for rendering. Abig advantage of this approach is thatthe simulation is concentrated to the ar-eas with perturbations and barely anycomputation is needed in areas withoutwaves. However, with lots disturbancesmore and more wave particles have tobe created which results in bad worst

    case performance. Wave particles are inthis wave very similar to ordinary parti-cle systems.

    [Cor08] extend the wave particle ap-proach to handle flow by coupling it witha low resolution flow simulation. [Cor07]couple a low resolution SPH simulationwith a surface wave simulation.

    2.2.2 Control and Detail

    Increasing particle numbers and gridresolution result in major performancedegradation. Therefore a lot of workhas been made regarding up-samplingand adding details to lower resolutionsimulations. Up-sampling a fluid with-out turbulence is fairly easy to do. Tomake a low resolution simulation moredetailed high frequency turbulence hasto be added. This can be done eitherby adding noise [BHN07, KTJG08] or

    by simulating the generation of turbu-lence at a higher resolution [PTSG09].Height field simulation lack foam andsplashes. Work has been done on how toadd this to existing simulations. [JG01]add foam from particles and steep wavesand render it by blending in a foam tex-ture. They also generate particles fromthe height field simulation to simulatesplashes. [Vla10] use flow to animate a

    texture with good result.

    Fluid simulations are generally hardto control and predict due to many pa-rameters (such as grid subdivision, staticgeometry, interacting objects etc) withoften large unexpected consequences.Therefore work has been made at con-trolling fluid animations while keepingthe overall appearance dynamic. ForSPH simulations the notion of guide par-ticles has been introduced [TKPR06].With this approach individual parti-

    cles are allowed to move freely but thelocal mean of particle motion is re-stricted. [NCZ+09, Nie10] propose amethod for guiding grid-based fluid sim-ulations. Neither of these approaches aredirectly applicable to height field simula-tions.

    2.2.3 Interaction

    There are mainly two different ways of

    interacting with a height field. Eitherthe height field and flow are modifieddirectly or the boundary conditions aremodified. The first approach is used in[CL95, Tes04a] to simulate the motionof rigid objects. In the approach usedby [Tes04a] the height of the water is in-creased in front of a moving object anddecreased behind it. When an object issubmerged the height is increased aboveit corresponding to the volume of the

    object and when an object emerges theheight is decreased. This approach canalso be used to add and remove water.The other approach is to use handle in-teraction by applying pressure. When anobject is floating in the water pressure isapplied to the height field resulting in alower height below the object.

    [Tes04a] also use what they refer to asan obstruction mask. This mask con-

    6

  • 8/2/2019 Real Time Interactive Water Waves

    15/47

    2.2. RELATED WORK

    tains which parts of the water surface

    that is obstructed. This is used to createrigid boundaries against the obstructedareas. This is not physically correct butresults in plausible reflections against dy-namic objects.

    7

  • 8/2/2019 Real Time Interactive Water Waves

    16/47

  • 8/2/2019 Real Time Interactive Water Waves

    17/47

  • 8/2/2019 Real Time Interactive Water Waves

    18/47

    CHAPTER 3. OVERVIEW

    inverse Fourier transform in each step.

    We present a different solution.Our method is the following: h is split

    into different parts (h1, h2, h3, . . . , hk)representing different ranges of wavelengths. We will refer to these as subgrids. h1 contains wave lengths down tosome wave length , h2 wave lengths be-tween and 2 , h3wave lengths between2 and

    4 , and so on. With this repre-

    sentation the shortest wavelengths of hiare twice those of hi+1 (i

    Z, i > 0). Be-

    cause of this hi can be simulated at halfthe resolution of hi+1. The total heighth can be retrieved by interpolating andsumming hi for all possible i.

    The big advantage of this approach isthat all the wave lengths contained in agrid are fairly small compared with thegrid cell width. Because of this the con-volution operator L can be approximatedwith a small convolution kernel. Withina sub grid the wave speed will not vary

    as much as within the whole range offrequencies and simple approximation ofL can be used. By splitting the gridinto several sub grids the total numberof grid cells being simulated increase butthe computation per cell is drastically re-duced.

    All the sub grid together will be re-ferred to as a pyramid.

    3.2 Level of Detail

    To make the simulation fast without sac-rificing detail it is important to controlthe resolution of the grid so that ar-eas of high importance get higher res-olution than unimportant areas. Whenviewed through a perspective projectionthe water close to the observer will re-quire higher resolution since it occupies

    41236

    Figure 3.1. Level of Detail. Example dis-tribution of different resolution pyramids.

    more of projected space. As the observermoves different areas will need higherresolution.

    Our system solves this by having poolof pyramids of different resolutions allwith the same width ( 6 m for exam-ple). These are dynamically distributedto simulate water close to the observerwidth a high resolution and water fur-ther away with a higher resolution. Seefigure 3.1 for an example distribution.

    3.3 Interaction

    Interaction is handled by displacing the

    height field. When an object is pulledout of water the water height is de-creased and when pushed down heightis increased. See figure 3.2. Using ourwavelength decomposition into sub gridsmakes this more complex. Only waveswith correct wavelength should be addedto a sub grid. This can be achieved bybandpass filtering the displacement witha filter corresponding to the wavelengths

    10

  • 8/2/2019 Real Time Interactive Water Waves

    19/47

    3.3. INTERACTION

    A

    B

    C

    Figure 3.2. Example of Object Interaction.A, B and C show an object moving in differ-ent directions (arrow) and the correspondingchange in height-field (gray).

    represented in the sub grid.To simplify the interaction the inter-

    section between an object and the watersurface is approximated by an ellipse. In-stead filtering the ellipse numerically anapproximate analytical filter is used.

    11

  • 8/2/2019 Real Time Interactive Water Waves

    20/47

  • 8/2/2019 Real Time Interactive Water Waves

    21/47

  • 8/2/2019 Real Time Interactive Water Waves

    22/47

    CHAPTER 4. THEORY AND TECHNIQUES

    where L is defined as:

    L = F1g |k| tanh |k|

    H

    (4.6)

    This equation can now be solved bycomputing L and solving (4.5) numeri-cally. While feasible, [Tes04a] does this,solving (4.5) directly requires a lot ofcomputation because of the convolution.If waves of unlimited size are allowedL has to be computed accurately in

    the whole frequency range resulting in alarge kernel. If the range of wavenum-bers is limited L can be approximated tobe correct within that range and to havea small kernel size. Ideally wavelengthsshould also be fairly small compared withthe grid size to avoid computation on ahigher frequency than needed.

    4.2 Laplacian Pyramids

    Laplacian Pyramids, first introduced in[BA83], have been successfully used tosolve various problems within computergraphics. Laplacian pyramids decompo-sition is a way of representing an image,much similar to wavelets. The basic ideais very simple. To represent an image Iusing a Laplacian pyramid an iterativealgorithm is used. An overview of thealgorithm is given in figure 4.1 and anexample decomposition in figure 4.2.

    In essence this means that each imagein the Laplacian pyramid only containsa limited amount of frequencies. Alsothe wavelengths stored in each image aresmall compared with the pixels size andthe original image is retrieved by sum-ming all images in the pyramid. We canthus conclude that the Laplacian pyra-mid is a great match for the requirementsposed in the end of section 4.1.

    Usually, a Laplacian is constructed

    only once, some calculation are per-formed on it and then it is convertedback into an ordinary image. One wayof implementing wave propagation us-ing Laplacian pyramids. Each frame thepyramid is constructed, the waves arepropagated and the resulting pyramidis then summed. The results are thendrawn and displacements of the watersurface are generated. The reason the de-composition algorithm has to be run each

    frame is to allow for interaction throughheight displacements. This is a potentialbottle neck of the algorithm. The de-composition algorithm requires each im-age in the pyramid to be down-sampled,blurred and then up-sampled. We there-fore propose an implicit construction ofthe Laplacian pyramids. The basic ideais that instead of running the decompo-sition algorithm each frame on the wholewater surface only the displacements are

    decomposed. To simplify the decompo-sition further we propose a new methodin section 4.5.

    4.3 Approximating L

    To take advantage of the water heightfield representation introduced in 4.2 weneed an approximation for L. The goalfor this approximation is to accurately

    approximate L for wavenumbers betweenj and 2j for some values j where j satis-fies j = Ch where h is the grid cell widthand C is some constant. We have usedwavelengths between 6h and 12h. Thismeans that the range of frequencies rel-ative to grid cell width represented in agrid are independent of grid size. The ap-proximation should also be fast to com-pute.

    14

  • 8/2/2019 Real Time Interactive Water Waves

    23/47

  • 8/2/2019 Real Time Interactive Water Waves

    24/47

    CHAPTER 4. THEORY AND TECHNIQUES

    0 jj 2j2j

    -6 -4 -2 0 2 4 6

    3 px

    5 px

    7 px

    target

    Pixel

    Wavenumber

    Magnitude

    Figure 4.3. Approximation ofL. The first

    plot show L in the Fourier domain. The sec-ond plot shows the corresponding Gaussianfunctions.

    A12

    +A22B

    e k

    2

    4B2 (4.8)

    The weights were determined by test-ing various values for B and comparing4.8 with F(L). When k approaches zero4.8 approaches

    A12 +A22B . Therefore

    A2was chosen so thatA22B

    = A12

    to

    keep the simulation stable at low fre-quencies. A1 was chosen visually to make4.8 and F(L) close in the area of interest,between j and 2j. We start by choos-ing A1, A2, B for F(L) with infinite wa-ter depths. To make our approximationindependent of pixels size and averagewavelength we parametrize it based on

    Pixels B A1

    7 0.53 h 5.91 g jmean5 0.74 h 10.2 g jmean3 1.24 h 26.0 g jmean

    Table 4.1. Approximation ofL: Values forB and A1

    pixel width grid cell width h and meanwavenumber, jmean. A2 is not calculatedanalytically. Instead it is calculated nu-merically once the Gaussian kernel hasbeen discretized. This is to ensure sta-bility with the discretized kernel. Thecalculation is done by numerically inte-grating I = eB

    2r2 and setting A2 =A1I .

    See figure 4.3 and table 4.1.In order to handle non infinite water

    depths we need values for A1, A2, B forwater depth limited wave speeds. Forcomputational simplicity B is not al-lowed to vary with depth so that a subgrid will not need multiple B values. In-stead we simply clamp A1 and A2 toavoid the wave speed from reaching overthe shallow water speed.

    4.4 Interaction

    For interaction simple linear displace-ment of the height field was chosen forits simplicity. The displacements haveto be decomposed to be distributed to

    the different sub grids in the Laplacianpyramid. Computing the intersectionbetween an arbitrary body and the wa-ter surface is complex. Because of thisa simple approximation of the intersec-tion is used. All interacting bodies aremodeled as ellipsoids and their resultingintersections as ellipses. This makes itpossible to do an approximate analyticaldecomposition rather than numerical de-

    16

  • 8/2/2019 Real Time Interactive Water Waves

    25/47

    4.5. BANDPASS FILTERED ELLIPSES

    composition as we shall see in section 4.5.

    A horizontally moving body is modeledby increasing the water height in front ofit and decreasing it behind. To do thisthe intersection ellipse is used to modifythe height field twice. It is moved for-ward and used to increase water heightand backward to decrease water height.When a body is moved vertically throughthe water surface the ellipse is used tochange the water height dependent onthe change of submerged volume.

    4.5 Bandpass Filtered

    Ellipses

    In order to generate bandpass filtered el-lipses we derive an approximate analyti-cal expression. This expression is correctfor ellipses which are considerable larger

    than the size of the band pass filter.The basic idea is the following: Let

    f(d) be the edge response function of aband pass filter . An ellipse can locallybe approximated by a line segment. Letd(x, y) be the signed distance functionto the ellipse. Then f(d(x, y)) will lo-cally represent the bandpass filtered el-lipse, given that the filter is much smallerthan the line segments, so that curva-ture does not start to play a role. If

    we can find an expression for d(x, y) overthe whole ellipse f(d(x, y)) will have anapproximation for the band pass filteredellipse valid for large ellipses.

    We will use two properties of d in ourderivation: its gradient is perpendicularto the boundary of the ellipse and thegradients magnitude is one.

    An ellipse is usually described by thefollowing equation:

    x2

    r2x+ y

    2

    r2y= 1 (4.9)

    Where x and y are orthogonal coor-dinates in a coordinate system definedso that the direction of x and y coincidewith the major and minor axis of the el-lipse and rx and ry are the radii alongthe x and y directions respectively. Tofind d we start by finding an expressionof the form:

    x2 + y2 = r2(x, y) (4.10)

    We therefore propose r2(x, y) of theform:

    r2(x, y) =r2xr

    2y(x

    2 + y2)

    r2yx2 + r2xy

    2(4.11)

    We need to prove that 4.9 and 4.10 areequivalent:

    x2 + y2 =r2xr

    2y(x

    2 + y2)

    r2yx2 + r2xy

    2(4.12)

    1 = r2xr

    2y

    r2yx2 + r2xy

    2(4.13)

    r2yx2 + r2xy2 = r2xr2y (4.14)

    x2

    r2x+ y

    2

    r2y= 1 (4.15)

    Using this expression we can findan approximation for d :

    x2 + y2

    r2(x, y). This expression equals dwhen the ellipse is a circle since it reducesto the distance from origin minus the ra-dius. For ellipses it is inaccurate sincethe gradient of x + y is not perpendic-ular to the boundary of the ellipse. To

    17

  • 8/2/2019 Real Time Interactive Water Waves

    26/47

  • 8/2/2019 Real Time Interactive Water Waves

    27/47

  • 8/2/2019 Real Time Interactive Water Waves

    28/47

    CHAPTER 4. THEORY AND TECHNIQUES

    (0.0, 0.0)

    0.0(0.0, 0.0)

    0.0(0.0, 0.0)

    0.0(0.0, 0.0)

    0.0(0.0, 0.0)

    1.0(0.0, 0.0)

    0.0(0.0, 0.0)

    0.0(0.0, 0.0)

    0.0(0.0, 0.0)

    0.0

    (0.35, 0.35)

    0.09

    (0.5, 0.5)

    0.12 0.09(0.5, 0.5)

    0.12(0.0, 0.0)

    0.16(0.5, 0.5)

    0.12

    0.09(0.5, 0.5)

    0.12 0.09

    (dx, dy)

    A

    (0.35, 0.35)

    (0.35, 0.35)(0.35, 0.35)

    (0.0, 0.0)

    0.0(0.0, 0.0)

    0.0(0.0, 0.0)

    0.0(0.0, 0.0)

    0.0(1.0, 0.0)

    1.0(0.0, 0.0)

    0.0(0.0, 0.0)

    0.0(0.0, 0.0)

    0.0(0.0, 0.0)

    0.0

    (0.71, 0.71)

    0.29

    (0.0, 0.0)

    0.0

    (0.0, 0.0)

    0.0(1.0, 0.0)

    0.41(0.0, 0.0)

    0.0(0.0, 0.0)

    0.0(0.71,-0.71)

    0.29(0.0, 0.0)

    0.0(0.0, 0.0)

    0.0

    (0.0, 0.0)

    0.0(0.0, 0.0)

    0.0(0.0, 0.0)

    0.0(0.0, 0.0)

    0.0(0.71, 0.71)

    1.0(0.0, 0.0)

    0.0(0.0, 0.0)

    0.0(0.0, 0.0)

    0.0(0.0, 0.0)

    0.0

    (0.71, 0.71)

    0.41

    (0.0, 0.0)

    0.0

    (0.0, 1.0)

    0.29(1.0, 0.0)

    0.29(0.0, 0.0)

    0.0(0.0, 0.0)

    0.0(0.0, 0.0)

    0.0(0.0, 0.0)

    0.0(0.0, 0.0)

    0.0

    A B C D

    Figure 4.5. Propagation of Detail Waves.A explains the meaning of the different val-ues. B, C and D show example propagations.

    pixel shader.Instead we propose a method for mod-

    eling the existence of waves rather thana height field. The idea is that insteadof propagating waves information aboutwave direction and amplitude is propa-gated. Simulation is done in a grid. Eachgrid cell contains the wave energy, E, anda 2d vector containing the average direc-tion of the waves, d, this vector is notnormalized. Because of this the d con-

    tains information about how directionalthe waves are. If |d| = 0 no directionis favored , if |d| = 1 they are com-pletely directional. This representationis clearly inaccurate and violates the su-perposition principle. However our re-sults using the approach are promising.

    A method of propagation is neededto use this representation. We basethe propagation on three simple obser-

    vations:

    If |d| = 1 they should propagate inthat direction and maintain |d| = 1.

    If|d| = 0 one possible reason for thisis that the waves are traveling in alldirections. In that case they shouldpropagate in all directions and be-come more and more directional.

    Sum ofE for all cells should be con-served.

    Based on this E is propagated in twoways dependent on |d|. E is splitinto two parts: directional |d|E andnon-directional (1 |d|)E. The non-directional part is diffused equally in alldirections. The directional part weightedby the scalar product between d and thedirection to the adjacent cell. Energy isonly moved in the directions where the

    20

  • 8/2/2019 Real Time Interactive Water Waves

    29/47

    4.8. PHENOMENOLOGICAL BOUNDARY CONDITIONS

    scalar product is positive. See figure 4.5

    for examples. Propagation speed is con-trolled by the amount of energy beingpropagated.

    E and d are then exposed in a pixelshader to generate the actual details.

    4.8 Phenomenological

    Boundary Conditions

    Correct handling of boundary conditions

    is a hard problem. [Tes04a] uses a phe-nomenological approach and simply setsthe water displacement to zero wherethere is no water. This results in arigid boundary condition which gener-ates reflected waves. However thesewaves are completely unphysical sincethe water height is kept constant at bor-ders. A better approximation would bea free boundary condition. Using thisboundary condition is more complicated.

    Therefore we use a simple approxima-tion: water displacement is modeled bydiffusion where there is no water. Physi-cally this is very inaccurate and may gen-erate both energy and mass. In practiceit is a cheap way of generating plausi-ble boundary interactions and also hasa dampening effect on wave amplitude.The diffusion is cheap to calculate sincewe already calculate L which can directlybe used to calculate the diffusion.

    This model does not take non linear ef-fects of water boundaries. A large wavegenerates smaller waves when interact-ing at a boundary. In order to modelthese effects we allow waves in low reso-lution sub grids to move into higher res-olution sub grids near borders. This alsocompensates for the energy loss of theboundary condition approximation.

    21

  • 8/2/2019 Real Time Interactive Water Waves

    30/47

  • 8/2/2019 Real Time Interactive Water Waves

    31/47

  • 8/2/2019 Real Time Interactive Water Waves

    32/47

  • 8/2/2019 Real Time Interactive Water Waves

    33/47

  • 8/2/2019 Real Time Interactive Water Waves

    34/47

    CHAPTER 5. IMPLEMENTATION

    A B C

    Figure 5.2. Border sizes for Different GridResolutions.

    nomenological detail model. The texturemap the height values which are usedfor normal calculation. For simplicity allgrids are represented in the whether theyare simulated or not. However, only thegrids that are currently active are ren-dered.

    The vertex buffer is generated ata lower resolution than simulation toincrease performance of the renderingwhile the texture map is generated at fullresolution. The textures for all the gridare stored in a single texture using a tex-ture atlas approach.

    The normals are generated from thetexture map by computing the gradient.In addition to this details are added inthe vertex buffer using the phenomeno-logical detail simulation. The directionis used to blend in an animated texturemoving in that direction. The energy isused to scale the amplitude of the ani-mated texture. The texture is animatedusing the method of [Vla10].

    In order to provide smooth transitionsbetween LOD levels the highest resolu-tion grid in a pyramid are faded towardsany neighbors with lower resolution.

    5.6 Physics Interaction

    The Frostbite engine has existing sys-tems for handling rigid body physics andbuoyancy. Our simulation interacts withthis system in three ways.

    The bottom height is determined bychecking vertical rays for intersec-tion with static geometry

    Interacting bodies are updated withthe current water height at their po-sition to handle buoyancy

    Interacting bodies are approximatedwith an ellipsoid to find an intersec-tion with the water surface to gen-erate waves. See 4.4.

    26

  • 8/2/2019 Real Time Interactive Water Waves

    35/47

    Chapter 6

    Results

    6.1 Octave Implementation

    These are the results of the GNU Octave implementation. Wave speeds where cal-culated by measuring zero crossings of a standing wave. The iwave implementationuses a kernal constructed by a numerical inverse Fourier transform of eq. (4.6).

    Figure 6.1. Sum of eight bandpass filteredfunctions.

    27

  • 8/2/2019 Real Time Interactive Water Waves

    36/47

    CHAPTER 6. RESULTS

    base ellipse our approximation convolution

    heighteld

    fouriertransform

    heighteld

    fouriertransform

    Figure 6.2. Bandpass Decomposition.

    28

  • 8/2/2019 Real Time Interactive Water Waves

    37/47

  • 8/2/2019 Real Time Interactive Water Waves

    38/47

  • 8/2/2019 Real Time Interactive Water Waves

    39/47

    6.2. FROSTBITE IMPLEMENTATION

    6.2 Frostbite Implementation

    These are the results of the optimized implementation. All measurements wheremade on a 8 core Intel Xeon x5550 processor running at 2.67 GHz with 12 GB ofRAM and a Nvidia GeForceGTX 470 graphics card.

    Pyramid resolution Time per frame (ms)

    128 6.5

    64 2.1

    32 0.9

    16 0.5

    Table 6.1. Time Measurements for 8

    Connected Pyramids. Measurements wheremade in Frostbite with 8 pyramids of dif-ferent resolutions. The measurements showthe time spent on propagation and bordercopying.

    No. of pyramids with resolution Time per frame spent on

    64x64 32x32 16x16 All Simulation (ms) Rendering (ms)

    4 12 0 16 2 0.5

    6 24 0 30 4 0.7

    4 12 36 52 3.1 0.76 18 54 78 4.5 1.0

    4 16 64 84 4.3 0.9

    6 24 96 126 6.5 1.3

    Table 6.2. Time Measurements for Vari-ous Pyramid Configurations. Measurementswhere made in Frostbite. The measurementsshow the time spent on propagation and bor-der copying and the amount of time spent onthe CPU to generate vertex buffers and tex-tures.

    31

  • 8/2/2019 Real Time Interactive Water Waves

    40/47

  • 8/2/2019 Real Time Interactive Water Waves

    41/47

  • 8/2/2019 Real Time Interactive Water Waves

    42/47

    CHAPTER 7. DISCUSSION

    iWave results. However, while being less

    accurate, our method accounts for heightdependence.

    7.1.4 Level of Detail

    The level of detail system presented au-tomatically adapts resolution of the sim-ulation while keeping the performanceconstant. One big disadvantage of thepool-based method is that the total pos-

    sible area of the simulation is held con-stant. This becomes a problem when theobserver is moved far from a large watersurface. Also as the number of pyramidsincrease in the pool border copying be-comes an larger issue. For 4x4 grids thesize of the border is 8 times larger thanthe grid itself. See figure 5.2.

    7.1.5 Interaction

    All intersections are modeled as ellipses.In the implementation in the Frostbiteengine this has not limited the interac-tions. Finding accurate intersection foruse more advanced system is currentlytoo costly to be of practical use. Theellipse method allows for fairly varied in-teraction without becoming overly com-plex.

    7.1.6 Phenomenological

    boundaries and details

    The phenomenological boundaries anddetails improves the visual quality byadding interest and detail. Naturallyan accurate high resolution simulationwould be better but given the constraintson performance this is not possible.

    7.2 Future Research

    7.2.1 Different approximations of

    L

    Our approximation of L is fast to com-pute but not accurate. For future gamesand other applications a more complexapproximation may be of interest. Lcould potentially be modeled as a sumof several Gaussian functions, two keepthe separable property. Another alterna-

    tive would be to generate a two dimen-sional kernel computed directly from awindowed frequency response of L.

    7.2.2 Hybrid Methods

    Hybrid methods are common in fluidsimulations. See for example [Cor08].Using out method in conjunction withanother model is an interesting futurearea of research. One way of doing thisis to couple our linear wave theory basedmethod with another height field methodsuch as shallow water equations. Shal-low water equations do not account fordispersion effects but handles flow. Aninteresting use would be to couple a lowresolution shallow water equations solu-tion with a high resolution linear wavetheory solution. To do this the linearwave theory solver would need an advec-tion step. Another similar possibility isto couple a static laminar flow solutionwith our solution. to simulate rivers etcwhich have a close to constant flow.

    Coupling our simulation with a turbu-lence model could also be interesting.

    7.2.3 Level of Detail

    Researching more advanced LOD meth-ods for our multiresolution simulationis an important area of future research.

    34

  • 8/2/2019 Real Time Interactive Water Waves

    43/47

    7.2. FUTURE RESEARCH

    The current system uses equal sized

    pyramids of varying resolution. This lim-its the algorithm to a maximum area:the total area of all the pyramids. Sev-eral other methods were considered butnot implemented due to time constraints.A promising approach is to have a poolof equal resolution grids. The pyra-mid hierarchy is created globally by dy-namically varying the scale of the grids.This makes it possible to grid to tran-sition from one scale to another making

    the LOD algorithm independent of scenescale. The equal size of grid also removesthe problem of border copying becominga larger performance hit for small grids.

    7.2.4 Rendering

    In order for the simulation to be per-ceived as realistic in a computer or videogame the visualization needs to be real-istic. This research is beyond this thesis

    but is still an important field of research.

    7.2.5 Interaction

    We have limited ourselves to interactionsthrough ellipses. A more advanced ap-proach using general intersections andnumerical bandpass filtering should beinvestigated. Also a more accurate bandpass filter should investigated.

    7.2.6 Boundary ConditionsThe boundary conditions we have usedare phenomenological in their nature. Amore scientific approach should be con-sidered.

    7.2.7 Performance Comparisons

    Comparing performance is important tofind the most efficient method. With

    level of detail methods and different ap-

    proximations such a comparison is hardto do. Nevertheless such comparisons areimportant and so far have not been donewith height-field based methods. To dosuch a study it is important to find agood metric of simulation quality.

    7.2.8 Other uses

    The multiresolution method for solvinglinear wave theory is applied to simu-

    lation for computer and video games.Combined with a better approximationfor L it could potentially be used for non-real-time simulations. Another possibil-ity is to use this multiresolution meth-ods with higher order methods and othersimilar computational problems.

    35

  • 8/2/2019 Real Time Interactive Water Waves

    44/47

  • 8/2/2019 Real Time Interactive Water Waves

    45/47

    Bibliography

    [BA83] P. Burt and E. Adelson. The Laplacian pyramid as a compact imagecode. IEEE Transactions on communications, 31(4):532540, 1983.

    [BHN07] Robert Bridson, Jim Houriham, and Marcus Nordenstam. Curl-noisefor procedural fluid flow. ACM Trans. Graph., 26(3):46, 2007.

    [BMF07] R. Bridson and M. Mller-Fischer. Fluid simulation: SIGGRAPH 2007course notes Video files associated with this course are available fromthe citation page. In ACM SIGGRAPH 2007 courses, page 81. ACM,2007.

    [CL95] J.X. Chen and N.D.V. Lobo. Toward interactive-rate simulation of fluidswith moving obstacles using Navier-Stokes equations. Graphical Models

    and Image Processing, 57(2):107116, 1995.

    [Cor07] H. Cords. Mode-splitting for highly detailed, interactive liquid simula-tion. In GRAPHITE 07: Proceedings of the 5th international confer-ence on Computer graphics and interactive techniques in Australia andSoutheast Asia, pages 265272, New York, NY, USA, 2007. ACM.

    [Cor08] Hilko Cords. Moving with the flow: Wave particles in flowing liquids.In Journal of WSCG (WSCG08), 2008.

    [Day09] Mike Day. Insomniacs water rendering system, 2009. retrieved fromhttp://www.insomniacgames.com/tech/articles/0409/files/water.pdf.

    [Fin04] Mark Finch. Effective water simulation from physical models. In GPUGems. Addison-Wesley Professional, 2004.

    [FS06] G. Falkovich and K.R. Sreenivasan. Lessons from hydrodynamic turbu-lence. Physics Today, 59(4):43, 2006.

    [Gre08] Simon Green. Particle-based fluid simulation for games.http://developer.nvidia.com/object/gdc-2008.html, 2008. RetrievedSeptember 10th 2010.

    37

  • 8/2/2019 Real Time Interactive Water Waves

    46/47

    BIBLIOGRAPHY

    [HHL+05] T.R. Hagen, J.M. Hjelmervik, K.-A. Lie, J.R. Natvig, and M. Ofstad

    Henriksen. Visual simulation of shallow-water waves. Simulation Mod-elling Practice and Theory, 13(8):716 726, 2005. Programmable Graph-ics Hardware.

    [Igl04] A Iglesias. Computer graphics for water modeling and rendering: asurvey. Future Generation Computer Systems, 2004.

    [JG01] Lasse Staff Jensen and Robert Golias. Deep-water animation and ren-dering. http://www.gamasutra.com/gdce/2001/jensen/jensen_01.html,2001. Retrieved September 10th 2010.

    [Kal08] Daniel Kallin. Real time large scale fluids for games. Linkping Elec-

    tronic Conference Proceedings (Proceedings of SIGRAD 2008), 2008.

    [KID10] Jeffrey Kiel, Kumar Iyer, and Sebastien Domine. Takingfluid simulation out of the box: Particle effects in dark void.http://developer.nvidia.com/object/gdc-2010.html, 2010. RetrievedSeptember 10th 2010.

    [KLLR05] B.M. Kim, Y. Liu, I. Llamas, and J. Rossignac. Flowfixer: Using bfeccfor fluid simulation. In Eurographics Workshop on Natural Phenomena,volume 1. Citeseer, 2005.

    [KM90] Michael Kass and Gavin Miller. Rapid, stable fluid dynamics for com-

    puter graphics. In SIGGRAPH 90: Proceedings of the 17th annual con-ference on Computer graphics and interactive techniques, pages 4957,New York, NY, USA, 1990. ACM.

    [KTJG08] Theodore Kim, Nils Threy, Doug James, and Markus Gross. Waveletturbulence for fluid simulation. ACM Trans. Graph., 27(3):16, 2008.

    [LH10] Hyokwang Lee and Soonhung Han. Solving the shallow water equationsusing 2d sph particles for interactive applications. The Visual Computer,26:865872, 2010. 10.1007/s00371-010-0439-9.

    [Lov02] J. Loviscach. A convolution-based algorithm for animated water waves.In Eurographics, volume 2, pages 381389, 2002.

    [Lov03] J. Loviscach. Complex water effects at interactive frame rates. Journalof WSCG, 11:2003, 2003.

    [LvdP02] Anita T. Layton and Michiel van de Panne. A numerically efficientand stable algorithm for animating water waves. The Visual Computer,18:4153, 2002. 10.1007/s003710100131.

    [MK99] A.J. Majda and P.R. Kramer. Simplified models for turbulent diffusion:Theory, numerical modelling, and physical phenomena. Physics Reports,314(237):574, 1999.

    38

  • 8/2/2019 Real Time Interactive Water Waves

    47/47