Graphics Reference
In-Depth Information
to simulate the smoke rising from a fire, each particle represents one puff of smoke. Each
particle maintains a position, a velocity, and perhaps a rotation and scale, all of which are
updated every time step of the simulation. Here, the update method generally makes each
particle drift in some direction, with a semi-perturbed pathway. After each simulation step,
the particle system is rendered with each particle being represented as a small quad with a
smoke-puff texture applied to it. With all of the particles moving independently, but with
the same rules applied to them, we can model a more complex system with a simple one.
The same concept applies to the other examples mentioned above, except that perhaps the
particle properties, the rendering attributes, and the update method would be changed to the
appropriate version for that type of particle system.
Particle systems have been used in computer graphics for a very long time. In the
past, they were implemented on the CPU and then simply rendered after each update.
However, with the parallel nature of the GPU and the very parallel nature of the updating
mechanism, the GPU is an ideal processor to perform the simulation. In addition, since
the simulation results are already residing in video memory, the rendering process doesn't
need to transfer it out of system memory, which results in faster rendering. The sample
program discussed in this section implements such a GPU-based particle system, while
taking advantage of some of the new features in Direct3D 11. This particle system provides
a specific implementation of a particular type of system, but it can easily be adapted to sup-
port other particle systems as well.
12.2.1 Theory
The particle system we will build in this section represents
a particle emitter and consumer, where the emitter creates
particles and the consumer destroys them when they get
too close to it. The system will be governed by a simple
gravity system based around the consumer. This could be
thought of as a simplified black hole, which exhibits a
large gravitational pull on each particle and will swallow
them up once they pass the event horizon. Before mov-
ing to the implementation of the particle system, we will
examine the basic laws of gravitation in order to imple-
ment our particle update method in a physically plausible
manner.
Newton's law of universal gravitation states that there is an attractive gravitational
force between two point masses, which is proportional to the product of the two masses,
and inversely proportional to the square of the distance between them. This relationship
is depicted in Figure 12.10, and is defined in Equation (12.6), where F is the gravitational
Figure 12.10. Two point masses
attracting one another, based
on Newton's law of universal
gravitation.
Search WWH ::




Custom Search