An Accurate Model of Wave Refraction Over

An Accurate Model of Wave Refraction
Over Shallow Water
Manuel N. Gamito1 and F. Kenton Musgrave2
1
2
ADETTI, Edifı́cio ISCTE, Av. das Forças Armadas, 1600 LISBOA, Portugal
[email protected]
FractalWorlds.com, 15724 Trapshire Ct. Waterford, VA 20197-1002, USA
[email protected]
Abstract. A computer model of wave refraction is desirable, in the context of landscape modeling, to generate the familiar wave patterns seen near coastlines. In this
article, we present a new method for the calculation of shallow water wave refraction.
The method is more accurate than previously existing methods and provides realistic wave refraction effects. We resort to Fermat’s principle of the shortest path and
compute the propagation of wavefronts over an arbitrary inhomogeneous medium. The
propagation of wavefronts produces a phase map for each terrain. This phase map is
then coupled with a geometric model of waves to generate a heightfield representation
of the sea surface.
1
Introduction
Water waves are influenced at every point along their propagation path by the
depth of the sea. In deep water, waves are able to move freely without regard
to the geometry of the submerged terrain. As the depth decreases, the influence
of the bottom becomes significant, causing the wave trains to slow down in
a manner analogous to the propagation of light waves in media of increasing
refractive index. As with light, the wave frequency remains unchanged; only the
wavelength is affected [16]. This dynamic causes the wavefronts to pack more
closely together and to align with elevation isocontours of the sea floor. The
depth at which refraction becomes significant is roughly equal to the wavelength
of the deep water wave train. Thus, waves having small wavelengths, e.g. ripples,
are essentially independent of the submerged terrain. Large scale oceanic waves,
on the other hand, are markedly affected by this phenomenon. As these waves
approach the shore and pack together, an instability is reached, due to gravity,
that causes the wavefronts to fall down (wave breaking) or to slide down the
front face of the wave (wave spilling) [5]. This paper focuses on the refraction
mechanism of large scale oceanic waves near the coast. The ocean surface will
be represented by a heightfield in this model. Consequently, wave breaking will
not be considered. The reason for this approach is to allow easy integration into
current heightfield-oriented applications in the area of landscape modeling. A
mechanism already exists that will allow wave breaking to be included in this
model; it represents work in progress and is briefly referred in [10].
2
State of the Art
The topic of wave modeling, and wave refraction in particular, is not new in
Computer Graphics. As early as 1980, Schachter modeled deep sea waves with
a sum of sine functions [22]. Max used a similar technique [19]. Mastin, Waterberg and Mareda [18] and Tessendorf [23] used spectral synthesis to model
wind driven waves. These models did not address interaction with shallow water,
concentrating instead on the formation of waves by the action of wind. Fournier
[9] and Peachey [20] in 1985, presented the first wave refraction models. These
models took into account the deceleration of waves close to shore but did not
consider the bending of the wave paths. Later, Ts’o would consider wave deflection by successive applications of Snell’s law of refraction along the trajectory
of the waves [24].
Other authors model the behavior of water by directly discretizing the NavierStokes equations for fluid motion [14,6,8]. Due to the computational expense
associated with the Navier-Stokes equations, low spatial sampling rates are used
for the waters heightfield, with the undesirable effect of high numerical viscosities in the resulting motion. In other words, the fluid has an effective viscosity
which is much higher than its true physical viscosity. Sluggish fluid motions are
produced, with an absence of high frequency detail in the fluid surface, typical
of fluids significantly more viscous than water.
Gonzato [12] improves on the results of both Fournier and Ts’o. He presents
a model with both wave path deflection through the application of Snell’s law
and wave deceleration by the decrease of wavelength with decreasing depth.
There are important shortcomings to the works that attempt to model wave
bending by successive application of Snell’s law (namely [24] and [12]). Firstly,
Snell’s law of refraction is strictly a boundary law. It is only valid at the interface
between two media with different indices of refraction. A different law must
hold for wave transport inside a single medium with a smoothly varying index
of refraction. Secondly, it is numerically equivalent to an Euler integration of a
dynamic system. It gives a steady increase in numerical error, which substantially
impacts on the accuracy and stability of the solutions.
It is interesting to note that the simulation of wave refraction patterns, while
still undergoing active investigation in Computer Graphics, is already a well
established field of study in Oceanography and Civil Engineering of harbors
and other marine structures [1]. The computation of the refraction map of deep
water waves is an essential step in the design of new harbors. One tries to check,
given the bathymetry of the ocean floor near the harbor and the prevalent wind
directions throughout the year, that no focusing of waves could have destructive
consequences on the structures to be built.
In this paper, a new method for wave refraction in Computer Graphics is
proposed that relies accurately on the theory of wave transport. In Sect. 3, we
present this model. Section 4 follows with the geometrical representation of the
waves, dealing with the problem of associating a height profile to the wave phase
information that is computed during the refraction stage. Results are presented
in Sect. 5 and Sect. 6 concludes the paper.
3
Wave Refraction in Heterogeneous Media
The simplest case of a wave is a sinusoidal function that propagates linearly
along a given direction in space. This is expressed by:
η(x, t) = a sin (κx − ωt)
(1)
where the spatial coordinate x is measured along the direction of propagation.
Several parameters of importance are present in (1). The first one is the amplitude a, which is equal to two times the height of the wave relative to the
water level at rest. The spatial frequency κ, usually called the wave number,
indicates how many times the wave is replicated per unit length. This is related
to another parameter, the wavelength λ, according to λ = 2π/κ. The wavelength
is the minimum distance traveled by the wave before it starts repeating itself.
The temporal frequency ω, or simply the frequency, measures how many cycles
of oscillation a fixed point along the wave takes per second. Similarly to the
spatial frequency, it also has an associated parameter, the period T , given by
T = 2π/ω. The period is the amount of time that it takes for a point on the wave
to go through a new cycle of oscillation. The speed at which the wave propagates
forward is given by:
v=
λ
ω
=
κ
T
(2)
The expression inside the sine function of (1) is also called the phase of the wave.
For this simple wave it is written as:
φ = κx − ωt
(3)
The phase identifies uniquely every point along the moving wave. The propagation speed v is usually called the phase speed because it indicates how fast every
point on the wave (a crest point or a trough point, for example) travels forward.
Provided the depth h is large enough compared to the wavelength λ, all these
parameters remain constant, and the wave moves along with no interaction with
the bottom. Kinsman considers h = λ/2 to be a good threshold between deep and
shallow water [15]. For values of h < λ/2 the wavelength becomes progressively
shorter as the wave approaches the shore. This dependence on depth manifests
itself on velocity of the wave by the following relation:
v(h) = c tanh (κh)
(4)
where c is the wave speed in deep water. The deep water speed is related to the
the shallow water speed v according to v = c/n, where n is the refraction index
of the medium. The index will be equal to one in deep water, meaning that
there is no refraction taking place there, and will gradually increase close to the
shore. Unfortunately, equation (4) is transcendental because v is a function of
κ, according to (2). It would be very cumbersome for a refraction model to solve
this equation numerically every time a new sample of v(h) became necessary.
We can approximate the dependence of v on the depth with a simpler equation:
p
v(h) = c tanh (κ0 h)
(5)
where k0 = ω/c is the wave number in deep water. We have used here an
approximation for the wave number that was first proposed by Fournier in [9]. It
is accurate within 5% of error. According to the approximation (5), the refraction
index is given by:
1
n(h) = p
tanh (Sκ0 h)
(6)
We have found it useful to introduce a scaling factor S to exaggerate the
refraction patterns, and thus create results that are visually more striking. The
velocity relation (5) is modified in a similar fashion.
3.1
The Topology of a Wave Train
Waves originate in deep seas. Friction transfers energy from the wind on to the
surface of the sea. A prevalent wind causes a train of waves to be generated.
These waves move parallel to one another along the direction of the wind. The
motion of a train of waves can be represented with a suitable mapping in two
dimensional space; Figure 1 shows an example. There are two important families
of isolines in this mapping: wavefronts and wave rays. A wavefront is the set of
points along the wave train that share the same phase. The energy of a wave
train is transported by the wavefronts. A wave ray is the path traveled by any
given point on the wave. Wave rays are initially parallel in deep water and later
bend when crossing shallow water.
wavefront
u
PSfrag replacements
s
wave ray
Fig. 1. A wave train as a two dimensional mapping
The mapping is expressed as r(s, u) where s is the distance traveled, or
arclength, along a given wave ray. The variable u identifies wave rays. A ray
with u = 0 is arbitrarily defined and all the other rays are expressed, relative to
this one, by their perpendicular distance at the start.
A wave train can be initialized from a given wind speed vector. The wind
direction will determine the initial direction of the wave rays, while the wind
strength will determine the wave amplitude in deep water. The initial position
of the train, given by s = 0, is placed in sufficiently deep water so that refraction
is not significant. The wave equation is now expressed as:
η(s, u, t) = aw(φ, u, t)
Z s
n(h(r(ε, u)))dε − ωt
φ(s, u, t) = κ0
(7a)
(7b)
0
where the phase integration is performed along the path corresponding to ray u.
We have replaced the initial sinusoidal profile from (1) for a more general wave
profile w(φ, u, t), defined in Sect. 4. The amplitude a(s, u, t) also changes with
position and is explained in Sect. 3.3.
3.2
Fermat’s Principle of the Shortest Path
The phenomenon of wave propagation over an uneven bottom is entirely similar, in its theoretical foundations, to that of a light wave propagating over an
heterogeneous medium. The practical significance of such similarity is that we
can import knowledge from optics, where this kind of phenomena is very well
studied.
Consider a wave ray traveling from a point P1 to a point P2 . From all the
possible paths linking the two points the ray will follow the shortest one. This
is the Fermat Principle of the Shortest Optical Path [4]. One might think that
the shortest path is a straight segment linking P1 to P2 but that will only be the
case if the medium is homogeneous, i.e, if the refraction index n is constant. To
formalize these ideas, we will state Fermat’s Principle as a variational problem.
Consider a ray r(s, u) and the functional:
Z P2
J {r; P1 ; P2 } =
nds
(8)
P1
The shortest path for r is the one that minimizes (8). By a change of variables:
Z P2
Z P2
nds = c
dt
(9)
P1
P1
we see that the optimal path is also the one that takes the least amount of time
to go from P1 to P2 . The rays that constitute extremal solutions of (8) will also
be the solution of:
!
∂
∂r
n
= ∇n
(10)
∂s
∂s
by an application of the Euler equations to the previous variational problem [11].
This result can be further expanded, to become:
!
∇n ∂r ∂r
∇n
∂2r
+
·
=
(11a)
∂s2
n ∂s ∂s
n
or
∂2r
+
∂t2
∇n ∂r
·
n ∂t
!
∂r
=
∂t
2
∇n
c
n
n
(11b)
depending on whether we choose the arclength or the travel time for the independent variable. These equations, together with a suitable set of starting
conditions, form a set of ordinary differential equations (ODEs), describing the
dynamics of the wave rays.
The term on the right hand side of (11b) is a force term, causing the wave
rays to bend in the direction of regions with higher indices of refraction. The
second term on the left side is a viscosity term that dissipates energy and causes
the waves to decrease speed as they reach the shore. So, not only is there an
analogy with optics but also with Newtonian mechanics, since the waves describe
trajectories subject to attraction forces and viscous damping.
3.3
Calculation of Wave Amplitudes
Waves carry energy along with them. In fact, waves are just that: energy being
transported along the sea surface. The amount of energy at each point on the
wave train is directly related to the amplitude of oscillation at the same point.
As the waves spread out over a shoaling bottom, the energy is dispersed along
a larger area and the wave amplitude decreases correspondingly. In the opposite
case, if the bottom causes the wave rays to approach each other, energy is focused
and the wave amplitude increases. When this amplitude increase is large enough,
the waves break. The wave amplitude is dependent on the local deformation of
the wave mapping r(s, u) and, in particular, on the local rate of expansion of
the rays ∂r/∂u.
From an energy conservation standpoint, the amplitude of the waves, at every
point, can be shown to be:
∂r −1/2
k
(12)
∂u
In this expression, D is an amplitude modulation factor that only depends
on the depth, and k∂r/∂uk−1/2 is the refraction coefficient. It describes the
deformation of the wave trains. The factor D was derived by Kinsman [15] and
is given by:
a = a0 D k
D2 =
1
1
tanh κh 1 + 2κh/ sinh 2κh
(13)
The effect of D is to cause a slight decrease on the wave amplitude for
intermediate depths, just before increasing sharply close to the shore, where a
singularity exists. Wave breaking at the shoreline is not taken into account in
this simple energy-based model of wave amplitudes and, so, the singularity at
h = 0 is not meaningful. In practical terms, the value of D must be damped to
some maximum value in our implementation.
As for the refraction coefficient, it becomes necessary to track the expansion
vector ∂r/∂u along the path of the waves. The equation that determines the
evolution of this vector is obtained by taking partial derivatives on both sides of
(11a) or (11b) relative to u. We present in appendix a complete description of
the dynamic equations for the wave system.
At this point, it occurs to ask what happens to the amplitude when ∂r/∂u =
0. The model expressed in (12) predicts that the amplitude should become infinite. The canceling of the expansion vector takes place whenever a wavefront
becomes self-intersecting and it gives rise to a phenomenon known as caustics.
In topological terms, it is equivalent to a fold of the wave mapping over itself,
with a singularity on the point where the fold originates. The locus of the points
∂r/∂u = 0 is the caustic boundary and waves that propagate past this boundary
become caustic waves. The amplitude model, presented here, is no longer valid
for this type of waves. We do not attempt, at present, to solve this problem.
Caustic waves can be avoided, in our model, by sufficiently smoothing the terrain prior to wave refraction (see Sect. 3.5). We refer the reader to [2] for an
interesting approach to the modeling of caustic waves.
3.4
Wave Tracing
The numerical integration of the wave paths is now possible, with the knowledge of the dynamic equations for the wave train. Rather than implement an
integration scheme of our own, we resorted to a pre-existing library of integration routines [13]. Notice that each wave ray only senses the underwater terrain
immediately beneath it and is independent of any surrounding rays. This causes
the dynamics of the ODE system to be decoupled and provides linear time complexity with the number of wave rays.
The process of wave tracing is similar, in many ways, to the one described
by Gonzato [12]. The main difference is that we seek to build a two dimensional
grid φm,n of phase values. This amounts to computing a fixed phase map of the
wave propagation process, that can later be used to compute the heightfield of
the sea. The grid φm,n only contains the spatial component of the phase, as
expressed by the integral in (7b). The animation of the waves is then possible
with the addition of a factor −ωt for any desired instant t.
At the start, rays are evenly spaced along the line u = 0. The rays obey
the equation (11a), where the arclength s is the driving parameter. Each ray
is individually marched forward along a predefined arclength step δs. Figure 2
illustrates the procedure.
If two neighboring rays become too far apart, relative
√
to the distance 2δs, an intermediate ray is created (Fig. 2(b)). The parameters
for the new ray are obtained by interpolation from the two original rays.
r(si+1 ,uj+1 )
PSfrag replacements
m,n
r(si ,uj+1 )
r(si+1 ,uj )
(a)
(b)
Fig. 2. A mesh of triangles is created between the current and the previous position
of the rays (a) The interaction between the triangles and the underlying mesh (b) An
intermediate ray is created between two diverging rays
After all the rays have been marched for one iteration, a tessellation is created
between neighboring rays. Each triangle of this tessellation is examined to see if
it contains one or more samples of the phase grid. If no samples are contained
within the triangle, it is ignored. Otherwise, the phase from the triangle vertices
is interpolated onto the enclosed grid samples. There is such a case in Fig. 2(a)
for the triangle formed by the ray points r(si+1 , uj ), r(si , uj+1 ) and r(si+1 , uj+1 ),
where the grid sample φm,n is inside.
We have chosen the arclength s for the independent variable, instead of the
time t (choosing the dynamics (11a) over (11b)), because it generates a much
more regular coverage of the sea floor with equally sized triangles. If t was the
independent variable, triangles would become increasingly thin near the coast,
due to the decreasing speed of the wave train. This would have a negative impact
in computation time, as a much larger number of triangles would have to be
processed.
For the sample in Fig. 2(a), the phase value will be given by:
φm,n = pi+1,j φ(si+1 , uj ) + pi,j+1 φ(si , uj+1 ) + pi+1,j+1 φ(si+1 , uj+1 )
(14)
where pi+1,j , pi,j+1 and pi+1,j+1 are the barycentric coordinates of φm,n relative
to the triangle [7]. To use the wave equation (7a) we need to store a tuple {φ, a, u}
at every grid point {m, n}. A procedure similar to (14) is performed for the grid
amplitudes am,n and the origin coordinates um,n .
The final height of the sea at a grid sample is then:
X
ηm,n (t) =
ai w(φi − ωt, ui , t)
(15)
i
where the sum is performed over all the tuples corresponding to the {m, n}
sample. This allows different wavefronts, from the same wave train, to cross
each other and superimpose their effects. What is more, the procedure can be
repeated for any number of wave trains that we wish to consider. This can be
used to simulate the interference of several wave trains reaching the shore from
different directions, similar to the results of Ts’o [24].
Figure 3(a) shows the algorithm at work for a wave train approaching a shoaling bottom in a south to north direction. The dotted lines represent consecutive
positions of the wave train, while the full lines represent wave rays. Notice how
the rays converge slightly near the beachhead at the center right of the picture.
This focusing of rays is accompanied by a slight increase in wave amplitude, as
can be seen in 3(b). In an opposite way, the rays diverge when traveling into the
bay carved by the beachhead. New rays are spawned there to keep a constant
representation of the wave train. Amplitude also decreases at such a place, as
the wave train spreads out over a larger area.
3.5
Terrain Prefiltering
Some conditions must be met by the depth field, if the wave rays are to integrate smoothly over the bottom. We would like the trajectory of the wave rays
to be continuous and smoothly varying. This requires the depth field to be C2
continuous, because derivatives of h up to second order are involved in the dynamics of the rays (refer to the Appendix). However, wave refraction should be
able to work on any arbitrary depth field. Such fields can come from geophysical
databases. Fields can also be generated procedurally or even painted as a depth
image with the help of some paint application. The C2 continuity requirement
implies that the depth field must be prefiltered in some way to guarantee that
wave integration proceeds in a stable manner, without causing the numerical
procedure to crash.
A convenient filtering method is given by the following Helmholtz-type equation:
∂ 2 h0
∂ 2 h0
+
+ γ(h0 − h) = 0
∂x2
∂y 2
(16)
where h0 is the filtered depth. This filter guarantees that h0 will be C2 provided
that h is continuous, which is the case in any heightfield. The filter also smoothes
the terrain, causing the adaptive step integration routine to advance along the
wave paths at a faster rate. From a physical point of view, h0 can be considered as
an elastic membrane that is laid out over the terrain. The membrane is attracted
to the terrain through an elastic force that is proportional to the constant γ.
By increasing γ, the membrane represents the terrain more accurately but also
has more high frequency content to slow down the integration. This parameter
is used to avoid any caustic formation in our model. We decrease γ up to the
point when any caustic has disappeared from the refraction mapping.
Equation (16) must be complemented with a suitable boundary condition.
The obvious condition is that the shoreline of the terrain must be preserved. If
0.16
0.14
0.12
0.1
0.08
0.06
0.04
0.02
1e−07
(a)
(b)
Fig. 3. A wave train refracting on a shoal bottom (a) The bottom is gray coded
according to depth (b) The amplitude map of the train
we define the curve (or set or curves):
Sh = {x : h(x) = 0}
(17)
then we must have Sh0 = Sh . The portions of the terrain above sea level are not
affected by the filtering operation. The filter only applies to the areas, bounded
by Sh , where the terrain is submerged, because that is where the refraction of
wave rays takes place. The original unfiltered terrain is still used for rendering
purposes, both above and below sea-level. The filter equation is discretized into
finite differences, for a grid hi,j of depth values, and solved with a conjugate
gradient relaxation method [21].
It is also necessary to interpolate the discrete depth field h0i,j into a continuous
form h0 (x) so that wave rays can integrate correctly over it. As mentioned before,
h0 (x) needs to be C2 continuous. The interpolation uses a fifth degree Hermite
surface to insure continuity up to the second order spatial derivatives of the
depth field.
4
Geometric Model of Shallow Water Waves
The phase information, collected during the wave tracing stage of the algorithm,
and described in section 3.4, is now useful for the second stage of wave refraction
that we call wave sampling. At this point, a geometrical model is applied, in the
form of a wave equation, that will give the three-dimensional shape of the wave.
The wave equation of the form (7) is quite general and many geometric models
could be used for the wave function w(φ). A function that has been widely
used by other authors is the trochoid [9,12]. The trochoid was first proposed by
Gerstner and Biesel to describe the shape of wind driven waves [3]. It is expressed
by the parametric function:
x =x0 − r sin (κx0 − ωt)
z =r cos (κx0 − ωt)
(18a)
(18b)
and is only valid, for purposes of wave modeling, when the shape parameter
τ = rκ ≤ 1. For higher values of τ , the curve self-intersects and no longer has any
physical meaning. When waves approach the shore, the wave number increases
and the trochoids become more crested, up to the limit explained above.
In spite of their close resemblance to wind waves, the trochoids implemented
in previous works look unnatural, with wave crests stretching to the horizon in
regular succession. True coastal waves look much more disordered. Some level of
randomness is desirable in (18) to achieve such an effect. We use a sparse convolution noise [17], where small sections of trochoids are used for the convolution
kernel. The wave function takes the form:
X
w(φ, u, t) =
kτ (φ − φi )s(u − ui )s(t − ti )
(19)
i
where kτ (φ) is the trochoidal kernel, for some value of the shape parameter, and
s(u) = 2u3 − 3u2 + 1 is a cubic spline function that spreads the influence of
kτ around a time sample ti and wave origin ui . The wave train consists of
several wave crests randomly distributed around a set of samples {φi , ui , ti }. The
appearance of the time variable in (19) allows the wave train to be animated, not
simply by moving the waves forward (which is done implicitly through the phase
variable), but also by shifting the wave function in noise space. This shifting
effect gives us an extra degree of realism. We use a three-dimensional noise space
{(φ, u, t)} and extract consecutive two-dimensional slices w(φ, u) along the time
axis.
The space {(φ, u, t)} is subdivided into unit sized cubes and a single sample
of a trochoid is randomly placed inside each cube. Each of these samples has
a maximum radius of influence equal to one, so that it can only influence the
immediately neighboring cubes. When evaluating (19), the trochoid in the cube
containing the requested sample is computed, along with all of its 26 neighbors.
The kernel is obtained by storing a set of cycles from the periodic trochoidal
function (18), for several values of the shape parameter, into a lookup table. This
operation is performed only once and the results are valid for all future runs of
the algorithm.
5
Implementation and Results
Color plates 1, 2 and 3 show three examples of wave refraction. The terrains were
modeled, with a size of 512 × 512 samples, using a simple paint program and
then converted to heightfield format. There is a small but discernible staircasing
effect affecting the shape of the terrains. This was caused by the paint program
that generates depth maps with only 8 bits of resolution. The wave trains start
at one the edges of the terrains, with an initial number of 256 wave rays. New
rays
√ are spawned whenever the distance between two rays increases by a factor
of 2 relative to their original distance. The decay in wave amplitude with the
spreading of wave rays is particularly noticeable in Plate 2. Plate 3 shows how
a wave train can interfere with itself, after passing an obstacle in its course.
Although only single frames of each example are shown, animated sequences can
easily be produced, since the time variable is an integral part of the model.
The trochoids in these simulations were clamped to a maximum shape parameter of τ = 0.8. Values higher than this create an excessive steepness of the wave
crests which, in turn, tend to cause aliasing problems when sampling the waves
heightfield. The implementation of the sparse convolution noise was optimized
due to its high demand during the wave sampling process. Fixed point number
representation was used for faster indexing into the lookup table of trochoid
kernels.
The performance of the test cases was measured on a SGI O2 workstation.
The results, expressed in CPU seconds of user time, is show in the Table 1.
The prefiltering stage is only done once per terrain. It is implemented with
a conjugate gradient method and, therefore, is guaranteed to converge to the
solution in N steps at the most, where N is the number of unknown filtered
depth values. As a consequence the computation time for preprocessing becomes
Table 1. Performance for three test cases, in seconds of CPU
Plate 1
Plate 2
Plate 3
Prefiltering
94.29
74.08
137.79
Tracing
16.73
14.64
28.52
Sampling
21.21
15.17
30.77
proportional to the area of the terrain that is submerged. This property can be
hinted from the tabulated values for the three terrains. The wave tracing stage
needs to be repeated only when some of the initial parameters of the wave train
are changed, like direction of travel, deep water speed or wavelength. The wave
sampling stage is then applied for each frame of animation. The amount of time
necessary to compute the wave sampling stage is largely affected by the presence
of overlapping regions on the wave trains. The case of Plate. 3 is an example,
where two wave functions have to be computed and accumulated in the wake of
the island.
6
Conclusions
With this work, we have achieved a more rigorous formulation of the problem
of wave refraction over shallow water by incorporating precise laws of geometric
optics. Although the field of geometric optics has been developed within the
context of light wave transport, it is valid to a great extent for water waves.
The application of Fermat’s principle of the shortest optical path leads to
a system of ODEs for the wave rays that can be solved in the order of tens
of seconds. We obtain solutions of wave refraction whose accuracy is bounded
everywhere by an arbitrarily small error. This error tolerance is an input parameter, supplied to the ODE solver. Previous methods resorted to successive
applications of Snell’s law of refraction and assumed linear wave paths in between, causing an increase in the approximation error with time.
A prefiltering of the underwater terrain is necessary to insure the stability
and convergence of the system of ODEs. This prefiltering step takes in the order
of minutes to process with the numerical method that we have chosen, but only
needs to be performed once for every terrain. The water surface is described by
a sparse convolution noise, where cycles of trochoid curves have been used as
convolution kernels. This leads to a realistic looking sea heightfield except for
small regions near the shore where wave breaking should occur.
The results obtained with this method show high accuracy, with respect to
wave refraction patterns, up to the limit imposed by discretization effects. A consequence of this level of accuracy is to bring up a new form of wave transmission
phenomenon for which no solutions yet exist in computer graphics. The particular phenomenon that we have identified is the formation of caustic waves. It is
curious to find that previous attempts at wave transport modeling for computer
graphics have ignored this phenomenon, while our experience shows it to be
quite common in many situations that we have considered. We hope to improve
our model in the future to account for this transport mechanism. We also plan
on incorporating a mechanism of wave breaking to further increase the realism
close to the shorelines.
Appendix A. The Complete Dynamic System
The trajectory of wave rays obey a precise set of ordinary differential equations (ODEs), as a result of Fermat’s principle of the shortest path. Each ray is
characterized by three state variables, namely:
• The phase φ of the wave.
• The position r(s, u) of a given ray u, for a distance s along the ray.
• The rate of expansion of the wave map ∂r/∂u, at a map coordinate (s, u).
This variable indicates if the rays in a small neighborhood of point r(s, u)
are spreading apart as they move forward.
The main driving term for the dynamics of wave rays is the refraction index
of the medium, given by:
1
tanh (Sκ0 h)
n(h) = p
(A-1)
where κ0 is the wave number in deep water and S is a depth scaling coefficient.
The refraction index, in turn, depends on the depth field h(x). In what follows,
we will use some simplifications of notation. We refer to the expansion rate as
a = ∂r/∂u. We use the letter t as an abbreviation for tanh (Sκ0 h). We refer to
the first and second derivatives of r(s, u) relative to s as ṙ and r̈, respectively;
similarly for φ and a. The equations of motion are:
φ̇ = κ0 n
(A-2a)
r̈ +
∇n
∇n
· ṙ ṙ =
n
n
(A-2b)
ä +
∇n
H{n}
∇n
H{n}
∇n
· ṙ ȧ +
· a r̈ +
a · ṙ +
· ȧ ṙ =
a
n
n
n
n
n
(A-2c)
where ∇n is the gradient and H{n} is the Hessian matrix of n, respectively.
Equation (A-2a) gives the temporal evolution of the wave phase. It simply integrates the index of refraction along the trajectory of the wave ray. Equation
(A-2b) is already present in Sect. 3.2 and gives the dynamics of each wave ray
in terms of a force field and a viscous damping factor. Equation (A-2c) gives the
evolution of the expansion rate for a wave ray. To complete the system, we have:
∇n
1 dn
=
∇h
n
n dh
H{n}
1 dn
1 d2 n
T
=
H{h} +
∇h · ∇h
n
n dh
n dh2
Sκ0 1 − t2
1 dn
=−
n dh
2
t
1 d2 n
(Sκ0 )2
=
(1 − t2 )(3t−2 + 1)
2
n dh
4
(A-3a)
(A-3b)
(A-3c)
(A-3d)
The starting conditions for the set of ODEs are:
φ(0, u) = 0
r(0, u) = l(u)
(A-4a)
(A-4b)
ṙ(0, u) = m
(A-4c)
a(0, u) = dl/du
(A-4d)
ȧ(0, u) = 0
(A-4e)
where l(u) is a line corresponding to the initial position of the wave train and m is
a unit vector, perpendicular to l(u), pointing along the direction of propagation.
Appendix B. Interfacing with the ODE Numerical Solver
We present here some details related to the implementation of the dynamic
system, using the ODEPACK collection of differential equation solvers [13]. The
particular routine we have chosen from the collection is lsodar. It features an
Adams predictor-corrector method for non-stiff systems of ODEs. An additional
feature of lsodar, that we find to be quite useful, is the ability to stop the
integration prematurely whenever one of a set of conditions is verified.
The standard representation for a dynamic system of ODEs, which lsodar
is capable of solving, is given by
ẏ(x) = f (y, x)
y(x0 ) = y0
(B-1a)
(B-1b)
where y(x) is the state vector of the system and the dot in (B-1a) represents
differentiation with respect to the independent variable x. The wave ray dynamic system is even simpler because there is no explicit dependence of the
state derivative on x. The starting condition y0 , valid for x = x0 , is supplied
and the routine computes consecutive states of the system along increments δx
of the independent variable. At the heart of the routine is the user-supplied
dynamics function f (y, x). We present below a C++ implementation of this
function for the case of the wave ray dynamics. The numerical routine is called
independently for every wave ray. The state vector of a wave ray is given by
y = [φ rx ry ṙx ṙy ax ay ȧx ȧy ]T .
static int
func( int* n,
// number of state variables (=7)
double* x,
// current value of arclength (unused)
double* y,
// state vector
double* ydot ) // derivative of the state vector
{
Vector dh; // gradient of the depth function
Tensor ddh; // hessian of the depth function
double dn, ddn; // first and second derivatives of the refraction index
Vector r(y[1],y[2]); // current position vector
// Get the depth and its derivatives
double h = H(r,dh,ddh);
// get derivative of the phase and also of the refraction index
ydot[0] = K(h,dn,ddn);
// first and second derivatives of the position
double visc = dn*(dh.x*y[3] + dh.y*y[4]);
ydot[1]
ydot[2]
ydot[3]
ydot[4]
=
=
=
=
y[3];
y[4];
dn*dh.x - visc*y[3];
dn*dh.y - visc*y[4];
// first and second derivatives of the expansion vector
double j11 = dn*ddh.dx + ddn*dh.x*dh.x;
double j12 = dn*ddh.dxy + ddn*dh.x*dh.y;
double j22 = dn*ddh.dy + ddn*dh.y*dh.y;
double force = dn*(dh.x*y[5] + dh.y*y[6]);
double dvisc_x = j11*y[5] + j12*y[6];
double dvisc_y = j12*y[5] + j22*y[6];
double dvisc = dvisc_x*y[3] + dvisc_y*y[4] + dn*(dh.x*y[7] + dh.y*y[8]);
ydot[5]
ydot[6]
ydot[7]
ydot[8]
=
=
=
=
y[7];
y[8];
j11*y[5] + j12*y[6] - visc*y[7] - force*ydot[3] - dvisc*y[3];
j12*y[5] + j22*y[6] - visc*y[8] - force*ydot[4] - dvisc*y[4];
return 0;
}
The stopping criteria for the integration are supplied by a set of conditions
gi (y) = 0, with i = 0, . . . , m for some value of m. We currently check against
the following criteria and stop the integration accordingly:
• The wave ray reaches the shore.
• The wave ray crosses the boundaries of the grid.
• The amplitude along the wave ray falls bellow a predefined threshold.
The last criterion is particularly useful because it prevents unnecessary computations in areas where the wavefronts are widely spread and the amplitudes
fall to negligible values. Stopping criteria are fed into the numerical solver by
the following routine:
static int
stopcond( int* n, // number of state variables (=7)
double* x, // current value of arclength (unused)
double* y, // state vector
int* m, // number of conditions (=6)
double* gout ) // return values of the conditions
{
// checks
gout[0] =
gout[1] =
gout[2] =
gout[3] =
against the boundaries of the grid
y[1];
// west boundary
y[2];
// south boundary
y[1] - N + 1; // east boundary
y[2] - N + 1; // north boundary
Vector r(y[1],y[2]); // current position vector
Vector a(y[5],y[6]); // current expansion vector
// checks if shoreline has been reached
gout[4] = H(r);
// checks if amplitude has gone below threshold
gout[5] = A(r,a) - epsilon;
return 0;
}
References
1. Arthur, R., Munk, W., and Isaacs, J. The direct construction of wave rays.
Trans. Am. Geophys. Un. 33, 6 (1952), 855–865.
2. Benamou, J.-D. Multivalued solution and viscosity solutions of the eikonal
equation. Tech. Rep. 3281, INRIA Rocquencourt, October 1997. available at
http://www.inria.fr/RRRT/RR-3281.html.
3. Biesel, F. Study of wave propagation in water of gradually varying depth. In
Gravity Waves. 1952, pp. 243–253. U.S. National Bureau of Standards Circular.
4. Born, M., and Wolf, E. Principles of Optics: electromagnetic theory of propagation, interference and diffraction of light. Cambridge University Press, Cambridge,
UK, 1997.
5. Campion, D., and Brewer, A. The Book of Waves: Form and Beauty on the
Ocean, third ed. Roberts Rinehart Pub., December 1997. ISBN 157098168X.
6. Chen, J. X., da Vitoria Lobo, N., Hughes, C. E., and Moshell, J. M. RealTime fluid simulation in a dynamic virtual environment. IEEE Computer Graphics
& Applications 17, 3 (May–June 1997), 52–61. ISSN 0272-1716.
7. Coxeter, H. S. M. Introduction to Geometry. Wiley, New York, 1961.
8. Foster, N., and Metaxas, D. Realistic animation of liquids. Graphical Models
and Image Processing 58, 5 (1996), 471–483.
9. Fournier, A., and Reeves, W. T. A simple model of ocean waves. In Computer
Graphics (SIGGRAPH ’86 Proceedings) (Aug. 1986), D. C. Evans and R. J. Athay,
Eds., vol. 20, pp. 75–84.
10. Gamito, M. N., and Musgrave, F. K. Non-height field rendering. available at
http://www.wizardnet.com/musgrave/sundry.html.
11. Gelfand, I. M., and Fomin, S. V. Calculus of Variations, rev. english ed.
Prentice-Hall, Englewood Cliffs, N.J., 1963.
12. Gonzato, J.-C., and le Saec, B. A phenomenological model of coastal scenes
based on physical considerations. In Computer Animation and Simulation ’97
(1997), D. Thalmann and M. van de Panne, Eds., Eurographics Association,
Springer Computer Science, pp. 137–148. ISBN 3-211-83048-0.
13. Hindmarsh, A. C. Odepack: A systematized collection of ode solvers. In Scientific
Computing, R. S. Stepleman, Ed. North-Holland, Amsterdam, 1983, pp. 55–64.
Package available at www.netlib.org.
14. Kass, M., and Miller, G. Rapid, stable fluid dynamics for computer graphics.
In Computer Graphics (SIGGRAPH ’90 Proceedings) (Aug. 1990), F. Baskett, Ed.,
vol. 24, pp. 49–57.
15. Kinsman, B. Wind Waves. Dover, 1984.
16. le Méhauté, B. An Introduction to Hydrodynamics and Water Waves. SpringerVerlag, New York, 1976.
17. Lewis, J.-P. Algorithms for solid noise synthesis. In Computer Graphics (SIGGRAPH ’89 Proceedings) (July 1989), J. Lane, Ed., vol. 23, pp. 263–270.
18. Mastin, G. A., Watterberg, P. A., and Mareda, J. F. Fourier synthesis of
ocean scenes. IEEE Computer Graphics and Applications 7, 3 (Mar. 1987), 16–23.
19. Max, N. L. Vectorized procedural models for natural terrain: Waves and islands
in the sunset. In Computer Graphics (SIGGRAPH ’81 Proceedings) (Aug. 1981),
vol. 15, pp. 317–324.
20. Peachey, D. R. Modeling waves and surf. In Computer Graphics (SIGGRAPH
’86 Proceedings) (Aug. 1986), D. C. Evans and R. J. Athay, Eds., vol. 20, pp. 65–74.
21. Press, W. H., Teukolsky, S. A., Vetterling, W. T., and Flannery, B. P.
Numerical Recipes in C: The Art of Scientific Computing (2nd ed.). Cambridge
University Press, Cambridge, 1992. ISBN 0-521-43108-5.
22. Schachter, B. J. Long crested wave models. Computer Graphics and Image
Processing 12 (1980), 187–201.
23. Tessendorf, J. Simulating ocean water. In Simulating Nature: From Theory to
Applications (1999), D. S. Ebert, Ed., no. 26 in SIGGRAPH 99 Course Notes.
24. Ts’o, P. Y., and Barsky, B. A. Modeling and rendering waves: Wave-tracing using beta-splines and reflective and refractive texture mapping. ACM Transactions
on Graphics 6, 3 (1987), 191–214.
Plate 1. Wave train reaching a curved shoreline
Plate 2. Wave train going through a narrow strait
Plate 3. Wave train splitting across an island