September 20th, 2024

Mitosis in the Gray-Scott model: writing shader-based chemical simulations

The article explains the Gray-Scott model of reaction-diffusion systems, highlighting GPU advantages for simulations, introducing shader-based programming with GLSL ES, and encouraging experimentation to observe complex emergent patterns.

Read original articleLink Icon
Mitosis in the Gray-Scott model: writing shader-based chemical simulations

The article discusses the Gray-Scott model of reaction-diffusion systems, which illustrates how simple chemical reactions can lead to complex patterns through simulation. It emphasizes the importance of using GPUs for these simulations due to their ability to perform parallel computations efficiently, as opposed to CPUs, which would be too slow. The author provides a beginner-friendly introduction to writing shader-based simulations using GLSL ES, specifically focusing on the Gray-Scott model. This model involves two chemical species, A and B, undergoing an auto-catalytic reaction, with diffusion playing a crucial role in the emergence of patterns. The article outlines the basic principles of chemical reactions, diffusion, and the specific characteristics of the Gray-Scott model, including the feed and kill rates that influence the system's dynamics. It also explains the concept of shaders, which are programs that run on GPUs to render graphics, and how they can be utilized to simulate the Gray-Scott model effectively. The author encourages experimentation with the simulation to observe emergent behaviors and patterns, highlighting the potential for complex visualizations in scientific programming.

- The Gray-Scott model demonstrates how simple chemical reactions can create complex patterns.

- GPUs are preferred for running simulations due to their parallel processing capabilities.

- The article serves as an introduction to writing shader-based simulations using GLSL ES.

- Key concepts include chemical reactions, diffusion, and auto-catalytic reactions.

- The simulation allows for interactive experimentation to observe emergent behaviors.

Link Icon 4 comments
By @pcouy - 4 months
Hey! I'm the author of this article and just noticed the huge traffic spike.

This was my first time writing a shader. I was just playing around on shadertoy when I realized I could implement this chemical model that has fascinated me for quite some time. I'm really happy with how well my results align with results from other people who have done this before me.

While writing the article, I noticed that the same kind of shader implementation has already been done before.

Feel free to ask me anything about the implementation or the chemical model

By @Slackermanz - 4 months
I also used a GPU shader-based approach (custom vulkan engine), but used a cellular-automata-first implementation for exploring and evolving through these emergent wonderlands.

Unfortunately, my writeup isn't anywhere near as coherent on the technical/engine details, and the actual code is a right mess. It's more focused on the pattern family design.

Overall, my results came out very similar to Lenia in many ways, and some discovered patterns also directly resemble reaction diffusion.

---

https://slackermanz.com/understanding-multiple-neighborhood-...

https://www.shadertoy.com/user/SlackermanzCA

https://www.youtube.com/@Slackermanz/videos

By @danwills - 4 months
If you're into reaction-diffusion there's an open source app called 'Ready' which I think is a great way to explore example patterns or tinker with formulas:

https://github.com/GollyGang/ready

Some fun ones from me can be found in Patterns/Experiments/DanWills

By @zokier - 4 months
I wish there would be more about how to connect this to actual chemistry and less about generating random pretty pictures