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 Multiple shaders on the same object work flow

Discussion in 'Shader Graph' started by HassanKhallouf, Oct 6, 2021.

  1. HassanKhallouf

    HassanKhallouf

    Joined:
    Mar 5, 2015
    Posts:
    52
    Hello everyone,

    The main issue is, we don't have experience in writing shaders in our team, we are relying on the new Shader graph for our shaders.

    The game we have has so many effects that can be applied to a lot of characters in the game, for example:
    blinking, burning, dissolving and so on.

    Creating each shader on its own is not a problem, we created so many shaders with no issues, the problem is in the workflow and how the shaders are supposed to work in Unity in an efficient way.
    Now here is the problem:
    Say I Have character, this character uses the main shader provided by HDRP, it uses the diffuse color, normal map, AO maps, metallic maps and so on.
    Now I want to apply a dissolve effect for this shader, I have to re implement the entire unity HDRP default shader to keep everything as is and just apply dissolve effect.
    The problem Continues, say this character is taking damage and we want to show a blink effect on the character to give feedback of taking damage

    Now we have a compound problem, we have to rewrite the default Unity shader AND do some logic to control which effect is active, we have done that for very few effects, but it can't scale at all, the attached picture can probably illustrate the issue



    we have made each effect as sub-graph, but even with this solution this won't scale well and well eventually get out of hand if not causing a bug, not to mention that this is missing everything from the default shader

    I have asked before in the forums about this issue, but I didn't get an answer, except from a user who suggested something with directives, but that's not for shader graphs, but rather for coded shaders.

    I hope the issue is clear, we don't usually have issues with reaching a result we want, but most of our problems are about workflow and best practices, there are very very little resources when it comes to advanced users.

    To Summarize:
    1- is there a way to build on top of the main shader?
    2- if not, is there a way to rebuild the main shader?
    3- how can we stack multiple effects on the same character ? if we swap shaders this won't scale well either, each character can have the same effects but well have different base Material, and changing materials has some efficiency issues as well

    Thank you in advance
     
  2. DEEnvironment

    DEEnvironment

    Joined:
    Dec 30, 2018
    Posts:
    437
    Your approach for building sub-graph is a good step however, instead of adding them consider building the graphs more stackable as in they would have inputs to collect the graph before it. When stacking graphs this way the order would tell what effect gets layered over or under each other.

    I also have this workflow in my asset DE Environment made with ASE by making core functions for the main shader and modules that can be stacked inline onto the cores .. also made what I call common functions that are reused in the core or modules..
     
    Last edited: Oct 6, 2021
  3. HassanKhallouf

    HassanKhallouf

    Joined:
    Mar 5, 2015
    Posts:
    52
    Thank you for your reply

    But is this really how it's supposed to be ?
    wouldn't a shader with 20 stacked effects be too heavy and hard to use?
    what about losing everything in the main shader just to add some glow to an object?
     
  4. DEEnvironment

    DEEnvironment

    Joined:
    Dec 30, 2018
    Posts:
    437
    yes as more effects that are added the complexity goes up / slower
    add what you need when you need it and use multiple that are smaller / faster

    use of sampler states can go a long way to help reduce the cost and avoid heavy operations such as tessellation and expensive math steps .. a single uber shader with all 20+ effects may crush your users

    not certain what the question is about losing every thing in the main shader
     
  5. HassanKhallouf

    HassanKhallouf

    Joined:
    Mar 5, 2015
    Posts:
    52
    The main shader has everything setup and ready, normal maps, smoothnes, metalicness, AO maps etc
    when you create a new shader you have to plug in all of these things from scratch
     
  6. DEEnvironment

    DEEnvironment

    Joined:
    Dec 30, 2018
    Posts:
    437

    when making a new shader and use the same "Property Name" the material should not fall off

    in shader graph they call this the “Property Reference”


    the industry standard is to use the same property names as the unity standard shaders so when you switch from the default shaders to any custom shader the textures and or settings don’t get lost