HDRP no custom shaders?

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?

For a shader to be compatible with a scriptable render pipeline, it has to have a tag.

Example for HDRP:

Tags{ "RenderPipeline" = "HDRenderPipeline" }

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.

1 Like

is there a way to convert custom shaders to Shader Graph?

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.

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.

is there an example out there that shows a rewritten shader?

Will this change in the future?

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.

1 Like

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.

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.

1 Like

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.

1 Like

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.

1 Like

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?

3682180–302569–Fur.zip (42 KB)

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.

In practice, for projects already started some time ago they can forget about the HDR Pipeline.
Well.

This Unity tutorial claims (about 1 minute in) that hand-written shaders can coexist with ShaderGraph shaders. Is that no longer true? Or does it apply to some pipelines and not others?

1 Like

:eyes:

Custom shaders work fine with any SRP. Shader Graph itself is only used by the editor to generate normal vertex fragment shader code that is what the engine actually sees and uses. Most of the built in shaders for the SRPs are custom shaders since there are a lot of features that Shader Graph doesn’t yet support.

The only difficulty is both SRPs are renderers in active development, which means things can change. To be fair, this has been true even for the built in renderers with common macros changing every couple of versions of Unity 5.

OK, that’s useful information. I’m not sure if it’s practical information, though, since creating a starter shader with any of the “Create > Shader” options produces a non-HDRP compatible shader, as does following the manual on writing shaders. And in my searching this morning, I found plenty of Unity folks saying “custom shaders will have to be rewritten” but not a peep about what exactly has to be done.

So, is there any information on what must be added, removed, or changed to make even a trivial custom shader work under HDRP? I’m sure the information is out there (perhaps in the form of source code) but I don’t know where to find it.

3 Likes

Unlit shaders work fine.
Lit shaders Unity is going to direct you to use Shader Graph, and as best I can tell don’t want to have to support or actively document the actual HLSL shader code.

In lieu of that, you can look at the code yourself, and see both what the shaders do and the code that sets the values they’re using. Or you can start from Shader Graph and use it to generate a starting shader.

As mentioned, things are in flux still. I think someone in the community put out tutorial and example shader for Lightweight a month or two ago that I think is already out of date.

And yes, it means a lot of the documentation isn’t applicable for the SRPs.

1 Like

Bumping this.
With the release of 2019.3, I would like to know if there’s any plan on documenting about custom shaders in HDRP.
Besides, the latest version of shader graph features new vertex outputs (Position, Normal and Tangent), instead of the old Position, which messes with all the vertex displacement calculations I have done.
I am in a crossroad right now, because I have a very complex shader written for the standard pipeline that I have no idea on how to convert to HDRP nor Shader Graph, due to the lack of non-outdated tutorials.

I have checked the code of the Lit shader and some shaders that a guy from Unity Japan posted in github, but the files are infinitely large, and (besides HLSL seeming very much usable than CG) its difficult to tell what is needed to create a shader in HDRP.