# Reaction-Diffusion Simulation

This image illustrates the steps that I use to place a reaction-diffusion texture on a model.

Upper Left: The original polygon mesh.
Upper Right: Points randomly distributed over the mesh.
Middle Left: Points after they have repelled one another to form an even spacing.
Middle Right: Voronoi cells surrounding the points.
Lower Left: Chemical concentration after simulating reaction-diffusion.
Lower Right: Smooth version of chemical concentration by using a weighted average of nearby concentrations.

The basic idea is to first create a set of fairly similar-sized cells over the surface of the model. We do this by placing points randomly over the surface, one point for each cell. This random placement of points is not likely to give good cell placement. To fix this, we have each point push away all of the neighboring points. The result of this repulsion by each point is that the points spread themselves in a fairly even distribution over the surface of the model.

Next, we construct what are known as the Voronoi cells surrounding each point. The Voronoi cell for a given point is just the set of all the positions on the surface that are nearer to the given point than to any other points. The lines separating two neighboring Voronoi cells is exactly midway between the points in the center of each cell. These Voronoi cells are now used to simulate a reaction-diffusion system.

To simulate a reaction-diffusion system, each cell initially contains a random amount of two given chemicals. Then over time, the chemicals spread from one cell to its neighbors ("diffusion") by moving from cells that have a lot of the chemical to other cells that have a lower concentration. If diffusion were the only process going on, then eventually all the cells would end up with the same amount of each chemical. We also simulate reaction steps, however. These reaction processes can, for instance, cause high amounts of one chemical to break down the other chemical. Another reaction process might cause one of the chemicals to be produced if the other chemical is present in large enough quantities. Depending on the nature of the reaction processes and the rates of chemical diffusion, a variety of patterns of chemical concentration can be formed.

Once we have a stable variation of chemical concentration, we can use the amount of a given chemical to guide the color of the surface. In the above image, white means a high concentration of a certain chemical and blue means low chemical amounts. If we color each cell according only to the amount of chemical in that one cell, we get the blocky texture seen in the lower left. If we average together nearby colors, though, we get the smoother texture seen on the lower right.

Go to the Reaction-Diffusion Page.