Search Unity

Question Particle Strip Manager

Discussion in 'Visual Effect Graph' started by Qriva, May 11, 2022.

  1. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,315
    There are bullets/projectiles that leave trails behind as they move. I wanted to create master trail manager to render all of them (one VFX rendering all trails), but I am not sure how to do it - or to be more specific I think this is not doable.

    I guess I would approach this problem with gbuffer, there would be list of all projectiles and buffer would be filled with positions. Next I would sample buffer in VFX graph (to spawn particles each frame) and I would use each record index as particle strip index. In theory it should work, however what to do when projectile died? Well, I would just stop spawning particles in that strip, but I would need to keep all other indexes correct. This still could be done with some pain, but the main problem is what if that strip index is reused again - I would get these "teleport" lines between end and new start point and I think there is no way to overcome this problem as there is no way to make break or jump strip to other position.

    Or am I wrong maybe? Is there way to overcome these problems or this is simply not doable?
     
  2. JulienF_Unity

    JulienF_Unity

    Unity Technologies

    Joined:
    Dec 17, 2015
    Posts:
    326
    Hi. yes before reusing a strip index, you will have to make sure the latest particle in the strip has died (so adding a "particle in strip lifetime" delay. This is done automatically when using gpu event: typically when having some (possibly not rendered) particle system to drive the trails. But even by using this you would have to manage the reuse of driver particles yourself anyway. It should be doable as you said, but not that easily.

    However, with the new instancing feature that is coming, you should be able to do this directly with components. Basically just attaching a vfx component to each of you projectile and they will all be batched in a single update/render.
     
  3. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,315
    I assume we are talking about C# side, so I would need to track delay for each index. If thats the case then it would be more bad than good thing from such a system. Particle system or trail renderer might be better choice.

    Yeah :D I can't wait - it will be huge milestone.
     
  4. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,315
    I have one question regarding instancing feature, what will be the rules of instancing?

    If there is some simple visual effect A with single system, and effect B made from 3 systems, where one of them has the same shader and setup as A, then it means they are batched? If there is another one - C and there is subgraph of A inside, is it batched with other A systems? I am asking, so me or other people who could potentially upgrade projects in the future could design their effects without need of huge refactoring later.