Graphics Reference
In-Depth Information
implementation and discuss the features that are used. Our particle system will be simu-
lated in the compute shader, and then rendered using the rendering pipeline in a similar
fashion as we have seen in the fluid simulation sample. We will begin with a discussion of
what type of resources to use, followed by a description of how we will add particles into
the system. We will then clarify how the particle update phase is performed, and finally will
discuss the rendering technique used to present the results of the simulation.
Resource Selection
To select an appropriate resource type, we once again must consider the type of data we
will be storing in it. We would like to store a list of all of the particles that exist within the
particle system. Since the particles can be stored in a list, this implies a ID storage type. In
addition, the data that will be stored for each particle will consist of at least a position and a
velocity, plus whatever additional specialized data is needed for a particular type of particle
system. Since there are more than four individual data items to store (the position and veloc-
ity are both vectors), it is not possible to use
a single 1D texture to hold the data. Instead,
we will use a structured buffer to hold our
particles. This will allow the creation of a
customized structure for our particle data and
will provide a very easy method of accessing
the data.
The nature of a particle system al-
lows for the use of one of the special vari-
ants of a structured buffer. We have seen in
Chapter 2 that a specially made unordered
access view allows a structured buffer to be
used as an AppendStructuredBuffer or a
ConsumeStructuredBuffer from within
HLSL. The append and consume buffers
allow for a simple storage mechanism, in
which the order of the elements is not re-
quired to be preserved, which in turn allows
for some optimizations to be implemented
in the GPU when reading and writing to and
from the resource. Our particle system is
comprised of a varying number of particles,
and there is no reason to be concerned with
the order that they appear within the buffer
since they are all treated in exactly the same
Figure 12.11. Two structured buffer resources
used as append and consume buffers to manage
particle data.
Search WWH ::




Custom Search