Graphics Reference
In-Depth Information
To accommodate this simulation, we need to maintain two pieces of information for
each column of fluid. We need the height of each column, as well as the current flow in each
virtual pipe. The height value is the property that we will be using to render the results of
our simulation, and the flow values are needed to maintain the inertia of the system from
time step to time step. This allows for disturbances in the fluid level to be propagated from
one side of the simulation field to another and then be reflected back again.
12.1.2 Implementation Design
With a clear understanding of the theory behind this algorithm, we can explore how to use
the tools that are available Direct3D 11 to implement the simulation and render the results.
The update phase of the simulation is performed first, and will be executed in the compute
shader. This will allow the use of some of the special capabilities of the compute shader,
including data sharing and thread synchronization.
Resource Selection
As we have seen in the section on theory, we are interested in maintaining the status of the
simulation as a series of height values. Since the simulation is composed of a grid of fluid
columns, this height data can naturally be mapped onto a 2D texture resource with a single
floating-point component. It is also necessary to maintain a record of the current flow val-
ues into and out of each of the water columns. Since there eight different neighbors that
can interact with a fluid column, it would seem that we would require two four-component
Figure 12.3. The bidirectional flow values managed for each fluid column.
Search WWH ::




Custom Search