Search Unity

Question Shader Graph and non-PBS lighting in URP

Discussion in 'Shader Graph' started by alan-lawrance, Jan 21, 2022.

  1. alan-lawrance

    alan-lawrance

    Joined:
    Feb 1, 2013
    Posts:
    360
    URP provides a "Simple Lit" shader, but not as a shader graph.

    I don't see "Simple Lit" as an option in the list of Universal Materials in the the Graph Inspector of a shader graph.

    This leads me to believe it is NOT possible to create a "Simple Lit" type shader that uses Blinn-Phong, and you are locked into using the physically based lighting model if you author a shader in shader graph.

    Is that correct?
     
  2. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,307
    Well... yes, but on the other side nothing stops you to make custom function and use 'UniversalFragmentBlinnPhong' function. You need to setup keywords and other stuff, but surely it is possible to do.
     
  3. alan-lawrance

    alan-lawrance

    Joined:
    Feb 1, 2013
    Posts:
    360
    So I have this straight...

    URP is designed to work on a broad range of hardware, including mobile.

    The intended way to author shaders with URP is shader graph.

    Yet shader graph only supports a physically based lighting model, which is not really compatible with mobile or low end hardware.
     
    Beauque, tiptoe and MP-ul like this.
  4. JJRivers

    JJRivers

    Joined:
    Oct 16, 2018
    Posts:
    137
    What do you mean it is not compatible? I've seen it done on low end hardware with a fully 3D game running on potato for a phone. It simply means you have to actually optimize your game.


    But on the other hand, you might infact Want to use BlinnPhong lighting not just for performance reasons. It is curious why they didn't add a target to the shader graph that compiles with that.

    On that note as Qriva mentioned you can infact override it with custom functions and it shouldn't take any more expertize than handwriting your own shaders (less infact overall), but you do have to get familiar with the tool.
     
  5. alan-lawrance

    alan-lawrance

    Joined:
    Feb 1, 2013
    Posts:
    360
  6. MP-ul

    MP-ul

    Joined:
    Jan 25, 2014
    Posts:
    230
    The only option in urp is to go in by hand and start from 0 with the shader. There is no other option to be honest since shader graph is to limited at what it can do. I have been trying to recreate a shader I made few years ago for urp and is more of a pain in the ass to do giving the stuff that it brakes with every urp update ,that sometimes you need because of the visual targets.
     
  7. JJRivers

    JJRivers

    Joined:
    Oct 16, 2018
    Posts:
    137
    I've read that part several times and there is a strong kernel of truth to that, i'm merely suggesting that you actually define the hardware you want to target as a minimum and test if it will run or not. With otherwise properly setup project there is a better than even chance it'll actually work for you and your game will look quite a lot better for it especially compared to competition. That portion of the docs was written awhile ago now and the hardware that is considered low-end is vastly superior today than it was when that was written.

    Obviously if you really do want Any phone to run your game then yes, you have a problem and you really will need handcrafted shaders.
     
  8. Zallist

    Zallist

    Joined:
    Dec 4, 2020
    Posts:
    3
    Copying from my other comment (https://forum.unity.com/threads/sha...a-simple-lit-graph.575578/page-2#post-8111975), since I also came across this thread while trying to find one:

    I needed the Simple Lit target, and came across this thread. And found that nobody had just made the relevant UniversalSimpleLitSubTarget, which isn't really that much effort for the current version of URP (2022.1+, at least). So I've went and done just that and released it under an MIT license on Github for everyone to use:

    https://github.com/Zallist/unity-universal-shadergraph-extensions

    And it just does what Unity should do, in exposing a Simple Lit material to the Universal target in Shader Graph:



    Feedback welcome. Or not, you can just take it.

    The code is basically just the Lit MasterNode, stripped down to what it needs just for Simple Lit and the logic necessary to call Blinn Phong.

    It does NOT work for Deferred Rendering right now since I have no need for that. Or VFX Graph.
     
  9. FixItFelix

    FixItFelix

    Joined:
    Mar 27, 2017
    Posts:
    54
    Hi,

    first of all @Zallist thanks for that awesome simple lit shader graph node.
    We discovered a brighter outcome of the color if we turned the specular highlights on and set smoothness to 0.
    The resulting color is way brighter than it is on the standard simple lit shader from unity (without shader graph).
    Any idea why?