Hello everyone,
Following previous work on Flock Using Custom HLSL for VFX Graph, I am sharing an updated approach: a scalable 3D Hash Grid implementation. This iteration improves upon the concepts demonstrated in the prior 2D grid sample.
A short video demonstrating the 3D flocking simulation, featuring 131,072 boids ![]()
The sample project is hosted on GitHub and is compatible with Unity 6000.1.11f1 and newer versions. The README provides detailed setup instructions and a comprehensive technical overview of the GPU pipeline and its integration with VFX Graph.
Behind the scene, this system involves a C# component, HashGrid, which coordinates a series of compute shaders to build and maintain the 3D spatial grid entirely on the GPU. The spatialization on GPU uses a widely recognized technique described in Particle Simulation using CUDA by Simon Green.
Integration with VFXGraph relies on a Custom HLSL block, called within two update contexts. The GraphicsBuffers are bound to the VisualEffect Component by the HashGrid component mentioned previously.
This sample is designed as a practical reference for GPU-accelerated spatial partitioning, suitable for adaptation. It offers a foundation for developing advanced real-time simulation techniques. There are several candidates for performance improvement that we have not yet fully explored. More details can be found in the README.
Additionally, an actual embedded solution for VFXGraph for neighbor search is still on track, see Unity Roadmap.
I hope this new iteration sparks further ideas! Feel free to share your impressions or ask any questions you might have.
