Fill object with Random Box packing in Geometry Nodes?

Hi Everyone - I’m trying to create a node setup in Geometry nodes that will allow me to fill/pack a base object like ‘Suzanne’ with boxes like the examples below:

enter image description here

I’ve managed to somewhat get the effect via distributing points within a mesh volume but it ends up looking more like a minecraft model than the more randomised, hand-stacked look I’m hoping to achieve…

I’ve seen some examples in other software where this effect is achieved using packing algorithms and physics simulations so I’m wondering if there’s something similar I could do in Blender or maybe workaround methods for shuffling up the grid?

enter image description here

Would also be great to be able to control things like random rotation for the boxes and the gap size/density between them if possible

any help would be greatly appreciated, thank you!

Random Boxes.blend (1.3 MB)

There are different way you can approach this but it’s always a bit challenging…

First you can look into the accumulate field node :

you can also look for tutorials for uneven sized brick wall :

When I searched this a while ago I found that it’s harder to pack in 3 dimensions, 2D is much easier. Therefore you can always put together different slices of 2D packed stuff and that works ok to give a 3D packed feel.

you can see how it looked like there :

I’m sure now this could be done much simpler since there is are bunch of new tools that can help.

Another approach can be based on the UV packing algorithm :


This is obviously a starting point that you need to tweak further…

Another approach is to make tiny boxes and grow them randomly step by step, and stop them once they touch another one…

As for the rigid body simulation, this can give you another kind of results but geo nodes doesn’t comes with a dedicated solution for that actually.

Finally I’d first try to do a cube of packed stuff of the size of your target object and eventually remove everything that is outside of it so it take the shape of the final object.

Anyway, that’s just random thoughts to get the brain started. Since coming up with a fully working solution probably involves hours of trial and errors you’ll probably have to walk that road on your own.

Have fun !

4 Likes

A related post :

1 Like

Thanks for the amazing response!

That’s definitely given me a lot of food for thought so really appreciate that, the accumulate fields option is seeming like the best approach so far.

I’m thinking I could combine that with a Raycast node to achieve a sort of ‘Shrinkwrap’ version of packing that would essentially morph the randomly packed stacks of boxes onto my object shape (See below):

The main issue with this method is that I can’t seem to find a way to create unique fields when I instance them… so my stacks just end up being identical and straight when raycasted, any ideas?

Random Boxes.blend (3.0 MB)

1 Like