Jump to content

Is there a way to snap points on a surface using an SDF?


magneto

Recommended Posts

Hi,

I am experimenting with SDF volumes and want to snap points in a point cloud surrounding the SDF onto the surface.

I got the normal from the Volume Gradient VOP and inverted it if the value returned by Volume Sample VOP is positive, so it moves towards the surface.

So I am adding the (normalized_normal * signed_distance) to the original point positions but they aren't ending up on the surface of the object. Am I missing something or is this not a valid way to use SDFs?

Thanks :)

Link to comment
Share on other sites

Thanks, when I did that the points inside the SDF moved on to the surface, but not the points on the outside.

Also you are right, I was using 10 for the res, and now changed it to 100 just to see the result. My method still seems to keep the points a little far from the surface, inside or outside.

Link to comment
Share on other sites

SDF values will be negative inside and positive outside so just need to manipulate those values (you might need to negate it before multiplying with gradient)

Edited by tmdag
  • Like 1
Link to comment
Share on other sites

Ok I am just doing this now for all points:

P + normalized_gradient * negate(signed_distance);

which gives me the same result but now it's simpler I think :)

EDIT: Attached my file showing the result. When I apply a Ray SOP, it moves some points even further so you can see they are not exactly on the surface. Not sure if it's to do with the math or the SDF resolution.

sdf_points.hip

Edited by magneto
Link to comment
Share on other sites

I don't think that SDF will give you perfect alignment with surface border as there will be always small difference between voxel position and point position. You can try using intersect sop in direction of gradient.

  • Like 1
Link to comment
Share on other sites

Thanks I thought it would that's why I was thinking that I did something wrong. It's hard to judge from the visualization of the SDF to see how detailed the surface is, so I could use that as the reference when judging if the points end up on the surface or not, but that doesn't work.

Intersect doesn't seem to work but might have to play with it more. Some points are gathered in the hole at the center.

Ray SOP helps, but I just wanted to experiment with SDFs :)

Link to comment
Share on other sites

The SDF's (or, generally, LevelSet's) gradient is exactly* the same thing as a vector from current point to a closest position on the surface (and it is also a normal at this pos.). So, the most precise solution is to use RaySOP in Minimum Distance mode or Minimum Position VEX node ( minpos() VEX function ).

*I meant "normalized gradient multiplied by the SDF value". Sorry for the inaccurate formulation.

Edited by nord3d
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...