Jump to content

Cull Particles by Pscale that Intersect Along Ray to Camera


Recommended Posts

I have a scene with a lot of particles that I am trying to optimize. I've already culled the particles outside of the camera, but I want to get rid of the ones that aren't seen by the camera's rays (the shape is blobby, so I can't just use the z position).

What I'm trying to do is take into account the pscale and delete the particles that are hidden behind others.
I have a basic working solution in sops via a for each, but it's painfully slow. I want to try and do this with vex. The end result would need to work on millions of particles.

The basic steps I thought of are:

1- find direction to cam 
2- ray particles to cam (rayline) 
3- find neighbors along the rayline
4- use pscale to determine if this intersects with neighbors' pscale
5- if it intersects multiple times, remove the original point

I've attached a file for what I used in sops. If anyone has any ideas on how to make it faster or a way to get it working with vex it would mean the world to me. I assume it would be with the intersect() function, but I'm not very familiar with it.

Thanks

particle_intersect.hip

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