Move Points to Closest Edge
Saw this cool effect in a CGMatter video — points snapping to the closest edge. Had to try recreating it in Houdini.
The idea is simple: for each point, find the nearest edge on the reference geometry and project the point onto it. You end up with all your scattered points sitting right on the wireframe edges, which looks great with some color and glow.
How It Works
- Scatter points on or around a mesh
- Extract the edges from the mesh (using Divide SOP or Convert Line)
- Use a Ray SOP to snap the scattered points onto the edge geometry
The Ray SOP does all the heavy lifting — set it to “Minimum Distance” mode, feed your scattered points into the first input and the edge geometry into the second, and it projects every point to the closest position on the edges. No code needed.
VEX Alternative
If you want more control, you can achieve the same thing with a few lines of VEX in a Wrangle SOP:
// Run over Points — Input 1: scattered points, Input 2: edge geometry
int prim;
vector uv;
float dist = xyzdist(1, @P, prim, uv);
vector closest = primuv(1, "P", prim, uv);
@P = closest;
xyzdist() finds the closest spot on the edge geometry, and primuv() gives you the exact position — then you just move the point there. This approach lets you do extra things like blend between the original and snapped position, or filter by distance.
Tips
- Add Attribute Noise on
Cdafter snapping for that colorful wireframe particle look - Play with point count — more points = denser edges
- Works on any geometry, not just boxes — try it on a Pig Head or a Rubber Toy