← BACK TO NOTES
2026-09-13 |
HDK HOUDINI

UVs in C++: Points vs Vertices

UVs are the coordinates that map a 3D surface onto a 2D image.
In Houdini they live in an attribute called uv, and you can put it on points or on vertices. That choice changes how seams work.

Points and vertices

A point is shared by several faces.
So a UV on a point can only have one value per point, and cannot say "the face on this side and the face on that side should have different UVs across the seam". A vertex belongs to one face, so it can express a seam directly.

My UV nodes (the PRIME group) give the projection and placement nodes a Point/Vertex switch (UV Storage).
The default is vertex, which keeps seams intact.

Vertex to point: Promote

Some game engines and tools accept only per-point UVs.
So I made PRIME UV Promote to convert vertex UVs to points. It uses Houdini's conversion (GU_Promote), and when one point has several values you can choose how to decide: Mean, First, Last, Max, Min, Mode, Median or Sum.

GA_Attribute *result = GU_Promote::promote(gdp, src, GA_ATTRIB_POINT, true, method, dst, nullptr);
if (result) return true;
if (method == GU_Promote::GU_PROMOTE_MEAN && promoteVertexUvToPointsMeanFallback(gdp, attrib_name, dst))
    return true;

For the mean, I also keep a hand-written fallback: walk the vertices, add up per point, and divide by the count.

for (GA_Iterator it(gdp.getVertexRange()); !it.atEnd(); ++it) {
    const GA_Offset vtx = *it;
    const GA_Offset pt = gdp.vertexPoint(vtx);
    accum[pt] += src.get(vtx);  counts[pt] += 1;
}   // then write accum / counts to each point

A point on a seam gets the average of the UVs on both sides.
That means the seam information is gone the moment you convert, so it is safest to convert at the very last stage of output.

Projection

PRIME UV Projection makes UVs from positions.
It has six methods: Planar, Normal, Cylinder, Sphere, Triplanar and Box. Planar fits a position range (center ± half the size) onto 0 to 1 along two chosen axes. Box does not compute anything itself; it hands the job to the HDK's GU_TextureUnwrap, and if the output is on points, it then converts with the mean.

Islands and seams

Finding UV "islands" is the job of the nodes that place UVs into a trim sheet.
Faces are joined along shared edges, and two faces are merged into one island only if the UVs of the vertices on both sides of that edge agree within a tolerance (default 0.0001), using union-find. An edge whose UVs differ stays a seam, so the island splits there.

The tolerance is limited to between 1e-8 and 1.0, because going smaller than float precision is meaningless.

Packing and trim sheets

PRIME UV Pack puts islands into named rectangular cells.
It is not a free-form packer; it fits to cells, with layouts Custom, EqualGrid, Quad, RGB and CMYK. An island already inside 0 to 1 is treated as the unit square so the scale does not jitter.

PRIME Trimsheet cuts a plane with axis-aligned lines into rectangular cells.
Each cell gets a primitive group cell_N and an atlas uv. PRIME UV Trimsheet Fit moves a mesh's islands into a chosen cell, with four placement modes: Fit, Stretch, Stack Overlap and Stack Shelf.

PRIME UV MultiUV can also layer transforms, rotations, scales and packs onto ranges chosen by group or attribute.

The GPU: not yet

I also put in an entry point for running UV Promote on the GPU.
But the inside is not built yet, so turning on "Use GPU" gives a warning and runs the CPU path. As I wrote in article 8, I plan to decide whether the GPU is worth it only after measuring.

Summary

What matters most with UVs is to decide up front between points and vertices.
If you want to keep seams, hold UVs on vertices, and convert with Promote only at the final stage where you need points.

Next, the second half of the series moves to where Houdini meets the outside world.

Related articles

2026-09-08

Four Traps of Attributes and Groups in C++

What I made into rules for handling Houdini geometry attributes and groups in C++, and the four places I actually got stuck (handles outside loops, announcing changes, group name collisions, and mixing up points and vertices).

2026-09-22

Growing Trees and Cliffs in C++

How my vegetation and cliff nodes (prefix BIO) are built. Two ways to make a tree, the heavy branch junctions and a speed-up that missed its goal, the rules for placing plants, and how cliffs are made.

2026-09-04

I Put Nodes on the GPU, and They Got Both Faster and Slower

I moved terrain nodes to the GPU with OpenCL. Changing a setting got about ten times faster, and the very first cook got slower. The structure, the measurements and the precision story.

Comments