danielshervheim / unity-flocking

CPU and GPU implementations of Craig Reynold's boids in Unity.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Flocking in Unity

A Unity implementation of Craig Reynold's boids.

gif

20,000 boids simulated entirely on the GPU, running at 60 fps (watch on Youtube).

About

Includes CPU and GPU implementations.

Both are naïve O(N2) implementations. The CPU version can handle about 150 boids at 60 fps, while the GPU version can handle about 20,000. (As tested on a Ryzen 5, Nvidia GTX 1060 machine. Your mileage may vary).

The GPU version requires a graphics card that supports Compute shaders and GPU instancing in Unity.

The CPU version includes a script to visualize some of the parameters of the boids. (Nearest neighbors, forces, and path over time).

To-do

  • Implement vertex animations for swimming fish and flying birds.
  • Improve performance with some kind of spatial data structure.
  • Add environmental awareness / obstacle avoidance.

About

CPU and GPU implementations of Craig Reynold's boids in Unity.

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:C# 73.6%Language:HLSL 16.0%Language:ShaderLab 10.4%