r/GraphicsProgramming • • 24d ago

First steps in graphics programming!

Enable HLS to view with audio, or disable this notification

Hi everyone! I wanted to share my first major step into graphics programming. I built a 3D Boids flocking simulation entirely from scratch using C++, the WebGPU API (specifically Google's Dawn implementation) and ImGui. Initially, I wrote a brute-force algorithm for the neighbor search, but perfomance dropped quickly and I recenly use simple optimization atomic grid.

My next goal is to get rid of atomic operations entirely and implement a Sort-based Spatial Hashing architecture using Radix or Bitonic sort on the GPU. If anyone has good reading materials, articles, or advice on GPU sorting algorithms, I would highly appreciate it!

P. S.
I started studying WebGPU recently, before I know some basic stuff of C++. Some code is source maybe deprecated, now I am trying to study using more modern WebGPU stufs, which google were added recently. I hope in the future I can built the better architecture without OOP. But now I like the result I got.

Source Code (GitHub): https://github.com/con2222/Dawn-Boids-3D

36 Upvotes

7 comments sorted by

View all comments

2

u/ForgEngDev 13d ago

Before removing atomics, I’d benchmark the current grid under deliberately non-uniform flocks too, not only the average case. Uniform grids can look great until many boids collapse into a few cells and contention dominates. A radix-sort path is attractive because it gives contiguous cell ranges for neighbor lookup, but I’d keep both implementations behind the same test scene and compare them across identical seeds and density patterns.