Faster Grid_Plus Node

john's Avatar


27 Jan, 2021 10:37 AM

Grid_plus is one of the most useful nodes in my node library. Defining the grid by cell size is usually much easier than figuring out the final dimensions of grid itself. It also lets you limit the total points (overriding the rows value). AND it lets you arrange those points in one of four different orders (start from top left, top right, bottom left, or bottom right).

Those four ordering options, though, were wildly inefficient because of NodeBox's switch problem. Switch nodes are a major cause of slow performance because Nodebox does all the calculations for EVERY option even though you only need one of them. I didn't appreciate this problem when I was first coding with Nodebox, but now I am careful whenever I use a switch.

But I was not careful about this in my original version of the grid_plus node. Most grids are rather small, often only a few dozen points, rarely more than a few thousand. When you only have a thousand points, calculating all four orders is barely noticeable.

But my image node, which uses grid_plus, has to handle up to 100,000 points - which IS noticeable when you quadruple the calculations. So in that node I modified grid_plus to eliminate the other three options, dramatically reducing the render times.

That was a temporary fix. Today I am releasing an updated version of the node (attached) which retains the ability to generate all four orders but does so efficiently.

In Top Left mode (which is what you want 99% of the time) it's quite fast. Top Right and Bottom Left are a little slower and Bottom Right slower still, but better than before.

Those of you who care about such things can look inside this node to see how I did it. The basic trick is to add more switches upstream, so that the total number of calculations needed for each unused option is reduced to a bare minimum. If you look into my more recent nodes you will see that I now do something similar whenever I use switches.

This updated version of grid_plus will be included in the next release of my node library. But you can start using it now.



Reply to this discussion

Internal reply

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

Attaching KB article:


Already uploaded files

  • grid_plus_screenshot.png 292 KB
  • 2.15 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

16 Jun, 2022 05:30 AM
15 Jun, 2022 06:03 AM
06 Jun, 2022 01:07 PM
02 Jun, 2022 11:58 PM
30 May, 2022 07:48 AM


24 May, 2022 06:27 PM
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