Compute Shaders and Emergent Algorithms

A few months ago a tweet caught my eye. A guy named @arsiliath was offering a course described as an "advanced workshop [that] introduces compute shaders via a series of video tutorials related to biological & physical simulation." I got on the waiting list for the next session, and got in for the April 2021 workshop. 

(Update Dec 2021: Arsiliath no longer offers this as a live class, but has moved all the materials into a package on Gumroad you can do at your own pace. I've updated the link above to point there.)

It was challenging but the people, content, and coursework were quality. Below is a collection of videos that I produced throughout the course. 

The first bit was on an algorithm called CCA, or Cyclic Cellular Automata

The next week we covered more traditional Cellular Automata as might be seen in Stephen Wolfram's book A New Kind of Science

And here is a project with agents who move about by following trails left behind by the others, similar to ants. This is called Stigmergy. It's also been recognized as a way slime molds propagate, as presented by Professor Jeff Jones

Next up was the classic Boids flocking algorithm, but we could really push the numbers like in the prior stigmergy example. 

All of these prior examples had the compute shader outputting a texture which was then put on a plane in Unity. Next, we dove into the fastest geometry instancing method in Unity, DrawMeshInstancedIndirect. The first thing we did with this was to make a boatload of cubes and then drive them with one of the prior projects. This one below is driven with the CCA algorithm. 

And now that we've gotten familiar with drawing hundreds of thousands of cubes in 3D space, we adapted the boids routine to 3D. This required some ingenuity as the course did not spell it out explicitly. The trickiest part was using a 3D texture to store positions and velocities, and then using that for neighbor finding. This was basically the final test.

Once the course was over, I went back to see if I could implement Conway's Game of Life on my own, and it went pretty smoothly.

Comments

Hi, I'm Ben Throop


This is my personal site about game development and emergent behavior. You can learn more about me here.