Search Unity

Question [SOLVED] Particles become invisible after creating a new system.

Discussion in 'Visual Effect Graph' started by SadShadyBoi, Dec 25, 2022.

  1. SadShadyBoi

    SadShadyBoi

    Joined:
    Oct 9, 2020
    Posts:
    10
    I am using a graphics buffer to set position and color of particles in my system.

    If I set the color in Initialize node everything works fine. But as soon as I try to change the color in Update particles are only visible on the current used system and all old ones become invisible.

    upload_2022-12-25_11-38-49.png

    The positions and outlines are still there but color seems to be invisible.
    upload_2022-12-25_11-39-47.png
     
  2. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,313
    Assuming sampled color from buffer is valid, then you possibly used spawnIndex as buffer index, and it can be used only when spawning particles.
     
  3. SadShadyBoi

    SadShadyBoi

    Joined:
    Oct 9, 2020
    Posts:
    10
    I use particleID to sample the buffer. The entire graph works fine until I Release the buffer.
    In the 1st picture above of the scene view you can see some particles that are visible ( those are from the current used VFX Graph object ) and the outline of the particles from the last one. I am a bit confused as the location and size of the particles is clearly saved after buffer Release but the color is gone.

    Here's the entire VFX Graph in case you need it.
    upload_2022-12-25_18-33-38.png

    And here's the code where I Release the buffer and create a new one. I set the buffer size to 10k particles to keep track of the particle systems more easily.
    upload_2022-12-25_18-35-40.png

    p.s.
    Thanks for the help and Happy Holidays! Hope you're having a great time!
     
  4. SadShadyBoi

    SadShadyBoi

    Joined:
    Oct 9, 2020
    Posts:
    10
    So I can't use the buffer data in update as I Release the buffer each time I make a new VFX Graph object in my game.
    Because of that I need to somehow save all the data I need in initilize.

    I have found a workaround for the problem I had which is a hacky way to do it. I set my bool int to texIndex (as I do not use a flipbook for my particle texture) and later I use it to update the particles. This way it works.
    upload_2022-12-25_19-46-52.png

    If anyone has a better way of doing it or if my way of thinking is flawed please let me know. I'd like to learn a bit more.
    If not I will set the thread as solved tomorrow.
     
  5. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,313
    If you released the buffer then how graph is supposed to sample it? When particles are initialized you sample buffer, it exists, but next frame you released it, but you still use it in the update.
    In this case you must either store all required data in particles while initialized (like you did with texIndex) or do not release buffer and keep it. You can also create new buffer and set it after releasing the old one, but allocating huge buffer every frame does not sounds like good idea, it would be better to reuse existing one.
     
  6. SadShadyBoi

    SadShadyBoi

    Joined:
    Oct 9, 2020
    Posts:
    10
    Yeah I thought so, thanks for the help!