Search Unity

Help Wanted Shader always on top

Discussion in 'Shader Graph' started by darkesco, Jul 16, 2019.

  1. darkesco

    darkesco

    Joined:
    Mar 19, 2015
    Posts:
    22
    Sorry for the trivial question. I assume this is so easy that no one asks, but here goes: I am trying to make health bars, inventory dialogs, etc. I need to know how to disable depth so the UI is always on top. I believe this was ZTEST Always or something in shader lab. How do I set this in shader graph?

    Thank you.
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    7,000
    You don't, it's not a feature that's currently supported.
     
  3. ph_

    ph_

    Joined:
    Sep 5, 2013
    Posts:
    114
    I've created a plugin on the asset store that add the ZTest / ZWrite / Cull settings in ShaderGraph, among a lot of other features (like SimpleLit master node, toon and custom lighting, lot of different noises ...).
    Here's what it looks like
    sge_settings.jpg

    If you're interested, you can get it there: ShaderGraph Essentials on the asset store
    Don't hesitate to pm if you have any question!
     
    bgolus likes this.
  4. darkesco

    darkesco

    Joined:
    Mar 19, 2015
    Posts:
    22
    Thanks bgolus. If I impliment this myself, do you know if it will cause performance issues? Honestly, I don't understand render pipelines and wonder if this will disrupt the flow. I can test it myself possibly, just wondering if this is why it's not added yet. I would think UI elements would be a critical shader technique for almost all apps and games, so maybe there is a reason Unity didn't add it yet.
     
  5. darkesco

    darkesco

    Joined:
    Mar 19, 2015
    Posts:
    22
    I will check this out. Looks really neat! Thank you.
     
    ph_ likes this.
  6. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    7,000
    None that I know of.

    Okay ... let's go down this hole.

    Shader Graph in its current form was designed for making shaders that go on objects in the scene. Any use beyond that is outside of the scope of its current functionality. Unity has stated explicitly that Shader Graph isn't intended to be used for UI or post process effects. I don't think there's any grand "reason" for this outside of looking to limit the scope of Shader Graph to get it into a working state for users. Unfortunately anyone coming from other tools with similar node based material editors, or even users of Shader Forge and Amplify Shader Editor are already used to using the node based editor to make shaders for basically everything, and Shader Graph simply wasn't created with that in mind. It probably doesn't help that Shader Graph is being written at the same time as the LWRP (now Universal RP) and the HDRP which have significantly different and frequently changing requirements. One of the original intents for Shader Graph was having a single shader that can be used in both pipelines equally, but that has already been kind of lost as for the HDRP they added the Lit Master Node which is incompatible with the LWRP, and there remains no way to make a Shader Graph that uses the LWRP's more efficient Simple Lit shading model.

    The PBR Master Node remains, being more expensive than what many LWRP users want to use, and less featured than either pipeline user wants access to.

    I have no doubt that more features will come eventually, but I don't envy the Shader Graph team's task. Some of this speaks to the amazing job Amplify have done with their own node based editor, though that was partially built on top of almost a decade of Unity's work on Surface Shaders and targeting the mature and mostly static built in rendering paths, they do also now support the LWRP and HDRP. It also speaks to the huge gulf Unity has in their goal to finally catch up to and potentially surpass Unreal in areas Unity has traditionally been lacking in.
     
    iSinner and ph_ like this.
  7. darkesco

    darkesco

    Joined:
    Mar 19, 2015
    Posts:
    22
    That makes perfect sense. Thank you for the clarification.
     
    ph_ likes this.
  8. cptSwing

    cptSwing

    Joined:
    Jul 2, 2015
    Posts:
    8
    With the new Scriptable Render Passes you can choose to not render a certain layer and then render it specifically at a certain order in your render queue :cool:
     
  9. Flow-Fire-Games

    Flow-Fire-Games

    Joined:
    Jun 11, 2015
    Posts:
    190
    you can make a mesh / plane and change the "Priority" in the mesh renderer
    We definitely use shaders for UI, with a bit of fiddling it does work, but you may need to make other UI parts as mesh with shader as well, and as always seperate camera for UI