Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

Feedback Wanted: Shader Graph

Discussion in 'Graphics Experimental Previews' started by Kink3d, Jan 10, 2018.

Thread Status:
Not open for further replies.
  1. mosaic_school

    mosaic_school

    Joined:
    Dec 12, 2012
    Posts:
    73
    Is there a way to have something like the 'Final Color Modifier' with ShaderGraph as there was for Surface Shaders?
     
  2. Andy-Touch

    Andy-Touch

    A Moon Shaped Bool Unity Technologies

    Joined:
    May 5, 2014
    Posts:
    1,018
    andydbc likes this.
  3. Andy-Touch

    Andy-Touch

    A Moon Shaped Bool Unity Technologies

    Joined:
    May 5, 2014
    Posts:
    1,018
    Final Color Modifier? Im not sure what you mean... Do you have example code you can share?
     
  4. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,411
    i think he talking about the same final color function as in surface shader
     
  5. Karearea

    Karearea

    Joined:
    Sep 3, 2012
    Posts:
    333
    All the transparent shaders I create have the scene shadows of more distant objects render in front of them- is this something I’m doing wrong?
     
  6. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    7,163
    I imagined it's been mentioned, but having support for outlines and outline colours would be pretty great.
     
    Adam-Bailey likes this.
  7. Bers1504

    Bers1504

    Joined:
    Apr 28, 2018
    Posts:
    2
    The ability to write custom shaders is awesome!

    One thing I still can't figure out is how (or if possible at all) to add a secondary utility shader function for the primary shader function to use.

    The Voronoi-Node shader function, for example, uses such a local utility function :"inline float2 unity_voronoi_noise_randomVector (float2 UV, float offset) "

    In the example below, my understanding is the shader function is prepended with the function signature at some point before compilation. Is there a way to workaround this, in order to define and use a function such as "test(){..}" below?

    If anybody knows whether or not I am losing my time trying to figure out, let me know!

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEditor.ShaderGraph;
    3. using System.Reflection;
    4.  
    5. [Title("Custom", "My Custom Node")]
    6. public class MyCustomNode : CodeFunctionNode
    7. {
    8.     public MyCustomNode()
    9.     {
    10.         name = "My Custom Node";
    11.     }
    12.  
    13.     protected override MethodInfo GetFunctionToConvert()
    14.     {
    15.         return GetType().GetMethod("MyCustomFunction",
    16.             BindingFlags.Static | BindingFlags.NonPublic);
    17.     }
    18.  
    19.     static string MyCustomFunction(
    20.             [Slot(0, Binding.None)] DynamicDimensionVector A,
    21.             [Slot(1, Binding.None)] DynamicDimensionVector B,
    22.             [Slot(2, Binding.MeshUV0)] Vector2 UV,
    23.             [Slot(3, Binding.None)] out DynamicDimensionVector Out)
    24.     {
    25.         return
    26.             @"
    27. {
    28.    float3 apb = A+B;
    29.    Out.xy = UV.xy*apb.x;
    30.    Out.z = .5;
    31. }
    32.  
    33. inline float2 test()
    34. {
    35.    return float2(0.2,0.3);
    36. }
    37. ";
    38.     }
    39. }
     
  8. Bers1504

    Bers1504

    Joined:
    Apr 28, 2018
    Posts:
    2
    Ok, so I just found the source code for the Voronoi node. That seems to answer the question:

    from here

    Code (CSharp):
    1. using System.Reflection;
    2. using UnityEngine;
    3.  
    4. namespace UnityEditor.ShaderGraph
    5. {
    6.     [Title("Procedural", "Noise", "Voronoi")]
    7.     public class VoronoiNode : CodeFunctionNode
    8.     {
    9.         public VoronoiNode()
    10.         {
    11.             name = "Voronoi";
    12.         }
    13.  
    14.         public override string documentationURL
    15.         {
    16.             get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Voronoi-Node"; }
    17.         }
    18.  
    19.         protected override MethodInfo GetFunctionToConvert()
    20.         {
    21.             return GetType().GetMethod("Unity_Voronoi", BindingFlags.Static | BindingFlags.NonPublic);
    22.         }
    23.  
    24.         static string Unity_Voronoi(
    25.             [Slot(0, Binding.MeshUV0)] Vector2 UV,
    26.             [Slot(1, Binding.None, 2.0f, 0, 0, 0)] Vector1 AngleOffset,
    27.             [Slot(2, Binding.None, 5.0f, 5.0f, 5.0f, 5.0f)] Vector1 CellDensity,
    28.             [Slot(3, Binding.None)] out Vector1 Out,
    29.             [Slot(4, Binding.None)] out Vector1 Cells)
    30.         {
    31.             return
    32.                 @"
    33. {
    34.    float2 g = floor(UV * CellDensity);
    35.    float2 f = frac(UV * CellDensity);
    36.    float t = 8.0;
    37.    float3 res = float3(8.0, 0.0, 0.0);
    38.    for(int y=-1; y<=1; y++)
    39.    {
    40.        for(int x=-1; x<=1; x++)
    41.        {
    42.            float2 lattice = float2(x,y);
    43.            float2 offset = unity_voronoi_noise_randomVector(lattice + g, AngleOffset);
    44.            float d = distance(lattice + offset, f);
    45.            if(d < res.x)
    46.            {
    47.                res = float3(d, offset.x, offset.y);
    48.                Out = res.x;
    49.                Cells = res.y;
    50.            }
    51.        }
    52.    }
    53. }
    54. ";
    55.         }
    56.  
    57.         public override void GenerateNodeFunction(FunctionRegistry registry, GenerationMode generationMode)
    58.         {
    59.             registry.ProvideFunction("unity_voronoi_noise_randomVector", s => s.Append(@"
    60. inline float2 unity_voronoi_noise_randomVector (float2 UV, float offset)
    61. {
    62.    float2x2 m = float2x2(15.27, 47.63, 99.41, 89.98);
    63.    UV = frac(sin(mul(UV, m)) * 46839.32);
    64.    return float2(sin(UV.y*+offset)*0.5+0.5, cos(UV.x*offset)*0.5+0.5);
    65. }
    66. "));
    67.             base.GenerateNodeFunction(registry, generationMode);
    68.         }
    69.     }
    70. }
     
  9. Andy-Touch

    Andy-Touch

    A Moon Shaped Bool Unity Technologies

    Joined:
    May 5, 2014
    Posts:
    1,018
    Oh, I remember that now! :D I don't think there is an method currently in the PBR Master Node for Final Color.
     
  10. Ramphic

    Ramphic

    Joined:
    Jun 21, 2017
    Posts:
    57
    Hi, can't we see the final generated shader code of shader graph?
     
  11. xrooshka

    xrooshka

    Joined:
    Mar 5, 2014
    Posts:
    57
    Hi there. I wander is there ability to make transparent decal shaders in shader graph? Like adding decal:blend parameter in Blend dropdown
     
    AntonioModer likes this.
  12. Andy-Touch

    Andy-Touch

    A Moon Shaped Bool Unity Technologies

    Joined:
    May 5, 2014
    Posts:
    1,018
    Right click the Master Node -> Copy Shader -> Paste into a text-editor of your choice. :)
     
  13. JacketPotatoeFan

    JacketPotatoeFan

    Joined:
    Nov 23, 2016
    Posts:
    27
    Hello,

    Does the Shader Graph not work with the HD Render Pipeline yet?

    I downloaded 2018.1 RC, installed the latest preview versions for the HD Render Pipeline and Shader Graph using the Package Manager, but when creating a new Shader Graph, it's pink in the preview. Anything I do to try and effect the outcome doesn't work.
     
  14. Andy-Touch

    Andy-Touch

    A Moon Shaped Bool Unity Technologies

    Joined:
    May 5, 2014
    Posts:
    1,018
    No HD support yet; its in development.
     
  15. Cynikal

    Cynikal

    Joined:
    Oct 29, 2012
    Posts:
    122
    Not sure if i'm missing something, but I don't have the black board to change properties and their names.

    I have a single slider that i made a property, removed it, made a new one, and the code is showing 2 Vector1's with different names.

    I see in the screenshots, the properties are shown above the preview, but on my end, it's just the preview only.

    Any ideas?


    EDIT: Uninstalling, and reinstalling shader graph, letting it open up in it's default window and size, the blackboard shows up. If I resize the window, it's gone again. There should be checks to make sure it's in the viewable area, as i'm confident it's just outside of the area. (running dual monitors)

    Also, there is now a bug with the blackboard of constantly following my mouse.
     
    Last edited: Apr 30, 2018
  16. GameDevCouple

    GameDevCouple

    Joined:
    Oct 5, 2013
    Posts:
    2,474
    Andy you might want to make a "repository of confirmed knowledge" or "the state of things faq" sticky post containing all the things your having to repeat multiple times a day such as "HD support coming" ;)
     
  17. Luckymouse

    Luckymouse

    Joined:
    Jan 31, 2010
    Posts:
    481
    As I know that currently the shader graph doesn't support Texture3D format, I'm wondering if the shader graph will have Texture3D nodes in the future?
     
    elbows likes this.
  18. Hilmyworks

    Hilmyworks

    Joined:
    Mar 3, 2017
    Posts:
    1
    Echoing Cynikal's experience. I installed 2018.2.0b1 and found the Blackboard missing. I decided to try an older version - 2018.1.0f1 - and got the Blackboard to appear in a new Project. However, opening the previous Project within 2018.1.0f1 did not bring up the Blackboard.

    01 - Blackboard in two different projects.jpg
    Did a test in the Test Project by resizing the Blackboard and the Preview panels to their smallest size. Turns out while the Preview panel has a small horizontal pale handle that allows to resize it again, the Blackboard doesn't, and I'm stuck with a Blackboard I can't open again.
    02 - Lower right handles on panels.jpg

    Since opening a newer version Project in an older version of Unity could cause problems, I then opened the test Project from 2018.1.0f1 in 2018.2.0b1. Found that the Blackboard still fully minimized.
    03 - Window information carried into newer Unity versions.jpg

    Found out that if I convert input nodes into Property, I can still view/modify the Property within the Inspector. So the Blackboard functionality could still be there, but the Blackboard panel itself is inaccessible.
    04 - Convert to Property does make item visible in Inspector.jpg
     
  19. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    679
    elbows and Luckymouse like this.
  20. mosaic_school

    mosaic_school

    Joined:
    Dec 12, 2012
    Posts:
    73
  21. sschoener

    sschoener

    Joined:
    Aug 18, 2014
    Posts:
    73
    Hi there, ShaderGraph is already a very helpful tool! :) Is support for PerRenderer properties planned? I cannot seem to find any mentions of that :(
     
  22. alexandre-fiset

    alexandre-fiset

    Joined:
    Mar 19, 2012
    Posts:
    445
    Any ETA, even roughly, for the HD graph?

    Our new project is scheduled for 2020 and we'd love to start experimenting with the graph as soon as possible so we can setup our workflow the right way during development.

    The Lit shader is great overall, but we need more fancy things such as water intersect and etc.
     
  23. mattrified_

    mattrified_

    Joined:
    Jul 17, 2013
    Posts:
    32
    I'm also having this problem in 2018.1.0f2 currently.
     
  24. ShaneTheVeryTall

    ShaneTheVeryTall

    Joined:
    Nov 28, 2009
    Posts:
    11
    I'm also missing blackboard in 2018.1.0f2. Have never seen it. It doesn't appear to be minimized, unless it's like 1x1 pixels or something.
     
    Last edited: May 3, 2018
  25. ASFghost

    ASFghost

    Joined:
    Nov 21, 2016
    Posts:
    10
  26. tripsan

    tripsan

    Joined:
    Dec 26, 2013
    Posts:
    14
    also not getting a blackboard.

    using unity 2018.1.0f2.
     
  27. Fallc

    Fallc

    Joined:
    Mar 13, 2015
    Posts:
    48
    Hi there!

    Loving the shader graph and currently porting our existing shaders over. Everything looks so clean and "professional" now. :D
    But there are three things I really need for a 100% port:
    • Global variables from script (!)
    • Support for 3D Textures (I can emulate them for now...)
    • Consistent property names
    Also nice to haves:
    • Comments
    • Static Branching
    • Custom Code nodes (could actually solve my global var problem)
    • Shader graph for custom render textures
    • Vertex displacement
    • Tessellation control
    • Abilitly to explicitly process something in vertex stage

    Many thanks again,
    Julian
     
    Last edited: May 3, 2018
  28. Andy-Touch

    Andy-Touch

    A Moon Shaped Bool Unity Technologies

    Joined:
    May 5, 2014
    Posts:
    1,018
  29. hazukiaoi

    hazukiaoi

    Joined:
    Mar 6, 2015
    Posts:
    3
    Can we custom the master node?I want custom a node like toon shader or other stylized.I am try to write custom node and is not hard.But i don't know how to custom master node.
     
  30. Glaswyll

    Glaswyll

    Joined:
    Feb 13, 2014
    Posts:
    94
    Can you please add support for alt + right-click to zoom? I use a Logitech Trackman which is great for 3D modeling and navigating 3D environments, but no scroll wheel. That would also make it consistent with Unity's Scene view control scheme, Animator, Maya's Hypershade, etc. Thanks!
     
  31. resetme

    resetme

    Joined:
    Jun 27, 2012
    Posts:
    197
    is kinda cool but Unity Shader Graph is not mobile frindly at all right? Is just for fast prototyping?

    Checking the code there is a lot of Float, how can i change all my variables to half inside the graph?
    Also i dont need all those includes files, anyway to deselect them?
    Many of the computation are inside the fragment part and i want to do all inside my vertex and send the result to fragment, how should i do it?
    Checking profile in snapdragon show that shadergraph use lot more gpu clock then a normal shader code.

    im doing something wrong?
     
    Elecman likes this.
  32. equalsequals

    equalsequals

    Joined:
    Sep 27, 2010
    Posts:
    132
    Creating a custom Master Node is totally possible but non-trivial at this point. I'd like to see Unity make it a bit more simplistic as the system is fleshed out.

    If you look in the code for how the Master Node gets defined for one of the Lightweight Graphs, everything is there. It isn't exactly an easy read, though.
     
  33. Kandy_Man

    Kandy_Man

    Joined:
    Mar 8, 2014
    Posts:
    46
    2018.1 no blackboard for me either. Also really looking forward to being able to define the name of our properties internally as it's the only thing stopping shader graph from being able to write shaders for sprites (I get an error about sprite shader requiring _MainTexture or something like that. If we could rename them that would solve my problem).
     
  34. Andy-Touch

    Andy-Touch

    A Moon Shaped Bool Unity Technologies

    Joined:
    May 5, 2014
    Posts:
    1,018
  35. fdsagizi2

    fdsagizi2

    Joined:
    Nov 4, 2013
    Posts:
    69
    Preview nodes extremly big - look ugly, must be smaller 4 times! And nodes must be small as possible!
     
  36. wayfarergames

    wayfarergames

    Joined:
    Sep 7, 2013
    Posts:
    2
    Looks great so far, I've had no problems using it! Other than the lack of vertex displacement, but I assume that's on the way? I really hope it is, at least!
     
  37. Andy-Touch

    Andy-Touch

    A Moon Shaped Bool Unity Technologies

    Joined:
    May 5, 2014
    Posts:
    1,018
    If they were 4 times smaller; how would you be able to effectively see what the node/graph was doing?
     
    equalsequals likes this.
  38. fdsagizi2

    fdsagizi2

    Joined:
    Nov 4, 2013
    Posts:
    69
    Of course, we have used such tools for many years. I know what I'm talking about (Unreal Engine, Shader Forge, and now we use Amplify shader editor, because shader forge not suppoted any more and Shader Graph not eat ready to use)

    You do so for yourself! Where ? In your own blog - you can see what is done by the zoom out - as a result nodes became normal size, but text is not readable - too small!

    link on blog, head img ;): https://blogs.unity3d.com/ru/2018/0...raph-build-your-shaders-with-a-visual-editor/
     
  39. vProject

    vProject

    Joined:
    Sep 11, 2013
    Posts:
    8
    I see that properties references can be changed in next version, so graphs can now include _MainTex, etc. Will this mean I can use it as an alternative to the default sprite mat? My understanding is that setting a texture properties reference on the blackboard to _MainTex will cause that texture to use the sprite provided in the editor, is this correct?

    My plan was to create a graph that replicates the sprite renderer as it is now, then adds some color overlay based on depth to give the appearance of fog. Any ETA on this commit?
     
  40. MythrilMan51

    MythrilMan51

    Joined:
    Apr 24, 2017
    Posts:
    145
    If I were to do, well, THIS over here...
    Olimar-New-Challenger-01.gif
    I would know I would need to blend that image with hard light, but HOW THE HELL could I sample the world to blend it? I know the master node has some blend modes premade, but it doesn't have the blend mode I'm looking for.

    Shield Wall.png
     
  41. tripsan

    tripsan

    Joined:
    Dec 26, 2013
    Posts:
    14
    my blackboard is still missing any word on how i can fix this?
     
  42. MythrilMan51

    MythrilMan51

    Joined:
    Apr 24, 2017
    Posts:
    145
    ...............
    .... That too.
     
  43. SergejsK

    SergejsK

    Joined:
    Jun 30, 2016
    Posts:
    5
    I noticed Blackboard is missing for existing project, where I have added Lightweight RP from package manager.
    If I create new project and select Lightweight RP it works great and there are Blackboard.
     
  44. JustinBillson

    JustinBillson

    Joined:
    Jun 27, 2017
    Posts:
    2
    How do I access the properties that I create in the blackboard in my normal scripts?

    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using UnityEditor.ShaderGraph;
    4.  
    5.  
    6. public class NewBehaviourScript : MonoBehaviour
    7. {
    8.  
    9.     private void Awake ()
    10.     {
    11.        var mat = GetComponent<Renderer>().material;
    12.      
    13.      
    14.         Debug.Log(mat);          
    15.     }
    16. }
    This for example is a script on a cube that has the shader graph material on it and I'm trying to access the material variables that have been exposed to the inspector. Debug.Log(mat); returns the instance on the shader that has the properties on it but I have no idea what I need to type to access the variables of the shader. Also I have no idea if I need to use "using UnityEditor.ShaderGraph" or another using statement of some sort. I'm trying to access the _emissionStrength variable that is on the shader...
     

    Attached Files:

    Last edited: May 4, 2018
  45. Giles-Coope

    Giles-Coope

    Joined:
    Jan 5, 2015
    Posts:
    48
    As far as I understand you can't sample the color of the world from within a shader graph shader, you are limited to certain alpha blends. You can do a soft light blend on the current texture, using the Blend Node, https://github.com/Unity-Technologies/ShaderGraph/wiki/Blend-Node. However this won't affect the whole scene, only the current object being rendered.

    If you wan't this fancy blend over the whole image I believe you would need to render to a texture, then have another render pass, like a postprocessing effect.
     
  46. tripsan

    tripsan

    Joined:
    Dec 26, 2013
    Posts:
    14
    i feel like the blend node is missing a "mix" or "normal"(as its called in photoshop) mode.

    is there another node that accomplishes this i am unaware of?

    -j
     
  47. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,380
    Hi there,

    Just having a play around with the shader editor, it's great! I noticed a few things though that I thought I'd mention.

    If I delete a property and then save the asset, the property doesn't get cleared out of the inspector.
    Any chance you could make alt + right click work as zoom? (That would put the controls in line with the new animator view and 2d Scene view)
    There's heaps of blank space next to "Save Asset" and "Show in project" maybe you could put some of the functions there? Create Node for instance, because you are gonna be using that all the time.

    Anyway, I'm really looking forward to having this as part of my workflow, Thanks!
    Pete
     
  48. Andy-Touch

    Andy-Touch

    A Moon Shaped Bool Unity Technologies

    Joined:
    May 5, 2014
    Posts:
    1,018
    Setting Property Reference Names (That can be accessed from Script) is coming in the next version of Shader Graph. :)
    https://github.com/Unity-Technologies/ShaderGraph/blob/master/CHANGELOG.md
     
    JustinBillson likes this.
  49. rootsworks

    rootsworks

    Joined:
    Jan 31, 2016
    Posts:
    9
    Hey I followed the instructions from the live training videos and added the shader graph and lightweight render pipeline from the package manager and I'm still getting pink in the preview window, am I correct in understanding there's scripted render pipeline dependencies that need to be cloned from github before that pink will go away, or am I missing some other step?
     
  50. Andy-Touch

    Andy-Touch

    A Moon Shaped Bool Unity Technologies

    Joined:
    May 5, 2014
    Posts:
    1,018
    We zoomed out that screenshot (I took it myself ;) ) to show how nodes can be constructed an flow together. You can use Shader Graph's editor zoom to focus on specific areas of the graph. :D
     
Thread Status:
Not open for further replies.
unityunity