Entropy Posted January 16, 2018 Share Posted January 16, 2018 (edited) Hello to all, this is my first post I am starting to learn houndini i try to convert some of my projects done with grasshopper i want to do a line mesh intersection test to cull points that are behind a mesh obstacle for each point i need to create a line to the camera origin and then check if the lines intersect with the mesh if true then i need to remove those points Any suggestions ? Thanks in advance. Ioannis Edited January 17, 2018 by Entropy Quote Link to comment Share on other sites More sharing options...
toadstorm Posted January 16, 2018 Share Posted January 16, 2018 take a look at this file... it's using a Wrangle to create the projection vector to the origin for each point, and a Ray SOP to actually do the projection. ray_project_cull.hip Quote Link to comment Share on other sites More sharing options...
Entropy Posted January 16, 2018 Author Share Posted January 16, 2018 (edited) Hi Henry, Thanks a lot for the file it is working fine as long as the points are based on different geometry when i use the same object to construct the points there are a lot of inaccuracies normally all the points that are facing the camera should be visible please have a look at the file Thanks in advance.Ioannis ray_project_cull_self.hip Edited January 16, 2018 by Entropy Quote Link to comment Share on other sites More sharing options...
toadstorm Posted January 17, 2018 Share Posted January 17, 2018 You just need to introduce a little ray bias into your Ray SOP. A value of 0.1 got me pretty close. If all you're trying to do is remove points that are backfacing the camera, there's a simpler way. Unique the points on your mesh using a Facet SOP or however you like, create point normals via a Normal SOP, scatter, then just use a Delete SOP in Normals mode. There's an attribute there that accepts a camera input to determine backfaces. As long as the scattered points inherit your mesh's point normals, this will work. 1 Quote Link to comment Share on other sites More sharing options...
Entropy Posted January 17, 2018 Author Share Posted January 17, 2018 I did offset the points along the Normal direction to fix the inaccuracies of the Ray test intersection and all is working now thanks again Ioannis ray_project_cull_self_offset.hip Quote Link to comment Share on other sites More sharing options...
Noobini Posted January 17, 2018 Share Posted January 17, 2018 (edited) isn't it simple as this ? Edited January 17, 2018 by Noobini 1 Quote Link to comment Share on other sites More sharing options...
Entropy Posted January 17, 2018 Author Share Posted January 17, 2018 Hi Noobini, does this method work for culling curves that flow over a surface ? the way i am doing it now is resampling the curves and delete the points that are behind the mesh thanks Ioannis Quote Link to comment Share on other sites More sharing options...
Noobini Posted January 17, 2018 Share Posted January 17, 2018 (edited) dunno for your exact situation...but i tested on 'lines' and it works even not needing any blocking mesh (coz it works on N forward or backfacing)...you must initialize N first tho... Edited January 17, 2018 by Noobini Quote Link to comment Share on other sites More sharing options...
toadstorm Posted January 17, 2018 Share Posted January 17, 2018 You can avoid the need to resample with some Clip SOP magic. Compute dot(I, N) where I is the normalized vector between your camera and point position, set a rest position, then use a wrangle to move your points into a world position based on that dot product: vector camP = point(1, "P", 0); vector I = normalize(camP - @P); @dot = dot(@N, I); v@rest = @P; @P = set(0,@dot,0); Then use a Clip SOP to cut off any primitives where dot product is less than 0. The defaults work fine here. Afterwards, just move your points back to their original rest positions. smooth_line_clip.hip 2 Quote Link to comment Share on other sites More sharing options...
Entropy Posted January 18, 2018 Author Share Posted January 18, 2018 Hello Henry, it is magic indeed! i can't though make it work with nurbs curves ray test intersection works thank you Ioannis nurbs_curve_clip.hipnc Quote Link to comment Share on other sites More sharing options...
toadstorm Posted January 18, 2018 Share Posted January 18, 2018 It's something to do with the trails you're generating from the VDB Advect Points SOP... they don't seem to be getting the right normals. If you AttributeTransfer N from your original points onto the trails, it should work fine, even as NURBS curves. Quote Link to comment Share on other sites More sharing options...
Entropy Posted January 18, 2018 Author Share Posted January 18, 2018 Hello again Yes it is working thank you very much Ioannis nurbs_curve_clip_ok.hipnc Quote Link to comment Share on other sites More sharing options...
Entropy Posted January 18, 2018 Author Share Posted January 18, 2018 self culling dosn't work do you have any idea why this is happening ? nurbs_curve_clip_issue.hipnc Quote Link to comment Share on other sites More sharing options...
f1480187 Posted January 21, 2018 Share Posted January 21, 2018 I would render the underlying mesh as a matte object. The surface will naturally cull geometry behind it. Nice way to render wireframes. If you want to do it in SOPs, I would stick to the Ray node method. Delete-by-normal method doesn't really cull things. It works properly in the file you posted. Here is VEX version of initial idea (identical to just using the Ray, though): // Point wrangle. vector camP = point(1, "P", 0); vector dir = normalize(camP - @P); float bias = 0.01; // Error margin to avoid self-occlusions. // Get all intersections along the ray. vector hit_ps[]; int hits = intersect_all(2, @P, dir * 100, hit_ps, {}, {}); if (hits && distance(@P, hit_ps[-1]) > bias) { // Occluded by some surface. removepoint(0, @ptnum); } vex_cull_curves.hipnc 5 2 Quote Link to comment Share on other sites More sharing options...
Entropy Posted January 24, 2018 Author Share Posted January 24, 2018 nice one! thank you very much vex version should be handy as it performs faster 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.