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.

Examples

  1. Unstable

  2. Coral

  3. Baceria

Usage

You may simply run python main.py 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:

1
python main.py -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:

当前网速较慢或者你使用的浏览器不支持博客特定功能,请尝试刷新或换用Chrome、Firefox等现代浏览器