Comment

Comment by jesse__

I've been working on a voxel game engine called Bonsai for ~10 years.

Probably the most interesting thing about it at the moment is the editor. The world, and most things in it, are represented as collections of SDFs. More accurately, they're density fields, but, potato-tomato. The world generator and editor operate almost entirely on the GPU. I've been writing a graph compiler similar in spirit to compilers that execute LLMs, with some key differences. The SDF 'program' gets jitted into a kind of bytecode and fed through an interpreter in the world gen shader. This way, the world gen and edits can be applied deterministically using one big fused program, and transferred back to CPU land using the async PCIe hardware. I get something on the order of ~99% ALU residency, 95% L2 hit rate and 20-40% vram bandwidth usage.

Compared to doing world gen on the CPU, it's so fast it feels like magic. It's taken me the better part of two years to get this working well.

One neat thing about representing the world as SDFs is they've been thoroughly researched and documented by a guy named Inigo Quilez, and they have a lot of nice mathematical properties. For example, you can do a smooth union of arbitrary SDFs to get nice rounded contours where shapes join.

I'll do some shameless self-promotion and leave some links here for anyone interested in looking at the engine, language code, or some pretty pictures.

https://github.com/scallyw4g/bonsai

https://github.com/scallyw4g/poof

parent jesse__ 14 hours ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton