Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

VFX Grass Sample - How to Ignore Velocity & Alpha

Discussion in 'Visual Effect Graph' started by dyburke, Feb 4, 2022.

  1. dyburke

    dyburke

    Joined:
    Nov 11, 2012
    Posts:
    15
    Hi,

    I've been struggling to recreate something that's done within the VFX Grass Sample project. In that project, they use the built in 'velocity' and 'alpha' values of a particle system to carry info across frames. However, when the particle system runs we never see the system use these values as you might think it would; velocity never introduces movement to the particles and alpha never seems to disturb the visibility of the particles. I have attempted to do the same sort of thing in a new graph and can't reproduce it; my particles always respond to the fact that I put data in velocity and often disappear and reappear based on the value in alpha.

    How is this graph ignoring these values so that we can use them for other information? The notes in the graph describe using velocity/alpha, but not how that doesn't interfere with the systems simulation.
     
  2. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    804
    Particle attributes are usually used by simulation, for example when you set velocity somewhere, it will update position like described in Attribute Usage and Implicit Behavior section. However it can be disabled in Update block and this way you can do whatever you want with velocity attribute. In your case you want to use alpha, but it is used by default in output shader. To overcome this you can do one of two things - you can use custom shader or reset alpha directly in output.
    By reset I mean to set alpha attribute to 1 - if you do this in output, it will not override this value forever, but only during rendering just to feed default shader.
     
  3. dyburke

    dyburke

    Joined:
    Nov 11, 2012
    Posts:
    15
    Qriva! Thank you so much! I just found the "Update Position" option in the inspector when the Update context block is selected. Still throws me off to find options in the inspector instead of somewhere in the graph window, but I had no idea the contexts had options as well.

    I'm trying to use alpha as a rolling number over many frames so I'm not sure resetting it will work, but I'll give it a go. In any case, I'm pretty sure I can get by using the 3rd component of velocity for the value I'm storing in alpha.

    Thank you again! You swiftly put an end to such a long saga!
     
  4. JulienF_Unity

    JulienF_Unity

    Unity Technologies

    Joined:
    Dec 17, 2015
    Posts:
    284
    Hi, if you need to read/write/store custom data per particle in your system, you should use custom attributes instead which are meant for this. A custom attribute is defined by a name and a type and can be written with Set Custom Attribute block and read with Get Custom Attribute operator. (Note that this is marked as experimental feature so you need to have the checkbox enabled in your VFX preferences)

    https://docs.unity3d.com/Packages/c...@10.8/manual/Operator-GetCustomAttribute.html