Graphics Reference
In-Depth Information
12
Simulations
As seen in Chapter 10, "Image Processing," the compute shader can be used to implement
new types of algorithms on the GPU in a very intuitive way. However, these new algo-
rithms are certainly not limited to the image processing domain. Many different algorithms
lend themselves to being executed on a massively parallel architecture, and this chapter
aims to introduce several such applications. In general, as the GPU has continued to be-
come more powerful, there has been a general trend to move more of the workload off of
the CPU and onto the GPU. With this trend comes the guideline to minimize the interaction
needed between the CPU and GPU during any given frame. These sample programs were
designed with this concept in mind—minimal input is required by the CPU to both execute
a simulation and to render it.
The first sample algorithm implements a fluid surface simulation technique. In partic-
ular, water simulation has become a very important topic in real-time rendering. Providing
a fluid simulation that reacts to its environment in a realistic manner is becoming more and
more desirable. This sample demonstrates how to use the compute shader to dynamically
update the state of a 2D grid of fluid columns. This approximation provides convincing
results, while still maintaining a data structure that can take advantage of the new features
available in the compute shader.
The second sample algorithm demonstrates one of the oldest effects in computer
graphics—a particle system. Even though the concept has been around for a long time,
there are some new tricks to be applied to the old problem. This particle system is imple-
mented entirely on the GPU and only interacts with the CPU through parameters pro-
vided to the system in constant buffers. This sample simulates how particles would behave
around a black hole. While the physics are not calculated to scale, they provide a convinc-
ing effect, and demonstrate the general concept of a particle system that can be used as the
basis for other types of simulations as well.
543
Search WWH ::




Custom Search