[VFX Graph] Accessing particles data in Scripts

Hey there,
I’m trying to use the VFX graph to filter out and modify input particles, so I can access a reduced amount of the initial particles in scripts.

I have a KinectV2 generating a point cloud, quite dense.
My idea is to use the VFX graph and keijiro’s base to use this point cloud in the VFX graph, do some of the heavy processing of downsampling, AABoxKill, etc. and send back to a script the filtered particles, which would allow me to do more efficient CPU processing because it would only handle the reduced, filtered positions.

So my main question here is : is it possible to retrieve the particle data in scripts after the update context ?
Or does it make more sense to actually use computer shaders for that ?

Thank you

Hello,

There is no way to readback particle data to CPU at the moment. This is something that is planned in the future.
Also accessing particle buffers from GPU in a external compute shader is not yet there but may come soon.

Ok thanks,
so basically I should just use compute shaders to do all the heavylifting and then go back to CPU (maybe some ECS then do to clustering ?)

Any news on this?

Hi, also looking for this. Looking to get the particle position on die event.

Any update on this?

I am working on a project for this… It is not performance friendly but it works to have some datas.
I get my particles dying on collision, and generate a new particle on die, which color depends on its position. I have a camera with a render Texture and a script that detects the particle’s color. It is not effective at all but it works. I can share it in some are interesting

2 Likes

This would be awesome Levrden, need it for some experimentation (grabbing particle data) so it being not performance friendly is fine for now

I’m super interested in that too. Can you DM with with more info?

Hello sorry, i missed the answers ! For now i don’t have a lot of time to comment my unity project, but i can send it !
It is a project for making haptic gloves with arduino, so i use OSC jack from Keijiro ro get and send my datas.
It is a hdrp 2019.3.3 project.

The settings are :

  • There are hands controlled my leapmotion that have empty objects at the end of each finger, and on the palm. So 12 objects tracked.
  • In the hierarchy, you have the SimplePartsEmission, the VFX graph.
    -there a a lot of property hided, for all the 12 objects.
  • the script var2vfx aims to sync my incoming osc properties to the vfx properties. You can use it or not. I used to use it before the propertybinder component.
  • the propertybinder script is there to syncronize the 12 objects, the output position of the particles that depends on properties, and the position of the second camera.

In the hierarchy, the partpos object is the output position of the articules, and inside the second camera. The camera outputs a rendertexture.

Then, you have the OSC EventTrigger, that has a script for getting the color of the particle, and output it has a property, or a value, or whatever you need. In my script, it is in a value “col” that take the grayscale value of a pixel on the texture.

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

THE GRAPH

To make it less messy, i have made subgraph operators and blocks.

The principle is : When a particle is very close to one of my fingers, it changes of color and die.
the color changes depending on the scale of the empty object the particle approches. In that way, i can know which finger has been touched.

At the end of the update, and event trigger on death another graph that outputs a single particle in front of the second camera which inherit the color of the dead particle.

Here is the Github : GitHub - Levrden/LutherieNumerique-Levrden

I hope it is clear enough. If you have any suggestions of questions, i am of course open to it !

Thank you very much! Do you have any idea how to send back particle data from GPU to GPU(other shader), rather than from GPU to CPU like in your project?

Of course, after getting it on the cpu, you can send it back to another gpu thread, but I assume that you don’t want that…

Yeah… It’s very performance heavy. Any ideas how to send from GPU to GPU? That could save performance

I don’t see, sorry. It it the famous problem on how to get particle data, but as far as i know, it’s not yet possible