Search Unity

Resolved How can I get all particles positions in VFX graph?

Discussion in 'Visual Effect Graph' started by alevjen, Oct 21, 2022.

  1. alevjen

    alevjen

    Joined:
    Sep 11, 2020
    Posts:
    11
    I'm tryig to create some boids in VFX graph. I thought it could be relatively simple, but I need ot know the position of all other particles to do avoidance etc. Is there an attribute for this?

    Also, any links or tips for VFX boids would be super helpful!

    Thanks
     
  2. OrsonFavrel

    OrsonFavrel

    Unity Technologies

    Joined:
    Jul 25, 2022
    Posts:
    192


    Morning @alevjen , at the moment in VFXGraph, Particles can't have access to other Particles Attributes such as Position, Velocity that would be required to implement a Boids algorithm.

    "Nearest Neighbor Search", and "Particles' Attributes Read" is on our list. So don't hesitate to vote for those feature in the VFXGraph Public RoadMap.
    In the meantime , VFX and Game is always about "cheating", or giving an illusion...
    So you could give the Illusion of a Flock.

    You can use a "GameObject" as a Target and Feed its position thanks to an "Exposed Properties".
    This will let you have a "Center" or "Target" vector for the First "Behavior Rules" of a Boid: "Attraction to the Center".
    This Center can be used as a “Force Attractor”. Look at the Block "Conform to Sphere" that could be a good inspiration for the first part of the Flocking Behavior.

    You could also use the "Forward Vector" of the "Game Object" as an “Exposed Properties” and use so that the Particles slowly Aligned to this vector.

    You also need some "Cohesion". Within a range Particles should Try to Match their Neighbor velocity.
    It will not be perfect but by playing with "Drag" force and "Low-Freq Noise" you could get the impression that they "move together".

    The third part , that is "Avoidance" is not gonna be possible without the Features described on Top.

    But If the Movement of the particles is Mostly driven by a "Low-Frequency " Noise, Drag, and Attraction to Center, you should get an impression of Flocking. It really depend on how close your camera is gonna be....

    Hope this helps a little. I will try to take a stab at this :)

    Also here are some links:
    Simulating Flocking with the Boids Algorithm
    Boids with a Fuzzy way of Thinking
    Flocks, Herds, and Schools: A Distributed Behavioral Model
    Steering Behaviors For Autonomous Characters
     
    Opaweynch and alevjen like this.
  3. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    569
  4. OrsonFavrel

    OrsonFavrel

    Unity Technologies

    Joined:
    Jul 25, 2022
    Posts:
    192
    Would you mind Sharing more infos about the Repo @andybak , you piqued my curiosity :)
     
  5. alevjen

    alevjen

    Joined:
    Sep 11, 2020
    Posts:
    11
    Thanks! This is super helpful. I don't suppose you have an ETA on the new features?

    If i'm implementing boids via shader graph and compute shader, can I still do collisions? i.e. not have the boids go through colliders in the scene. Are there any collision option in the VFX graph for this? I know in the old particle system it has a collision system built in.
     
    Last edited: Oct 23, 2022
    OrsonFavrel likes this.
  6. OrsonFavrel

    OrsonFavrel

    Unity Technologies

    Joined:
    Jul 25, 2022
    Posts:
    192
    Sorry I don't have an ETA on those Features.What I can say is that they’re both really important as they are building blocks that should unlock very cool possibilities.

    Regarding Collision:
    At the moment VFXGraph simulations are GPU only. This means that we can’t access Physics and Colliders.
    That being said, we still have some “collisions” with VFXGraph.
    You can find different “Collision Blocks” in the Update Context.
    Collision Box
    Collision Plane
    Collision Cone
    Collision Sphere

    Collision Signed distance Field
    Collision Depth Buffer

    So thanks to “VFX property Binder” Script and those modules you should be able to collide with “game Objects” in your scene . For colliding with a lot of game Objects, it can be useful to look at “Baking an SDF”(signed distance Field) or try to collide with the DepthBuffer.

    Hope those leads help.
    Have a great day.
     
  7. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    569
    Here's all the information I have on that repo: "I typed VFX Graph Boids into Github search".

    ;-)
     
    Flannelot and OrsonFavrel like this.