Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Poor performance with transparency using Shader Graph in HDRP

Discussion in 'Shader Graph' started by Velo222, Dec 28, 2020.

  1. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,437
    I seem to have run into a performance issue with Shader Graph shaders in HDRP specifically. I'm getting very poor performance with transparent particles using a shader graph shader. Especially when they take up more and more screen space (i.e. if they take up half the screen for example).

    I have read that this may be due to Shader Graph doing operations on a per-pixel basis, instead of doing some (or most) of the work on a per-vertex basis. Is this true?

    If it's true that per-pixel operations are the problem (and very expensive) -- how does one make a Shader Graph shader "per-vertex" instead (or at least partially per-vertex)? I still can't seem to find any pictures or descriptions of what nodes to use, or how to hook the nodes together and what they attach to.

    Here is a picture of my current Shader Graph shader I'm using (by the way soft-particles don't seem to be working either but that's another issue):

    Particle Shader Graph Issue1.png


    Are there any suggestions how to make a Shader Graph shader for particles perform better?
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,329
    HDRP is expensive, period. AFAIK it only supports per pixel lighting on all objects. There is no option for per vertex lighting within the renderer at all, so there's no way to make a particle shader that does lighting per vertex. Even if there was, there's no way to do that with Shader Graph, even when using the URP which does support per vertex lighting (or at least, it's plausible to write a custom shader that supports it).

    So, yes. Lit particles in HDRP are expensive. There's no solution to that apart from using fewer particles to prevent overdraw and/or limiting their screen size, or using unlit particles.

    On a pure optimization stand point, using a Hue node is probably the most expensive thing in the entire graph... perhaps as or more expensive than all other nodes in the graph combined. But even then it's probably an inappreciable part of the overall HDRP lit shader.
     
  3. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,437
    Thank you for your response. That does help me know what options I can take then.

    I ended up going with the "unlit" shader option you mentioned. Using a master unlit shader node in the Shader Graph, since some of my non-essential particle effects don't need that much detailed lighting, fortunately. It actually ended up being ok for me to do this. It has helped greatly performance-wise in most instances as well.

    On one of my essential particle effects, that still needs lighting (and lots of particles), I still have heavy performance drops in certain play-state instances -- but it's only for a small amount of time during the game now. Compromises and improvements I guess :cool:

    Thanks for the info.