Fragments and Metaballs

john's Avatar


22 Mar, 2022 08:44 AM

Attached is a demo for a revised node, Fragments, and a new node, Metaballs.

Fragments takes a list of overlapping shapes and returns the fragments arising from the spaces between those shapes. The classic use case is a Venn Diagram where the overlapping spaces form regions showing each possible combination of three variables. Although the human eye perceives those spaces as distinct shapes, Nodebox does not - unless you feed the three rings into a Fragments node. (They have to be rings, not circles or open paths, because Fragments requires a list of closed shapes that create interior spaces.)

Metaballs are, in a sense, the opposite of fragments. Metaballs are the distinct shapes - or clumps - formed by the union of overlapping shapes. Metaballs are surprisingly useful. When animated they can create a sense of smoothly flowing water or mercury beading into odd shaped drops. More generally they allow you to form complex shapes by melding simpler ones. I learned about metaballs from a Nodebox user - see the fascinating discussion here:

After that discussion I modified my Fragments node and tried to make it serve both purposes. But the more I used it the more I realized that it wasn't working terribly well for either case. It mostly worked (with modifications) but failed in certain corner cases. When used to make metaballs it produced more shapes than it needed with bigger shapes covering smaller ones. So I went back to the drawing board and broke it into two separate nodes.

The revised fragments node now works perfectly as far as I can tell. It will return the interior fragments and only those fragments (with an option to toss any fragments below a given size). The metaballs node returns distinct clumps and only those clumps - no more hidden shapes. And my node allows you to retain any holes inside each metaball or fill them.

The bad news is that both nodes are now less efficient than the original fragments node. If you feed them many overlapping shapes dense enough to create many potential fragments, and/or shapes which are complex (containing many curved segments), the node may start to bog down. You can speed processing - sometimes significantly - by resampling curved shapes before feeding them into the node.

The attached demo shows two sets of overlapping shapes. On the left I feed it a random scatter of As, Bs, and Cs. On the right I toss a set of 18 "sticks" (skinny rectangles). For each input I show the resulting fragments and metaballs. For the "metasticks" I check the "fill holes" box. All sets are colored across the same spectrum so you can easily distinguish the resulting shapes.

Play with the settings (sizes, seeds, etc.) to get a feel for how these work. And please try them out to create your own work. If you find any issues (or just want to say thanks) please reply and let me know.

Both of these nodes will be included in version 3.0 of my Node Library which will be released imminently!

Go forth and create!


Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Already uploaded files

  • Fragments_and_Metaballs_screenshot.png 539 KB
  • 6.84 KB

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

29 May, 2024 05:47 AM
29 May, 2024 05:15 AM
29 May, 2024 05:12 AM
28 May, 2024 07:37 PM
25 May, 2024 11:52 AM


24 May, 2024 07:39 AM
16 May, 2024 02:11 AM
14 May, 2024 01:29 AM
12 May, 2024 07:46 PM
05 May, 2024 04:38 PM
03 May, 2024 06:50 AM