Search Unity

Unable to create custom Shader Graph node due to inaccessibility of CustomFunctionNode class

Discussion in '2019.1 Beta' started by mleodev, Nov 22, 2018.

  1. mleodev

    mleodev

    Joined:
    Mar 4, 2015
    Posts:
    6
    Error: CS0122: 'CodeFunctionNode' is inaccessible due to its protection level

    Unable to inherit from the class CodeFunctionNode due to its protection level, I was trying to create a custom shader graph node,
    I'm using:
    • Unity 2019.1.0a9
    • Core RP Library 5.1.0
    • Lightweight RP 5.1.0
    • Shader Graph 5.1.0
     
  2. izym

    izym

    Unity Technologies

    Joined:
    Jul 27, 2013
    Posts:
    24
    Hi there,

    We're working on a new API for making custom nodes that will address some of the issues people had with the current API, as well as distance the public API more from the internals of Shader Graph such that we don't back ourselves into a corner. Unfortunately we've had to make the current API internal before the new API is ready. We know that this sucks right now, but something better is coming :) Everything you've created with CodeFunctionNode will be convertable (manually though) to the new API, and graphs made using custom CodeFunctionNodes will continue to work if you follow some simple guidelines when converting to the new API. Currently we're aiming to have it ready for 2019.1.
     
    hawken, hippocoder, jashan and 2 others like this.
  3. mleodev

    mleodev

    Joined:
    Mar 4, 2015
    Posts:
    6
    Good to know, thanks for the proper and clear response! Waiting for the new API to come!
     
    izym likes this.
  4. deus0

    deus0

    Joined:
    May 12, 2015
    Posts:
    16
    I wish there was a way to get pinged when it's available, is there a mailing list? haha. Thanks for the great work, loving the beta and alpha updates.
     
  5. sewy

    sewy

    Joined:
    Oct 11, 2015
    Posts:
    46
    Any ETA about this? After update to 2019.1.0a10 got this error and most of my shaders cannot compile. Making the current API internal before the new API is ready with no temporary hack, to be able to continue was not a good decision at all.

    Shader Graph + HDRP 5.2.3.
     
    Last edited: Jan 3, 2019
  6. ArchVizPRO

    ArchVizPRO

    Joined:
    Apr 27, 2014
    Posts:
    331
    Unity 2019.1.0a13, still same problem. :(
     
  7. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    1,487
    The goal is still to have the new API ready for 2019.1, which is targeted to be released in April. It will likely become available before then on GitHub but not in the next couple of weeks.
     
    hugokostic and LennartJohansen like this.
  8. asdzxcv777

    asdzxcv777

    Joined:
    Jul 17, 2017
    Posts:
    19
    any updates on this ??
     
  9. TimNedvyga

    TimNedvyga

    Joined:
    May 18, 2015
    Posts:
    63
    +++ any news would be great!

    We still not able to make custom nodes with 2019.1b5 and ShaderGraph 5.6.1 :(
     
  10. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,342
    I was told it's being worked on, and will probably (cant predict exactly as it has to be code reviewed and merged etc). I verified this with a visit to github and it's being worked on without a specific date other than to land within 2019.1.

    It's intended to land in 2019.1 for sure through. You will just have to be patient since it's at most within 4 weeks.
     
  11. jay3sh

    jay3sh

    Joined:
    Dec 30, 2013
    Posts:
    6
    I'm still seeing this problem in 2019.2.0a9. Does it have the new API?
     
  12. TimNedvyga

    TimNedvyga

    Joined:
    May 18, 2015
    Posts:
    63
    You can create Custom Function node in ShaderGraph now.
     
  13. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,342
    Yes and it's not related to what alpha you have, but what version of SRP is in use.
     
  14. Renanmgs

    Renanmgs

    Joined:
    May 16, 2016
    Posts:
    25
    Hey @hippocoder , i upgraded my projet to 2019.1 and my customnode broke as well, where i can find the guidelines to upgrade it for the last version of HDRP?
     
  15. Zundrium

    Zundrium

    Joined:
    Aug 12, 2013
    Posts:
    2
    What's the reason behind this change? Maybe I'm criticizing incomplete work but the previous API was way more flexible and easy to understand. Having to specify a custom node each time in the ShaderGraph GUI vs creating a C# superclass and selecting the node like any other node.. this way will get very annoying when you have around 20 custom nodes. Please tell me we'll get the CustomNode base class back :O
     
    TimNedvyga and Renanmgs like this.
  16. TimNedvyga

    TimNedvyga

    Joined:
    May 18, 2015
    Posts:
    63
    For the sake of justice, you could actually create subgraph for custom node and reuse it. But I agree that C# class was much more handful in terms of share. It's just easier to share your work when a user has the opportunity to look at the node's code right on GitHub without a need to import it to Unity.
     
    GameDevCouple_I likes this.
  17. Renanmgs

    Renanmgs

    Joined:
    May 16, 2016
    Posts:
    25
    My problem now is: I have a customNode to my shader work with DrawMeshInstanced. Without the customNode Codes i cant specify my shader to be a MeshInstanciable.
     
  18. cpinard

    cpinard

    Joined:
    Feb 18, 2019
    Posts:
    1
    Just a heads up I wasn't able to get this to show up in 2019.1b10 until I had updated the RP Core/LWRP to 5.10.0
     
  19. hawken

    hawken

    Joined:
    Aug 22, 2013
    Posts:
    475
    any news?

    This was handy for custom things like refraction nodes
     
  20. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    531
    It's been replaced in 2019.1 forward with a Custom Function node instead of the C# API.
    With the node, you can either directly write HSL code in it or attach an HSL file to it.

    upload_2019-4-16_3-55-19.png
     
  21. hawken

    hawken

    Joined:
    Aug 22, 2013
    Posts:
    475
    Last edited: Apr 16, 2019
  22. Zundrium

    Zundrium

    Joined:
    Aug 12, 2013
    Posts:
    2
    I've been told using HLSL files is a lot cleaner than pasting HLSL code inside a C# class. I guess that's correct. However, I do hope to see a guide about this as well. Trying to use Kejiro's 3D noise as a test. But error messages like `_CustomFunction_3B100912_New1 used without having been completely initialized.` isn't really giving me a direction on where to search..
     
  23. 479813005

    479813005

    Joined:
    Mar 18, 2015
    Posts:
    39
  24. Kink3d

    Kink3d

    Unity Technologies

    Joined:
    Nov 16, 2015
    Posts:
    45
    Hi all,

    We understand that there is some confusion around how the custom function node works and/or the way we recommend that you work with it. We are currently working on the documentation for this node, but it is becoming clear that documentation alone may not be enough and a blog post or similar might be required. Thanks for the input here.

    For the record, if you are sharing custom function nodes (within Sub Graph as is recommended and noted earlier) we recommend you use File mode for various reasons (code diff, viewing source on github etc). File mode also allows you much more options such as defining custom uniforms, data structures and including more files etc.
     
    hashimoto-y, Renanmgs and hawken like this.
  25. bauke

    bauke

    Joined:
    Apr 19, 2019
    Posts:
    11
    Looking forward to the documentation.

    To summarize the example 479813005 added:
    the hlsl function name should end with _float (althought the name field in the shader graph does not)
    Results are returned as out values (the return value is not used and can always be void?)
    The source field searches from the base unity directory

    upload_2019-4-19_22-48-10.png

    test.hlsl:
    Code (csharp):
    1. void PixelShaderFunction_float(out float4 color, out bool test)
    2. {
    3.     color = float4(1,0,0,1);
    4.     test = true;
    5. }
    I couldn't get the inline code (type = String) to work. It seems to fail on the parameter declaration.
     
  26. asdzxcv777

    asdzxcv777

    Joined:
    Jul 17, 2017
    Posts:
    19
    any update on documentation for this ??
    i am having difficulty understanding how output works. does it have to be out parameter or return value
     
    Last edited: Apr 22, 2019
  27. bauke

    bauke

    Joined:
    Apr 19, 2019
    Posts:
    11
    put your result values
    Out parameters

    For example, to create a node with 2 input booleans and 2 booleans as output:
    void fn_float(bool InValue1, bool InValue2, out bool OutValue1, out bool OutValue2)

    Assign your resulting value to the out params. Make sure the inputs and outputs on the custom node match your function and you should get a result from the node.
     
  28. hawken

    hawken

    Joined:
    Aug 22, 2013
    Posts:
    475
    Screen Shot 2019-04-23 at 22.07.31.png @bauke you need to match the names your Out parameters exactly (with no spaces) as they appear in both the custom fields and your inline string.

    So "Test boolean" is invalid, it should be "test". "Color" is also invalid, it should be "color" (not recommended as this is a reserved term)

    Also, inline strings only work without brackets, as far as I can tell (I'm only testing with one liners)

    Having the custom parameter names as white on grey is my biggest challenge right now ;):(o_O:eek::)
     
    Last edited: Apr 25, 2019
    bauke likes this.
  29. bauke

    bauke

    Joined:
    Apr 19, 2019
    Posts:
    11
    Ah, thanks for clearing that up @hawken .
    I was putting the entire function inside the body of the custom node, rather then just the content of the function.

    It's interesting that the parameter names are used inside the generated code thought. When using an hlsl file the first output is mapped to the first out value and the parameter names are purely aesthetic (and also visible on the node so making them readable names seems like the logical thing to do).
     
  30. Lightway82

    Lightway82

    Joined:
    Dec 19, 2018
    Posts:
    10


    Where i can find it?
    Shader Graph version 6.5.3
     

    Attached Files:

    • 111.png
      111.png
      File size:
      18.5 KB
      Views:
      4,636
    Last edited: Apr 25, 2019
    hegdavid96 likes this.
  31. hawken

    hawken

    Joined:
    Aug 22, 2013
    Posts:
    475
    upgrade to 5.10
     
  32. 3d_Artist1987

    3d_Artist1987

    Joined:
    Jul 9, 2012
    Posts:
    707
    I install the latest shader graph (5.7.2) via package manager but still don't find custom node.
     
    hegdavid96 likes this.
  33. m3rt32

    m3rt32

    Joined:
    Mar 5, 2013
    Posts:
    58
    Alright, but this node looks like removed in latest versions. Is that mean another change/removal coming up?
     
    Last edited: May 5, 2019
  34. hawken

    hawken

    Joined:
    Aug 22, 2013
    Posts:
    475
    the latest in 2019.1 is 5.13
     
  35. 3d_Artist1987

    3d_Artist1987

    Joined:
    Jul 9, 2012
    Posts:
    707
  36. 3d_Artist1987

    3d_Artist1987

    Joined:
    Jul 9, 2012
    Posts:
    707
    ok,I got it
     
  37. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    915
    It looks like the custom node has been removed from 6.5.3 (Unity 2019.2.0b1) :confused:
    It's really annoying... :(
     
  38. brokenCarry

    brokenCarry

    Joined:
    Apr 30, 2015
    Posts:
    3
    Which version of Shader Graph do I need to have access to the Custom Node API. I have been trying a bunch of different version and none of them let me access the class. This is becoming very annoying at this point.
     
    JimmyCushnie likes this.
  39. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    915
    I think that only ShaderGraph 5.13 (unity 2019.1) contains the custom function node...:confused:
     
  40. brokenCarry

    brokenCarry

    Joined:
    Apr 30, 2015
    Posts:
    3
    That sucks if that the case im in using the preview version since the 2019.1 version of unity crashes on project load
     
  41. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    890
    kalagaan likes this.
  42. brokenCarry

    brokenCarry

    Joined:
    Apr 30, 2015
    Posts:
    3
  43. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    915
    In 5.13 you can write the code in the node or add a path to a HLSL file.

    according to the change log of 7.0.0, it will be possible to link a file to the node :)
    • The Custom Function Node now uses an object field to reference its source when using File mode.
     
    Last edited: May 22, 2019
  44. monark

    monark

    Joined:
    May 2, 2008
    Posts:
    1,494
    You should probably remove this from the docs as it appears to no longer be relevant

    https://docs.unity3d.com/Packages/c...anual/Custom-Nodes-With-CodeFunctionNode.html
     
  45. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    1,487
  46. _watcher_

    _watcher_

    Joined:
    Nov 7, 2014
    Posts:
    129
    Just to Up this incase it was forgotten, remove please. I also just spent quite a while trying to integrate no-longer-usable code into my project (like this one and many other github code repos are now unusable). Cheers! :confused: Or atleast add a WARNING and a link to this thread on top, so people dont waste time digging in.
     
    LeonhardP likes this.
  47. _watcher_

    _watcher_

    Joined:
    Nov 7, 2014
    Posts:
    129
    Since the old docs are still up, is there any place one could get the docs you mentioned or the blog post? Your message is almost 4months old, so either it was forgotten completely, no longer required(?), subject to change, or whatever the reason, id love to get some basic info with some examples maybe, as im currently starting to learn to use this tool.
     
  48. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    1,487
    _watcher_ likes this.