length. This extra information is added at the end of
the texture. This way all the information needed for
the rendering process that will be used by the vertex
shader is stored in the same texture (actually we use a
texture for positions and another one for orientations).
Note that, independently of the acquisition
method, if we are able to obtain the aforementioned
information, that is, positions and orientations, we can
plug it into our system.
3.2 Path Information
As we have already explained, we start with the pre-
computed data of a falling leaf and provide it to the
vertex shader in the form of a texture. Concretely, the
trajectory information is stored in a couple of 1D tex-
tures, each containing a set of RGB values that encode
position (x, y, z) and rotation (Rx, Ry, Rz) respectively,
at each moment t. Given an initial position of a leaf
(x
0
, y
0
, z
0
), subsequent positions may be computed as
(x
0
+ x, y
0
+ y, z
0
+ z). Rotations are computed the
same way. In order to make easy the encoding, the
initial position of the path is (0, 0, 0), and subsequent
positions encode displacements, therefore, the value
of y component will be negative for the rest of the po-
sitions. On their hand, orientations encode the real
orientation of the falling object. The relevant infor-
mation our vertex shader receives from the CPU is:
Number of frames of the path: Used to determine
if the provided path has been consumed and we
must jump to another reused position (see Sec-
tion 4.2).
Current time: Moment of the animation.
Total time: Total duration of the path.
Object center: Initial position of the leaf.
Path information: Two 1D textures which contain
positions and orientations respectively.
The vertex shader also receives other information
such as the vertex position, its normal, and so on.
Each frame, the vertex shader gets the correspond-
ing path displacements by accessing the correspond-
ing position (t, as the initial moment is 0) of the tex-
ture path. This simple encoding, and the fact that the
same texture is shared among all the leaves at vertex
shader level, allows us to render thousands of leaves
in real time, because we minimize texture information
change between the CPU and the GPU. Having a dif-
ferent texture per leaf would yield to texture changes
at some point. In Section 4.2 we show how to use the
same path in order to create different trajectories, and
how to reuse the same path when the initial y position
of the leaf is higher than the represented position in
the path.
3.3 Overview
At rendering time, for each leaf, a vertex shader com-
putes the new position and orientation using the cur-
rent time t. It performs the following steps:
1. Looks for the initial frame f
i
(different per leaf)
2. Seek current position in path ( f
i
+t)
3. Calculate actual position and orientation
In step 2, if we have a falling path larger than the
one stored in our texture, when we arrive at the end,
we jump to a different position of the path that pre-
serves continuity, as explained in Section 4.2. Once
we know the correct position and orientation, step 3
performs the corresponding geometric transforms and
ensures the initial and final parts of the path are soft,
as explained in the following subsection.
3.4 Starting and Ending Points
As we have mentioned, the information provided by
our texture path consists in a fixed set of positions and
orientations for a set of defined time moments. Ide-
ally, a different path should be constructed for each
leaf according to its initial position, orientation, and
its real geometry. This way, everything could be pre-
computed, that is, the vertex shader should only re-
place the initial position of the element by the position
stored in a texture. Unfortunately, for large amounts
of leaves, this becomes impractical due to the huge
demand of texture memory and, moreover, the limita-
tion in number of texture units would turn rendering
cost into bandwidth limited because there would be a
continuous necessity of texture change between CPU
and GPU. Thus, we will use the same path for all the
leaves (although we could code some paths in a larger
texture and perform a similar treatment).
In our application, a path is a set of fixed posi-
tions and orientations. Being this path common to all
leaves, and being the initial positions of leaves even-
tually different, it is compulsory to analyze the initial
positions of leaves in order to make coherent the ini-
tial orientations of leaves in our model, that depend on
the model of the tree, and the fixed initial orientation
of our falling path. Note that the position is unimpor-
tant because we encode the initial position of the path
as (0, 0, 0) displacement. As in most cases the orien-
tations will not match, we have to find a simple and
efficient way to make the orientation change softly.
Therefore, a first adaptation movement is required.
Our vertex shader receives, among other parame-
ters, a parameter that indicates the moment t of the
animation. Initially, when t is zero, we must take
the first position of the texture as the information for
REAL TIME FALLING LEAVES
247