Interpolate Points (KDTree)
Thicken up a sparse point cloud without losing the shape
- points
- Points3D
Sparse point clouds render like a bad screensaver - holes everywhere, edges that shimmer as you rotate. Interpolate Points (KDTree) is the pack's density booster: it manufactures new points between existing ones so the cloud fills out, without you having to re-run the slow high-quality conversion from the image side.
Here's the trick it's built on. Rather than inventing geometry from nothing, it exploits the fact that a point cloud from a depth map is sampled geometry - the surface is already there, it's just under-sampled. Between any two nearby points that sit on the same surface, the space between them is (almost certainly) also on that surface. So the node places new points midway between existing neighbors, and the shape gets denser without the shape changing.
How it works
For every point in the cloud, the node finds its n nearest neighbors using a KD-tree (scipy's cKDTree, the same index used by the Clean Points node). Then, for each neighbor, it creates a new point somewhere on the line between the original point and that neighbor, positioned by the value blend. New points inherit interpolated colors too, so the RGB stays smooth. The result is appended to the original cloud.
The two dials are dead simple:
- value (0–1, default 0.5) - where along the line each new point lands. 0 keeps it at the original point (useless), 0.5 puts it exactly mid-way (the sensible default), 1 puts it on the neighbor. Low values add points clustered near the originals, which fills gaps conservatively.
- n (0–32, default 3) - how many neighbors each point gets interpolated toward. This is your density multiplier: n=3 means each original point spawns 3 new ones, so a 100k-point cloud becomes ~400k points. Watch the memory on big clouds.
Output: Points3D - the original cloud plus the new interpolated points, roughly N × (n+1) points total.
Install
Pack-standard: Manager → "ComfyUI_depthMapOperation", or:
cd ComfyUI/custom_nodes
git clone https://github.com/chri002/ComfyUI_depthMapOperation
Restart. No model files; deps are stock (torch, numpy, opencv-python, scipy, pandas), with scipy providing the KD-tree.
Where people get burned
The main trap is greed. n=3 already triples-ish your point count; crank it to 16 and a dense cloud becomes millions of points that slow down every downstream node - and the renderers here aren't exactly real-time. Use this when a cloud is genuinely sparse, not as a "more points = better" button. Clean up first, too: interpolating a noisy cloud just spreads the noise around. Run Clean Points (KDTree) before you densify, and remember the whole pack is single-frame only.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| points | Points3D | — | |
| value | FLOAT | 0.500–1 | — |
| n | INT | 30–32 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| Points3D | Points3D | — |