Search Unity

Feature Request Custom master node, is it on the roadmap?

Discussion in 'Shader Graph' started by bitinn, Apr 16, 2019.

  1. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    I believe the SG team already know people want it, but I couldn't find a thread about it in this forum, so here is my request for it.

    To be honest, after going through many feature request threads here, I realize many of these problems could have been solved if we are given the chance to write a master node.

    I have solved these problems using a custom master node in 2018.3 (with 4.x release):

    - Custom vertex shader.
    - Custom keyword.
    - Toggle things like ZWrite/ZTest.
    - Rewrite the parser and create custom template tags.

    (Basically trying to make it as flexible as Amplify Shader Editor)

    Screen Shot 2019-04-16 at 22.01.01.png Screen Shot 2019-04-16 at 22.10.16.png Screen Shot 2019-04-16 at 22.12.01.png

    SG is perhaps the main reason I couldn't easily migrate to 2019.x releases, I am not going to blame anyone but myself, but hey, I think supporting that could cut your feature requests in half :)

    (I skimmed past the GDC video, pretty sure this isn't available in 5.x, so apologize if there is an alternative.)
     
  2. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    +1 for this. Custom Master Nodes is currently the only possible way I found to implement real toon lighting that supports all lights: https://forum.unity.com/threads/shadergraph-request-allow-a-custom-lit-masternode.663250/

    ....and gives users an option to solve almost all problems that could eventually show up

    After some consideration, I think It'd be a fine solution to just make it easy and well-documented to create MasterNodes (as opposed to what I was suggesting in my thread). So far I was only able to modify existing PBR code in order to achieve my result, but I haven't figured out how to actually add a new custom MasterNode.

    Are you saying it is now impossible to create MasterNodes in 2019.1?
     
  3. pitibonom

    pitibonom

    Joined:
    Aug 17, 2010
    Posts:
    220
    mebe the best could be for SG to allow code nodes ^^

    just like the one in blender.

    therefore allowing custom master node ?
     
  4. alexandral_unity

    alexandral_unity

    Unity Technologies

    Joined:
    Jun 18, 2018
    Posts:
    163
    @PhilSA , it *was* possible to create custom master nodes in 2018.3, though not really documented that well. :p In 2019.1 it's not possible without modifying the package source code in your local project, as the API needed for that (and custom C# nodes) has been made internal. We'd obviously love to open up flexibility, but it comes with the technical debt of creating APIs that are (like you said) easy to use, and having a technical writer available to document it. The obvious goal is for the graph to be as fully featured and flexible as possible, but it takes time. Hopefully you guys can bear with us on the growing pains as we get it more spec'd out. :)
     
  5. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    Could we at least reach a middle ground where the API is made not-internal again even though there will be no documentation? It would at least give us some kind of option for working with custom lighting/etc.... I'm sure we could reverse-engineer existing MasterNodes and it's better than it being impossible

    Or does your team have plans for making it more approachable in the future?
     
    Last edited: Apr 19, 2019
    MadeFromPolygons and ph_ like this.
  6. alexandral_unity

    alexandral_unity

    Unity Technologies

    Joined:
    Jun 18, 2018
    Posts:
    163
    The answer to the Master Node API being internal is going to be the same as the Code Function Node API being internal, which we've explained a little bit in other threads and in our 2019 GDC video.
    Making the API internal now allows us to make it more approachable in the future. Leaving it open for the public adds a lot of tech debt to our development and makes adding new features and functionality much harder. We know it's frustrating for right now, but leaving the API open means a lot more overhead in maintenance rather than potential refactors, and new features will take much longer to push out because of it.
     
    ph_ likes this.
  7. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    Hi Alexandra, I am wondering if there can be a workaround for this issue:

    - Because we are too deeply integrated into SG 4.x API, it's holding us back from using Unity 2019 and LWRP 5.x
    - We would like to use a supported version of LWRP. (4.x isn't supported, Unity 2018 LTS will be stuck with it)
    - I wonder if there is any chance, for us to run SG 4.x on Unity 2019, with LWRP 5.x
    - When SG 5.x is up to the task, we will happily deprecated SG 4.x

    It's a lot to ask, and I don't expect SG 4.x to ever be supported. But to us, since SG is really a Shader generating tool, it's not as critical as making sure we use a supported SRP.

    (We spent quite a lot of time switching from ASE to SG during Unity 2018, but it looks like we have to switch back, if no recourse is given on this topic.)
     
    MadeFromPolygons and ph_ like this.
  8. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,983
    The problem with that is a lot of users are now dependent on LWRP and you are stopping them from updating and therefore gathering feedback for the newer versions of unity, effectively making a subset of people who have been testing for you unable to test any further. I am sure I dont need to point out how this is not a good thing when it comes to getting well rounded testing feedback.

    Im not sure I see how this decision makes sense. Its a little irritating hearing LWRP is out of preview in 2019.1, and yet features that worked in previous version now break and therefore stop us updating and actually using the 2019.1 features that we really need. Its a bit of a silly position to be in and can be avoided by making it not internal and putting a pinned thread saying that its not internal so people can access it but no support will be given or documentation until ready.

    Users are already hacking around it anyway as mentioned here: https://forum.unity.com/threads/sha...-a-custom-lit-masternode.663250/#post-4469533

    So why not just make it not such a hurdle to those who have chosen to come on this journey with you and adopt LWRP so they can give you feedback etc.

    At the very least flash a giant warning message next time on the blog post about 2019.1 being released explaining this in the bit that says LWRP is out of preview, as it was very misleading given the current limitations.

    Anyway good luck to you and the team, but hope this is resolved soon as its a long time to wait just to author a simple toon lighting shader using NdotL and step.

    EDIT: like above user, we have also had to switch between ASE and SG a ton and would love not to have to switch back just because of this.
     
    KAJed and ph_ like this.
  9. huwb

    huwb

    Joined:
    Oct 19, 2013
    Posts:
    24
    Since its been a little while, I wanted to check if there was an updated timeline on having the Master Node API exposed and usable from asset store packages? In our particular case the ability to add our own master node would transform our offering as it would open up a key shader in our system to artists.

    Other relevant threads were mentioned above but I didn't easily find them, please let me know if there's a status elsewhere, or better place to post this.

    Thanks!
     
  10. PDivision

    PDivision

    Joined:
    Nov 10, 2012
    Posts:
    1
    + For the question. I want to implement custom lighting (stylized) with HDRP. I need proper decals with lighting and tiled render in HDRP does it.
    Does it still make sense to modify HDRP package and add custom master node or there is better API underway?
     
  11. fct509

    fct509

    Joined:
    Aug 15, 2018
    Posts:
    108
    Before LWRP, URP, and HDRP, I could extend the surface shaders to output additional channels that would be rendered to an array of buffers made from a collection of RenderTextures. This lets me extract all sorts of additional data that's helpful for machine learning. While AOV extracts some of the things I need, it doesn't get all of it; for instance, being able to assign a unique object id to each game object and then pass that to the fragment shader which outputs it to a pixel is quite handy. Being able to create a custom MasterNode with the ability to output additional channels would be quite helpful.
     
  12. adamgryu

    adamgryu

    Joined:
    Mar 1, 2014
    Posts:
    188
    Also just chiming in to say a custom master node / output channel would be really nice.

    As someone who is comfortable writing shaders from code, I'd still be interested in using the Shader Graph to author specific shader effects, while defining a general custom lighting model in code (since it feels more maintainable to me there).
     
    ftejada and fct509 like this.
  13. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    569
    Only if you assume we're asking for a) documentation b) stability. We're not.

    Go head and leave it undocumented. We can read the source.

    Go ahead and break it in every point release. We're grown ups and we accept that's the price to pay for using semi-internal stuff.

    Feel free to put up big scary warnings everywhere. Feel free to not offer any support or help on the forums.

    There IS an option that has no cost for you and a huge benefit for us. It's called "take away the guard rails for those that don't want them".
     
    mddsvr, DerMark, Yetman and 1 other person like this.
  14. mddsvr

    mddsvr

    Joined:
    Aug 3, 2020
    Posts:
    6
    Bump! Any updates on this feature?
     
  15. BenCloward

    BenCloward

    Unity Technologies

    Joined:
    Jul 15, 2021
    Posts:
    143
    If you're interested in creating your own lighting model in Shader Graph, we've just released Megacity Metro demo. For this demo, I created a set of shaders that uses a custom lighting model - so you can use that as an example to learn how it's done.

    https://unity.com/demos/megacity-competitive-action-sample

    The lighting model that I created is simplified for better performance on mobile platforms, and scales based on the user's selected quality setting. Download the demo and take a look at the shader that's used on the buildings.
     
    zenbin3d, lilacsky824 and mgear like this.
  16. BenCloward

    BenCloward

    Unity Technologies

    Joined:
    Jul 15, 2021
    Posts:
    143
    This new sample set that Unity just announced today also has an example (3 of them actually) of a custom lighting model built in Shader Graph. It has a tune shader, a simplified PBR lighting model, and a complete lighting model - all made from Shader Graph nodes.



    The video has the instructions for how to download the sample set.
     
  17. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,314
    Good job, nice to see examples made in shader graph, and thank you for creating it with 2022 in mind, not just 2023.
    What minor unity version is required to install samples?
     
  18. zenbin3d

    zenbin3d

    Joined:
    Jul 7, 2023
    Posts:
    25
    Awesome!
    Really really hope the graph samples aren't built like the custom lighting graph I just saw in the megacity sample you mentioned.o_O
    It is a mess...this is no way to author responsible shaders. ‍:(
    unnamed.png
     
  19. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    569
    Ugh. I can't wait for the text based shader authoring to be ready (assuming it isn't abandoned)
     
  20. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    569
    I'm not seeing a clickable link - are you saying we have to watch the video to find the download? Could you just post the link?
     
  21. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,314
    I don't know the minimal unity version, but it's available at least in 2022.3.21
    Navigate to
    Window > Package Manager
    , find Shader Graph, click Samples and import "Feature Examples".
     
  22. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    569
    Ah! Thanks. I didn't realise it was a package Sample
     
  23. BenCloward

    BenCloward

    Unity Technologies

    Joined:
    Jul 15, 2021
    Posts:
    143
    This is good feedback, zenbin3d - thank you! I spent a few hours today and went through all of the shaders in the Megacity sample adding notes and making the graphs a bit more readable. We didn't get a chance to do that the first time around because the release schedule was pretty compressed. My changes will go out the next time the sample is updated. This particular graph is still fairly complex, but I hope it's better.

    Lighting in general is fairly complex, but this portion of the graph specifically looks a bit more like spaghetti because of the Quality nodes I added. When quality is set to high, the full lighting calculations are used. On medium, the additional lights calculations are dropped, and on low, the specular calculations are also dropped. This saves a ton of performance on Android devices. Having the ability to turn features of the shader on and off based on quality adds a lot of power and flexibility to the graph, but it also adds node and wire complexity to the appearance of the graph.
     
  24. zenbin3d

    zenbin3d

    Joined:
    Jul 7, 2023
    Posts:
    25
    Totally understandable! No worries. Thank you so much for the follow up and for extra cleaning and improvements!
    I thought that was the final form it was released in and it was gonna stay like that.

    Yes, indeed when working with shader graphs, especially complex ones, node wire complexity can explode very quickly.
    That's why I'm not very fond of approaching a complex shader fully in shader graphs and rather try to separate more of the complex logic into external code functions called from the graph. I saw that you guys also used external code functions but leaving most of the logic inside the shader graph.

    But yeah, I guess there is no easier way to make shader graphs more readable.
    Thank you again for helping us devs better understand flexible ways of approaching Unity!