Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Vfx graph question.

Discussion in 'Graphics Experimental Previews' started by Danua, Jan 6, 2019.

  1. Danua

    Danua

    Joined:
    Feb 20, 2015
    Posts:
    197
    Does vfx graph have analogue of rate over distance? I've found something called "Spawn over distance", but it seems not working.
     
    Last edited: Jan 6, 2019
  2. ThomasVFX

    ThomasVFX

    Joined:
    Jan 14, 2016
    Posts:
    45
    Hello!

    Indeed the spawn over distance is your way to go if you need to spawn based on a moving position. Although it does not seem to work at first it needs to record a moving position every frame to compute the amount of particles to spawn: For instance the world position of the game object that holds the component.

    The reason about this behavior is you do not necessarily need to use the owner position (for instance you would probably want to spawn based on a procedurally animated position)

    upload_2019-1-8_10-8-43.png

    Basically it expects a value that changes every frame to perform the computation. So providing the 0,0,0 local position every frame does not do much, but instead using a Change Space to convert the value into world space will do what you expect.

    Also, this node does set two SpawnEvent attributes : position and old position, really useful if you need to distribute the particles in between the position and the previous position.

    upload_2019-1-8_10-9-54.png

    I've attached this sample effect so you can try it out. (It's been made on the 4.6.0-preview of the package)
     

    Attached Files:

  3. Danua

    Danua

    Joined:
    Feb 20, 2015
    Posts:
    197
    oh sweety. ty
    here is current state my particles
     
  4. Danua

    Danua

    Joined:
    Feb 20, 2015
    Posts:
    197
    There is two another question.
    1) I got wierd behaviour when use flipbook player with 7x7(odd atlas size 3x3 5x5 f.e) atlas particles, sorta lagging twitching
    2) How to randomly pick frame from flipbook? Like in shuriken? I've got 4 debris pict in flipbook atlas, and i want to pick that one, randomly per particle
     
  5. JulienF_Unity

    JulienF_Unity

    Unity Technologies

    Joined:
    Dec 17, 2015
    Posts:
    324
    We'll take a look about flipbook texture with odd dimensions to see if we can reproduce the issue.

    Flipbook index is actually an attribute called "texIndex" (may be renamed in the future). So if you want to select a given frame randomly per particle just set the texIndex attribute to be random in the init context of your system. In you case a random number between 0 and 4 and set uv mode to be flipbook without interpolation in your output.
     
  6. VladVNeykov

    VladVNeykov

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    550
    Hi Danua,

    I can't reproduce the issue you are experiencing with the odd atlas sizes (tried 7x7 with different flipbook player speeds and outputs, as well as both the flipbook and flipbook blend mode). The flipbook player math is quite simple (texIndex += FrameRate * deltaTime;) so there really shouldn't be anything flipbook size-dependent.

    I'd recommend checking if you may not be adjusting the texIndex attribute somewhere else in the graph. If you are still experiencing an issue, if you can share a video of the issue or the VFX asset itself, we can take a look.
     
  7. Danua

    Danua

    Joined:
    Feb 20, 2015
    Posts:
    197

    Sorry for too long wait. I've try catch that bug whole that time, but i can't, it's always flickering when use uneven texture flipbook size
     
  8. id0

    id0

    Joined:
    Nov 23, 2012
    Posts:
    455
    I have that bug too! It's only appear when exit edit window, or enabling "Force runtime" When you edit effect, everything looks normal. And it have "burst once" (I make explosion so it need play only once)
     
    Last edited: Jan 29, 2019
  9. Crouching-Tuna

    Crouching-Tuna

    Joined:
    Apr 4, 2014
    Posts:
    82
    Hi, i'm trying to make a brush stroke type with this without using the "setting position with random lerp" in Initialize.
    This means i want Velocity Threshold to be say, 1. And Rate per Unit to be:
    Distance (current Pos, old Pos).
    But (i think) since the Spawn Over Distance node sets the oldPos at the "end" of the node, i can't use the oldPos value to be used inside the node.
    If i set RatePerUnit to like 50, and Velocity Threshold to 1, it does work like a brush but i want to control when i'm moving slow, to spawn accordingly.
    Oh and i'll use Line Output and use oldPos as targetPos; the main reason why oldPos has to accurately be the pos of the previous particle.
    If all this is not possible, then i'm thinking of setting a Vector3 from C# called "oldPos", in Update, and let some calculations for distance compared to that, and use a ConstantSpawnRate instead based on the distance.
    Attached is what i'm trying to do (and some traces of failed attempts..)
    upload_2019-8-28_15-5-35.png
     
  10. ankush85698

    ankush85698

    Joined:
    Aug 30, 2019
    Posts:
    1
    Very helpful thread...
     
  11. kkrg001

    kkrg001

    Joined:
    Mar 6, 2019
    Posts:
    35
    Thank you for the wonderful sample!
    It was very helpful.

    This sample interpolates the emitter position for each frame and seems to fill the random space between them with particles, but a gap like a picture was created with a fast bullet. Is there any good idea to solve this?
     

    Attached Files:

    • 06.png
      06.png
      File size:
      392.6 KB
      Views:
      851
  12. gambon0120

    gambon0120

    Joined:
    Sep 13, 2019
    Posts:
    2
    Does this still work in the latest version of unity? I can't get anything to show on screen with the example
     
  13. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    569
    Nominating this post for the "add this to the docs please" award...

    I wished I'd bookmarked all the similar head-slapping "ah! so that's how it's meant to be used!" posts I'm seen in the VFX graph threads. I could have put together some half-decent docs of my own by now ;-)
     
  14. ysawamura

    ysawamura

    Joined:
    Jan 17, 2020
    Posts:
    1
    Hello, the trail effects such as lower using the VFXgraph, please tell me how to create?

     
  15. boo1ean

    boo1ean

    Joined:
    Mar 31, 2020
    Posts:
    1
    1. Set "Space" to "World" in "Initialize Particle"
    2. Add "Set Position" block to "Initialize Particle" and set it to local 0,0,0
     
    FlightOfOne likes this.
  16. ManaWorksKirill

    ManaWorksKirill

    Joined:
    Oct 15, 2019
    Posts:
    14
    How could I increase a number value over time, is there a way to add 1 each frame until the value reaches 10 and then stop?
     
  17. VladVNeykov

    VladVNeykov

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    550
    Hi @ManaWorksKirill,
    You can do something like this: create a custom attribute (named here MyValue) and set it in Initialize to 0 and increment it with a Set Custom Attribute block in Update (you can change it's mode to Add in the inspector). You can then use a GetCustomAttribute node to check for the current value of MyValue, compare to see if it's less than 10, and if so, add 1 to it in Update.
    upload_2020-5-7_18-6-39.png

    If you want this to happen per second, and not per frame, just multiply the result of the Branch node by Delta Time.

    Note: to use custom attributes, you need to enable the experimental Operators/Blocks in Preferences - Visual Effects.

    Hope this helps!
     
  18. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    569
    Hi, @ManaWorksKirill

    Just to add to @VladVNeykov 's answer - there might be a simpler way to achieve what you want - if we knew what your actual end goal was.

    (this is known as the XY problem - https://en.wikipedia.org/wiki/XY_problem - and I find it's always worth asking for the implied question behind the question actually being asked)

    For example if you just want a number cycling from 1 to 10 per frame then taking currentFrame % 10 would do the trick.
     
    VladVNeykov likes this.
  19. ManaWorksKirill

    ManaWorksKirill

    Joined:
    Oct 15, 2019
    Posts:
    14
    Thank you so much will test it out now!
     
  20. ManaWorksKirill

    ManaWorksKirill

    Joined:
    Oct 15, 2019
    Posts:
    14
    Very new to this so I apologize for dumb questions. I'm using output mesh blocks in the VFX graph but they don't come with a spawn, initialize and update blocks to animate them, for example, to change the size or change the material attributes assigned to them I need create a way for change over time to happen. I was trying to animate the exposed variables on the timeline but it doesn't always work for me. The triggering doesn't happen or not at the time I expected. So I want to do all the animation in the graph and have it happen after the VFX is spawned in the world. Thank you so much for looking at this.

    -Kirill
     
  21. VladVNeykov

    VladVNeykov

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    550
    Can you use an Output Particle Mesh or Output Particle Lit Mesh to animate it?
    Output Meshes are, as you mentioned, not connected to anything, but you can use Output Particle Mesh to animate the mesh as a particle a bit more easily.
     
  22. ManaWorksKirill

    ManaWorksKirill

    Joined:
    Oct 15, 2019
    Posts:
    14
    Thank you so much for quick reply, there is no custom material option in particle mesh block. upload_2020-5-7_12-37-16.png upload_2020-5-7_12-38-3.png
    I have a custom scrolling texture material that I would like to use.
     
  23. ManaWorksKirill

    ManaWorksKirill

    Joined:
    Oct 15, 2019
    Posts:
    14
    So sorry for asking this question but how may I create a custom attribute (named here MyValue) and set it in Initialize to 0. When I try to create a float these are my options: upload_2020-5-7_12-40-44.png
    What should I looking for?
     
  24. ManaWorksKirill

    ManaWorksKirill

    Joined:
    Oct 15, 2019
    Posts:
    14
    A great option in my opinion is the age over lifetime node. I would expect the mesh object start growing from size zero, but it just disappears, why? upload_2020-5-7_13-7-5.png

    Do I need to somehow convert the data it outputs in to something compatible? I've tried the remap node and clap, no luck yet.
     
    Last edited: May 7, 2020
  25. ManaWorksKirill

    ManaWorksKirill

    Joined:
    Oct 15, 2019
    Posts:
    14
    Periodic vector animation works but it's on a repeat is there a way to set it up to play once?
     
  26. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    569
    Why is everyone posting questions in this thread rather than creating their own thread for their question? That's called "hijacking" in my book. :)

    It seems to happen a lot in the Unity forums so maybe it's a UI problem - but this is a fairly standard message board.

    Are you all so young you didn't cut your teeth on crappy PHP forums??

    Maybe more active moderation would help (split posts, move posts, rename posts etc...)

    And why is the title of this post "Vfx graph question"! the title should be the question otherwise *every* post would have a title like this...

    Sigh...
     
    bunnybreaker likes this.
  27. VladVNeykov

    VladVNeykov

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    550
    You have to enable the experimental operators/blocks:
    upload_2020-5-8_13-47-35.png

    This will also expose the Shader Graph option in your particle outputs. (when you create a new sahder graph, use the VFX Shader Graph option.)

    This is the age of a particle. The mesh output doesn't age, so this will always return 0. You can use Total Time instead, or expose a property in blackboard , assign it to your mesh output scale, and then you can control the size from the inspector / via script.
     
  28. ManaWorksKirill

    ManaWorksKirill

    Joined:
    Oct 15, 2019
    Posts:
    14
    So sorry, I will wrap this up and make a new thread, thank you for speaking up and helping me be less ignorant. Thank you!
     
    Last edited: May 8, 2020
    andybak likes this.
  29. ManaWorksKirill

    ManaWorksKirill

    Joined:
    Oct 15, 2019
    Posts:
    14
    Thank you so much for taking the time to answer!
     
    MrMahgu and VladVNeykov like this.
  30. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,068
    No - It is a Unity problem of not having proper documentation.

    When unity staff shows in the thread it is obvious that it is the best source of information.
     
    qsleonard likes this.
  31. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,221
    Your graph is connecting distance multiplier to rate per unit, which is also distance so you're controlling particle spawn by distance^2. I don't think that's right.