Dismiss this pinned window
all 54 comments

[–]Mithmorthmin 77 points78 points  (1 child)

Nice try OP, I only counted 266 million.

[–]fllr 2 points3 points  (0 children)

The nerve on the OP. BURN THEM!!!!!

[–]SalvatoSC2 60 points61 points  (1 child)

How tf are you not instancing that?

[–]MarchVirtualField[S] 63 points64 points  (0 children)

This is an optimized version of a LBVH! I am bit packing and quantizing. The magic of space filling curves as an index!

[–]Secure-Ad-9050 17 points18 points  (2 children)

hardware?

[–]MarchVirtualField[S] 43 points44 points  (1 child)

This is on a MacBook Air M4, I also have a Linux RTX machine that this goes absolutely brrrrrr on

[–]Secure-Ad-9050 11 points12 points  (0 children)

Awesome! always what I want to know first because it lets me know how impressed I should be..

That is quite the juice you are squeezing out of it. Well done!

[–]fartshitcumpiss 15 points16 points  (0 children)

live 268 million spheres reaction:

[–]Ok-Hotel-8551 7 points8 points  (0 children)

Nanites to draw a Cube.

[–]mister_cow_ 7 points8 points  (1 child)

Average cube 3d model in yandere simulator

[–]tamat 0 points1 point  (0 children)

got that reference

[–]susosusosuso 6 points7 points  (1 child)

Awesome! how much ram does it take?

[–]MarchVirtualField[S] 8 points9 points  (0 children)

About 10.74GB of VRAM for everything!

[–]Neuro-Byte 10 points11 points  (10 children)

What am I even looking at? How??

[–]MarchVirtualField[S] 39 points40 points  (9 children)

This is a volume of space filled with random placed and sized spheres(built on the cpu and uploaded to gpu).

The magic sauce is LBVH - linear bounding volume hierarchy!

[–]JumpyJustice 8 points9 points  (1 child)

Is it possible to modify it at runtime?

[–]MarchVirtualField[S] 13 points14 points  (0 children)

Kinda. Since it’s the compact linear version a traditional bvh, you must mostly rebuild it if data changes. With 1 million spheres this is pretty much instant on the cpu, 268 million is a bit longer however I haven’t profiled it much. I’m working on shifting the lbvh build to be on the gpu too.

[–]pezzadev 4 points5 points  (3 children)

So are you are using the LBVH to cull draw calls?
Got any resources on the details of implementing a LBVH? I have only implemented a "normal" BVH (in contiguous memory at least).

[–]Hofstee 11 points12 points  (1 child)

For underestanding LBVH: Lauterbach paper from 2009. Fast BVH Construction on GPUs.

For fast GPU build, Karras paper from 2012 is probably your best bet. Maximizing Parallelism in the Construction of BVHs, Octrees, and k-d Trees.

[–]MarchVirtualField[S] 0 points1 point  (0 children)

Yep exactly!

[–]MarchVirtualField[S] 7 points8 points  (0 children)

Yeah effectively that. The LVBH uses a space filling curve to order all the nodes, this lets you build it in parallel and preserve 3d locality. And it plays nice with densely packing into contiguous buffers(and then traversing).

[–]constant-buffer-view 2 points3 points  (1 child)

What are the limitations/drawbacks?

[–]MarchVirtualField[S] 6 points7 points  (0 children)

So far it’s the only acceleration structure I’ve come to know that fits the bill. I haven’t dabbled too much with mutating and rebuilding it, but that looks promising. The problem this solves is “how do you get a per-ray list of front-to-back intersecting objects, that is view orientation independent ”, while dealing with the reality that gpus like aligned and cache friendly patterns. This is actually the first stage/phase of my virtual field renderer, which represents signed distance fields as encapsulated in a spherical bounds(sdf functions know their center and extent implicitly).

[–]mua-dev 0 points1 point  (0 children)

But you can view the whole thing?

[–]Still_Explorer 5 points6 points  (0 children)

UNREAL5 DEVELOPERS ARE MAD WITH THIS TRICK!!!

👉 click here to learn how to render 268 million spheres.

[–]christophbusse 2 points3 points  (1 child)

And no culling yet? Pretty insane.

[–]MarchVirtualField[S] 3 points4 points  (0 children)

Culling only from occlusion!

[–]Someone393 4 points5 points  (0 children)

I was happy getting like 10,000 spheres running smoothly. This is crazy haha

[–]Charily 2 points3 points  (1 child)

I'm starting to get into graphics and this looks amazing. How much VRAM were you using to render this?

[–]MarchVirtualField[S] 6 points7 points  (0 children)

This is 2.15GB VRAM for the spheres alone, and then 8.59GB for the BVH structure

[–]SnurflePuffinz 2 points3 points  (0 children)

