Search Unity

Question Shader Graph shader/particle performance

Discussion in 'Shader Graph' started by Velo222, Feb 15, 2020.

  1. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,437
    I'm trying to make a shader for cloud particle effects using the HDR pipeline (HDRP).

    I noticed that even if I don't modify the default shader-graph shader at all, and I apply the shader to all of my cloud particle systems -- I get terrible performance when looking at them all on the screen at the same time.

    For example, when NOT looking at the clouds I get around 60 fps. When viewing them all on screen at once, I'm getting about 25 fps. That's a massive performance hit. I'm fairly certain it's from using the Shadergraph shader that I'm using.

    So my question is is there anything I can do to get Shader-graph shaders to perform better? I read that shader-graph uses per-pixel calculations instead of per-vertex, but I'm not sure if that even applies here or not? And is there a node or something I could use to fix it, or to force it to use per-vertex?
     
    hippocoder likes this.
  2. marcrem

    marcrem

    Joined:
    Oct 13, 2016
    Posts:
    340
    Use the vfx graph for particles, or build yourself a complex raymarching shader
     
  3. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,437
    Ok, but can you tell me why when I view the particles (with the ShaderGraph Particle Lit Soft shader) in a smaller resolution I get much better performance. Then when I maximize the game window, the performance pretty much tanks (is terrible)?

    What causes such a huge performance hit given the resolution size? I'm just trying to find out why it's so bad based on screen size.
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    Bigger window, higher resolution. Higher resolution, more pixels to render. More pixels to render, the longer it takes to render.

    If a transparent shader overlaps in some pixel, those pixels cost roughly twice as much to render than if only one layer of the transparent surface was visible, because you’re rendering it twice. Each additional overlap makes those pixels that much more expensive. More overlapping transparent surfaces at a higher resolution means the higher the number of expensive pixels to render.

    The default HDRP Lit shader (Shader Graph or otherwise) is expensive, more expensive than the opaque version of the same shader. So each pixel your particles cover is increasing the time it takes to render. And overlapping particles even more so.
     
  5. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    For a quick fix, you could try changing the master node to unlit and plugging in your own lighting.
     
    Velo222 likes this.
  6. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,437
    Ok thanks Hippocoder, I will try this.


    Thanks for the explanation Bgolus.
     
  7. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,437

    I noticed the "unlit" shader master nodes do not have input slots for normal maps. Why is this?

    All I'm really wanting is a normal-mapped particle shader that performs semi-well. Seems like it's one or the other right now.
     
  8. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    An unlit shader is ... unlit. Meaning it is unaffected by lighting. A lit or pbr shader is going to use a normal map to modify the surface normal vector used for calculating lighting; all the values you set on a Lit shader or Lit/PBR Master Node are used to determine the final shaded color you see. The color you output to the Unlit Master Node is the color that shows up on screen (ignoring transparency blending, fog, etc), it doesn't do anything to it since it is unlit.

    Which is why @hippocoder mentioned plugging in your own lighting. You'd have to calculate it all the lighting yourself using the nodes.
     
    Velo222 and hippocoder like this.