ZOYKU火线榜

jtsorlinis/boidsunity技术文档

jtsorlinis/boidsunity documentation on GitHub Hot

目录大纲 (TOC) (1 章节)▾
多语言回退提示:当前仓库原作者暂未发布本地化文档,已为您无缝切换至官方英文原版(English),排版及代码实例完整保真。
极速安装
git clone https://github.com/jtsorlinis/boidsunity.git

2D/3D Boids Flocking Simulation (CPU/GPU)

See it in action here: Boids

Native builds of the latest commit: Windows · macOS · Linux (the macOS app isn't notarized, so allow it under System Settings > Privacy & Security on first launch)


I wanted to learn about GPGPU and Compute shaders so ended up making a boid flocking simulation in unity.

I first made it in 2D on the CPU, then using Burst/Jobs, and eventually moved everything to the GPU, which brought an insane performance increase.

The simulation uses a uniform spatial grid as an acceleration structure to determine nearest neighbours, as brute force method would cap out at around 50k entities even on GPU.

Method used is inspired by this presentation: https://on-demand.gputechconf.com/gtc/2014/presentations/S4117-fast-fixed-radius-nearest-neighbor-gpu.pdf

3D: 16,776,960 boids on the GPU

2D: 67,107,840 boids on the GPU

文档镜像归档自 GitHub 官方源路径 · 访问原项目 GitHub
最后同步快照:2026-11-11