Jump to content
Entropy

[SOLVED] remove points behind obstacle

Recommended Posts

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 by Entropy

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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 by Entropy

Share this post


Link to post
Share on other sites

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.

  • Like 1

Share this post


Link to post
Share on other sites

isn't it simple as this ?

delbackface.jpg

Edited by Noobini

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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...

test.jpg

Edited by Noobini

Share this post


Link to post
Share on other sites

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

  • Like 2

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.png.6e6d2bd1a7e56c92bddeab34ecf4a3c7.png

vex_cull_curves.hipnc

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×