Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

VFX Graph Sorting Order

Discussion in 'Graphics Experimental Previews' started by dancitron, Jul 9, 2019.

  1. dancitron

    dancitron

    Joined:
    Aug 7, 2017
    Posts:
    6
    Hey all!
    I'm building an explosion in VFX Graph with multiple different vfx graphs to simulate different aspects of the explosions. I'm having issues with the rendering order in which the effects will flip quickly back and forth in front of each other. Is there a way to set the render queue for the vfx graph? See below for a sample of the issue!
    Thanks in advance!
     
  2. VladVNeykov

    VladVNeykov

    Unity Technologies

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

    Depending on how you have structured your effect, you can try the following:

    To sort individual outputs within the same VFX Graph asset, select the graph in the project folder and in the inspector reorder the outputs:


    To sort separate transparent systems, you can change their Transparency Priority within the Visual Effect component:


    And of course, you can also sort transparent particles with each-other within the same output:


    Hope this helps!
     

    Attached Files:

    nicloay, Threeyes, Makkasu and 10 others like this.
  3. dancitron

    dancitron

    Joined:
    Aug 7, 2017
    Posts:
    6
    Awesome - thanks so much!
     
    VladVNeykov likes this.
  4. ju_my

    ju_my

    Joined:
    Mar 7, 2017
    Posts:
    23
    Hi, i have my vfx transparent particles rendering behind transparent objects but sorting with other particles systems is ok.
    Is there a way to sort particles with other shaders? Thanks
     
  5. VladVNeykov

    VladVNeykov

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    550
    Hi @ju_my, the transparency priority should work when sorting against other non-VFX transparent objects as well, as long as they are not writing to depth. If you are using HDRP, just make sure your transparent materials have Depth Write disabled.

     

    Attached Files:

    ZeHgS likes this.
  6. ju_my

    ju_my

    Joined:
    Mar 7, 2017
    Posts:
    23
    Hi, thank you for your response but I'm using URP, depth writing options aren't available.
    Also, may i ask you if you know if lit output are planned for urp?
     
    diesersam likes this.
  7. VladVNeykov

    VladVNeykov

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    550
    ZeHgS likes this.
  8. ju_my

    ju_my

    Joined:
    Mar 7, 2017
    Posts:
    23
    Okay well we juste have to wait.
    Thank you very much for your support!
     
    VladVNeykov likes this.
  9. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,092
    What about legacy renderer? In my game targets are stacked on top of each other and sorted using render queue. I'm trying to switch to VFX as old particles system have glitched trails. Is there maybe any manual way to switch whole render queue of VFX system to 4000 from 3000?



    I think I will shift all transparent materials to 2501 render queue, sort objects in 2502-2999 and keep vfx in 3000... Any better solution?

    Nvm added Render Queue myself https://forum.unity.com/threads/added-render-queue-to-vfx-graph-unity-2019-2.820749/
     
    Last edited: Feb 2, 2020
  10. SniperED007

    SniperED007

    Joined:
    Sep 29, 2013
    Posts:
    345
    When is the sorting coming for URP?
    It doesn't seem to be available/working yet in 2020.1
     
  11. VladVNeykov

    VladVNeykov

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    550
    Full URP VFX support is currently being worked on. There are a lot of items on the list: Lit shader support, camera buffer access, sorting, mobile support for compute-capable devices, etc. Some of the items we aim to land in the 20.2 release, others might take a bit longer into next year's release.
     
    ZeHgS likes this.
  12. Toylips

    Toylips

    Joined:
    Feb 15, 2013
    Posts:
    28
    Hi! I'm using 2019.4.. lts. And how to sort rendering for subgraphs? I have flames, sparks, and smoke graphs, so I did flamethrower using all like subgraphs. so smoke always above everything, but for FPS view it's better when smoke gonna be last.
     
  13. VladVNeykov

    VladVNeykov

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    550
    Hi @Toylips ,

    I don't think this is possible at the moment, but it does sound quite useful; we've added it to our backlog.

    In the meantime, it looks like the order is determined by when a subgraph was added, so maybe try adding the smoke effect first, and then everything else? (full disclaimer, tried this in the editor in HDRP, and it seems to remain after an editor restart, but this behavior is not heavily tested).

    If the suggestion above doesn't work for you, then the most reliably thing might be to add the various effects within a single VFX Graph as this supports output sorting.
     
    ZeHgS likes this.
  14. Toylips

    Toylips

    Joined:
    Feb 15, 2013
    Posts:
    28
    Hi @VladVNeykov ,

    I noticed that when others have flamethrowers, those graphs should be resorting somewhere in update, cause I can see them from all sides ) is it possible to sort using distance to the main camera?

    Thank you very much for your support!
     
  15. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,098
    The best solution I can imagine would be an option that allowed to generate VFX effect as normal transparent quads (sorted with other transparent objects in scene).
    Or sorted separately with other transparent objects inside bounds and other particles from other VFX that bounds are intersecting.

    Yes I know. Performance. But still having this choice would be awesome.
     
  16. VladVNeykov

    VladVNeykov

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    550
    Sorry, I didn't quite follow; is this for sorting between different flamethrowers altogether, or the different outputs within the flamethrower effect (i.e. smoke with fire)? If it's the latter, are you saying that the order changes for other's flamethrowers?

    The GPU sorting in the individual outputs sorts them based on distance, but that's per-particle. Otherwise, I believe the bounds of the VFX are used for sorting.
     
    ZeHgS likes this.
  17. marcrem

    marcrem

    Joined:
    Oct 13, 2016
    Posts:
    342

    Hi there, sorry to take this thread back from the abyss :p

    Is there a way to sort particles between 2 different outputs (graphs actually) but per-particle? I do not want to give the priority to graph A over graph B, I want the particles between the 2 systems to blend correctly. Here's an example:


    Thanks so much!
     
  18. VladVNeykov

    VladVNeykov

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    550
    Hi @marcrem,
    You won't be able to mix the sorting of particles in different systems as they are in separate draw calls. Your can try making the particles from the whirlwind base spread out and go larger the higher they go to make a seamless transition:
     

    Attached Files:

    ZeHgS and laurentlavigne like this.
  19. marcrem

    marcrem

    Joined:
    Oct 13, 2016
    Posts:
    342
    Hi, thanks for the answer, much appreciated!

    I see, so it's not possible. My issue is that I'm making a physically realistic simulation, and the cloud above the tornado is called a wall-cloud. It is independent of the tornado and has its own shape and behaviour. Here's an example:





    As you can see, the wall-cloud above is a much larger rotating cloud having its own behaviour, and the funnel that constitutes the tornado comes out of it. I do have control over the shape of my tornado and I can make it larger on top when needed.

    In your example, the tornado would be at the end of its life cycle so the wall-cloud is pretty much all gone.

    Scratching my head here as to how I could "cheat" my way into making it work. Any idea?

    Thank you again so much for your time.
     
  20. VladVNeykov

    VladVNeykov

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    550
    I see!

    Not sure if this will meet your needs, but you might alleviate the popping a bit if you set the priority at the Visual Effect component of the wall-cloud to be higher than the one of the funnel (the second example from this post in this thread) so it always draws on top. It should then always look like this from the side:

    This, however, won't hold very well when you are looking at it from below though.

    Alternatively, you can think of making the funnel be an actual opaque (or alpha cutout) mesh or at least alpha cutout particles, so you won't get the sorting issue. Something like this, but less stylized.

    You can still cushion it with some transparent VFX which will have the same sorting issue, but the main structure will be distinct enough to sell the illusion well without popping behind the wall-cloud.
     

    Attached Files:

    ZeHgS likes this.
  21. marcrem

    marcrem

    Joined:
    Oct 13, 2016
    Posts:
    342
    Thanks for your help, I appreciate it. So since it cannot be sorted between graphs for now obvious draw calls reasons, what makes it possible in engines like Unreal?

    Cheers
     
  22. marcrem

    marcrem

    Joined:
    Oct 13, 2016
    Posts:
    342

    Also another thing that makes me confused is this. I am using this asset here to create volumetric fog areas. The effect is made with ray-marching and works with transparency.
    https://assetstore.unity.com/packag...n-camera-effects/volumetric-fog-mist-2-162694

    It was obviously not working well with VFX graphs, but then I used this hack :
    https://forum.unity.com/threads/uni...ender-queue-to-vfx-graph-unity-2019-2.820749/

    I can now see my VFX graphs blend with the volumetric fog correctly, perfect!

    Now I can't believe there would not be anything I can do, even with the render queue added to my VFX graph. I feel like this defeats the purpose of GPU particles, if I can't at least have proper sorting between systems while other engines do it out of the box.
     
  23. VladVNeykov

    VladVNeykov

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    550
    The render queue can't help with this. The issue is quite common, we have two transparent objects (doesn't matter that they are particles) which are drawn separately. As an example, we can either pick the blue ring or the green square to be first. Out of the box, the green square cannot be in the middle unless the blue ring is split into 2, with one bit rendering before the green square and the other after.


    I'm not familiar with other engines to comment how easy it is to set it up there. It might require rendering of the VFX in a volume and then raytracing the result, or some other solution. We certainly have lots of things we still want to add to the VFX Graph, you can check out the public roadmap and submit new ideas.

    The original suggestion of using the same system and just splitting your logic should work in your scenario, but again apologies if I'm missing something. In a nutshell you can grab a segment of your particles and tell every nth particle to do something different.

    In this example, we split the particle pool into 2 (odd and even particleID), and then branch out and use that to control the behavior and look of our particles. The benefit of this is that all particles belong to the same draw call and can be sorted among each-other.

    Here's a quick (non-artistic :) ) example of this in action to show different shapes, behaviors, and colors:


    I've uploaded the asset here if you'd like to take a look.

    Hope this helps!
     

    Attached Files:

    Baloouis and ZeHgS like this.
  24. marcrem

    marcrem

    Joined:
    Oct 13, 2016
    Posts:
    342
    Yeah, that's exactly what we're doing here for the dust cloud at ground level, we're splitting the pool of particles and using a part of them for the rotating dust cloud near the ground.

    upload_2021-4-28_14-45-22.png

    It does work well. I'm probably going to end up including the wall-cloud to the same graph then, I just wanted to compartmentalize autonomous systems.

    Question: Won't I be forced to use the same texture for all my particles though?

    I am going to look at your .vfx though, it might help to compare how it was done.

    To conclude, I just want to say a huge thank you for taking the time to help. Pretty amazing support right there.
     
    Lex4art and VladVNeykov like this.
  25. VladVNeykov

    VladVNeykov

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    550
    You can use a flipbook and specify the TexIndex attribute for each part of the effect to pick the desired part of the texture.

    You're most welcome, good luck!
     
    ZeHgS likes this.
  26. Clamoxyl

    Clamoxyl

    Joined:
    Mar 4, 2015
    Posts:
    8
    Hi, I saw you were talking about z order in this thread. @VladVNeykov, I have this problem with my particle system in Unity 2020.3.10f1 using URP.


    https://i.postimg.cc/dQCNgFyC/particles-Wrong-Depth.gif

    As you can see, particles are rendering in front of the sprite even though the sprite's z is lower. Is there a solution here? I've been fiddling with the primitive output z options but nothing changes.

    Thanks!
     
  27. SniperED007

    SniperED007

    Joined:
    Sep 29, 2013
    Posts:
    345
    I see the sorting issue is still a problem in 2021.1.12f1, please tell me it's coming to 2021.2 ?!
    Currently VFX is pretty useless if you have more than one particle system (like smoke and blood etc.) as it just looks so broken.
     
  28. marcrem

    marcrem

    Joined:
    Oct 13, 2016
    Posts:
    342
    Indeed. My workaround that worked was to set the renderqueue in a script. Good luck if you need to blend them though.
     
  29. MathiasSeverinTrackman

    MathiasSeverinTrackman

    Joined:
    Mar 1, 2021
    Posts:
    5
    We are getting very close to 2022, any news on public render queue on shader graph vfx?
     
  30. VladVNeykov

    VladVNeykov

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    550
    Hi @MathiasSeverinTrackman ,
    From 2021.2 onward you can set up various sorting options in both HDRP and URP. If I understood your statement correctly, yes, this works as well for VFX Graphs using ShaderGraph in their outputs. Let us know if you are running into any issues!
     

    Attached Files:

    ZeHgS likes this.
  31. Red-Sprites

    Red-Sprites

    Joined:
    Jun 24, 2018
    Posts:
    8
    Please. Please.

    How do you get this type of code-

    GetComponent<MeshRenderer> ().material.renderQueue = 3002;

    -to work for VFX's in scripts.

    Like literally this tutorial, but for Visual Effects. Unity Mask 3D - YouTube
     
  32. alti

    alti

    Joined:
    Jan 8, 2014
    Posts:
    94
    I had a brain fart with sorting. Guys, if your VFX graph has more than one output, make sure to disable the ones you aren't checking the rendering order on. This way you can find which one is causing the issues with drawing.

    For me, I had a lit quad and an unlit quad rendering in the same VFX graph. I paid attn to the former, when it fact it was the latter that had a transparent render queue of "before refraction". I don't even know why it was that or even what it is. I put it back to default and the rendering went to as expected. Click your VFX output, and at the bottom of the inspector window, you'll see a transparent render queue dropdown option.
     
  33. LiamShannon

    LiamShannon

    Joined:
    Nov 8, 2021
    Posts:
    1
    I have been tooling around with the Priority and sorting layer options of my two VFX graphs that I want to change the render order of, to no avail. I set the value of one graph to 1, and it changes nothing. Any ideas why? How do I do this the right way.
     
  34. ZeHgS

    ZeHgS

    Joined:
    Jun 20, 2015
    Posts:
    117
    Thanks a lot for all your help in this thread, I really appreciate it! I learned some very important core concepts and couldn't have finished my effect without you!
     
    Last edited: Jun 2, 2022
    Fressbrett likes this.
  35. Fressbrett

    Fressbrett

    Joined:
    Apr 11, 2018
    Posts:
    111
    Hi everyone!
    I am using URP and its render features (material override) to have the player meshes drawn half-transparent when behind opaque objects.

    Now we have VFX parented to the player that give feedback to various events. Is it somehow possible to have these VFX also be drawn half-transparent when obstructed by opaque objects? I am unable to use the render features and its material override for that, since the VisualEffects do not use any materials I could override.

    What is the best approach here?
     
  36. Fressbrett

    Fressbrett

    Joined:
    Apr 11, 2018
    Posts:
    111
    For anyone having the same problem, we just figured out a solution that doesn't rely on any render features:

    Instead of spawning a single particle through the VFX graph, we now spawn two.
    The first one is just a standard opaque mesh.

    The second one is pretty much a copy of the first one, only that is has a custom dither effect on it, making it appear "half transparent". We want this one to render behind opaque objects, i.e. when our first particle is obstructed by something. To achieve this, we set the "Z Test" of its output node to "Greater" within the inspector - this causes this second particle to only render when behind opaque objects.

    Now there is still a problem persisting, and that is our transparent particle also renders infront of our opaque particle, no matter how we adjust our system render que within the VisualEffect (might be a bug with our Unity version 2021.2.12f1). However, there is a hacky workaround for that: We just offset the particle towards the camera by a short distance (0.5 units in this case), so that our half-transparent particle is actually a tiny bit "infront" of our opaque particle and as such doesn't render there, since it only renders when behind something.

     

    Attached Files:

    Last edited: Jun 28, 2022
    staring_at_foxes likes this.
  37. ngarces

    ngarces

    Joined:
    Jul 19, 2019
    Posts:
    4
    Something else worth mentioning in this thread. I had a somewhat related issue where the Z-Depth between particles in the emitter were not being ordered properly causing some lit quads further from the camera to be rendered in front of quads closer to the camera. The fix for this was to set the Z Write Mode to "On". This was almost an immediate fix, but it did result in the alpha to render in front of particles behind it cutting them out from the camera view. Turning on Alpha Clipping remedied this though. Luckily I didn't have any soft edges on my alpha so it was a straight forward fix! Hope this helps anyone running into this same issue.
     

    Attached Files: