VFX Graph - Update all existing particles while changing exposed property (optimization)

Hey,
I have a VFX graph and I would like to change the color of the particles instantly but only once during a playthrough.

To better understand: the VFX represents a checkpoint, it starts white and turns red when the player reaches it. So this change will occur only once in a lifetime of the game. The color is an exposed property of the VFX graph and is changed by a script.

I made 3 attempts:

  1. Set color on initialization, but then it does not turn red instantly when the player reaches it (it needs to wait for particles to die and then the new particles will be red)

  1. Set color on update, works like a charm but Im concern about having many VFX graphs constantly updating their colors in the scene while this change actually occurs just once.

  1. Set color on update but deactivate the module with an exposed boolean (only activate it for a few frames when the change occurs using a coroutine), works like a charm but is it worth it? Am I over-optimizing? Is there something better to do?

Thanks for your feedback!

You are overoptimizing unless there is a lot of them.
I guess disabling block would be faster because you avoid writing data.

There is one more option that should be faster than everything above, you could set color in Output context, so it would not write to memory, but instead calculate all of it in vertex shader.
The only problem is that it assumes that all particles change color (like your second attempt).

2 Likes