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.



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