Fragments and Metaballs

john's Avatar

john

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:

http://support.nodebox.net/discussions/nodebox-2-3/6255-reproducing...

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!

John

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
  • fragments_and_metaballs.ndbx.zip 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

Generic

? 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

24 May, 2022 06:27 PM
24 May, 2022 11:36 AM
20 May, 2022 04:12 PM
05 May, 2022 02:25 AM
03 May, 2022 04:46 AM

 

01 May, 2022 09:22 AM
18 Apr, 2022 09:01 PM
18 Apr, 2022 02:02 AM
16 Apr, 2022 06:01 PM
14 Apr, 2022 07:38 PM
22 Mar, 2022 08:44 AM