Show HN: BepuPhysics – 3D real-time physics simulation library in C#
github.com
github.com
Are there any other demos/games built with the library yet?
I did build it for a reason, though- over the coming weeks I'll be diving into actually making stuff with it. That'll be a nice change of pace.
(I remember early on sketching out the development plan for v2 and coming up with like 9 months of work... Things escalated.)
The library is .NET Standard 2.0 compliant, though, so in theory it should work. It may require some extra work on the runtime side of things. As time goes on, I'd hope that mono/CoreRT or whatever the AOT story ends up being/CoreCLR converge and Unity can embrace them for all their target platforms. (Burst is also an option, but that would require a massive rework in bepuphysics that I can't really afford to do given that my projects aren't on Unity.)
And then everything went open source, some fruits of Midori started getting rolled in, and a focus on performance appeared. Stack that on top of the fact that C# has some pretty darn good tools, and I was comfortable jumping in more deeply. Notably, I did not just start making bepuphysics v2 at that point. It's sort of the tip of the iceberg- bepuphysics v2 is C# because all the other private stuff I've built is C#, and it's nice to minimize the developmental and runtime overheads between projects when possible.
Also, do you have a performance comparison with other physics engines?
Regarding GPGPU, you're correct that bepuphysics v2 is strictly CPU-side, and also that I could likely make a GPGPU version faster. I wrote a blog post about why I chose to go with CPU-only: https://www.bepuentertainment.com/blog/2019/1/16/-but-gpus-a...
The short version is comparative advantage. I have other things to use the GPU on, and the GPU is even better at those things. And driver bugs.
Also, as I've mentioned elsewhere, while I have not done rigorous benchmarking, a casual evaluation showed that bepuphysics v2 on the CPU compares well with physX 4.1 running on a GPU of similar cost. Collision detection heavy scenes tend to favor GPU physX, while solver-heavy scenes tend to favor bepuphysics v2.
(Except for AMD's Threadripper CPUs unclear reasons. I suspect inter-CCX communication kills effective memory bandwidth in the solver. A 1700x is about as fast as a 2950x, and modern Intel cpus with full rate AVX2 can be much faster. Zen 2 should change things significantly.)
> if you want to run physics serverside, it’ll probably need to run on things that aren’t windows
On the other hand, you’re in control of hardware. For some kinds of projects, CUDA saves lots of time compared to DirectCompute or OpenCL: better libraries (these hand-optimized BLAS, FFT, etc.), better runtime i.e. simpler CPU-GPU interop, and better language, CUDA is relatively modern C++, with templates and constexpr. Unlike graphics, CUDA runs fine on Linux.
I’m not an expert in CUDA but I’ve completed a couple of projects where my clients needed to compute some GPGPU stuff on their servers, or on other people’s servers they’ve rented.
For my purposes, CUDA isn't really an option due to needing to run simulations on both servers and unknown clients (ideally with a single codebase), but for other services that never leave the datacenter I'd definitely consider it.
So not a big deal, just a notable quirk.
Unity is C#, no? I remember reading that they are moving most of the traditionally C++ 'backend' engine code to C# now, too.
Edit: Found the article: https://lucasmeijer.com/posts/cpp_unity/
The work in Unity's Burst/HPC# is very recent, though, and the CoreCLR/language features I rely on in bepuphysics are still pretty obscure. I wouldn't expect most people outside of the weird niche I live in to know about the ecosystem's progress.
In other words, I was just trying to get an unaware visitor to raise an eyebrow.