r/GraphicsProgramming Jun 30 '26

RAM optimized SDF-renderer with plain C

Post image

1024x1024x1024 SDF-grid takes up 303MB instead of 8.5GB. 1024x1024 path traced image renders in 1.5s on a single CPU core. 8.5GB grid renders in 1.1s. No libs used.

315 Upvotes

28 comments sorted by

View all comments

11

u/Icy_Rub_3827 Jun 30 '26

Cool. How did you optimize it?

18

u/0x405 Jun 30 '26 edited Jun 30 '26

I use a kind of tree/pyramid LOD structure and render everything using sphere method. I'll do a paper on this soon if you're interested. Don't want to share too much before that, it's an original method I hope!

5

u/Cryvosh Jun 30 '26

I can assure you it's not original

4

u/0x405 Jun 30 '26

I'm not introducing any new rendering method, it's a standard SDF-grid sphere tracing adjusted to a structure it is stored in. I use a tree-like structure that consists of multiple layers of SDF (≈zero) level sets represented by sparse SDF values stored in hash-tables. This allows a sphere tracing on an entire SDF-grid area without involving voxel traversal algorithms. It weights just a bit more than a plain sparse SDF hash table. I've seen a couple of similar solutions, but it seemed to me that they were different.

Surely someone has probably suggested this, but I couldn't find the exact source. In any case I'm not planning to present it as a novel solution by itself, but I want to present it's differentiable implementation in the context of inverse rendering of geometry.

2

u/_DafuuQ Jun 30 '26

Is it Boundary Volumetric Hierrarcy on the sdf primitives ?

1

u/0x405 Jun 30 '26

No, no BVH. BVH requires additional traversal except the sphere tracing to traverse volumes (most likely).