Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question URP Lit Shader in Shader Graph

Discussion in 'Shader Graph' started by jp_xsi4life, Sep 2, 2020.

  1. jp_xsi4life

    jp_xsi4life

    Joined:
    Jan 2, 2020
    Posts:
    7
    Is there a way of starting with the URP LIT shader and extending it with Shader Graph? Or do I need to rebuild the entire LIT shader graph and add my extra features to it?
     
  2. jp_xsi4life

    jp_xsi4life

    Joined:
    Jan 2, 2020
    Posts:
    7
    Found a version of the HDRP Lit Shader Graph if anyone finds that useful:
    https://github.com/RemyUnity/SG-HDRP-Lit

    It would be great if there was a standard example graph included in URP and HDRP for the main coded shaders.
     
  3. Armegalo

    Armegalo

    Joined:
    May 14, 2018
    Posts:
    25
    I too am looking for a shader graph version of the URP Lit shader. I'm relatively new to shaders so wanted to start there as an example for learning. My own efforts are sadly lacking :(
     
  4. JordanRy

    JordanRy

    Joined:
    Jun 3, 2020
    Posts:
    1
    Did any of you have success?
     
  5. Sinterklaas

    Sinterklaas

    Joined:
    Jun 6, 2018
    Posts:
    93
    Old post, but since it's been bumped recently:

    Unity actually wrote a blogpost that tells you how to do lighting in URP:
    https://blog.unity.com/technology/custom-lighting-in-shader-graph-expanding-your-graphs-in-2019

    The shader graph interface in their pictures is a little bit different from current Unity versions, since the post is from 2019, but it still works. However, make sure that your shader is set to either Unlit or SpriteUnlit, or else you'll get lighting twice.

    If you also want your objects to cast shadows, make sure to instead set your shader to Lit, and to pipe your lit color into the Emission port of the output node so that you don't get lighting twice. I don't know if custom shadow receiving works in Unlit/SpriteUnlit shaders, but it definitely works with the Lit method. But only if your shader's surface is set to "Opaque" or you have "Transparent Receive Shadows" enabled in your Forward Renderer Data asset.

    Also, I got some errors with the #ifdef KEYWORD directives in their code, but replacing them with #if defined(KEYWORD) directives solved that issue for me. Might be a problem with my Unity version, but that's how you fix that problem in case it does occur.

    Lastly, the guide doesn't cover ambient light, emission or normal mapping. The first can be done yourself by using an Ambient Light node, the second is a simple add operation between your lit color and your emission color, and the third can be done with the graph below. You just use the output of that graph instead of the Normal Vector node used in the blogpost, and there you go you've got normal mapping.

    I think that about covers it.
     

    Attached Files:

  6. SweetBro

    SweetBro

    Joined:
    Jan 14, 2013
    Posts:
    69
    Performing necromancy on this thread to see if anyone's managed to find a solution to this.
     
    MagiJedi, matheus_inmotionvr and lrb like this.
  7. syjgin

    syjgin

    Joined:
    Feb 13, 2015
    Posts:
    136
    upload_2022-8-29_12-3-47.png
    Now needed node is seems to be working in last 2021 LTS
     
  8. Bersaelor

    Bersaelor

    Joined:
    Oct 8, 2016
    Posts:
    110
    Your image is showing a node from a VFX graph. not the shader graph.

    That said, I'd still like to know what people use as a good URP/Lit shader replacement as a starting point for adding additional features.
     
    ben_hip likes this.
  9. corgan13353

    corgan13353

    Joined:
    Feb 21, 2022
    Posts:
    1
    Anybody find a replacement for the URP/Lit in shadergraph?
     
  10. Zai-shen

    Zai-shen

    Joined:
    Sep 8, 2020
    Posts:
    2
    2023 and developers still would want an answer instead of building everything from the ground up.
     
    StrangeWays777 likes this.
  11. mlddigits_phellmann

    mlddigits_phellmann

    Joined:
    Apr 17, 2015
    Posts:
    2
    any news 3 years later? I am still searching the Unity URP StandardSurface shader as a base to build upon it in shader graph to change couple of features, like AO map with UV2 channel.
     
  12. Elliott-Mitchell

    Elliott-Mitchell

    Joined:
    Oct 8, 2015
    Posts:
    86
    Cough Cough. Anything?
     
    StrangeWays777 and Kondziu2504 like this.
  13. unity_483C4357D3269025FA3B

    unity_483C4357D3269025FA3B

    Joined:
    Jul 2, 2022
    Posts:
    20
  14. Adegmood

    Adegmood

    Joined:
    Aug 8, 2018
    Posts:
    1
    I have also dealt with this problem, is my solution - https://assetstore.unity.com/packages/slug/249542
     
  15. ashwinFEC

    ashwinFEC

    Joined:
    May 19, 2013
    Posts:
    48
    tonyomendoza likes this.
  16. hellobard

    hellobard

    Joined:
    Sep 26, 2012
    Posts:
    139
    GAHHH.

    (sorry, too many years of frustration came out there in one word.)
    (what went wrong, unity?)