Graphics Reference
In-Depth Information
Particle System with Point Sprites
The next example we cover is rendering a particle explosion using point
sprites. This example demonstrates how to animate a particle in a vertex
shader and how to render particles using point sprites. The example we
cover is the sample program in Chapter_14/ParticleSystem , the results
of which are pictured in Figure 14-3.
Figure 14-3
Particle System Sample
Particle System Setup
Before diving into the code for this example, it's helpful to cover at a high
level the approach this sample uses. One of the goals here is to show how
to render a particle explosion without having any dynamic vertex data
modified by the CPU. That is, with the exception of uniform variables,
there are no changes to any of the vertex data as the explosion animates.
To accomplish this goal, a number of inputs are fed into the shaders.
At initialization time, the program initializes the following values in a
vertex array, one for each particle, based on a random value:
Lifetime —The lifetime of a particle in seconds.
Start position —The start position of a particle in the explosion.
End position —The final position of a particle in the explosion (the
particles are animated by linearly interpolating between the start and
end position).
 
 
 
Search WWH ::




Custom Search