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

Resolved URP & Shader Graph Basic Questions

Discussion in 'Shader Graph' started by sigil_tech, Feb 28, 2020.

  1. sigil_tech

    sigil_tech

    Joined:
    Sep 18, 2019
    Posts:
    17
    I am currently developing a mobile title utilizing Unity 2019.3 and Shader Graph. I have prefab game objects which use the PBR Master Node and PBR input sub-graph, these game objects can be cracked, dissolved, glow, etc. and thus have many different Shader Graph effects I would like to use.
    1. Should I have all of these effects in one Shader and utilize scripting to call them? If so what nodes would I use to create the appropriate logical statements to selectively active them?
    2. Would it be better to have multiple shaders (one for each effect) and change the shader via script as needed?
    Obviously performance is a concern as I want the game to run well on mobile. Any insights into best practice would be deeply appreciated. I currently have some effects functional which are divided into sub-graphs, but it is getting harder and harder to make them all play nice and independently within the same shader. Thank you for your time reading my inquiry.
     
  2. sigil_tech

    sigil_tech

    Joined:
    Sep 18, 2019
    Posts:
    17
    I was able to resolve this issue by utilizing the same shader for all desired effects. I simply used arithmetic to add all shader effect outputs, and subtract the original input values that were fed into each shader sub-graph. This resulted in the net shader output for example of (abledo + albedoeffect1 + albedoeffect2 + albedoeffect3), where those values are zero for any effect not in use. The same for all other shader outputs. I hope this helps other beginners who are trying to resolve a similar issue. I have found shaders are very intuitive after some time toying with them, time well spent.