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 Trying To Replicate The Hdrp Lit Shader, I Need Help With The Detail Input Part

Discussion in 'Shader Graph' started by CosmosBear, Apr 12, 2019.

  1. CosmosBear

    CosmosBear

    Joined:
    Aug 2, 2012
    Posts:
    67
    Hi,
    So I'm trying to replicate the HDRP lit shader and I'm quite stuck at the "detail input part". I was easily able to replicate the "surface Inputs" part (base map, Mask map and Normal map) and for some reason I was able to mix the Detail map Normal map (G,A) with the base normal map but I can't seem to get the same result with the Detail Albedo (R) and the Smoothness (B).

    I guess i'm missing something

    helpmeobiwankenobiyouremyonlyhope.jpg
     
  2. alexandral_unity

    alexandral_unity

    Unity Technologies

    Joined:
    Jun 18, 2018
    Posts:
    163
    Without seeing the expected output vs actual output for the albedo map, it's a bit hard to figure out where the issue is.
     
  3. CosmosBear

    CosmosBear

    Joined:
    Aug 2, 2012
    Posts:
    67
    This is what is expected expected.jpg

    This is what I get right now with the same values
    unexpected.jpg

    by cranking the Albedo Str Scale to 4 (thats the vector 1 plugged at the oppacity in at the blend node) I get a closer resul with the white line but the dark place get too much pronounced. Untitled-1.jpg

    I also tried with a hard light blend instead of overlay, it's close but still not it.
     
  4. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    703
    Lex4art, OdderOtter, DylanF and 5 others like this.
  5. CosmosBear

    CosmosBear

    Joined:
    Aug 2, 2012
    Posts:
    67
    This is just beautiful, thank you!
     
  6. Amitloaf

    Amitloaf

    Joined:
    Jan 30, 2012
    Posts:
    97
    This works almost amazing :) Uploaded a small issue If found to Issues on github. But other than that it looks amazing! just like the normal one
     
  7. NatureManufacture

    NatureManufacture

    Joined:
    May 20, 2014
    Posts:
    2,023
    Does it still use overlay in detail albedo? I feel like it's wrong blend type.

    Edit: Solution from screen is totaly wrong in compare how HD RP Lit shader: Mistakes are in : - --- detail albedo blend
    - detail normal blend
    - detail smoothess blend
     
    Last edited: Aug 29, 2019
  8. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    Hi. Do you have can share the corrected version?
     
  9. jp_xsi4life

    jp_xsi4life

    Joined:
    Jan 2, 2020
    Posts:
    7
    @Remy_Unity You wouldn't happen to have a URP version of the Lit shader in Shader Graph would you?
     
  10. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    703
    Nope, don't have that. But URP/Lit shader is wayy simpler, and shouldn't be hard to replicate.
     
  11. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,193
    Thanks for linking that Shadergraph, @Remy_Unity . That will really help my understanding.

    One question: Do you know if there is a big performance/efficiency difference between your SG version of the Lit shader, and the normal HDRP Lit shader that comes with HDRP? I'm curious is there are optimizations in the Lit shader that can't be replicated in a Shadergraph. For example, in a normal Lit shader, it recompiles the shader whenever I enable/disable certain features. I assume that the more features enabled, the more "expensive" the shader gets. But with this Shadergraph, does it incur the cost of all of those things, even if no maps are provided to certain inputs?

    For example, does the full Lit shader know not to bother sampling certain maps if there's no map assigned? Do Shadergraphs know to do the same thing?
     
  12. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937

    Hi, did you find a solution for the blends you mentioned?
     
  13. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,068
    Unfortunately
    https://github.com/RemyUnity/SG-HDRP-Lit
    Don't do pixel/vertex displacement.

    WHY WHY WHY we cannot extend HDRP\Lit shader !!!

    Also everything related to HDRP\Lit is so tightly coupled that you just cannot copy Lit editors and classes from HDRP in library folder. And you cannot add there anything since

    "Asset Packages/com.unity.render-pipelines.high-definition/Editor/Material/Lit/LitCustomGUI.cs has no meta file, but it's in an immutable folder. The asset will be ignored."
     
  14. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
  15. swantonb

    swantonb

    Joined:
    Apr 10, 2018
    Posts:
    172
    did you do this eventually? I'll take it :D
     
  16. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    703
    No I didn't.
     
  17. swantonb

    swantonb

    Joined:
    Apr 10, 2018
    Posts:
    172
    Do it! We need a 1:1 lit shadergraph to use with VT. It should come out of the box with VT
     
  18. DylanF

    DylanF

    Joined:
    Jun 25, 2013
    Posts:
    55
  19. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    Some minutes before i tried to get the 2021.2 brach to run in 2021.3.2
    https://github.com/RemyUnity/SG-HDRP-Lit/tree/2021.2

    But without sucess. The new keyword seem not to work.
     
  20. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    703
    I'm working on this project when I have time available, I promise I will try to update it to latest LTS soon.
    Adapting all the HDRP keywords is not an easy task :/
     
    Genebris, Gooren and keeponshading like this.
  21. BenjaminLS

    BenjaminLS

    Joined:
    May 23, 2022
    Posts:
    1
    If it's "way easier" as you say and a lot of people (including me) need it, I hope you'll consider making it.
    If it's basic it should be easier for newbies to read and understand the shaders logic :)

    PS : I'm a newbie, I don't know how to make it yet, but that would help tremendously with what I'm working on.
     
  22. cubrman

    cubrman

    Joined:
    Jun 18, 2016
    Posts:
    409
    @Remy_Unity seriously guys, why can't we have a way to add functionality on top of the Lit shader? Expand the UI, instead of rewriting it? What if I want EVERY material in my game to have dither crossfade feature WITHOUT writing EVERY shader myself? I am honestly completely baffled why you do not support that. Make it limited, make it constrained, but make it happen!
     
  23. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    703
    @cubrman We consider to provide a "base" Lit shadergraph in the future, having common functionalities between the two pipelines, and that can be copied and extended.

    At the moment the lit shader is fully made from code, and not easily editable. If you really need it, it is still possible to make changes to it by copying the shader file into the project, or making a local copy of the HDRP package.
     
    giraffe1 and MrDizzle26 like this.
  24. DylanF

    DylanF

    Joined:
    Jun 25, 2013
    Posts:
    55
    A built-in shadergraph output node that mimics the entire lit shader would be great. Then we could easily add simple custom things like color changes and vertex displacements on top of it.
     
    SteveKouts and MrDizzle26 like this.
  25. cubrman

    cubrman

    Joined:
    Jun 18, 2016
    Posts:
    409
    I tried doing it and had some success, I even described how I did it in a thread 2.5 years ago. The problem is, there are so many underwater stones that a mere peasant like me won't be able to understand how to avoid them. I remember my custom dissolve shader completely breaking on cutout and/or transparent objects. The cutout pixels were never written to or shadows were improper (I don't remember exactly but it looked awful). No, given the complexity of HDRP pipeline I, an average person with an average shader knowledge, who (still) could edit Standard shaders in builtin pipeline effectively, proclaim that my brain is way too small to edit HDRP shaders' code myself.
     
    Last edited: Oct 25, 2022
  26. alexandre-fiset

    alexandre-fiset

    Joined:
    Mar 19, 2012
    Posts:
    714
    That would be great.

    We do something similar internally: A shader graph we call XRPLit which works across render pipelines and imitates HDRP Lit. We scan our scenes and replace all HDRP shaders with their XRP equivalent, which helps transitioning the project to URP when doing our Switch port as all textures and parameters share the same names (so URP uses HDRP values all the time).

    Anything that can ease the process of porting a game from one pipeline to the other is good. HDRP runs really well on PS5 and Xbox Series, somewhat okay on PS4 and Xbox One, while URP runs smoothly on all platforms. I believe a lot of devs want to build their games with HDRP, knowing that porting to URP is achievable.
     
    Vagabond_ likes this.
  27. cubrman

    cubrman

    Joined:
    Jun 18, 2016
    Posts:
    409
    I need extensibility: a way how to extend the existing functionality of HDRP Lit AND it's material interface. Ideally that would allow me to switch between Standard, Translucent, Iridescence, etc. - everything Lit interface allows AND have my own shader effects running alongside HDRP Lit.

    How do you implement the latter btw, @alexandre-fiset? Do you have a unique shader for each type (Translucent/SSS/Anisotropic)?
     
    Last edited: Oct 27, 2022
  28. MrDizzle26

    MrDizzle26

    Joined:
    Feb 8, 2015
    Posts:
    36
    A feature that would really alleviate some of these issues would be the ability to auto-import sub-graph properties into master graphs.

    Some of the sub-graphs we use have 8+ inputs, often just to recreate the inputs of the standard lit shader.

    At the moment sub-graph property inputs are not carried over, meaning they must be recreated each time to allow for custom maps and controls.

    This involves adding a name and recreating the default values, which for some reason also aren't carried across from the defaults set in the sub-graph.

    Doing all this manually is very time consuming and leads to inconsistencies in naming and setup, which leads to bugs.

    Adding a toggle to import the property when a sub-graph is added would be a big win for us!
     
  29. SteveKouts

    SteveKouts

    Joined:
    Aug 23, 2012
    Posts:
    79
    Yeh or at least a complete guide by Unity to rebuild the HDRP lit shader easily to then make modifications.