Occlude Node

john's Avatar

john

11 Jan, 2023 10:28 AM

Attention Floris, Jussi, and other Nodebox plotters.

Attached is a new node specially designed for plotters.

NOTE: SEE BOTTOM OF THIS THREAD FOR AN IMPROVED VERSION OF THIS NODE

Occlude takes a list of closed shapes or geometries in Z order (sorted from bottommost shape to topmost shape), and returns a matching set of shapes or geometries altered so that all occluded edges are removed. This allow a set of overlapping shapes to be plotted in a way that resembles the way it looks on a screen.

See attached screenshot and demo.

This node is an improvement over two earlier nodes I developed with Floris. My first attempt required separate nodes for paths vs. geometries, did not preserve colors, and was painfully slow. The improved node works for closed paths and geometries composed of closed paths, preserves the original colors, and is much faster - though still slow for large lists of shapes (more than about a hundred or so, slower if shapes are curved).

The demo creates two sets of shapes: 116 overlapping skewed rectangle paths (colored translucent blue) and 65 overlapping cylinder geometries (colored translucent green). It then applies the occlude node to the original set and a subset consisting of every other shape. Finally it slices out a single occluded shape so the you can more clearly see how each shape is altered. It does all this in under three seconds.

Not shown in the screenshot is a second test with 100 overlapping red circles. This example takes longer to occlude - almost seven seconds. Some shapes are more time-consuming to occlude than others.

The main use for this node is to enable plotters to correctly draw overlapping shapes. The node assumes the list of shapes are all closed and are already in Z-order. If need be, you can change the Z order of your list using the sort node; in these example I use sort Y to order the shapes from top to bottom.

The occlude node may also be useful in non-plotting situations as well. If your original list of shapes is translucent, and you do not wish to show overlapping areas in blended colors, occlude will remove the blended colors while still preserving the original colors of the non-blended areas.

I have not yet tested this node on a wide variety of shapes. I assume it will not work well with open paths for example. So this node needs to be battle tested using actual plotters.

So I need HELP! If you are using Nodebox to plot overlapping shapes, PLEASE try this node and report back. If it fails, please include your original source code and a description of what failed (with photo if possible) so I can debug and improve this node. I would also be curious to hear about situations in which this node took more than ten seconds to work. (If it worked perfectly please report that, too!)

If people are using this and it seems to work, I will add it to the next release of my node library,

John

  1. 1 Posted by Jussi Jokinen on 15 Jan, 2023 12:04 PM

    Jussi Jokinen's Avatar

    John,
    Thanks again for this amazing node!
    I tested it with overlapping shapes and it seems to be working great and produced consistent result compared to my flattener tool. The end result is definitely plottable. As far as I can consider, the result doesn't even need to be tested on plotter – one can check the result for example in Illustrator – if there are no overlapping lines then it will most definitely be fine. With complex drawings one might anyway use some line ordering / processing tool like vpype before plotting, so as long as original file hasn't got those hidden lines it'll be good.

    There's another point from my experience in plotting though: for me the problem hasn't really been the occlusion of _ closed shapes_. Illustrator (and probably Inkscape and alike) has the tool called Trim, that does the job ok. Of course it'd be cooler to get the plottable svg directly from Nodebox, but at least in my process 1min extra step before plotting hasn't been much of an inconvenience, since the plotting itself might take hours anyway. (for this reason I wouldn't worry at all about occlusion node being slow – I wouldn't run it all the time, probably just at the time of the exporting)

    The problems has been the occlusion of _ open lines / paths_. Illustrator cannot do this without extruding the lines to shapes. And in plotting you normally want to avoid that. Manually occluding lines is just pain or not doable. I attached a dead simple Nodebox example to illustrate my point. This was mainly the problem that made me write it myself since no viable solution couldn't be found.

  2. 2 Posted by Jussi Jokinen on 15 Jan, 2023 12:19 PM

    Jussi Jokinen's Avatar

    Here is another, more complex real life example of the problem with hidden shapes and lines.

  3. Support Staff 3 Posted by john on 16 Jan, 2023 02:00 AM

    john's Avatar

    Jussi,

    You raise a good point and thanks also for providing clarifying examples.

    My recent clip node does have the capability of handing both closed and open paths (which was not easy by the way). If I were to use it inside the occlude node it should be able to handle your open path examples.

    Unfortunately, my current clip node only clips inside a bounding area; it does not have an option like my mask node to reverse clip everything outside a bounding area. This feature is a pain to add but would obviously be useful, so was already on my TO DO list.

    I will attack that problem as soon as I finish some other projects. As soon as I have that working I will then try updating the occlude node to see if I can make it universal.

    So stand by. I will report back once I have made some progress.

    John

    P.S. In your second example you have "spider curves" drawn atop black "blobs". How would you want to plot this? I understand that you would want to occlude the curves underneath other spiders. But would you want to try to fill the blobs somehow to create that black look? Or would you only plot the boundary of the blobs to create transparent regions instead of black ones?

    This raises a more general question. Would you want an occlude node to automatically make all closed paths show only boundaries (make their fill alpha 0) so that the output on the screen more closely matches the actual plotted output? Or maybe provide this as an option?

  4. Support Staff 4 Posted by john on 26 Jan, 2023 01:24 AM

    john's Avatar

    Jussi, All,

    I am pleased to announce an improved version of the occlude node!

    Once I finished the improvements to my clip node (just posted on the forum) I was able to use it inside the occlude node. The improved occlude now is just a tad slower than it was, but should be universal. That is, is should be able to handle occluded solid shapes, occluded lines, and even occluded open curved spline paths.

    I also added an option to show edges only. If you check this box it will recolor the shapes to be transparent with one-pixel wide black strokes. Exact same shapes either way, but the edges only view should look more like the actual plotter output (if you are going to use it on a plotter).

    I have attached your original folder with both examples updated to include the new node - see screenshots. Change the shuffle seed on your spiders plot to watch different spiders move into the foreground or background. Be patient: the node takes almost 30 seconds to handle your list of complex spiders.

    I have also included an updated version of the occlude demo which looks just like the previous demo but now contains the new occlude nodes.

    I've been testing it and so far, so good. But the real test will be all the Nodebox plotters out there throwing all their creations at this. So please, give this thing a spin and report back!

    I will add the occlude node to the next rev of my Cartan Node Library.

    Happy Occlusions!

    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

  • Occlude_node_screenshot.png 591 KB
  • occlude_node.ndbx.zip 7.98 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

31 Jan, 2023 11:29 PM
28 Jan, 2023 10:39 AM
26 Jan, 2023 01:30 AM
26 Jan, 2023 01:24 AM
26 Jan, 2023 12:48 AM

 

20 Jan, 2023 02:32 PM
13 Jan, 2023 09:54 PM
11 Jan, 2023 10:32 AM
09 Jan, 2023 11:45 AM
28 Dec, 2022 11:19 PM
27 Dec, 2022 06:57 AM