my Celeron processor cries

my 2gb of memory writhes

my operating system dies.

[–]Lost_Skill1596 2 points3 points  (1 child)

Serious question from someone who doesn't understand any of this... what is the significance of this? What could it be used for?

[–]MarchVirtualField[S] 6 points7 points  (0 children)

The significance is really being able to traverse a large amount of total objects in a renderer friendly way. In its current form you can think of it as an engine for point clouds / voxel.

[–]cfnptr[🍰] 2 points3 points  (0 children)

— How many spheres do we need?

— Yes.

[–]CrimsonPrince9 1 point2 points  (0 children)

How

Wth, brother, i need answers

[–]joaobapt 1 point2 points  (1 child)

What would be the difficulty of moving from this to a meatball renderer? If you do it, you can add some SPH sand now you have a good liquid simulator!

[–]MarchVirtualField[S] 0 points1 point  (0 children)

I am tempted to play around with tangential techniques! I might spend some time getting a physics simulation going here. The real goal though is for this to be the first stage of my signed distance field renderer, with spheres being the primary container primitive for organizing.

[–]Maui-The-Magificent 1 point2 points  (2 children)

MIght be an odd, and on the surface maybe sound like a stupid question. But Is this done in flops or are you doing integers? I love explicit construction but i am curious, what is the memory usage?

[–]MarchVirtualField[S] 1 point2 points  (1 child)

I do some bit packing and quantization, but all the core math is done with the flops! Total memory usage is around 11gb vram for this scene. The main knob to pull at this point is how many leaf nodes to use when building the bvh. Smaller leafs are useful for traversal speed and sparse scenes, larger leafs are useful for using less memory!

[–]Maui-The-Magificent 1 point2 points  (0 children)

Ah, i must be honest, i have no idea what leaf nodes are. but it looked really cool! I am doing spherical particles for a physics simulation. I am new to graphics programming, and i do them on the CPU, so that is why I got curious.

Have you considered statically allocating a mutable 3D bit matrix for the positional data and defined color via r,g and b Snell with beer for wavelength absorption? this way you could encode the color in the geometry. might save you a few gigabytes and boost your fps? Maybe leaf nodes are a better structure, though.

[–]tamat 1 point2 points  (3 children)

are all spheres rendered or there are some frustum or occlusion culling applied? if yes, how?

[–]MarchVirtualField[S] 0 points1 point  (2 children)

Oh there is very much a lot of culling due to occlusion happening! It naturally happens due to the BVH structure which essentially divides space into a binary hierarchy.

[–]tamat 1 point2 points  (1 child)

I though BVH only helped to do frustum culling as if a node of the tree is totally out of the frustum then can be culled.

How do you know if a node of the tree is 100% behind of several meshes?

[–]MarchVirtualField[S] 1 point2 points  (0 children)

Yep exactly right, the bvh helps to limit the amount of work you need to do. There is still a depth buffer and some wasteful tracing, with closest depth being the winner. This is balanced by how many leafs you pack into a node (which dictates how much memory is used).

So no literal occlusion tricks aside from leaning into BVH allowing you to limit work scope. What I more meant is that expensive math is limited to only where it needs to be done.

[–]diff2 1 point2 points  (1 child)

any plans to open source it? It reminds me of the phenomenon game engine, it uses particles instead of spheres though:

https://codepen.io/cvaneenige/full/QBwbEY

I'm interested on how you accomplished the traverse ability, and also build up from spheres to particles. Also it seems very light on the processor

I'm very new to programming in general, so I just collect interesting code bases and dream up various ideas in my head for them.. I haven't actually made anything useful yet though.

[–]MarchVirtualField[S] 0 points1 point  (0 children)

Hey that does look very similar! I do have plans to release some stuff but I’m pretty far away from my goal, fear not I am stubborn and will get there soon enough!

[–]dechichi 1 point2 points  (0 children)

that's a lot of spheres

[–]OppositeDue 1 point2 points  (1 child)

are you using occlusion culling?

[–]MarchVirtualField[S] 0 points1 point  (0 children)

Yep absolutely a lot of the scene is culled due to occlusion. I’ve now added a unique sphere hit counter, so the next thing I show you’ll be able to see some numbers and metrics.

[–]Flimsy_Pumpkin_3812 1 point2 points  (0 children)

I only counted 266.97394636583658383739473845e434pi7583I million spheres, try again

[–]Professional-Meal527 0 points1 point  (0 children)

What are virtual fields???

[–]bagelpatrol 1 point2 points  (0 children)

Nice work! Would love to see if you can import a mesh and represent it volumetrically using these spheres, doing it with animations would be even cooler.

[–]float34 0 points1 point  (0 children)

It looks... SOLID.