Dynamic Grid system without Overlap

hello all, i am trying to create a dynamic grid system with boxes of different sizes based on instancing. I am this far now and stuck at trying to make the cells not overlap with each other. the random size is driven from the noise that is quantised and then multiplied by the respective box width and height. The cells that overlap should either be scaled down to zero or be set inactive in the instance Geo or be displaced along the x or y axis, I just want there to be no overlap.

I have tried so far working with the displace TOP to offset the r and g values according to the scale noise, to no success, and also tried some glsl with the help of chatGPT to check if a pixel’s neighbouring red/green value is 1 or bigger than 1, and if it’s bigger, to set the current pixel’s red/green to 0, so that the instance that is right of or below a bigger instance would be scaled to 0, but that did not work out, mainly because i am not really fluent in glsl and can’t adjust the script.

Has anyone got any other ideas or can help me with my suggested methods? Have you done something like this successfully? Glad about ideas inside and outside the box :slightly_smiling_face:

(I also tried it with widgets, but I think performance wise that’s not really possible to then also animate the grid, and also would probably generate a much more convoluted network and be generally harder to animate)

I think you probably need a fitting network / algorithm to help here. Even if you got your GLSL to test and move your instances, you need a looping system to keep moving everything until they’re non-overlapping. If you haven’t seen @paketa12 's youtube, they’ve got a nice set of techniques for doing collision / intersection detection in TOPs.

I’d take a look at this example for sure:

I think you could adapt some of the ideas here to get your rectangles to not overlap.

Thank you Matthew, haven’t thought about that! I will for sure check it out and report back when I find a way.