Search Unity

render all the particles with same transparency

Discussion in 'Visual Effect Graph' started by asger60, Feb 13, 2020.

  1. asger60

    asger60

    Joined:
    Mar 27, 2013
    Posts:
    45
    Hey
    Is it possible to render all the particles transparent but not have their transparency overlap? It should look like they're one single (smoke) object.
    Check the attached screenshot for reference.
    Screenshot 2020-02-13 at 22.04.44.png
     
  2. ThomasVFX

    ThomasVFX

    Joined:
    Jan 14, 2016
    Posts:
    45
    You can achieve what you want using two different methods.

    upload_2020-2-14_14-28-46.png

    1) Only with Visual Effect Graph, you can render your effect using two outputs, a first that will write only depth but not alter color. In order to do that you can use an additive blend mode, write 0,0,0 so you don't alter color, but instead enable depth write. In the other one, you render the exact same particles, as alpha blend and make them revealed by the depth. This is a two-pass that would look the same as render them as opaque, but it enables you setting a constant opacity. I have attached this graph (SingleSpheres.zip) so you can take a look at it.

    2) Another more technical solution that could help you achieve something interesting in your screenshot: I can see that you give your particles a metaball-like blending. You could use a HDRP Custom Pass in order to blit radial gradient sprites into an offscreen render target, then resolve this render target using a threshold (see screenshot below) and render it fullscreen at a given opacity.

    upload_2020-2-14_14-37-17.png upload_2020-2-14_14-38-26.png
     

    Attached Files:

    florianhanke and Fingerbob like this.
  3. asger60

    asger60

    Joined:
    Mar 27, 2013
    Posts:
    45
    Hey thanks for your answer. It works perfectly :)
    I would like to try out the metaballs approach, do you think it would be possible in URP?
     
  4. asger60

    asger60

    Joined:
    Mar 27, 2013
    Posts:
    45
    Another question:
    What's going on in the first solution, why does it work? I've tried to wrap my head around it, and my best guess is that by writing black into the depth (buffer?) it somehow cancels out the effect. Maybe because it is though there's no depth difference between the different particles.. Is that correct at all?
     
  5. JulienF_Unity

    JulienF_Unity

    Unity Technologies

    Joined:
    Dec 17, 2015
    Posts:
    326
    It's working because only one particle per pixel will be drawn because of the depth test.

    Another solution you can do if you dont want to write depth for this effect:
    Use a shader graph to fetch scene color and apply blending in shader.