# How to Delete Instances based on Proximity in Geometry Nodes?

How do I set up the nodes so that all of the overlapping instances are deleted? Or to put it another way, how do I delete an instance based on its proximity to another object?

PROJECT FILE

• Changing from Random to Poisson Disk on the Distribute Points on Faces node doesn't work? Nov 29, 2022 at 21:08
• I think that the system cannot determine the closeness of instances, try Realise Instance first Nov 29, 2022 at 21:13
• @LuizAntonio it works better but there are still overlapping geometries Nov 29, 2022 at 21:23
• @3pointedit I watched a tutorial where someone was able to do this using the Geometry Proximity node, but I can't remember which tut it was and I can't get that node to work in my favor. Hoping someone here can enlighten me ;) Nov 29, 2022 at 21:24

First, if you're spawning random points to spawn spheres on them, just use Poisson Disk distribution and specify the minimum distance as the diameter (two radiuses) of the sphere:

If the instances were already given to you you could use an approach like here:

How to use random cylinders inside a cube with geometric nodes?

You would need to realize instances first, and then you could decide if you want to remove only one instance of two overlapping instances, or both (e.g. if you're animating soap bubbles that are supposed to pop and disappear when they touch each-other) – in the former case you would only remove an instance if the ray hits something with a lower index. In both cases, however, as I pointed in that answer, you run into a problem that more than 2 spheres can overlap - in such case you could just put the setup into a custom node and repeat it a few times – repeating 10 times would be probably very reliable.

However, if you are given points, on which to instance, then you shouldn't instance to then remove instances. Instead use something similar like my quadratic sort, that is, create a copy of all points for each point, to e.g. find for each point the nearest other point that has a higher index, and then remove all points where some point with distance < 2 radiuses was found.

• Thank you for this. Poisson disc doesn't work because my objects are pill shaped and I want some of them to be closer together than the distance diameter allows. The cylinders solution would probably work for what I'm doing but it seems a bit convoluted. I did see a tutorial around the time 3.1 was released where this guy was scattering noise generated rocks on a landscape, and using some kind of proximity node setup to delete overlapping rocks. I tried recreating it from memory but I can't figure it out. Dec 2, 2022 at 5:00
• @GlenCandle Hmm, you used spheres in the question, so I assumed that… For pills I actually see a solution: figure out where the 2 points defining a pill are (e.g. based on instance rotation and instance origin), then check proximity of those points to the realized geometry - if you find something closer than the "pill radius", you have an overlap. You need some safety margin to not detect "self" as overlap. Then for each original point you can sample those two "pill ends" points if any has a captured overlap=True attribute, if so, don't spawn a pill on that point. Dec 2, 2022 at 11:23
• Thanks @MarkusvonBroady, that is interesting and I will try it. Apologies for the confusion, my "pill" shape is actually a candy product for a client, and my question was more or less a general 'how to deal with overlap' and not particularly 'how to deal with it in these shown icospheres.' I totally get how confusing that is, and again I apologize and I really appreciate your help ;) Dec 2, 2022 at 18:38