VFX Graph GPUEvent to Output Event

I’m currently testing the VFX Graph system for the first time, trying to create some particle fireworks like for example in Brackeys nice Youtube tutorial.

I can successfully spawn fireworks explosions at the end of the lifetime of the main “rocket” particles using GPUEvents (trigger event on die).
Now I would love to instantiate a point light at the exact moment and position of the explosion. I would guess that I have to create an Output Event to trigger some C# script to create the light. Unfortunately I can’t find any way to create this Output Event from my GPU Event, because the Output event node only takes input from a Spawn Event, which I do not have at this time. And at spawn time of the original rocket particle I do not know the end position when it actually dies.

Q: Is there any way to pass the position of a dying particle back to the CPU?

2 Likes

I have the exact same issue. Funny, I am also working an a fireworks system and I would like to play a detonation sound as soon as the fireworks explodes.

Has anybody an idea how to solve this?

1 Like

Same here, I also have a Trigger Event on Die which is connected to a GPUEvent to spawn a new particle, but I cannot get this GPUEvent to connect to the OutputEvent. Did you figure out a solution?

@VladVNeykov was talking about this exact use-case in this thread so it should be possible?
(I’m on 2021.3)
He did however say

Hi !
After searching for months, i’m now sure that this is just not possible at all, for now
I find that it is really misleading to call that a “GPUEvent” because it does not do what we think it is supposed to
It’s just a way to have an event started at the same time than the spawning, so it’s useful in only a handful of cases
I think i have heard that they are working on a real vfxevent, i’m really waiting for it !

1 Like

Is it still not possible to trigger an Output Event with a GPU Event? I want to execute a sound using a Trigger Event: On Collide.

I managed a workaround using a custom node that writes the alive states to a graphics buffer that I then read back to CPU and check for changes. I couldn’t make it work using async gpu readback though, perhaps because of simultaneous read/write.

VFXGraph Setup:

  1. Create a custom node in the VFXGraph and paste in this method:
int WriteToBufferFunction( in RWStructuredBuffer<float> buffer, in int id, in bool alive, in int countPassthrough )
{
	buffer[ id ] = alive ? 1.0 : 0.0;
	return countPassthrough;
}
  1. Connect the inlets:
    GraphicsBuffer property to “Buffer”
    GetParticleId to “Id”
    GetAlive to “Alive”
    The count to pass through to “CountPassthrough”

  2. Connect the custom node outlet to a Trigger Event set to “OnCollision”.

  3. In your C# script, something like:

_vfx.SetGraphicsBuffer( _propertyId, _buffer );
Array.Copy( _data, _lastData, _data.Length );
_buffer.GetData( _data );
_buffer.SetData( _zeroData );
DetectAndInvokeCollision(); // Compare _data and _lastData

If you know a better way, please lt me know.