Branches

john's Avatar

john

16 Jan, 2025 08:22 PM

UPDATE - see below for a bug fix and an add-on node!

The branches node, which I think is pretty cool, was a direct result of a request from a Nodebox user named Colt:

http://support.nodebox.net/discussions/nodebox-2-3/7213-new-to-node...

Colt wanted help creating some simple art nouveau style floral patterns. I have not yet figured out how to help him achieve this, but as a first step I created a prototype for the branches node. The prototype could only draw a branching line shape within a square. The fully developed node I am sharing today can do much more.

Branches divides a container into regions using an organic branching pattern. The pattern consists of a trunk, which can start from any point along the edge of the container and bend high or low to the left or right, and from zero to six branches on each side, which initially follow the tangent of the trunk and then gracefully bend towards the edges of the container.

Branches returns a grouped geometry containing the regions formed within the container by the branching pattern, the trunk and branches, and the outline of the container. You can then color the regions and branches independently. Depending on how severely the trunk bends and on the shape of the container, parts of the pattern may leak beyond the edges of the container. If this is not desired, you can use my clip node to trim the excess away.

Any closed path may be used as a container (including text characters produced by my new charpath node), but simple convex shapes like rectangles, polygons, or ellipses work best.

Branches takes the following parameters:

  • Container. Any closed path. Simple convex shapes work best.
  • Trunk angle. The angle from center that the trunk is pointing. A trunk angle of 0 degrees (due east) will produce a trunk which ends at the point along the container edge intersected by a 0 degree line, and begins at a point directly opposite to that. The value can range from -360 to 360.
  • Bend point. The point along the trunk, from 0% to 100%, where the trunk bends from. Values between 20% and 80% work best.
  • Bend amount. The amount the trunk bends, from -100% to 100%. Negative values bend to the left, positive to the right. Values between -40% to 40% work best.
  • Branches. The number of branches on each side, from 0 to 6. A pattern with N branches per side will produce 2N+2 separate colorable regions filling the container.
  • Margin. The percentage of space between the branching pattern and the edge of the container, from 0% to 100%. A margin of 0% stretches to the edges of the container and is usually what you want. A margin of 20% will produce a branching pattern which sits inside the container with negative space all around. The larger the margin, the less natural the regions look; in such cases you will probably want to color all the regions the same to produce a neutral backdrop. A margin of 100% will make the branching pattern disappear.
  • Colors. A list of colors used to color the branches and regions. The first color in the list will be used for the stroke color of the trunk and branches. Any additional colors will be applied to the regions. If no region colors are supplied, the default background color is a light tan. If no branch color is supplied, the default branch color is black.

NOTES

The thickness of the branches will match the stroke width of the supplied container. If you supply a container shape directly (with no intervening colorize node), or with a stroke width of 0, the branch thickness will be set to an aesthetically pleasing value based on the area of the container.

As mentioned above, severely bent branching patterns, or patterns placed in unusual concave containers, may leak beyond the edges of the container. If this is not desired you can use my clip node to trim the excess. WARNING: certain container shapes may require excessive computation time to clip. Most angular shapes clip quickly, but for some reason circles with trunks at particular angles can take a long time (15 seconds or more) to clip. Clipping generally works well for short text produced by my charpath node, but can bog down for long text.

The attached demo shows a pentagon filled with white branches and colors from my sanzo_colors node. You can play with all the parameters on the branches node to get a feeling for how they work. You can then feed in a variety of other container shapes and change the coloring scheme (sequential Color Brewer colors look nice even without a separate branch color). You can supply the containers with or without an intervening colorize node. If there is leakage (as there certainly will be with the charpath node) you can apply the clip node.

