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. TheWanderingBen

    TheWanderingBen

    Joined:
    Nov 3, 2015
    Posts:
    98
    Digging a bit deeper today, it looks like this texturing technique is actually done using the Stencil Buffer. Unfortunately, Shader Graph does not currently support writing to the Stencil Buffer.

    Does anyone have any information about when that might be included? I can't find anything posted about it.
     
    ImpossibleRobert likes this.
  2. HD-MI

    HD-MI

    Joined:
    Mar 9, 2017
    Posts:
    13
    So apparently HDRP 3.0.0's Shader Graph is still broken for me for 1) Transparent materials 2) _CameraDepthTexture grabbing. Both pretty vital for creating a water shader. Has anybody got these working in HDRP?
     
  3. Korindian

    Korindian

    Joined:
    Jun 25, 2013
    Posts:
    584
    I'm also having trouble getting _CameraDepthTexture to work for an equivalent to: http://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Shader_Editor/Depth_Fade

    I'm finding it a little troublesome to port my shaders over to HDRP given the current limitations of the Shader Graph. I can't wait for some in-depth documentation on how to code shaders for HDRP. Looking at the HDRP shader source is a little overwhelming for my current knowledge level.

    It would be nice to have Unity devs be as responsive on this thread as some of the devs are in other threads. Input system, Vector graphics, Text Mesh Pro, Collaborate and other such departments have really active participation by their respective developers. It's really great to see. It would help a lot to get some info on whether certain things will be supported in Shader Graph or not, or what features are upcoming or being developed. It seems like dev participation started off real strong in the beginning of this thread, but has kind of tapered off now except for @wyatttt

    I guess we'll have to wait for the 2018.3 beta to see any developments on the Shader Graph.
     
    MadeFromPolygons likes this.
  4. Clyde_Coulter

    Clyde_Coulter

    Joined:
    Jul 14, 2014
    Posts:
    58
    Anyone have any idea why it won't allow me to connect from the Transform (World to Object space) to the Position of the PBR Master node? I must be missing something very simple.
    (Unity 2018.2.2f1, LWRP & Shader Graph 3.0.0)


    NOTE: Before creating the sub graph (Gerstner) from most of the nodes, all of the nodes connected without a problem.
     
    Last edited: Aug 15, 2018
  5. madks13

    madks13

    Joined:
    May 8, 2016
    Posts:
    173
    @Clyde_Coulter : can you post the json of the graph? It's hard to read anything in the screenshot without zooming in 500%
     
  6. cAyouMontreal

    cAyouMontreal

    Joined:
    Jun 30, 2011
    Posts:
    315
    Hey guys, I was bored to change the render pipeline every-time I wanted to see the differences between legacy, LW and HD render pipelines, so I've created a shortcut to apply a new render pipeline that's currently selected in the project view.

    Code (CSharp):
    1.  
    2.  
    3. using UnityEditor;
    4. using UnityEngine.Experimental.Rendering;
    5. using UnityEngine.Rendering;
    6.  
    7. public class SwapRenderPipeline
    8. {
    9.     [MenuItem("RenderPipeline/Swap render pipeline %F1")]
    10.     public static void Swap()
    11.     {
    12.         RenderPipelineAsset renderPipelineSelected = Selection.activeObject as RenderPipelineAsset;
    13.         GraphicsSettings.renderPipelineAsset = renderPipelineSelected;
    14.     }
    15. }
    16.  
    If you select a render pipeline and press Ctrl+F1 it will apply it, select anything else or nothing, it will reset the property.
    That's verryyyyyyyyy simple but quite handy and time saver. Feel free to use it and change the key shortcut used (might not be the easiest one to press)
    Cheers !
     
    wyattt_ likes this.
  7. Clyde_Coulter

    Clyde_Coulter

    Joined:
    Jul 14, 2014
    Posts:
    58
  8. Clyde_Coulter

    Clyde_Coulter

    Joined:
    Jul 14, 2014
    Posts:
    58
  9. madks13

    madks13

    Joined:
    May 8, 2016
    Posts:
    173
    @Clyde_Coulter I tried setting the out(3) to positions(3) but it didn't work either. However if a create a Vector3 node, it can be linked to the position. I'm not sure the reason for this. But it happens on my computer too.
     
    Clyde_Coulter likes this.
  10. Clyde_Coulter

    Clyde_Coulter

    Joined:
    Jul 14, 2014
    Posts:
    58
    I'm installing 2018.2.3f1 right now (well, downloading currently) to see if it works in it.
     
  11. Clyde_Coulter

    Clyde_Coulter

    Joined:
    Jul 14, 2014
    Posts:
    58
    Nope, that didn't help.
    The thing is, the last node in the subgraph is a Vector3 that connects to the Subgraph Output node. The line coming from the subgraph should be yellow.
     
  12. Clyde_Coulter

    Clyde_Coulter

    Joined:
    Jul 14, 2014
    Posts:
    58
    I have created a very small subgraph, containing a single vector3 and then tried to use it in another graph.
    As can be seen, it is prepared to accept the output of the subgraph on all masternode inputs except the position.



    (Dang! Photobucket compresses the crap out of png files! :( )
     
  13. Lex4art

    Lex4art

    Joined:
    Nov 17, 2012
    Posts:
    445
    A question from non-shader guy: in HD shader graph is it possible to create a shader that can use edges and caverns of mesh geometry as a mask for effects like edge weathering and many more? Something like this:

    If I can have a realtime pointiness values and use them in shader graph for an arbitrary mesh it is possible to create effects like this without baking a mesh-specific textures - just layers of effects masked by angles between polygons:



     
  14. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    504
    Out of the users here, who is using the latest (up to date) SRP, LWRP and Post Processing using the Package manager? I'l be releasing my SGE demo shortly (see thumbnail) and I wanted to know which is most likely to be used. Currently it's on the LWRP for 2018.2 (moved from 2018.1).

    I've added a few more things based on feedback from this thread so it should be relevant to a fair few people.

    fireworks.png
     
    wyattt_ likes this.
  15. Ratatoeskr

    Ratatoeskr

    Joined:
    Oct 25, 2013
    Posts:
    9
    Hi there I'm using LWRP and Shader Graph (2018.2)
    One thing I recognized is that the Unlit Master Node doesn't offer appliance of the global unity fog. In my use case I want to manage lighting by myself but I also want to use the built-in fog. It would be great when I'd have the option to enable what I need for my specific master node (e.g. shadowing, etc.)
     
  16. K4stor

    K4stor

    Joined:
    Jul 31, 2018
    Posts:
    1
    Hello,

    I asked around on twitter, and from what I got so far, the results of the Shader Graph are re-rendered every frame, even when no animations are applied. And the texture actually is static. Can you confirm that ? If thats the case, how can I store the final texture into another one, lets say in a pre-compute step ?
     
  17. Desoxi

    Desoxi

    Joined:
    Apr 12, 2015
    Posts:
    195
    How can get acces to this particle vertex streams in my shader graph?

    Capture.PNG

    I tried using a UV node with Channel 3 but im not sure if thats the correct way because it doesnt work atm.

    EDIT: Okay i was able to access it via the UV node and channel 1 (because it obviously says TEXCOORD1 :D).
    But now i have the problem that i cant access the color values correctly...
    The color it outputs is not the color i have chosen in the Custom2 custom data module.
    For this im again using the UV node and channel 1 but accessing the yzw values.

    Capture.PNG

    EDIT2: Because i wasnt able to access the correct color value via the channel 1 yzw values, i added another "placeholder" vertrex stream for texcoord1.yzw and then another one for the Custom2 data using the full range xyzw values. This time i could access the via the UV node using channel 2.

    Capture.PNG
     
    Last edited: Aug 16, 2018
  18. Clyde_Coulter

    Clyde_Coulter

    Joined:
    Jul 14, 2014
    Posts:
    58
    I haven't tried it, but if I were to attempt it then I would take a look at using render to texture. Create a camera and new render texture and render certain assets to that using layers (?).
     
  19. NKlawitter

    NKlawitter

    Joined:
    May 19, 2015
    Posts:
    5
    Lighting and vertex displacement.

    I'm playing with deforming a spherical mesh with some noise and I've noticed that the lighting seems to only be calculated against the sphere proper and never on the deformations. Is this a forward vs deferred problem? e.g. there is a specular highlight that appears baked into the surface instead of updating as the noise deforms the surface.
     
  20. Clyde_Coulter

    Clyde_Coulter

    Joined:
    Jul 14, 2014
    Posts:
    58
    Are you modifying the normals also to conform to the deformations?
     
    NKlawitter likes this.
  21. MythrilMan51

    MythrilMan51

    Joined:
    Apr 24, 2017
    Posts:
    146
    upload_2018-8-16_20-52-25.png
    How I deal with it...
    upload_2018-8-16_20-54-3.png
    And when I graph it...
     
    wyattt_ likes this.
  22. monark

    monark

    Joined:
    May 2, 2008
    Posts:
    1,598
    How do you run a procedural node into a triPlanar projection. It only seems possible to pass it an existing texture, how do you turn a procedural node into a texture to pipe into a triplanar projection so you can texture geometry with no UVs procedurally?
    Maybe that just isn't possible to do entirely internally in a shader but it sure would be handy if you could procedurally pre-create textures to apply.

    Ah ha! Maybe using these
    https://docs.unity3d.com/Manual/CustomRenderTextures.html
     
    Last edited: Aug 17, 2018
  23. monark

    monark

    Joined:
    May 2, 2008
    Posts:
    1,598
    That does the job nicely.
     
  24. monark

    monark

    Joined:
    May 2, 2008
    Posts:
    1,598
    Is there a reason your voronoi noise node doesn't output distance 2?
     
  25. ssartell

    ssartell

    Joined:
    May 21, 2018
    Posts:
    14
    @Luoyue @MythrilMan51 I made a previous post showing the subgraph for LinearEyeDepth. Here it is again:

    You can use this to convert the _CameraDepthTexture value back to an actual distance that can be used to compare against z value of the Position node (in view space).

    If you want an example, here's that force field shader that leverages the LinearEyeDepth subgraph:

    There's probably some simplification that could happen here, but it was a quick pass.
     
  26. peter-klauser

    peter-klauser

    Joined:
    May 20, 2017
    Posts:
    1
    Is there support for [PerRendererData] properties in Shader Graph?
     
  27. UDN_46c91c6c-aeb1-471f-87fb-917fc1db02c9

    UDN_46c91c6c-aeb1-471f-87fb-917fc1db02c9

    Joined:
    Dec 3, 2017
    Posts:
    21
    Hello,
    I wanted to create a sprite shader where I change the albedo's color to a color defined by a gradient.
    But I found that the gradient can't be converted to a property. I would really love to modify the gradient per material. Even more, per instance.
     
  28. wyattt_

    wyattt_

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    424
    Heya! This is a problem with SubGraphs not being able to connect to the Vertex Stage of the Master Node. This is a known issue and on our radar. You can use them in the Fragment Stage (ie when you color your waves based on combined wave height from your Gerstner SubGraphs) and connect them to (I believe) everything except "Position". My suggestion is to, in the interim, convert your SubGraph to a custom node. Let me know if you have any questions about this process.
     
    Clyde_Coulter likes this.
  29. wyattt_

    wyattt_

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    424
    Can you explain this a bit more? Are you referring to the previews you see when the ShaderGraph asset window is open? And maybe provide info on what you are ultimately trying to accomplish then I might be able to give you a better answer.
     
  30. konsic

    konsic

    Joined:
    Oct 19, 2015
    Posts:
    995
    How to make custom lighting in shadergraph?

    I would like to control the frenel based on normal orientation (faking the light angle) so I could make something like this


    frenel.png
     
  31. NKlawitter

    NKlawitter

    Joined:
    May 19, 2015
    Posts:
    5
    Recalculating normals...

    I'm working on a graph that uses noise to create vertex displacements on a sphere, but I need to update the normals so the lighting and reflections are accurate. So far I have not found any examples of how to do this... Any thoughts?
     

    Attached Files:

    sewy and konsic like this.
  32. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    789
    a Normal From Height node should be coming in the next version of Shader graph so you will be able to use that to get the proper normals.

    From - Github Shader Graph Changelog
    upload_2018-8-20_13-24-51.png
     
  33. konsic

    konsic

    Joined:
    Oct 19, 2015
    Posts:
    995
    I can't update it because it tell me it's up to date with 3.0.
     
  34. MythrilMan51

    MythrilMan51

    Joined:
    Apr 24, 2017
    Posts:
    146
    ... What's the current version of it?
     
  35. konsic

    konsic

    Joined:
    Oct 19, 2015
    Posts:
    995
    [3.1.0]
     
  36. Clyde_Coulter

    Clyde_Coulter

    Joined:
    Jul 14, 2014
    Posts:
    58
    Any help getting started writing a Gerstner custom node would be greatly appreciated. I've been looking for any docs on writing custom shaders for shadergraph and what the available method(s) are. The CodeFunctionNode examples are really sparse, and only give very simple examples without any doc on writing a shader for that environment. This will be completely new to me, but I'm willing to and capable of learning.

    NOTE: I think I just need to implement a vertex or compute shader for this.
    EDIT: I found the code on GitHub for the current shadergraph nodes, that should help.
     
    Last edited: Aug 20, 2018
  37. MythrilMan51

    MythrilMan51

    Joined:
    Apr 24, 2017
    Posts:
    146
    I bet it's a bug... I mean... I'm on the latest version on Unity... 2018.2.4... So I wouldn't know... Unless.....
     
  38. MythrilMan51

    MythrilMan51

    Joined:
    Apr 24, 2017
    Posts:
    146
    I don't see it there... Take it up to the manager.
     
  39. konsic

    konsic

    Joined:
    Oct 19, 2015
    Posts:
    995
    What is equivalent to shaderforge's Append node in Shadergraph ?

    asp.JPG
     
  40. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    504
    combine node
     
    konsic likes this.
  41. ssartell

    ssartell

    Joined:
    May 21, 2018
    Posts:
    14
    Do you just want to do a fresnel effect from a different angle than the view angle? If so the equation is pretty simple and you could just replicate it.

    Out = pow((1.0 - saturate(dot(normalize(Normal), normalize(YourNewDirection)))), Power)
     
    konsic and Clyde_Coulter like this.
  42. wyattt_

    wyattt_

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    424
    Have you seen this yet? https://blogs.unity3d.com/2018/03/27/shader-graph-custom-node-api-using-the-code-function-node/
     
    Clyde_Coulter likes this.
  43. Clyde_Coulter

    Clyde_Coulter

    Joined:
    Jul 14, 2014
    Posts:
    58
    Yes, and that got me going pretty well with the hook up for deriving from the CodeFunctionNode, but the syntanx and the like for coding the shader was what took me a bit to figure out.

    I got it going, though, and it works pretty well. I'll post a video and pic in a bit once it uploads. I really like how the integration works, it makes it really pretty easy to implement a new node!
    (thanks for giving me a push to get started with it!) :)
     
    wyattt_ likes this.
  44. wyattt_

    wyattt_

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    424
    Awesome! Looking forward to seeing it!
     
  45. Clyde_Coulter

    Clyde_Coulter

    Joined:
    Jul 14, 2014
    Posts:
    58
    @wyatttt
    Here it is, 2 of the new nodes in action together: :D



    I'll have to work on the normals, can't quite get them right.

     
    Last edited: Aug 21, 2018
    URocks and wyattt_ like this.
  46. wyattt_

    wyattt_

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    424
    Nicely done! For the normals, you'll want to get the heights of neighboring pixels (most likely a kernel around the actual pixel) and then calc the normal based on those height relations.
     
  47. Clyde_Coulter

    Clyde_Coulter

    Joined:
    Jul 14, 2014
    Posts:
    58
    I tried using this from an article on it since I have most of those ready to be used from calculating the wave function. The article is at: https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch01.html



     
    Last edited: Aug 22, 2018
    URocks likes this.
  48. wyattt_

    wyattt_

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    424
    Was going to ask if you were following the GPU Gems article. I have been looking at that too but haven't gotten to the normal stuff yet.
     
    Clyde_Coulter likes this.
  49. Clyde_Coulter

    Clyde_Coulter

    Joined:
    Jul 14, 2014
    Posts:
    58
    I can post the code, if you want, for the node and maybe you can play with it and see how it goes.
    I thought that I might be able to use a Normal Blend node to blend from multiple Gerstner nodes.
     
  50. Clyde_Coulter

    Clyde_Coulter

    Joined:
    Jul 14, 2014
    Posts:
    58
    @wyatttt

    Edit: Oops, I might see the problem with the normal....I'm doing a dot(Di, wpos + offset), but wpos is a vec2 of worldpostion.xz, and offset is xyz (so I changed it to offset.xz).

    Code (CSharp):
    1. // Editor/GerstnerNode.cs
    2. [Title("CoulterMade", "GerstnerA")]
    3. public class GerstnerNode : CodeFunctionNode, IMayRequirePosition, IMayRequireTime
    4. {
    5.     public GerstnerNode()
    6.     {
    7.         name = "GerstnerA";
    8.     }
    9.  
    10.     protected override MethodInfo GetFunctionToConvert()
    11.     {
    12.         return GetType().GetMethod("GerstnerA", BindingFlags.Static | BindingFlags.NonPublic);
    13.     }
    14.  
    15.  
    16.     static string GerstnerA(
    17.          [Slot(0, Binding.WorldSpacePosition, 0, 0, 0, 0)] Vector3 WPos,
    18.          [Slot(1, Binding.None, 0.707f, 0, 0.707f, 0)] Vector2 direction,
    19.          [Slot(2, Binding.None, 2.0f, 0, 0, 0)] Vector1 waveLength,
    20.          [Slot(3, Binding.None, 0.2f, 0, 0, 0)] Vector1 amplitude,
    21.          [Slot(4, Binding.None, 0.5f, 0, 0, 0)] Vector1 speed,
    22.          [Slot(5, Binding.None, 0.7f, 0, 0, 0)] Vector1 steepness,
    23.          [Slot(6, Binding.None, 1.0f, 0, 0, 0)] Vector1 numWaves,
    24.          [Slot(7, Binding.None, 0, 0, 0, 0)] out Vector3 offset,
    25.          [Slot(8, Binding.None, 0, 0, 0, 0)] out Vector3 normal
    26.         )
    27.     {
    28.         offset = Vector3.zero;
    29.         normal = Vector3.up;
    30.  
    31.         return @"
    32.            {
    33.            float2 Di = normalize(direction);
    34.            float2 wpos = WPos.xz;
    35.            //{precision} wi = 6.283185 / waveLength;
    36.            {precision} wi = 2.0 / waveLength;
    37.            {precision} Qi = steepness / (wi * amplitude * numWaves);
    38.            {precision} QiA = Qi * amplitude;
    39.            {precision} Pt = speed * wi * _Time.y;
    40.            {precision} k = wi * dot(Di, wpos) + Pt;
    41.            {precision} cosK = cos(k);
    42.            {precision} qiAcosK = QiA * cosK;
    43.            offset.x = Di.x * qiAcosK;
    44.            offset.z = Di.y * qiAcosK;
    45.            offset.y = amplitude * sin(k);
    46.  
    47.            {precision} WA = wi * amplitude;
    48.            {precision} DdotP = wi * dot(Di, wpos + offset.xz) + Pt;
    49.            {precision} C0 = cos(DdotP);
    50.            {precision} S0 = sin(DdotP);
    51.            normal.x = -(Di.x * WA * C0);
    52.            normal.z = -(Di.y * WA * C0);
    53.            normal.y = 1.0 - (Qi * WA * S0);
    54.            normal = normalize(normal);
    55.            }
    56.        ";
    57.     }
    58.  
    59.     public bool RequiresTime()
    60.     {
    61.         return true;
    62.     }
    63. }
    64.  
     
    Last edited: Aug 22, 2018
    Reanimate_L, wyattt_ and sewy like this.
Thread Status:
Not open for further replies.