VEX - xyzdist on overlapping prims

   481   3   0
User Avatar
Member
296 posts
Joined:
Online
What does xyzdist do if two prims are overlapping identically?

I'm asking because I wonder if there is a way to detect all prims that are exactly the closest (for overlapping triangles or tetrahedrals).

https://www.sidefx.com/docs/houdini/vex/functions/xyzdist.html [www.sidefx.com]
User Avatar
Member
4531 posts
Joined: Feb. 2012
Offline
Hi,

I don't think xyzdist would return all of them. I haven't tested this but I suspect it returns the polygon whose normal is pointing towards the origin point.

In any case if you want to detect all overlapping polygons, you could use xyzdist first to find the nearest prim and then fire a ray in that direction using the intersect_all VEX function to find all intersected prims along that direction:
https://www.sidefx.com/docs/houdini/vex/functions/intersect_all.html [www.sidefx.com]

If the overlapping polygons all share the same points, a more robust and faster method would be to compare sorted primitive points:
https://www.sidefx.com/forum/topic/88523/?page=1#post-382336 [www.sidefx.com]

Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
User Avatar
Member
480 posts
Joined: July 2005
Offline
Hi,

you can use xyzdist() with the optional group parameter as well looping over every prim. It is quite slow compared to the other methods but you will get the captured attributes for every primitive. The normal on the closest point (on the primitive) is parallel to the direction from the source point to its closest point.
Here is an example. If you have a cube and take the center, every primitive has the same distance to this center. And if you duplicate the cube this fact won't change, but now you have also overlapping primitives.

Attachments:
capture_all_prims.hipnc (104.7 KB)

User Avatar
Member
296 posts
Joined:
Online
animatrix_
Hi,

I don't think xyzdist would return all of them. I haven't tested this but I suspect it returns the polygon whose normal is pointing towards the origin point.

In any case if you want to detect all overlapping polygons, you could use xyzdist first to find the nearest prim and then fire a ray in that direction using the intersect_all VEX function to find all intersected prims along that direction:
https://www.sidefx.com/docs/houdini/vex/functions/intersect_all.html [www.sidefx.com]

intersect_all sounds like a good idea, but I tried this on a point inside of a tetrahedral and intersect_all doesn't seem to be aware that it's within the prim unfortunately, which *does* work when using xyzdist.

An idea for grabbing all prims is to use within a render time shader and accumulate samples, but looping over all prims is going to be too expensive.

A constraint for my requirement is that the points that define the prim don't necessarily overlap, just end up generating a prim that can be found in the same sample point.
  • Quick Links