Search Unity

Question VFX Graph and Depth of Field in URP

Discussion in 'Visual Effect Graph' started by marcnon, Mar 15, 2023.

  1. marcnon

    marcnon

    Joined:
    Sep 2, 2021
    Posts:
    7
    Hey Guys,

    i am trying to get the depth of field (volume effect) running with the VFX Graph Particles. As i understood there is a problem with the transparency, when i have opaque particles it works. But i want to have additive particles. Is there a change to achive that for transparent particles?

    Thanks!
    Cheers.
     
  2. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,314
    Assuming you want to create some volumetric effect from particles, what exactly is the problem?
    I mean, if you want them to be additive it means they do not blend/override each other, but instead color is added, so if you have red and green particles on top of each other the order should not matter, you just end up with yellow anyway.
     
  3. marcnon

    marcnon

    Joined:
    Sep 2, 2021
    Posts:
    7
    Hey Qriva,

    the problem is that the additive particles always be blurred completely. So the focus distance does not work there. Its like they dont provide any depth information. When i make the particles oqaque it works, but the visual result does not work for that case.


    Screenshot (165).png Screenshot (166).png
     
  4. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,073
    Your graph on the picture is so small that nothing can be read from it.
     
  5. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,314
    I might be wrong, but I think depth of field requires depth buffer to work correctly, so the only way might be to enable Z-write in the output of the graph. Opaque works as it writes to depth by default, while transparent does not, however if you enable zwrite for additive I am not sure it will look the way you want. You need to try, it might be worth to experiment with z-test too, so they fill depth buffer, but still render on top of each other.
     
    marcnon likes this.
  6. marcnon

    marcnon

    Joined:
    Sep 2, 2021
    Posts:
    7
    Yes i thought so too. What i am missing here in the VFX Graph are the Graph Settings. Shouldn`t they supposed to be in the vfx graph editor window? There was once something like a graph inspector with the graph settings. I am here in unity 2023 with vfx graph 15.02.

    I suppose there should be the options to enable z-writing etc.
     
  7. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,314
    Any node you select in vfx graph window has standard inspector like any other game object.
    Click the output context and check inspector.
     
    marcnon likes this.
  8. marcnon

    marcnon

    Joined:
    Sep 2, 2021
    Posts:
    7
    Screenshot (167).png

    Nice one. That did the trick. Enable Z Write Mode and put Z Test Mode To "Always".
    Now i can adjust the focus distance, the picture underneath shows the foreground to be sharp and the background to be blurry.

    Thank you!