magneto Posted October 29, 2013 Share Posted October 29, 2013 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 Quote Link to comment Share on other sites More sharing options...
tmdag Posted October 29, 2013 Share Posted October 29, 2013 (edited) P + (normalized_gradient * abs(min(signed_distance, 0))) <- if they are inside maybe your sdf is not detailed enough ? Edited October 29, 2013 by tmdag 1 Quote Link to comment Share on other sites More sharing options...
magneto Posted October 29, 2013 Author Share Posted October 29, 2013 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. Quote Link to comment Share on other sites More sharing options...
tmdag Posted October 29, 2013 Share Posted October 29, 2013 (edited) 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 October 29, 2013 by tmdag 1 Quote Link to comment Share on other sites More sharing options...
magneto Posted October 29, 2013 Author Share Posted October 29, 2013 Thanks, abs(min()) confused me, so I negated the volume sample if it's greater than 0. Although when I look closely, the points seem like they are not exactly on the surface. I guess with 100 samples volume, it only gets you this far. Quote Link to comment Share on other sites More sharing options...
magneto Posted October 29, 2013 Author Share Posted October 29, 2013 (edited) 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 October 29, 2013 by magneto Quote Link to comment Share on other sites More sharing options...
tmdag Posted October 29, 2013 Share Posted October 29, 2013 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. 1 Quote Link to comment Share on other sites More sharing options...
Shinjipierre Posted October 29, 2013 Share Posted October 29, 2013 I guess you should use the raySOP or intersect in vop to achieve that 1 Quote Link to comment Share on other sites More sharing options...
magneto Posted October 29, 2013 Author Share Posted October 29, 2013 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 Quote Link to comment Share on other sites More sharing options...
yongbin Posted October 29, 2013 Share Posted October 29, 2013 With intersect vop, your ray should longer than hit distance. length(ray) > length(P-hitP) 1 Quote Link to comment Share on other sites More sharing options...
nord3d Posted October 31, 2013 Share Posted October 31, 2013 (edited) 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 October 31, 2013 by nord3d 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.