Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    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. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    Bumping this up in hope of some reply.

    To illustrate the issue, here are two images where other cube is using HDRP Lit shader and other is using simplest possible shader made with Shader Graph.

    When not using forward only from HDRP settings, both materials look identical:


    but when setting forward only on, shader graph generated shader gets really light while HDRP Lit shader looks just the same as on non-forward only:
     
    Last edited: Jul 24, 2018
  2. wyattt_

    wyattt_

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    424
    @Korindian Hiya! My pleasure! I've asked the HDRP team about your HDRP questions. Without much additional info/promises as things don't always make it into production (and I can't necessarily speak for the HDRP team):
    1. GPU instancing on HDRP shaders - Yes
    2. Custom Decal shaders in HDRP - Probably
    3. Custom UI shaders in HDRP - Probably not
    4. Multiple input slots per node (for Math nodes & more) - Yes
     
    elbows and Korindian like this.
  3. FellowPlayer123

    FellowPlayer123

    Joined:
    Dec 23, 2016
    Posts:
    114
    Hi!

    I would like to create unlit shader color with black border.
    Of course using graph nodes, not via coding.

    Any ideas how to do it?
     

    Attached Files:

  4. wyattt_

    wyattt_

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    424
    @MythrilMan51 Are you asking in regard "References" mentioned in eXecutex's question?

    If so, References would be any type available in ShaderGraph at the moment. Like Texture2D, Vector1, Vector2, Vector3, Color, etc. As for a list/documentation there is one on the GitHub wiki:

    https://github.com/Unity-Technologies/ScriptableRenderPipeline/wiki/Property-Types

    It's a tad outdated so we'll be updating it. Types missing include Gradient, Texture3D, TextureArray, and possibly a few others.
     
  5. Desoxi

    Desoxi

    Joined:
    Apr 12, 2015
    Posts:
    195
    I would like to have a possibility to set stencil buffer settings via the shader graph :/
     
    lucasjohansson and EricLowry like this.
  6. testa3d

    testa3d

    Joined:
    Jul 25, 2018
    Posts:
    3
    Hi Guys, I am using Unity 2018.2.0f2 the latest version on Mac and I dont have the shader graph, is it compatible with mac? or am I missing something?

    thanks in advanced.
    cheers
     
  7. ssartell

    ssartell

    Joined:
    May 21, 2018
    Posts:
    14
    @testa3d, you have to install it (along with one of the scriptable render pipelines) via the package manager. You won't see in a plain new project.
     
  8. MythrilMan51

    MythrilMan51

    Joined:
    Apr 24, 2017
    Posts:
    146
    I was gonna say.... It would be window -> Package manager... THEN you'll see our favorite feature so far.
     
  9. testa3d

    testa3d

    Joined:
    Jul 25, 2018
    Posts:
    3
    ssartell likes this.
  10. testa3d

    testa3d

    Joined:
    Jul 25, 2018
    Posts:
    3
    it says the current render pipeline is not compatible with this node 'PBR Master' I have gone to edit - render pipeline and updated for a high definition materials and it still doesn't work. I will keep browner to see if I find the solution :)
     
  11. MythrilMan51

    MythrilMan51

    Joined:
    Apr 24, 2017
    Posts:
    146
    Oh... YEAH.... THAT's annoying as hell.... Restart and try again.
     
  12. MythrilMan51

    MythrilMan51

    Joined:
    Apr 24, 2017
    Posts:
    146
    Also... If we can convert our gradients into properties... That would be awesome.
     
    MR-Heavy likes this.
  13. SUBZERO8K

    SUBZERO8K

    Joined:
    Jan 15, 2013
    Posts:
    36
    Is there a summary anywhere of what is and isn't possible with Shader Graph at the moment?

    I was considering using it to make a water shader, but wanted to know if it supports things like vertex displacement, reflection, refraction, etc.
     
  14. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    504
    Vertex displacement is in, kind of. I'd wait for a bit so it's a touch more stable and compatible, I think it doesn't play nice with some nodes?

    Reflection is great in the HDRP in 2018.2, reflection probes can now be planar reflection probes, which gives you the nice water reflections that 'just work'.

    Refraction could also do with some kind of probe, eventually, possible, not likely, but that isn't in yet. You can do it via script and another camera with a rendertexture and feed that in yourself.
     
    SUBZERO8K likes this.
  15. Jacksendary

    Jacksendary

    Joined:
    Jan 31, 2012
    Posts:
    408
    Have anyone had success in making basic for and if nodes and if so then how?

    Also is there anyway with this graph workflow to make "functions" or equivalent?

    Thanks in regards :)

    EDIT: I found compare which works for if, still not sure about for tho.
     
    Last edited: Jul 26, 2018
  16. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    789
    Sub Graphs = Functions and if you look through this thread a few pages back (around page 12 or so) @FreeGameDev made a lot of sub Graphs and posted a download link including "if" you can look through those to see if there's any other ones you would use.
     
    Jacksendary likes this.
  17. wyattt_

    wyattt_

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    424
    Totally doable for the vertex displacement. There are two caveats (that I can recall) with feeding data into the vertex shader (via the Position slot on the Master Node):

    1. You cannot reuse those nodes to feed data into the pixel shader (all the slots on the Master Node except for Position, ie Color, Smoothness, etc). You will basically have to copy-paste/reimplement the nodes again for any pixel shader inputs.
      • Good example of this is calculating height offsets for your vertices and wanting to use those values to color your crests/whitecaps. You'll have to do those calculations twice, once in the vertex shader and once in the pixel shader
    2. You cannot feed SubGraph output to the Position slot at the moment
    For reflection and refraction, stay tuned!
     
    SUBZERO8K likes this.
  18. wyattt_

    wyattt_

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    424
    Usually get that error if a render pipeline asset hasnt been specified for use in Graphics Settings

    If you havent done so, right click in your project folder and go to Create->Rendering and select either Lightweight or High Definition Render Pipeline Asset. After naming it, go to Graphics Settings and drag and drop your RP asset into the RP object field
     
    Gabadaba08 likes this.
  19. MR-Heavy

    MR-Heavy

    Joined:
    Jan 1, 2016
    Posts:
    14
    Yo @wyatttt ! I'm keep poking Graphics.Blit + shader graph, and compare results with same code on unlit/texture from built-in shaders and... Unlit/texture still work, SG - still a "black nothing" =(
    Do you have any progress with it?
     
  20. sewy

    sewy

    Joined:
    Oct 11, 2015
    Posts:
    150
    What do you mean by this? Where we need to put it to be in pixel shader?

    Is there a way to use this nodes (vertex displacement ones) for recalculating the normals?

    Thanks
     
  21. Jacksendary

    Jacksendary

    Joined:
    Jan 31, 2012
    Posts:
    408
    Thanks for the reply and help, Will read up on it right away! :)
     
  22. wyattt_

    wyattt_

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    424
    @MR-Heavy Hey! Ya I tried again (without copying the generated graph shader to a new one) and this time got the same results as you. Will fiddle around with it again when I have time. There's probably a lot more needed to get it working


    @sewy Here's my brilliant artist skills at work (Fragment Stage = Pixel):

    vertexfragmentstages.png
    vert to frag no can do.gif
    As of now, to use the data from the vertex offset displacement you'll have to redo the calculations for the fragment stage by duplicating the nodes

    - OR -

    You should be able to use the Position node in the fragment stage to get the result of your vertex offset calcs done in the Vertex Stage. In the case of doing a water shader, assuming the y value of the water vertices are all 0, you could do Position.y to get the "height" of the modified vertex and use that to color your water accordingly in the fragment stage. This will give you a vertex colored look, however.

    Here's an example:

    simple vertex water.png

    For the fragment stage, I use position again but this time it is the position that I modified during the vertex stage. I use the y component (which is effectively the height) of world position of the modified vertex to determine the color. Produces this:

    water anim.gif
     

    Attached Files:

    Last edited: Jul 27, 2018
    sewy and SUBZERO8K like this.
  23. wyattt_

    wyattt_

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    424
    And here is it with redoing the height calcs during the fragment stage:

    redoing calcs in pixel.png

    Which produces smoother gradients based on the height calcs:

    smoother color on water.gif
     
    sewy, MythrilMan51 and Dudledok like this.
  24. davl3232

    davl3232

    Joined:
    Dec 4, 2014
    Posts:
    1
    Hey guys, any chance we get access to ddx_fine/ddy_fine functions?

    I calculated normals from a greyscale input using ddx and ddy for a procedural shader and got a really blurry image as result. Capture.PNG

    I understand that the derivative calculation gives one value per 4 pixel square, and a solution I found online is to use ddx_fine and ddy_fine that calculate based on each pixel neighbors.
    So far I've tried creating a custom node, but the result didn't improve, I think it's not passing the compiler check I setup.

    Here's the code for the custom node:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEditor.ShaderGraph;
    5. using System.Reflection;
    6.  
    7. [Title("Math", "Advanced", "Ddx Fine")]
    8. public class DdxFineNode : CodeFunctionNode
    9. {
    10.     public DdxFineNode()
    11.     {
    12.         name = "Ddx Fine";
    13.     }
    14.     static string DdxFine([Slot(0, Binding.None)] DynamicDimensionVector In, [Slot(1, Binding.None)] out DynamicDimensionVector Out)
    15.     {
    16.         return @"
    17. {
    18. #ifdef UNITY_COMPILER_HLSL
    19.    Out = ddx_fine(In);
    20. #else
    21.    Out = ddx(In);
    22. #endif
    23. }
    24. ";
    25.     }
    26.     protected override MethodInfo GetFunctionToConvert()
    27.     {
    28.         return GetType().GetMethod("DdxFine", BindingFlags.Static | BindingFlags.NonPublic);
    29.     }
    30. }
    31.  
    Here's the input of the node and the custom node I made (which since is not passing the compiler check, actually does the same as the existing DDX node). Notice how blurry the DDX node's preview is.
    Capture3.PNG Capture2.PNG

    If there are no plans to include finer derivative nodes, what'd be a good way to do procedural normals with decent quality?
     
    Ziflin likes this.
  25. NatureManufacture

    NatureManufacture

    Joined:
    May 20, 2014
    Posts:
    2,026
    Hi!

    1#
    Remap node as property to achive this effect:
    upload_2018-7-27_15-56-33.png

    2#
    Normal vector input to get noise from normalmaps.
    upload_2018-7-27_15-58-29.png

    3#
    UV as property or uv offset and tiling as property so we dont have to use vector 4 to add offset and tiling.

    4#
    UV as property - list to chose which UV you want to use like in hd srp shader.

    5#
    Name in property should generate default name in shader code, manual changes are more then confusing


    I build some cool stuff today. I will not push this into more advanced results until world normal function will not going to be able get inputs.
    upload_2018-7-27_16-2-22.png
     
    elbows and eXecutex like this.
  26. Almgp

    Almgp

    Joined:
    Dec 9, 2014
    Posts:
    19
    Please help!!! I updated HDRP , and my project broken
     

    Attached Files:

  27. Mr-Mechanical

    Mr-Mechanical

    Joined:
    May 31, 2015
    Posts:
    507
    I love Shader Graph and Scriptable Render Pipeline. BUT, Shader Graph currently lacks the support for custom lighting models. It would be very very useful if Shader Graph could allow shaders with custom BRDFs. For example: I would like to change the fresnel approximation. For now this is impossible, as all shaders built in Shader Graph have to use the existing PBR equation.
     
  28. Almgp

    Almgp

    Joined:
    Dec 9, 2014
    Posts:
    19
    My expirience in shader graph
     
  29. Almgp

    Almgp

    Joined:
    Dec 9, 2014
    Posts:
    19
    Sci-fi displays))
     

    Attached Files:

  30. Carpe-Denius

    Carpe-Denius

    Joined:
    May 17, 2013
    Posts:
    842
    Your gradient node doesn't serialize well. Shaders with gradients don't work on machines with "," as a decimal seperator.
     
  31. VirtualPierogi

    VirtualPierogi

    Joined:
    Sep 3, 2012
    Posts:
    54
    Hey guys, couple ideas came to my mind:
    1. Since we have position could we get object rotation also
    (maybe transform matrix property and quaternions for some basic rotating action)
    2. Motion vectors node for some fancy stuff
    3. more human readable generated code (but that probably is the hardest thing I can imagine right now)
     
  32. MythrilMan51

    MythrilMan51

    Joined:
    Apr 24, 2017
    Posts:
    146
    Also... I might be out in the dark on this... But how do I use custom data from our particle system in our Shader Graph?
     
  33. sewy

    sewy

    Joined:
    Oct 11, 2015
    Posts:
    150
    Enable Custom data in particle renderer module (RENDERER!) and there are some preadded already like position, UVs etc. Next to each you can see what shader data are connected with it - e.g. UV on the photo is connected in TEXCOORD0.xy (UV node.xy) and Custom1.xy (Custom Data module) is connected with TEXCOORD0.yw (UV node.zw) etc.

     

    Attached Files:

    MR-Heavy likes this.
  34. MythrilMan51

    MythrilMan51

    Joined:
    Apr 24, 2017
    Posts:
    146
    And THIS would be the same if you're doing colors?
     
  35. MythrilMan51

    MythrilMan51

    Joined:
    Apr 24, 2017
    Posts:
    146
    upload_2018-7-29_12-55-20.png
    LIKE for example
     
  36. JCFR

    JCFR

    Joined:
    Nov 26, 2013
    Posts:
    2
    Hi every body,

    I'm starting to try ShaderGraph but i get an issue... In ShaderGraph Editor, my shader display correctly :
    But in the scene, it's the default gray shader... But it's the good shader in the material, and the good material in the object/sphere...

    Have you any idea ?

    EDIT : Ok i found the problem.. When i do CTRL+ S, that don't save the shader... I have to close te window to do it (after be promter to)...
     

    Attached Files:

    Last edited: Jul 29, 2018
  37. MythrilMan51

    MythrilMan51

    Joined:
    Apr 24, 2017
    Posts:
    146
    upload_2018-7-29_13-34-27.png
    ... Yep... It does... Follow the top 3 for instructions.
     
    Desoxi and wyattt_ like this.
  38. sewy

    sewy

    Joined:
    Oct 11, 2015
    Posts:
    150
    There is "Save Asset" button on the Top Left corner of the window ;)
     
  39. KillHour

    KillHour

    Joined:
    Oct 25, 2015
    Posts:
    49
    Do Shader Graph shaders not work with the MeshInstanceRendererSystem? The material shows up if I select the HDRenderPipeline/Lit shader, but not a shader from Shader Graph (even the default one).
     
  40. Carpe-Denius

    Carpe-Denius

    Joined:
    May 17, 2013
    Posts:
    842
    Did you check the "instancing enabled" checkbox?
     
  41. KillHour

    KillHour

    Joined:
    Oct 25, 2015
    Posts:
    49
    On the material or the shader? It's enabled on the material. I don't see anything of the sort on the shader itself.
     
  42. amritt_unity

    amritt_unity

    Joined:
    Jul 30, 2018
    Posts:
    13
    I also noticed that you can't use Sampler Texture 2D Output in Vertex Stage. I am trying to use ScreenPosition to sample a texture RGB value to change object position. Is there any solution to this? Also, the docs aren't updated and have broken wiki links. Having hard time finding stuffs.
     
  43. Luoyue

    Luoyue

    Joined:
    Jul 18, 2013
    Posts:
    3
    I have a problem ,how to use depth blend in shader graph?
     
  44. Luoyue

    Luoyue

    Joined:
    Jul 18, 2013
    Posts:
    3
    do you solve? i have the same problem:(
     
    MR-Heavy likes this.
  45. Chris_Riddell_VA

    Chris_Riddell_VA

    Joined:
    Mar 29, 2018
    Posts:
    3
    Hi Guys,

    I'm starting to use the new shader graph as a replacement to Amplify, I'm wondering do you have access to Light Direction? currently I don't see anything to do this.
     
    MR-Heavy likes this.
  46. TFgamesOG

    TFgamesOG

    Joined:
    Jun 2, 2017
    Posts:
    16
    Hey, @wyatttt thank you very much for your detailed posts! I have a very specific question:

    I dug deeper into the shader graph code and wondered what the precise difference between AbstractMaterialNodes and CodeFunctionNodes are?

    I understand, that CodeFunctionNodes generate functions that are then reused within the shader. Even though I understand what the classes are doing, I don't 100% understand why exactly is it done the way you guys did. Can you explain that to me?

    Thank you so much!
     
  47. wyattt_

    wyattt_

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    424
    There is a save button in the top left of the window so you don't have to close the window to generate the prompt to save
     
  48. wyattt_

    wyattt_

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    424
    You have to use Texture2DLod during the vertex stage
     
  49. Starsky

    Starsky

    Joined:
    May 11, 2015
    Posts:
    6
    Hi guys,

    I met a bug. I am not sure if it is a bug.

    I tried to create a water effect using the Shader Graph.
    First I would like to detect the distance between the surface of the water and the underwater ground (pic 1), so that I can make the water darker or lighter depending on the distance. To do that, I need to get the _CameraDepthTexture.

    TIM截图20180731101855.png
    Pic 1​

    I am suing Unity 2018.2.1f1, LWP, Unlit Graph. I did a test to obtain the _CameraDepthTexture and rendered it on a cube surface:
    This is the scene, very simple, a cube a camera and a directional light:

    TIM截图20180731102559.png
    Pic 2​

    And Created a very simple Shader Graph to obtain the _CameraDepthTexture:
    I added a property named "_CameraDepthTexture" which is the same as the "Reference", unchecked the "Exposed" box.

    TIM截图20180731102439.png
    Pic 3​
    I also set the LWP to support depth texture, and added the "Lightweight Additional Camera Data" script on the main camera.

    On the scene view, every thing worked good. I could see the depth texture in the Shader Graph editor window, I could see the cube rendered with the depth texture on its surface:

    TIM截图20180731103211.png
    Pic 4​
    However when I clicked the "Play" button everything became dark. No camera depth texture rendered:

    TIM截图20180731103502.png
    Pic 5​
    I don't know why it became like this. Anybody met the same situation ? Maybe all the global properties such as "_CameraDepthTexture" are not supported yet. I did not see any documents on this.
     
    sewy likes this.
  50. Korindian

    Korindian

    Joined:
    Jun 25, 2013
    Posts:
    584
    Feature request: Properties having a different tab color than other nodes to make them stand out.
     
    wyattt_ likes this.
Thread Status:
Not open for further replies.