Vex "intersect" and "removepoint" functions not working; removes ALL points

   1404   6   0
User Avatar
Member
11 posts
Joined: April 2021
Offline
I have a rock I've created and I am trying to set up a point group to add moss to the upwards facing sides of it, but only on parts of the rock where there's no geometry directly above/close to it. I have a group "Keep by Normals" set up and blasted everything else to keep those upwards facing surfaces. I then have a point wrangle with the following code:

vector hit_p, hit_uv;
vector dir = {0, 1, 0};

int prim = intersect(1, @P, dir, hit_p, hit_uv);
if(prim >= 0) removepoint(0, @ptnum);

Unfortunately this deletes ALL points except for several random ones. It even removes points on the very top of the rock. I've tried the same code on a simple setup with two spheres and it works as expected.

Would appreciate the help, I'm familiar with C from college but still learning Vex. I've attached some screens and the hip file (although the rock in the screens I roughed out in Blender and haven't included the .obj but it the rock gen setup works with a cube) Also there's a geo node with the wrangle working correctly on two spheres. Any help much appreciated!
Edited by ghanson752 - Nov. 20, 2022 20:26:48

Attachments:
Screenshot 2022-11-20 165106.png (2.3 MB)
Screenshot 2022-11-20 165122.png (2.2 MB)
Screenshot 2022-11-20 165138.png (1.9 MB)
Screenshot 2022-11-20 165224.png (1.8 MB)
Rocks2.hiplc (865.8 KB)

User Avatar
Member
2529 posts
Joined: June 2008
Offline
You could try to solve this problem with another approach. Colorize the top and bottom differently, then transfer the color from the bottom to nearby tops. This leaves parts of the top exposed. Use vex to detect the exposed color and create a new group you transfer back to the original mesh.
Edited by Enivob - Nov. 20, 2022 21:39:36

Attachments:
ap_Rocks2.hiplc (838.2 KB)
Untitled-1.jpg (327.6 KB)

Using Houdini Indie 20.0
Ubuntu 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
11 posts
Joined: April 2021
Offline
Enivob
You could try to solve this problem with another approach. Colorize the top and bottom differently, then transfer the color from the bottom to nearby tops. This leaves parts of the top exposed. Use vex to detect the exposed color and create a new group you transfer back to the original mesh.
Interesting, thank you, I'll check it out. Sometimes is easy to get so focused on making one solution work it's hard to remember there are other options.
User Avatar
Staff
356 posts
Joined: Feb. 2008
Offline
If you add a small offset when doing the intersect you'll avoid prims intersecting themselves.

vector hit_p, hit_uv;
vector dir = {0, 1, 0};

int prim = intersect(1, @P + dir*0.000001, dir, hit_p, hit_uv);
if(prim >= 0) removepoint(0, @ptnum);

This should give you what you're after.
User Avatar
Member
11 posts
Joined: April 2021
Offline
npetit
If you add a small offset when doing the intersect you'll avoid prims intersecting themselves.

vector hit_p, hit_uv;
vector dir = {0, 1, 0};

int prim = intersect(1, @P + dir*0.000001, dir, hit_p, hit_uv);
if(prim >= 0) removepoint(0, @ptnum);

This should give you what you're after.
That worked perfectly thank you!
User Avatar
Member
4495 posts
Joined: Feb. 2012
Offline
ghanson752
npetit
If you add a small offset when doing the intersect you'll avoid prims intersecting themselves.

vector hit_p, hit_uv;
vector dir = {0, 1, 0};

int prim = intersect(1, @P + dir*0.000001, dir, hit_p, hit_uv);
if(prim >= 0) removepoint(0, @ptnum);

This should give you what you're after.
That worked perfectly thank you!

When doing intersections like Nick said, you have to consider where you are shooting the rays from and whether to push them outside the surface so you can hit the prim itself or whether to sink the ray a bit inside to shoot it from the inside, and sometimes doing the latter but reversing the direction, etc.

I show these concepts in practice in these free videos if you wanna understand them fully:
https://www.sidefx.com/learn/collections/pragmatic-vex-volume-1/ [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 | animatrix2k7.gumroad.com
User Avatar
Member
11 posts
Joined: April 2021
Offline
Thank you everyone. I suspected there was a technical aspect of the Intersect function that I was missing. I'll probably use the mossy areas for a CopyToPoints and add a lot more detail but for now this is a good milestone.

Attachments:
mossyrock.png (1.0 MB)

  • Quick Links