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

Toon Shaders with URP and Shader Graph?

Discussion in 'Universal Render Pipeline' started by tonycoculuzzi, Sep 25, 2019.

  1. tonycoculuzzi

    tonycoculuzzi

    Joined:
    Jun 2, 2011
    Posts:
    301
    I've been wracking my brain trying to find a way to make a toon shader with correct shadows in the URP (LWRP in 2019.2.6)

    It seems like this simple idea of creating a custom-lit shader should be easy to create, but Shader Graph makes it very complicated.

    As a comparison, Amplify Shader Editor makes it very easy to make a custom-lit shader out of the box.

    I'd love to start using the URP+ShaderGraph by default, but they lack so many simple features that it doesn't seem viable at all.
     
  2. ScottyB

    ScottyB

    Joined:
    Apr 4, 2011
    Posts:
    146
    Unity recently released a quick video on this topic, in case you haven't already seen it:
     
    calurin likes this.
  3. tonycoculuzzi

    tonycoculuzzi

    Joined:
    Jun 2, 2011
    Posts:
    301
    I could be wrong, but that shader still wouldn't support shadows, right?

    All I'm seeing right now are a bunch of hacks to get "almost there" with anything you want to do, but there still isn't enough functionality to get all the way there. Custom lighting seems to be an example of this.
     
    Cynicat likes this.
  4. whoisj

    whoisj

    Joined:
    Jan 4, 2018
    Posts:
    26
  5. MrPaparoz

    MrPaparoz

    Joined:
    Apr 14, 2018
    Posts:
    157
    How to use it? I see PR is closed, how can I manually support this on my local machine?
     
  6. ChrisAbra

    ChrisAbra

    Joined:
    May 13, 2017
    Posts:
    1
    So what i've just done is to open up the Lighting.hlsl file in the pipeline package and do the modifications that are done in shader graph to the 'LightingPhysicallyBased' (toon ramp NdotL with smoothstep) and 'DirectBDRF' (similar for the specularity) methods.

    Essentially updating the lighting model URP is using for their Lit shader.
    This way you take advantage of everything the shader has to offer re:lighting,shadows, GI, etc. without having to implement it yourself and its only as expensive as every line you add rather than being on top of the current shader workload which spends the whole time arriving at 0 for each pixel.

    It also JustWorks™ for additional lights too and *should* follow all the settings in the pipeline assets.

    Yes you have to read and write the hlsl, but most of the functions and logic you need are identical to those you'll use in shader graph anyway and its pretty much all in this one file.
     
  7. NerdIt-

    NerdIt-

    Joined:
    Oct 19, 2018
    Posts:
    24
    if it's not to much to ask, could make a tutorial on how to do this cause I have know idea
     
    stychu likes this.
  8. RickshawDerpyDerp

    RickshawDerpyDerp

    Joined:
    Nov 6, 2018
    Posts:
    25
    Ditto, that would be helpful