The shader that I implemented is based on the cellular automata framework,
similar to the game of life, in which each pixel changes state based on
the states of its 4 nearest neighbors.
In my particular cellular automata simulation, the cells can transition
between two discrete states, 0 and 1.
![]() |
| Figure 1: The neighbor relationships necessary for state transition. Cells in state 1 are shown in White, while cells in state 0 are shown in Gray. The center cell, marked with a ? will transition to state 1 in these situations. |
The effect of this rule is to produce a pattern similar to a snowflake.
We see channels of lit up cells running through the material, separated
by channels of unlit cells.
![]() |
| Image 1: The pattern produced by the simple cellular automata rules. Because the texture wraps around at the edges, this simulation has reached an equilibrium in this state. |
![]() |
| Image 2: The pattern produced using the transition rule with a noise texture to determine the probability of transitions taking places. |
![]() |
| Image 3: The pattern produced using the transition rule with a noise texture and fading. The center part of the texture shows pixels that were turned on early in the simulation, and so have almost faded back to the zero state over time. |
I used two methods for rendering the results of my cellular automata
simulation. All of them use a texture map to display the data on a square.
To better visualize the results I use a view port, and rendered square,
that is larger than the resolution of the actual simulation data. Thus
a single cell is drawn over several pixels with linear filtering.
![]() |
| Image 4: A rendering of the simulation state using the additive blending technique described above. |
Complete source code for my shader project has also been provided. The
source code is intended as an example of my work not as a working demo.
It may contain references to external modules not included in the
.zip file.
<source code>
| struct v2f : vertex2fragment
{ half4 hPosition : HPOS; half4 texCoord : TEX0; half4 texCoord1 : TEX1; }; fragout main(v2f IN,
// input from vertex program
// Setup the texture
coordinate pairs and sample the center and its 4 nearest
half4 neighborStates;
// top neighbor
// right neighbor
// bottom neighbor
// set the default
result to be the same as the input.
// state transition
|
| Figure 2: The source code for my cellular automata fragment program.. |
![]() |
![]() |
| Video 1: The evolution of the symmetric pattern
shown above. This was produced using the transition rules, without the
use of any randomness, or fade away.
<mpeg video 2.0MB> |
Video 2: The pattern producedby the transition
rules using a constant 0.7 probability for all transitions. The effect
of the randomness is to break up the symmetry of evolution.
<mpeg video 1.1MB> |
![]() |
![]() |
| Video 3: A simulation that uses both probabilistic
transition and fade away. The fade away parameter is set very low, 0.01
units per frame, so the simulation runs out of empty space and dies out.
This was rendered using the additive blending technique.
<mpeg video 2.7MB> |
Video 4: A simulation using both probabilistic
transition and fade away. The fade away speed was increased to 0.1 units
per frame, so that the front can evolve forever by continuously moving
into areas vacated by faded cells.
<mpeg video 2.3MB> |
![]() |
|
| Video 4: A simulation using both probabilistic transition
and fade away. The fade away speed was increased even further, to 0.2 units
per frame, and the probability of transitions was lowered to 0.6. This
makes the simulation difficult to maintain as the front may die out if
not enough transitions occur. The result is a much sparser set of trails.
<mpeg video 4.7MB> |
|