Reaction-Diffusion simulation with pyglet and glsl

This project is motivated by pmneila's javascript project. The core part of the code are the two GLSL shaders reaction.frag and render.frag. The python scripts are merely for setting the UI and compiling the GLSL code.

Requirements: pyglet for the UI and OpenGL environment and ffmpeg for saving the animation to video files.


  1. Unstable

  2. Coral

  3. Baceria


You may simply run python and then use keyboard and mouse to play with the simulation (for keyboard and mouse control please see the printed doc).

You may also initialize the window by passing more options:

python -size 800x600 -fps 400 -conf 1 -scale 2

Here -size is the size of the window, -fps is the frames per second of the animation, if not specified then max possible value will be used, -conf is the line number of the pattern that the program will load from the file config.txt (which contains a few precomputed patterns), -scale is the "resolution" factor of the texture.

You may also use an image file to control the growth of the pattern by adding the -mask option: