Search Unity

Feedback Wanted: Visual Effect Graph

Discussion in 'Visual Effect Graph' started by ThomasVFX, Oct 21, 2018.

Thread Status:
Not open for further replies.
  1. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    569
    Think of it the other way round. You want to derive the UV from the particle ID.

    Something like:

    Code (CSharp):
    1.  
    2. u = ID % width;
    3. v = ID / width;
    If you use the built in "Set [property] from map" blocks then "sequential" and "random per particle" are both deterministic and should work.
     
  2. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    @o2co2 I don't know the reason in your particular case, but couldn't you just add a size multiplier to the output, and adjust it until the gaps are not visible.
     
  3. bjedlowski97

    bjedlowski97

    Joined:
    Feb 13, 2018
    Posts:
    46
    How does one get the vfx graph to simulate in world space like the regular particle systems, nothing i try seems to work. It only gets the system stuck at the origin doing nothing
     
  4. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    569
    This was also asked a page or so back. The answer is L/W toggle button but there's an extra step I've forgotten (I think you might have to get/set position). I keep meaning to try it and post the answer here (or find the original post that answers this).

    (Dear god do the VFX graph docs need improving)

    (And dear god we need a subforum for the VFX graph rather than a 19 page thread! Is it really that hard to add a subforum?)
     
    protoben likes this.
  5. Onigiri

    Onigiri

    Joined:
    Aug 10, 2014
    Posts:
    486
    Is it possible to get attributes of the particle with specific id?
     
  6. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    @Onigiri no, I don't think so. There's no nodes for that at the moment.
     
  7. bjedlowski97

    bjedlowski97

    Joined:
    Feb 13, 2018
    Posts:
    46
    If you could find the answer that would help me a bunch please. I have switched the local to world and done set posisitons but it still sticks to the origin
     
  8. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    569
  9. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    @bjedlowski97 @andybak It's also important where you do it - the effect is not same if you try to set position in Update, instead of Initialize, if I remember correctly particles will pile up to same spot if you use Update.

    EDIT: and you could of course use a position binder, too... I think it works just fine.
     
    Last edited: Nov 30, 2019
  10. Kirsche

    Kirsche

    Joined:
    Apr 14, 2015
    Posts:
    121
    When you press Space on the update context, where are the trigger event nodes supposed to be? They don't show up for me. However I'm able to copy/paste them from default systems.
    Tried with fresh empty project and HDRP 7.1.5.

    Anyone else with this issue?
     
  11. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    @Kirsche Events should be under GPUEvent section in the middle of the popup if you try to add blocks to the Update context. I'm pretty sure I had those on 7.1.5 all OK, but I updated to 7.1.6 a few days ago when that 2019.3.0f1 was released.

    And those Event nodes you place on the canvas are under Create Node/Context.
     
    Kirsche likes this.
  12. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    569
    @Kirsche Turn on "experimental nodes" or similar (search this thread for "experimental")
     
    Olmi and Kirsche like this.
  13. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
  14. bjedlowski97

    bjedlowski97

    Joined:
    Feb 13, 2018
    Posts:
    46

    Attached Files:

  15. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    @bjedlowski97 It does work. I tried it a few days ago as the subject seems to be recurring here. Your bounds is set to world? In the example it was Local. Let me check my test scene.

    EDIT: I got it set up like this:

    particles_spawn_in_world_space.png

    And I just tried and that bounds (W/L) doesn't seem to have any effect on the spawing, at least not on the level that it would make them appear at 0,0,0. If I move my VFX source around the screen, particles do spawn at that location.

    Have you tried this super simple setup in a clean graph? And are you sure you're not doing anything else later in the graph, like in the output node. Remove everything unnecessary when testing something that doesn't like work :).
     
    Last edited: Dec 2, 2019
  16. zeekindustries

    zeekindustries

    Joined:
    Jun 4, 2010
    Posts:
    19
    Hey @andybak Thanks a lot for the help! I was trying out this idea but then I figured that the result would not necessarily plug into the "Set [property] from map" blocks as it is already sampled. So I'm a little bit puzzled as how the correct connection should be. Another quick question would be the value of width, would that be the total number of points from the pCache or is it converted to a squared texture when it is sampled? I'm attaching an image with what I understood on sampling the pCache as a texture2D.

    Thanks a lot for all the help!
     

    Attached Files:

    Last edited: Dec 4, 2019
  17. CPerron

    CPerron

    Joined:
    Dec 3, 2019
    Posts:
    4
    Hello!
    Is it possible to sample the vertex colors of a skinned mesh right now?
     
  18. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    Hi @GeneralSaucisse,
    No, there's no support for skinned meshes at the moment. You would need to write that code yourself outside of VEG and then bring in the data.
     
  19. CPerron

    CPerron

    Joined:
    Dec 3, 2019
    Posts:
    4
    Ok, thanks for the reply! I will try to figure this out. If you know any resources or links on how to achieve that I would greatly appreciate it!
     
  20. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    @GeneralSaucisse Check RenderTextures and how you could write your data to one. Then you just have to build some process where you get your vertices, take their positions, write them to a RenderTexture, then set that texture to VEG and finally sample the positions from that texture.
     
  21. pbritton

    pbritton

    Joined:
    Nov 14, 2016
    Posts:
    160
    Someone posted earlier the option to use a custom shader using Shadergraph in VFX graph but that option is simply not available in 7.15 or 7.16. Am I missing something?
     
  22. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    569
    Olmi likes this.
  23. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    @GeneralSaucisse also a custom property binder might work just fine, no need to use compute shaders if you need just a few vertices. Although I'm not sure if the update rate is smooth with those. I imagined it was somehow uneven. But it would be easier to write positions with binder, just do it all C# as long as the SetPixels doesn't bog down the performance. I posted a video of a simple example I made and some tips a while ago in this thread.
     
  24. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    @pbritton Yes you have missed something - You need to go Preferences/Visual Effects and enable Experimental Operators/Blocks. And I think you have to force that vfx graph to save, adjust some values etc. and save project, I'm not 100% sure what does it but then you see that option pop up in your existing quad output etc.
     
    pbritton likes this.
  25. pbritton

    pbritton

    Joined:
    Nov 14, 2016
    Posts:
    160
    @Olmi Thank you very much. Is there documentation for these options and settings?
     
  26. CPerron

    CPerron

    Joined:
    Dec 3, 2019
    Posts:
    4


    Yes, I have checked this one out a little while ago, its great!
    But what I really want to do is use the vertex color data I made on my character skinned mesh in my vfx graph. I checked out the quick breakdown of Morgan from The heretic demo and how they use vertex color to control particles more precisely.
    I think Keijiro's Smrvfx is a great starting point but my skills in C# are not so developed just yet to figure out how to do it outside the VEG.
    I tried looking up custom render textures but there is not many resources I found that demonstrates what I need and I don't really need to have it updated every frame either. Maybe I'm looking a bit too far.

    See what I mean here at 11:45 :
     
  27. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    Probably not, I think that experimental feature was only mentioned earlier in this thread by the developers.
     
  28. maxscanlab

    maxscanlab

    Joined:
    Aug 17, 2018
    Posts:
    1
    Hello! I would find it very useful to be able to manually choose the position of the Flipbook, either inside the Flipbook player or in the Particle Quad settings. With that feature someone could control the flipbook by different parameters such as distance from camera. Basically I would like to produce an effect where the texture of the particle quad is changing depending of the distance from the camera. Is there a way to do it already? Cheers!
     
  29. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    @maxscanlab Just look at the existing nodes? You can definitely build that kind of setup.

    - Use Set Tex Index to set the index.
    - To get an index, you can measure distance to the camera.
    - To access camera, use Main Camera node and measure distance from the camera to particle position.
    - Or provide the distance value from outside using an exposed parameter.
    - Then normalize the distance value to a desired range (your frame count.), convert to uint. Use 1D sprite array if you don't want to handle 1D->2D indexing.

    Just like with coding, there's no pre-cooked solution for every specific case.
    Shouldn't be too hard to do if you put some thinking into it? :)
     
  30. bjedlowski97

    bjedlowski97

    Joined:
    Feb 13, 2018
    Posts:
    46
    Does anyone know how to get a particle to send collision callback messages? I'm using OnParticleCollision to check if the player is hit by them, and can't seem to find a setting like in the old Collision module.
     
  31. cfree

    cfree

    Joined:
    Sep 30, 2014
    Posts:
    72
    I think i catch a bug with the VFX Graph (very strange behavior).

    I am following a simple Brackeys tutorial on make a lit smoke VFX... so far so good, until i select the "Lit Quad Output" node and change the values in the Use Base Color Map (from Color and Alpha to Alpha).

    Then, my VFX started to render weirdly, and i could not back to the previous behavior, even setting the values to the original again. The only way is deleting the "Lit Quad Output" node and re-creating it.

    The attach image is the smoke before the change in the left and after the change in the right.
     

    Attached Files:

    • vfx.png
      vfx.png
      File size:
      820.3 KB
      Views:
      516
  32. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    @cfree did you try saving your project, re-opening VEG window, re-starting Unity? Haven't seen that happen myself, but if it's repeatable on latest VEG version, maybe submit a bug report?
     
    cfree likes this.
  33. JulienF_Unity

    JulienF_Unity

    Unity Technologies

    Joined:
    Dec 17, 2015
    Posts:
    326
    It seems to be because the texture was reinit to "default particle". So what you see is basically portion of the default texture because you're using a 8x8 flipbook on it. Just setting the right smoke flipbook texture in the base texture map should fix the issue.
     
    cfree and Olmi like this.
  34. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    (umh I guess my eyes were too tired to see that it's flip book...)
     
  35. cfree

    cfree

    Joined:
    Sep 30, 2014
    Posts:
    72
    Thanks a lot for the quick response!!

    Indeed this is the problem... i have a flipbook on the "Base Color Map", but this field is removed when i change the "Use Base Color Map" to "Nothing"... then when i change again to "Everything", the field appears again, but it resets the info to "DefaultParticle" instead of my previous flipbook.

    Not sure if this behavior is the best, but at least now i know what to do.

    Thanks a lot!
    PS.: VFX Graph is so awesome! Congrats to the team! Starting to use it a lot, new questions will arise soon ;)
     
  36. discofhc

    discofhc

    Joined:
    Dec 18, 2017
    Posts:
    47
    Guys...
    Please, i need that my VFX "gets affected" by the movement of its game object... in the default Particle System, i simply change the "Simulation Space" from "Local" to "World"... how can i do this with the VFX Graph?

    Thanks.
     
  37. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    @discofhc See my post earlier on this page (with image.) It's been answered earlier in this thread if you searched for it.
     
    discofhc likes this.
  38. discofhc

    discofhc

    Joined:
    Dec 18, 2017
    Posts:
    47
    Missed it... great!!

    Thanks!!
     
  39. wahntin

    wahntin

    Joined:
    Sep 17, 2019
    Posts:
    83
    I'm using VFX with the URP.

    I can't find a way to change the render queue order of VFX. It seems always to be rendered around 3000?

    Looks like the problem is two-fold:

    1. For transparent meshes I have to set them to 3000 or below, this is kind of annoying, but something I may be able to work-around.
    2. Particles are always drawn after the VFX, except when I set the order in layer to -1 or below. In this case the particles are drawn before my water, so this is not an option.

    How can I make VFX render at a later point in time? Is there an overview of when VFX are rendered in the URP? I couldn't find details on this.
     
  40. o2co2

    o2co2

    Joined:
    Aug 9, 2017
    Posts:
    45

    What causes this?
     
  41. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    569
    Does the effect change/disappear when you zoom in?

    Looks like a moire pattern between the particle grid and screen pixels.
     
  42. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    @o2co2 I don't know what causes it but when you create a sequential positions, but those distances don't exactly match. i.e. like having 100x100 grid of 1m cubes. But, it's easy to add a multiplier to fix the gaps. Maybe I have overlooked something in the settings but that's how I've fixed that issue. That moire pattern style thing doesn't show much if you get the gaps closed.
     
  43. comomomo

    comomomo

    Joined:
    Feb 16, 2014
    Posts:
    12
    I've been having trouble getting ResetOverride(string parameter) to work in my project. I switch VFX assets out at runtime and have been having trouble with parameters sticking around after they should have been reset. I tried going through parameters that had been set and running ResetOverride on them -- when I print their values they reflect the defaults but the inspector doesn't update (nor does the effect in the scene). It's like my reset is never committed in the graph. Has anyone else had this problem?
     
  44. PaulDemeulenaere

    PaulDemeulenaere

    Unity Technologies

    Joined:
    Sep 29, 2016
    Posts:
    154
    Thanks for reporting this issue, I reproduced it using 2019.3f3 : the "ResetOverride" restores the internal value but it doesn't update the serialized property (see attached gif).

    We filled a bug report if you want to track it : https://issuetracker.unity3d.com/product/unity/issues/guid/1206890/

    Meanwhile, a workaround is possible modifying directly the SerializedObject but it only works in editor and it requires a lot of code (this is how the VisualEffect inspector authors the component).
    Alternatively, you can delete and recreate the VisualEffect component, it will not carry the previous exposed parameters.
     

    Attached Files:

    Last edited: Dec 20, 2019
  45. dchamploo

    dchamploo

    Joined:
    Sep 14, 2017
    Posts:
    1
    Any chance of exposing the shader's blend parameters(BlendOp and Blend Mode) to be directly editable in the graph? right now the preset blend modes are kinda limited. thanks
     
  46. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,196
    I'm trying to create an effect where particles spawn nearby an object, in line of sight of the object, and move toward the object. So, if the object was in a room, I'd spawn particles within the room, but I wouldn't spawn any outside of the room, because there's no line of sight to that spot.

    I'm trying to figure out how much of this I can do in VFX graph, versus having to manually adjust things in code.

    As far as spawning particles goes, I assumed I would determine the next particle spawn position in code, via some raycasting to ensure line of sight, and then provide that position to the VFX graph, which it could use to spawn a particle. Does that seem reasonable? Or is there a built-in way to do this kind of thing in VFX graph?

    Making the particles travel towards the "center" point is simple, but making them die when they get there... I tried a Kill (sphere) node, but that doesn't seem to be doing anything. Is there a way to kill particles if they're within a certain distance of a position?
     
  47. CPerron

    CPerron

    Joined:
    Dec 3, 2019
    Posts:
    4
    Hey! Have you tried the Set Alive block? Use the property binder script to use the position of an existing game object in your graph and compare that position to the particle's. Then you can send the compare result to a Set Alive block.
     
  48. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,196
    I didn't know about that. I'll give it a try. I guess it's kind of just the inverse of what I was trying to do. Thanks.
     
  49. zeekindustries

    zeekindustries

    Joined:
    Jun 4, 2010
    Posts:
    19
    Hey guys!

    I'm trying to have my particles be oriented using the Look At Position, and for the most part it works as it rotates the particles to point into the proper direction, but I can notice that there's some angle compensation when rotating the camera, as if the particle is trying to face the camera.

    My question is if there's a way to have that compensation not happening at all.

    VFXGraph_LookAtPosition.gif

    I also tried this:
    VEG_LookAt.PNG
    But that will throw the following error:

    VFX_hexasphere_main : Exception while compiling expression graph: System.InvalidOperationException: The expression UnityEditor.VFX.VFXExpressionExtractAnglesFromMatrix is not valid as it have the invalid flag: InvalidOnGPU, PerElement
    at UnityEditor.VFX.VFXExpressionGraph.BuildMapper (UnityEditor.VFX.VFXContext context, System.Collections.Generic.Dictionary`2[TKey,TValue] dictionnary, UnityEditor.VFX.VFXDeviceTarget target) [0x0005b] in D:\03.KodanshaVR\08.AIL\unity\AIL02\Library\PackageCache\com.unity.visualeffectgraph@7.1.6\Editor\Compiler\VFXExpressionGraph.cs:174
    at UnityEditor.VFX.VFXExpressionGraph.BuildGPUMapper (UnityEditor.VFX.VFXContext context) [0x00001] in D:\03.KodanshaVR\08.AIL\unity\AIL02\Library\PackageCache\com.unity.visualeffectgraph@7.1.6\Editor\Compiler\VFXExpressionGraph.cs:146
    at UnityEditor.VFX.VFXGraphCompiledData.GenerateShaders (System.Collections.Generic.List`1[T] outGeneratedCodeData, UnityEditor.VFX.VFXExpressionGraph graph, System.Collections.Generic.IEnumerable`1[T] contexts, System.Collections.Generic.Dictionary`2[TKey,TValue] contextToCompiledData, UnityEditor.VFX.VFXCompilationMode compilationMode) [0x00022] in D:\03.KodanshaVR\08.AIL\unity\AIL02\Library\PackageCache\com.unity.visualeffectgraph@7.1.6\Editor\Compiler\VFXGraphCompiledData.cs:614
    at UnityEditor.VFX.VFXGraphCompiledData.Compile (UnityEditor.VFX.VFXCompilationMode compilationMode, System.Boolean forceShaderValidation) [0x005c3] in D:\03.KodanshaVR\08.AIL\unity\AIL02\Library\PackageCache\com.unity.visualeffectgraph@7.1.6\Editor\Compiler\VFXGraphCompiledData.cs:908 : at UnityEditor.VFX.VFXExpressionGraph.BuildMapper (UnityEditor.VFX.VFXContext context, System.Collections.Generic.Dictionary`2[TKey,TValue] dictionnary, UnityEditor.VFX.VFXDeviceTarget target) [0x0005b] in D:\03.KodanshaVR\08.AIL\unity\AIL02\Library\PackageCache\com.unity.visualeffectgraph@7.1.6\Editor\Compiler\VFXExpressionGraph.cs:174
    at UnityEditor.VFX.VFXExpressionGraph.BuildGPUMapper (UnityEditor.VFX.VFXContext context) [0x00001] in D:\03.KodanshaVR\08.AIL\unity\AIL02\Library\PackageCache\com.unity.visualeffectgraph@7.1.6\Editor\Compiler\VFXExpressionGraph.cs:146
    at UnityEditor.VFX.VFXGraphCompiledData.GenerateShaders (System.Collections.Generic.List`1[T] outGeneratedCodeData, UnityEditor.VFX.VFXExpressionGraph graph, System.Collections.Generic.IEnumerable`1[T] contexts, System.Collections.Generic.Dictionary`2[TKey,TValue] contextToCompiledData, UnityEditor.VFX.VFXCompilationMode compilationMode) [0x00022] in D:\03.KodanshaVR\08.AIL\unity\AIL02\Library\PackageCache\com.unity.visualeffectgraph@7.1.6\Editor\Compiler\VFXGraphCompiledData.cs:614
    at UnityEditor.VFX.VFXGraphCompiledData.Compile (UnityEditor.VFX.VFXCompilationMode compilationMode, System.Boolean forceShaderValidation) [0x005c3] in D:\03.KodanshaVR\08.AIL\unity\AIL02\Library\PackageCache\com.unity.visualeffectgraph@7.1.6\Editor\Compiler\VFXGraphCompiledData.cs:908
    UnityEditor.EditorApplication:Internal_CallUpdateFunctions()

    VEG_LookAt.PNG
     
  50. Cell-i-Zenit

    Cell-i-Zenit

    Joined:
    Mar 11, 2016
    Posts:
    290
    I think i found an error:

    the structure is as follows: I have an empty gameobject "root", which holds all my vfx graphs as childs.

    If i assign in code some textures to these vfx graphs, they work fine.

    Now the error comes if i disable the root object and in the same frame assign some textures. In this case the textures are not stored properly if i enable the object sometimes later...
     
Thread Status:
Not open for further replies.