Graphics Reference
In-Depth Information
the same directions. We'll sort this out now and also clean up the issue of
how to make sure the height field is only real-valued despite all the complex
numbers flying around. We now build the general real-valued solution from
a collection of real cosine waves:
h ( x, z, t )=
i,j
A ij cos( k
·
( x, z )
ω k t + θ ij ) .
(13.8)
Here A ij is the real-valued constant amplitude of the wave, k =2 π ( i, j ) /L
is the wave vector as before and now points in the direction of the wave's
motion, ω k is the time frequency of the wave from Equation (13.7), and θ ij
is a constant phase shift. We'll get to picking A ij
and θ ij
lateroninthe
chapter.
Equation (13.8) can be used directly to evaluate the height field at any
point in space and time, but if a lot of waves are involved the summation
becomes expensive. However a cheaper alternative exists by way of the
Fast Fourier Transform (FFT). Let n =2 m be a power of two—this isn't
essential as FFT algorithms exist for any n , but typically the transform is
fastest for powers of two—and restrict the wave indices to
n/ 2+1
i, j
n/ 2 .
(13.9)
We thus have an n
n grid of wave parameters. We'll additionally specify
that the constant term is zero, A 00 = 0, as this is not a wave but the average
sea level, and to simplify life also zero out the highest positive frequency
(which doesn't have a matching negative frequency): A n/ 2 ,j = A i,n/ 2 =0.
The sum will then actually only be up to i = n/ 2
×
1.
We'll now show how to evaluate h ( x, z, t ) for any fixed time t on the
1and j = n/ 2
n
x, z < L , i.e., where x p = pL/n and
z q = qL/n for integer indices p and q .Thisgridof h values can then be
fed directly into a renderer. Note that this in fact gives an L
×
n regular grid of locations 0
L tile that
can be periodically continued in any direction: we'll talk more about that
at the end of the chapter.
The problem is to determine, for a fixed time t and all integer indices
×
0
p, q < n , the height values as specified by
n/ 2 1
n/ 2 1
A ij cos( k
h pq =
·
( x p ,z q )
ω k t + θ ij ) .
(13.10)
i = −n/ 2+1
j = −n/ 2+1
This is not quite in the form that an FFT code can handle, so we will need to
manipulate it a little, first by substituting in the wave vector k =2 π ( i, j ) /L
Search WWH ::




Custom Search