Jump to content

Optimizing Perspective Object Silhouettes (+ Conforming Stuff to Them)

Recommended Posts

Hello all, I've been working on this setup for camera-space object silhouettes that will be used to conform/cull objects outside of them. 

While my setup is functional, it is sluggish...despite me trying to be quite performance conscious. 


I've prepared a simple example scene for you all to show where I'm at. The main sticking points here are Triangulate2D (slow, but faster than any alternative I've tried), and the group from bounding object (not too bad in the example file, but terrible with more complex silhouettes). 

I'd also love some help with conforming the points outside the silhouette back into it– the file I attached just does a simple minpos() to the silhouette because it's hard to do better without sacrificing performance. As a result, it fails when limbs get close together or if the geo to be conformed is too low-res.

Hopefully that all makes sense! 


Link to comment
Share on other sites


You can check for inside by raytracing your copied spheres against the 2d silhouette geometry from the camera direction with something like this:

string cam = chs("cam");

vector pnear = fromNDC ( cam, set ( 0.5, 0.5, 0 ) );
vector pfar = fromNDC ( cam, set ( 0.5, 0.5, -0.001 ) );
vector dir = normalize ( @P - pnear );

@N = dir;

After this you can either use a Ray SOP or call the intersect VEX function. In my test, I get about 5-6x speed up on that part. There are probably other optimizations that can be made.

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.

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