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

Your First HDK Node in 25 Lines

People hear "C++ plugin for Houdini" and picture a week of setup.
It is 25 lines.

The whole node

#include <UT/UT_DSOVersion.h>
#include <GU/GU_Detail.h>
#include <OP/OP_Operator.h>
#include <OP/OP_OperatorTable.h>
#include <SOP/SOP_Node.h>

class Hello : public SOP_Node
{
public:
    Hello(OP_Network *net, const char *name, OP_Operator *op) : SOP_Node(net, name, op) {}
    static OP_Node *make(OP_Network *net, const char *name, OP_Operator *op) { return new Hello(net, name, op); }

protected:
    OP_ERROR cookMySop(OP_Context &) override
    {
        gdp->clearAndDestroy();
        gdp->setPos3(gdp->appendPointOffset(), UT_Vector3(0, 1, 0));
        return error();
    }
};

extern "C" SYS_VISIBILITY_EXPORT void newSopOperator(OP_OperatorTable *table)
{
    table->addOperator(new OP_Operator("hello_point", "Hello Point", Hello::make, (PRM_Template *)nullptr, 0, 0, nullptr, 0));
}

No inputs, no parameters. It puts one point at (0, 1, 0), and that is all.

cookMySop is the function Houdini calls whenever the node has to compute something, and gdp is the geometry it hands back.
newSopOperator is the door Houdini knocks on when it loads the file, and it is where the node introduces itself.

Build it

Houdini ships with its own CMake package, so the build file is tiny:

cmake_minimum_required(VERSION 3.20)
project(Hello_Point CXX)

list(APPEND CMAKE_PREFIX_PATH "$ENV{HFS}/toolkit/cmake")
find_package(Houdini REQUIRED)

add_library(Hello_Point SHARED Hello_Point.C)
target_link_libraries(Hello_Point PRIVATE Houdini)
houdini_configure_target(Hello_Point INSTDIR "${CMAKE_BINARY_DIR}/dso")

$env:HFS = "C:\Program Files\Side Effects Software\Houdini 22.0.459"
cmake -G "Visual Studio 17 2022" -A x64 -S . -B build
cmake --build build --config Release

The INSTDIR is there on purpose: without it, Houdini's helper drops the DLL straight into your Documents/houdini22.0/dso folder, the one Houdini loads plugins from.
I wanted a build folder instead.

Run it

Point Houdini at the build folder and ask for the node.
Here it is in hython, the command-line Houdini:

n = hou.node("/obj").createNode("geo").createNode("hello_point")
n.geometry().points()[0].position()      # (0.0, 1.0, 0.0)

One point, at (0, 1, 0). A C++ node, running inside Houdini.

Make it do something

A single point is not very exciting.
Give the node two parameters, Count and Radius, and swap the cook for this:

GU_PrimPoly *ring = GU_PrimPoly::build(gdp, count, GU_POLY_CLOSED, 1);
for (int i = 0; i < count; ++i)
{
    const fpreal a = 2.0 * M_PI * i / count;
    gdp->setPos3(ring->getPointOffset(i),
                 UT_Vector3(radius * std::cos(a), 0.0, radius * std::sin(a)));
}

Now it makes a ring.
Set Count to 32 and Radius to 2.5 and you get 32 points on a circle of radius 2.5.
With the parameters included, the whole file is 70 lines.

Three traps

Houdini's rules start showing up with the very first node.
These three got me:

  • Forget <span class="obsidian-tag">#include</span> <UT/UT_DSOVersion.h> and nothing tells you. It compiles without a single warning, and then the node just never appears. That header adds the version stamp Houdini checks when it loads the file.
  • The first compile error is a wall of text. OP_Operator has several constructors that look alike, and the compiler cannot decide which one you mean. The odd-looking (PRM_Template *)nullptr, 0, 0, nullptr, 0 is how you tell it.
  • You cannot rebuild while Houdini has the file loaded. The linker stops with LNK1104: cannot open file. Close Houdini, build, open it again.

That last one shapes everything after it: every change is edit, build, restart Houdini.

What a change costs

For this tiny node, a rebuild takes about 6 seconds on my PC, plus a few seconds to start Houdini again.

A real node is a different story.
The edge-damage node from the first article takes about 26 seconds for a one-line change, and 70 seconds if the line lives in the shared code underneath it.
Its very first build took three and a half minutes, because the shared libraries have to be built too.

An HDA has none of that: you change something and it is already running.
Whether the trade is worth it depends on how much you want the speed from the first article.
For me it is, and that is why this series exists.

Next

Next up is how 230 of these nodes share one structure, so that the 230th is as easy to write as the second.

Related articles

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.

2026-08-17

Parameters in C++ Are a Chore

In an HDA you click a parameter into existence. In C++ you write every one of them. Nine lines for two parameters, folders you have to count by hand, and the helper that saves me.

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.

Comments