Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Feature Request Particle access from custom compute shaders

Discussion in 'Visual Effect Graph' started by arkano22, May 27, 2022.

  1. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    Hi all!

    This is my first contact with VFX graph, it all works really well. However I immediately hit a roadblock: I want to control particle emission from a custom compute shader, and I cannot find any mention of this anywhere.

    I initially thought this would be trivial to do, since VFX graph uses compute shaders to perform the simulation so particle data must lie around in compute buffers somewhere. Exposing these to users seems natural. My current workaround for this is to roll my own compute-based particle system, but that's wasteful given that there's a built-in one already.

    Is this even possible, and if not, is it a planned feature?

    kind regards,
     
    Nobuu-Nakata likes this.
  2. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,296
    Currently there is no way to read this buffer, however there is planned feature to allow access to particle data: https://portal.productboard.com/uni...tribute-buffer-read-access-from-outside-graph
    I recommend to vote it + add description of your usecase, so devs can take into account when implementing.
    Actually what do you need? Possibly there is slight chance to find other solution, maybe graphics buffer?
     
  3. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    Thanks! Just voted for it and added this description of my use case:

    "I have a compute-based fluid simulator, and want to implement foam (passively advected particles) by emitting VFX particles from a custom compute shader, and setting their velocity from another custom shader."
     
  4. VladVNeykov

    VladVNeykov

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    550
    Hey @arkano22 ,

    We added in 2021.2 Graphics Buffer support, which can also be used alongside compute shaders.
    As @Qriva said, you can't read (yet) the VFX particle data and send it to a compute shader, however if you'd like to control the simulation via your compute shader and send the data directly to the VFX Graph, then you can.

    There's a project in this post which contains among other things a SimpleExamples scene with a few simple ways of using Graphics Buffers, including one where you are binding it to a compute shader:

    If I remember correctly, there's some basic size, color, or position animation which is done in a compute shader and the VFX Graph is just being used for rendering (though you can add more logic on top of that within the VFX Graph as well).

    Maybe this will be something you can use in your scenario?
     

    Attached Files: