Move points to their closest unique neighbors

   469   2   0
User Avatar
38 posts
Joined: 9月 2021
I have a question along the lines of this [] one, but I have a feeling there's a more efficient and elegant way to handle what I'm trying to accomplish.

Basically, I have two geometries of points, each with an equal number of points.

Set 1:

Set 2:

I would like to smoothly transition each point from its location in the first set to its location in the second set. If I do this using traditional methods (like using a blendshape or lerping between the P attributes) there is a lot of weird motion because the point numbers in these sets are very different. I'd like each point in set 1 to move to the closest point in set 2, but I don't want any of the points from set 1 to end up on the same point in 2.

I've tried sorting the points across the diagonal vector, but simply due to the difference in point density, the point numbering is still different enough that there is too much weird motion when I blend their positions. I've also managed to make it so each point from set 1 moves towards the closest point it can find in set 2, which avoids the crazy motion, but this makes it so many points overlap (due to having the same closest point) once the motion is completed. Is there a way to achieve this effect?


set1.png (826.2 KB)
set2.png (633.6 KB)

User Avatar
3924 posts
Joined: 2月 2012

There are many ways to do this, including proper VEX methods that are a bit more involved. But for this case you can use a simple solution:

1. Flatten the first point cloud in Y temporarily (rest attribute).
2. Sort the points of both point clouds by proximity to origin (0, 0, 0).
3. Revert the original point positions of the first point cloud.
4. Now you can use Blendshape SOP.
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [] |
User Avatar
15 posts
Joined: 12月 2021
Wow, that's genius! I was thinking it'd need a graph algorithm with some double or triple nested loop, but this seems like it'll work great! I'm excited to try it out, thanks!
  • Quick Links