Viral
A performant cell simulation I implemented using compute shaders in raylib.
Written in 2025
About
Viral is a cell simulation. Each cell does different things and has different interactions with each other. Each cell does different things. For example, when a red cell(virus) touches a pink cell(normal cell), the virus kills the normal cell and duplicates itself. Or another interaction is when a blue cell(antibiotic) touches a red cell(virus), the antibiotic kills the virus.
Game Image

Controls
- Left Click - Place cell
- Line Button - Spawn cells whenever you move you mouse. Useful, for creating organized structures of cells
- Random Button - Randomly Spawns The Selected Cell Across The Screen
- Clear Button - Clears all Cells
- Static Button - Makes the next cells you spawn static. Static cells do not move. Click the button to toggle it off
- + Button - Increases the speed of the simulation
- - Button - Decreases the speed of the simulation
- Q Key - Lowers the size of the simulation borders
- E Key - Increases the size of the simulation borders
- Scroll Wheel - Zoom in
- WASD - Pan Around
- Bottom Color Buttons - Select the cell you want to spawn
Download
Warning in order to run the exe, ignore the security message. I just don't want to deal with the hassle of signing the exe.
Download Windows Exe FileOptimization
Viral is able to handle around 25,000 cells at 60 fps. To make Viral so fast, Viral takes advantage of compute shaders. Compute shaders are a way to run code on the GPU. Compute shaders are extremely useful for this task because they can simulate cell movement logic in parallel, while a cpu would have to waste time iterating over each cell. Another major optimization is Viral is chunking. Chunking is a way to group cells together. When checking for collisions between cells, you would think you need to check every cell against every other cell. But with chunking you only need to check cells in the same chunk.