Raycasting to GPU Particle System?

I’m trying to create a custom interface that allows the user to select geometry that’s animated in a GPGPU particle system. So far I’m running into two problems. I’ve implemented GPU picking on the particle system which works well but has significant performance issues because of the readRenderTargetPixels() function being performance heavy.

I’m trying instead to use a Raycaster but it appears Three.js’s Raycaster can only detect objects before their position is modified in a vertex shader.

Is it possible to correctly raycast to objects that are being dynamically animated via a vertex shader or is this a limitation of the engine?

Are there other ways to handle user interaction via GPU other than picking?

A couple. I use CPU-side raycasting, it’s fast enough for me to do a few tens of queries per frame without any noticeable overhead.

For you particular case - the bottleneck is the driver boundary. You can read out the entire viewport into a Uint8Array and then do picking from that in JS, this way you don’t have to call readRendrTargetPixels that goes through the driver.

1 Like