Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

HDRP no custom shaders?

Discussion in 'Shaders' started by jister, Aug 22, 2018.

  1. jister

    jister

    Joined:
    Oct 9, 2009
    Posts:
    1,655
    We ported a project of ours to use HDRP in 2018.2.2. as a test. First thing we noticed is that all custom shaders go pink. After some googling I read in some post around june 2018 that custom shaders (and even the Graph) are not supported (yet?).
    Some people said rewrite them, but i don't find any hint as to what to rewrite or how, also read "make a custom pipeline", but since there is not to much documentation yet it's kind of a blank on how to do that either.
    Is there any work around at the moment to get them to work?
     
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    735
    For a shader to be compatible with a scriptable render pipeline, it has to have a tag.

    Example for HDRP:
    Code (CSharp):
    1. Tags{ "RenderPipeline" = "HDRenderPipeline" }
     
  3. Julien_Unity

    Julien_Unity

    Unity Technologies

    Joined:
    Nov 17, 2015
    Posts:
    8
    Adding this tag is not sufficient. For a shader to be really compatible with a given pipeline it needs to have a set of passes specific to this pipeline.
    Porting a shader to HDRP, is actually a pretty involved process. We don't have documentation for this for now but the recommended way to do that in the future will be to use the Shader Graph.
     
    hippocoder likes this.
  4. jister

    jister

    Joined:
    Oct 9, 2009
    Posts:
    1,655
    is there a way to convert custom shaders to Shader Graph?
     
  5. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    6,694
    Not automatically, no. You’d have to recreate them from scratch in Shader Graph, just like you would have to write new vertex fragment shader passes for the LW or HD pipelines, but you would only need to do it once for both. However it should be noted that Shader Graph is like an even more limited Surface Shader which you can only create unlit or PBR shaders in, no custom lighting models.
     
  6. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    857
    I'm wondering if there are any plans to make a "surface shader" equivalent for the HDRP to make converting a lot of people's shader easier. It might have to be a little more complex than the old SURF setup, but a predefined structure that we can mostly just paste our code where it needs to go and link things up would be great for getting a lot of old shaders working with little effort.
     
  7. jister

    jister

    Joined:
    Oct 9, 2009
    Posts:
    1,655
    is there an example out there that shows a rewritten shader?
    Will this change in the future?
     
  8. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    6,694
    My understanding is that Shader Graph was intended to replace the concept of Surface Shaders, and they had no plans on extending or otherwise making a written code based shader generation system like it. There’s enough of us that have asked for it that they’ve made some comments about reevaluating this choice again at some point in the future. For now though, don’t expect it.

    Not really, no. The render pipelines have been in flux as they’ve still in active development. There’s no guarantee a custom shader written today will work with tomorrow’s version of either of the new pipelines.

    They’ve been adding some features that would allow to do some limited custom shading on otherwise unlit shaders, but so far it looks to be limited to ambient lighting and a single unshadowed directional light. This is similar to the he direction Unreal has taken where they’ve completely removed any support for custom lighting models being created within the node based material system. Instead if you want that, they’ll likely push you toward directly customizing the render pipeline itself, which is also what Unreal does.
     
    jister likes this.
  9. Shinao

    Shinao

    Joined:
    Mar 7, 2014
    Posts:
    26
    I'm still waiting for custom HDRP shaders before transitioning to the SRP. At least a way to generate an empty shader from the Shader Graph and we will have to plug into it our code. Without this I can't see how HDRP gains some traction there are too many features that would take time if at all possible to implement in the Shader Graph :
    - Use of instanced indirect
    - Custom StructuredBuffer
    - Custom shader variant
    I'm not an asset creator but I know some assets that I own that will also depend in some of those features and more.
     
  10. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    857
    You can. Just create a new PBR or Unlit shadergraph shader. Then write a code-node script that defines what inputs and outputs your node has and the functionality of it. So can write your whole fragment program in it and then simply create the node in the shader graph and connect its output to the master node.
     
    jister likes this.
  11. Shinao

    Shinao

    Joined:
    Mar 7, 2014
    Posts:
    26
    You just discarded half of my post though... Unless I am missing something I still can't use custom buffers and use them in a code-node script or have shader variants.
    To be honest even if it was possible to declare the buffers and create a special node to use in the Shader Graph the debugging and tweaking of the shader at the moment is a bliss and I think it would be a pain on the Shader Graph side (toggling comments, switching values, ordering, etc), though I see it useful if you already know what you want.
     
  12. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    857
    I was only replying to that part of your post, because yes it's limited in that way. Just wanted to point out that at least that feature exists and can be expanded upon as they develop things further.
     
    jister likes this.
  13. unity_zOvEB4IgVxRirA

    unity_zOvEB4IgVxRirA

    Joined:
    Sep 20, 2017
    Posts:
    238
    hello,
    there is an attached Fur shader that i tried to adding RenderPipeline tag to using it on HDRP ...
    but its not completely working ... can someone make this shader full support for HDRP?
     

    Attached Files:

    • Fur.zip
      File size:
      42 KB
      Views:
      79
  14. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,139
    Indeed. I saw a pull request where they renamed the function that samples shadow for main light in 4.0.0-preview so I agree creating custom shaders atm is just a ticking bomb.
     
  15. WILEz1975

    WILEz1975

    Joined:
    Mar 23, 2013
    Posts:
    288
    In practice, for projects already started some time ago they can forget about the HDR Pipeline.
    Well.