Life

aabouche

Computing States

Pixels can play Conways game of life on the GPU. Each pixel represents a cell and each cell is either alive or dead. The cell's state can be stored in it's color channels. I have chosen the green channel to represent alive (g=1) or dead(g=0). Since there are other channels (r,b,a) you can easily make more states for the cells. In dead cells (g=0), I used the red channel to represent death from overpopulation and the blue channel to represent death from loneliness. In live cells (g=1), I arbitrarily set the red channel to 1 if the cell had three neighbors.

The states can be stored in a framebuffer. Live cells can be drawn onto the framebuffer (with g=1) and this can be saved as a texture. Then a computation shader can be applied to the shader to find the next state of each cell (pixel).

In 3D

Given a geometric primitive you can draw several instances of it to represent each cell. Based on the shape's id you can use a shader to make the shape take on the state and location of a cell (pixel) in the framebuffer containing the states. Within the shader I mapped the states to different colors and different z-values (they fall away as they die). Using another framebuffer I kept the 3d scene as a texture and added a small blur.