HDRP Custom shaders

Hi there. Do HDRP has something like surface shaders in standard pipeline? How can I write custom shaders with vertex animation or UV animation etc. for HDRP?

Thanks.

not yet, and possibly not ever (although unity have said they would like an abstraction like this for shadergraph in the future)

1 Like

But shader graph generate file that has only nodes information and nothing about shader. And what I see in shader graph it is master node, and it seems like something surface output structure like in all visual shader editors.

Yeah but its not a surface shader.

IMO your best bet will be copying the code for the standard HD PBR master node in the shadergraph package when it becomes compatible with HDRP, and making your own custom master node starting from this.

I used this approach to make a toon shader in the LWRP, and it was very simple

Now I can use my “Toon” node in shadergraph just like with any other node. I basically just use ShaderGraph as a fancy custom inspector for my shader. All the logic that really matters is in code

EDIT: Here’s something to keep us busy until release:

6 Likes

huh, never realize that branch before. Is it stable to be tested with HDRP?

Not sure, I haven’t tried shadergraph with HD yet

I think we must drop our all surface shader experiences and start learning HLSL language for shader programming

1 Like

Hello! can you share what you did for creating that toon shader?

What I was doing to achieve toon shading is modding the dot product between the light direction and the normal in this function LightingPhysicallyBased() in Lighting.hlsl

Thanks!

How did you get the light direction?

I know how to using inbuilt pipeline but I cant find any concrete info on how to in new one?

Really want to be able to do NdotL etc

If we take the LWRP for example, you’ll find this in the “Lighting.hlsl” file in the LWRP package:

This should be a good place to start studying the whole system. You might need to go look at PBRMasterNode.cs in ShaderGraph to find out how all this is connected too. I actually forgot how I did all this

2 Likes

This is EXACTLY what I have been looking for, for a couple of days now! Thankyou for this!!!

Some additional info I just pieced together:

  • “LightWeightPBRSubShader.cs” is what defines the master PBR node in LWRP

  • it uses “lightweightPBRForwardPass.template” to define the main contents of the generated shader

  • In “lightweightPBRForwardPass.template”, the main lighting calculations are done by calling “LightweightFragmentPBR()” in the frag shader

  • “LightweightFragmentPBR()” is contained in “Lighting.hlsl”

So you have two options here:

  • Alter “lightweightPBRForwardPass.template” to make it calculate lighting using your own custom approach
  • Create your own custom equivalent of “LightWeightPBRSubShader.cs” and make it use another template entirely

The only thing I can’t remember is how “LightWeightPBRSubShader.cs” actually gets registered in ShaderGraph as a node that you can use

2 Likes

Thanks this is seriously useful information!

I am about to dive into the world of custom shaders using the SRP and will post back any findings I have on the forum and reddit so we can collate all this (diving in and out of different threads and forums to get all this info wasnt the best route me thinks!)

Any news on this subject ? I would like to write a custom lightning and I would be very interested in what you have to share

can anyone help me with this error?


This is a PBR surface shader I wrote in 8th grade with Unity 5. Hopefully Unity 2018 HDRP will eventually make it easier to customize BDRF because it really gives a chance to give your project it’s own feel.

Sorry image upload failure

Is there any chance Shader Graph will support custom lighting configurations?

If I could get a dime every time someone asks that… Even myself… Who was YELLING about it.