Branches was a particularly challenging and exciting node to create. I've already had great fun using it and look forward to see what others might do with it!

  1. Support Staff 1 Posted by john on 23 Jan, 2025 03:28 AM

    john's Avatar

    UPDATE

    I have found an obscure bug in the initial version of branches which, in rare circumstances, could cause some regions not to be properly closed. Bug fixed.

    I have also created a NEW NODE, add_depth, for use with the branches node.

    Add_depth takes the output of a branches node and returns the same node with subtle gradients added to all the regions, based on the initial coloring. These gradients create an added brightness and sense of depth.

    See attached screenshot for a before and after.

    Add_depth could not be any easier to use: just plug in a branches node. All the gradient settings are calculated automatically. (If you want to fiddle with my settings just open up the node and have at it.)

    Warning - I default to 100-band gradients for every region. This could require a little extra processing time. Not too bad for a single pattern (a few seconds at most), but could be more onerous if you have many branching patterns, like the individual characters of a title or phrase using my charpath node.

    Because of the added processing time and because this node will only work with the output of the branches node, I decided not to place add_depth in my library as a new node. Instead, I will include it in the library demo for the branches node.

    Give it a try!

  2. 2 Posted by lastvector on 23 Jan, 2025 05:31 PM

    lastvector's Avatar

    Impressive as always, John

    A while ago I bought a copy of Substance Designer (Steam version).
    Still love Nodebox, of course. this is a program for procedurally creating
    textures for 3D models.

    Since the last update a new feature has been added called "Scatter Splines".
    As i saw some similarities I thought I'd post a video here for inspiration.

    Here's the link.
    https://www.youtube.com/watch?v=aUUWV1dYQdI

    Have a nice day
    gottfried

  3. Support Staff 3 Posted by john on 23 Jan, 2025 11:10 PM

    john's Avatar

    Gottfried,

    Thanks very much for sharing that. It stirs up many reactions...

    As I was making my branches node, making it more general purpose and generic, I was aware how bespoke it still is. it is designed to make a very specific kind of pattern, so I wonder: should there be other nodes for other kinds of pattern? Or should there be a more fundamental node, like Scatter Splines, that could be used to make a whole universe of different patterns?

    It was fascinating to see all the different settings built in to their Scatter Splines node. Many of these generalize specific factors that I baked in to my branches node. They have some ingenious techniques for wrangling the myriad choices: how far along the trunk to start branching, how to distribute the branches, whether to arrange the branches symmetrically, alternating, randomly, etc.

    Seeing advanced 3D tools like Substance Design sometimes makes me question why I still keep using an aging, relatively primitive tool like Nodebox. I sometimes feel as if I am riding a tricycle in a Grand Prix while gleaming race cars fly past me at blinding speed.

    But this video also reminds me of what I don't like about Adobe products and others like them: too complex, too many choices at every turn, too many controls and menus and submenus.

    I continue to enjoy Nodebox precisely because of its limitations. It is so simple. Adding nodes to a network in Nodebox feels like snapping Lego bricks together. Adding nodes in Substance Designer feels like adding new control panels to a nuclear reactor control room. The sheer power is exhausting.

    Paradoxically, by adding more and more nodes to my Cartan Node Library, I run the risk of turning the NodeBox experience into a faint imitation of tools like Substance Designer. My library is getting so big that even I get lost in it sometimes.

    But I can't seem to help myself. So, inevitably, the video you shared gives me ideas for even more new nodes. One day at a time.

  4. 4 Posted by lastvector on 24 Jan, 2025 07:50 AM

    lastvector's Avatar

    So I don't see Nodbox as a relic from the old days, even
    if there are tools that are a bit more pompous.
    Everything has its place.

    As I wrote, I love Nodbox and appreciate it very much.
    Nodebox 3 is always on my desktop ready to quickly try
    out ideas. Especially if you try out a lot of other tools like I do,
    you appreciate Nodebox and when you see your creations it is
    obvious that there is a lot more to it than meets the eye.

    gottfried

Reply to this discussion

Internal reply

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

Attaching KB article:

»

Already uploaded files

  • branches_screenshot.png 541 KB
  • branches_demo.ndbx.zip 220 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

06 Feb, 2025 01:37 AM
04 Feb, 2025 06:32 AM
04 Feb, 2025 05:04 AM
30 Jan, 2025 09:31 AM
30 Jan, 2025 09:08 AM

 

30 Jan, 2025 08:40 AM
24 Jan, 2025 07:50 AM
22 Jan, 2025 11:42 PM
21 Jan, 2025 09:43 AM
21 Jan, 2025 09:41 AM
21 Jan, 2025 09:36 AM