← BACK TO NOTES
2026-08-12 |
HDK HOUDINI

230 Nodes Without Losing My Mind

Writing one HDK node is easy, as the last article showed.
Writing the 230th is a different problem: how do you stop it from becoming 230 slightly different programs?

My answer is boring and it works: every node is built the same way, in the same four layers.

Think of it as a building

SOP → {PREFIX}_Core → HDK_Shared → HDK_Common → Houdini

  • Common is the ground floor. It holds the base class every node inherits, a helper for parameters, and a table for the Tab menu. About 2,000 lines, and not one algorithm.
  • Shared is for code that two or more projects use: mesh smoothing, scatter, mesh cleanup, colour. About 3,000 lines.
  • Core is where each project keeps its own algorithms. Terrain has one, architecture has one, vegetation has one. This is the big floor, around 167,000 lines.
  • SOP is the node itself, the part Houdini sees: the parameters, one cook function, the registration. And it is supposed to be thin.

Where does new code go? One sentence covers it.
If two projects need it, it moves down to Shared. If only one does, it lives in that project's Core. The SOP only keeps the parameters and the wiring.

Dependencies only point downwards, so a Core never includes a SOP header, and Shared never depends on a Core.
I scanned the repo to see whether I had really kept to that, and I had: zero violations.

Thin really means thin

Out of 240 SOP folders, the median node is 198 lines.
Most nodes are a screen or two of parameters plus a call into a Core, and the real work happens down below.

There are exceptions, and I know where they are.
A few vegetation nodes (Tree, Vegetation, Grass, Biome) still keep their cook code in the SOP folder, and the repo's rule already says what to do about it: move it down into a Core the next time you touch the node.

The seatbelt: a base class in 82 lines

Every node inherits from HDK_SOP_Base, which does two small things around your cook function (trimmed here):

OP_AutoLockInputs inputs(this);                // lock the inputs first

try {
    return cookMySopSafe(context);             // your code goes here
} catch (const std::exception &e) {
    return onCookFailure(context, e.what());   // a C++ exception becomes a node error
}

Does it matter? I made the same two mistakes twice, once on a plain SOP_Node and once on the base class, just to see.

Reading an input I forgot to lock. On the plain node, Houdini crashed on the spot. No message, the session was just gone. On the base class it simply worked.

Throwing an exception inside the cook. On the plain node the exception flew out of Houdini as a Python error and the node showed nothing. On the base class the node reported my message as its error, which is how an error should look.

The first one is the scary one: a missing lock gives you no warning at all.
I would much rather have a base class that does it for me every single time.
(I only tried this in hython, the command-line Houdini, so the exception case might look different in the GUI.)

One line to register

Remember the newSopOperator function from the last article? In the repo, registering a node is one line:

HDK_SOP_REGISTER(TERA_Foo, "TERA_Foo", "TERA Foo", 1, 1);

It expands to that entry point, and it also files the node in the Tab menu under HDK/<PREFIX> using a lookup table, so 230 nodes end up in tidy folders instead of one endless list.

What the layers buy you

The first node in a project is slow to build, because the shared libraries have to be built with it: 208 seconds for the edge-damage node from the first article.
After that, a new node in the same project took 16 to 20 seconds, about a tenth of that.
A node from a different project, with a small Core of its own, took 20 seconds too.

That is the real payoff: shared code gets built once, and every new node only pays for itself.

The cost

The price is discipline.
Every new piece of code needs the question "where does this live?", and the answer has to be written down, so the next change follows it instead of inventing a new corner.
In my repo that lives in a few short rules files, and I keep them short on purpose.

Next

Next is the part of a node you touch all day: its parameters, and why writing them in C++ is more annoying than it looks.

Related articles

2026-08-08

Your First HDK Node in 25 Lines

A Houdini plugin sounds like a week of setup. It is 25 lines of C++ and a 9-line CMake file. Here is the whole thing, the three traps I fell into, and what it costs to change it later.

2026-08-21

Making a Node Use All 12 Threads

A Houdini node cooks on one thread unless you tell it otherwise. Here is the loop that spreads the work over every core, how fast it got on my PC, and the one thing that made Houdini crash on me.

2026-08-03

Why I Started Writing HDK Nodes

I began writing Houdini nodes in C++ with the HDK in January 2026, because they cook faster than HDAs. The same job, run both ways, with timings.

Comments