Search Unity

  1. Unity 2019.2 is now released.
    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. amritt_unity

    amritt_unity

    Joined:
    Jul 30, 2018
    Posts:
    13
    Thanks, it worked. But, what's the different between the two nodes - Texture2D and Texture2DLod?
     
  2. amritt_unity

    amritt_unity

    Joined:
    Jul 30, 2018
    Posts:
    13
    Also, How to use light probe nodes?
     
  3. sewy

    sewy

    Joined:
    Oct 11, 2015
    Posts:
    57
    You cant yet. You can run aroud this by exposing vector3 and feeding it via script with light direction
     
  4. xvart

    xvart

    Joined:
    Dec 12, 2010
    Posts:
    21
    Hey everyone I remember hearing that we can see the source code for the pre-shipped nodes. Is that true, if so where can I find those? I was planning to modify the gradient node to expose the colors/positions....
     
  5. Matt_MG

    Matt_MG

    Joined:
    Aug 2, 2012
    Posts:
    1
    Supposing I'm using shader graph to make a shader for a particle system and I used the Color Over Lifetime to change the color and transparency of the particles.

    The Vertex Color node does not seem to be passing the Alpha channel information from Color Over Lifetime unlike the RGB information.

    Then again maybe I'm doing this all wrong...
     

    Attached Files:

  6. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    483
    try the split node after the vertex colour, grab alpha, and stick it into emission and see if that works.
     
    Matt_MG likes this.
  7. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    1,212
    Not sure if this has been asked before, how do I create a material in code (C#) from a ShaderGraph? For example, if I had an existing Shader, and build a new Shader using ShaderGraph, how would I convert the following code to use the new ShaderGraph?

    Code (CSharp):
    1. Shader myShader = (Shader)AssetDatabase.LoadAssetAtPath(shaderPath, typeof(Shader));
    2.  
    3. if (myShader != null)
    4. {
    5.   Material mat = new Material(myShader);
    6. }
     
  8. Giles-Coope

    Giles-Coope

    Joined:
    Jan 5, 2015
    Posts:
    48
    The channel mask just makes all other components zero, so (r, g, b, a) -> (0, 0, 0, a) in your case, what you seem to be looking for is the split node which will make (r, g, b, a) -> (a)
     
    Matt_MG likes this.
  9. Lynxed

    Lynxed

    Joined:
    Dec 9, 2012
    Posts:
    55
    2018.2.1f1 HD Pipeline. Simplest Graph is getting me errors:

    upload_2018-8-2_16-20-14.png

    What am i doing wrong?
     
  10. daniel-griffiths

    daniel-griffiths

    Joined:
    Jun 14, 2016
    Posts:
    27
    Hello, does anyone know when Depth Blend will be added. ?

    Thanks
    Daniel
     
  11. daniel-griffiths

    daniel-griffiths

    Joined:
    Jun 14, 2016
    Posts:
    27
    Think it currently only works with Lightweight pipeline. might be wrong but this is what i believe it is

    GL
     
  12. MythrilMan51

    MythrilMan51

    Joined:
    Apr 24, 2017
    Posts:
    122
    I was gonna say... Split them
     
    Matt_MG likes this.
  13. Folstrym

    Folstrym

    Joined:
    Apr 11, 2016
    Posts:
    4
    I'm getting this error when running Shader Graph with .Net 4.x equivalent :

    ```
    Preview shader for graph has 3 errors:
    Shader compilation error in graph at line 5 (on ):
    Parse error: syntax error, unexpected ',', expecting ')'
    Shader compilation error in node Power (8fb364d8-58c0-49c1-a128-296772189efc) at line 109 (on d3d11):
    pow(f, e) will not work for negative f, use abs(f) or conditionally handle negative values if you expect them
    Compiling Fragment program
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_RGBM_ENCODING
    Shader compilation error in graph at line 252 (on d3d11):
    'TransformObjectToWorld': implicit truncation of vector type
    UnityEditor.EditorApplication:Internal_CallUpdateFunctions()
    ```
    I believe Shader Graph and .Net 4.x equivalent are not compatible. Any thought on this? Thanks
     
  14. Vanamerax

    Vanamerax

    Joined:
    Jan 12, 2012
    Posts:
    833
    I am having the same issues. Shadergraph turns magenta when the scripting runtime is set to .Net 4.x equivalent. Does not happen and works fine on .Net 3.5. Stack traces:
    Assertion failed on expression: 'success'
    UnityEngine.GUIUtility: ProcessEvent(Int32, IntPtr)

    Compilation error in graph at line 6 (on ):
    Parse error: syntax error, unexpected ',', expecting TVAL_ID or TVAL_VARREF
    UnityEngine.GUIUtility: ProcessEvent(Int32, IntPtr)

    I guess I cannot use both ECS and the shadergraph simultaneously then right now, as ECS requires .Net 4.x :(
     
  15. ImNotAfred

    ImNotAfred

    Joined:
    Dec 23, 2016
    Posts:
    29
    Very poor documentation and feedback on Unlit ShaderGraph. Shame!
     
  16. rizu

    rizu

    Joined:
    Oct 8, 2013
    Posts:
    1,188
    It's still in preview and not released, don't expect proper docs at preview stage, there's nothing shameful about this. You need to dial down your expectations for previews or wait for a final product.
     
  17. VitruvianStickFigure

    VitruvianStickFigure

    Joined:
    Jun 28, 2017
    Posts:
    11
    I started using Shader Graph back in 2018.1 and enjoy it very much; while I am experienced with Cg in Shader Lab, it is helpful to be in a visual state of thought while working on a new shader. It seems quite capable. However, I built a relatively complicated water shader the other day and I've bumped into a few concerns.

    First, do you have any intention of adding the ability to leave comments on the graph? In Blender, which also has a spaghetti graph for shader construction, we have the ability to add a frame node that displays text created with the text editor. (It's not as straightforward as humanly possible, I would love some kind of "Sticky Note" node, but it does the job.) (After building any shader, six months down the road I will most certainly have forgotten how it works, so I make heavy use of // comments.)

    Second, I'm seeing that shader subgraphs cannot reference other shader subgraphs. This might have a sound reasoning behind it, but I don't know what it is and it really surprised me. I've been using them like functions, and it's quite limiting. Whether the language is graphical or textual, the old rule of "If you have to write it twice, make it a function" still applies and aids readability. I can work around it for now, but I've been using subgraphs like functions, and this would be very helpful.

    Third and finally, I can still work five times as fast in Cg as I can in Shader Graph; not because I don't understand what's happening, but because every time even a minor change is made, even if the result is basically a given, the entire graph is recompiled for preview and I have to wait on it. (As an example, changing the identifier from "_Vector3_LongSequenceOfNumbers" to "_Position" would trigger a recompile, even though it seemingly does nothing to the shader itself.) For complex graphs, this is a tool killer--I just can't bring myself to use it on anything more complicated than the water shader. More control as to when the preview graphs are compiled (or even if they are compiled!) would be very helpful; making it a background process, maybe with a visual cue that it was updating the preview shaders, would be even better, kind of like Unity already does for C#.

    Otherwise, I love what you guys are doing and I look forward to it coming out of preview!
     
  18. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    483
    I second most of these comments.

    Shader forge does the notes thing pretty well, it adds a comment string above the node in the editor, and I also use empty relay nodes (no modification, just a relay) with text to store info/help/explainations.

    I think the no-subgraphs-referencing-subgraphs thing might in part be a protection against infinite loops. I don't find it too bad; just requiring a bit more assembly at the top shader graph level.

    100% agree with you on the compiling thing. Either compile and save it properly, and we'll be happy to wait a few seconds, or don't compile/save and let us work quickly. Choosing one or the other doesn't make sense.

    On a slightly more silly note, I made this
    sampler_dna_2d.png
     
  19. MythrilMan51

    MythrilMan51

    Joined:
    Apr 24, 2017
    Posts:
    122
    HOWEVER... I do wonder if you could use shader graph to make image effects like bloom and tone mapping....
     
  20. CaptainPronin

    CaptainPronin

    Joined:
    Apr 16, 2018
    Posts:
    2
    I have recently switched to shader graph and noticed a problem.
    Materials made with shadergraph ignore lighting layers. If i set a light to ignore a certain layer and put the object with the material on that layer it still gets lit. This is the case in both the lightweight and HD render piipeline.
    Is there a new function for this that im missing, or is this no longer a feature?

    Ok, i just did some more testing and noticed that only directional lights ignore layers. Point lights work as intended. So i assume this is a bug.
     
    Last edited: Aug 3, 2018
  21. sand_lantern

    sand_lantern

    Joined:
    Sep 15, 2017
    Posts:
    56
    While this may be true, I remember writing algorithms for detecting cycles in graphs fairly early in my Co Sci minor. Wouldn't it be better to be running check for a cycle in situations like this and then throwing a warning or error to the user and not building the graph? That certainly sounds more user friendly while still allowing more power to the subgraphs.
     
    VitruvianStickFigure likes this.
  22. SilferTech

    SilferTech

    Joined:
    Oct 19, 2017
    Posts:
    2
    This is nice feature, but I had a problem when prepared the unity to use shader graph in a project, the health gui attached to my player use the canvas in world space mode, but it work in editor but after build to android device its stop to work. I made several test and after unistal the Lightweight Render Pipeline its back to work!! Since shader graph needs the Lightweight Render Pipeline to work!! This bug appears when I created a minimap using 2 cameras, disable the cam the gui backs to work!! Cya and tks :) love shader graph!!
     
  23. Blitzkriegmlg

    Blitzkriegmlg

    Joined:
    May 1, 2013
    Posts:
    8
    I've followed along with this video using the Lightweight Render Pipeline in Unity 2018.2.1f1. The three shaders needed were created using shadergraph and then copying out the master node's code to make some final adjustments such as the stencil buffer writing and the tags. The rest of my scene is set up exactly as it is in the example scene linked from that video.

    It doesn't work. It seems that camera.SetReplacementShader() is bugged for the new render pipeline or something. At first I tried it the way the example project has it set up: I tried to replace shaders with a specific tag. Nothing happened, so I passed an empty string in SetReplacementShader() expecting everything in view to be rendered with the given shader, and nothing happened. Then I tried giving a nonsense string like "aflkahsdkasdf" that is clearly not tagged in any shader. The Unity docs say that if nothing is found with the given tag, nothing will be rendered, but again, nothing happened - everything was rendered on the screen normally.

    Maybe I've just set everything up wrong, but it seems to me that the SetReplacementShader() method currently doesn't do anything (at least in LWRP).

    Another thing: I've been working on creating a new master node to implement toon lighting so that I can move my current project to the LWRP, but I'm having difficulty making a new master node with a specific SubShader. I know that the SubShaders have a list of .template files that get used for rendering, and I see that MasterNode has a list of SubShaders and a method to add them and that gets called in UpdateNodeAfterDeserialization() where it takes any assemblies in the current domain and checks whether they are the right shader type to use in this master node.

    That leaves me with a couple questions: when and where are master nodes instantiated? in shadergraph/Editor/AssetCallbacks/CreatePBRShaderGraph.cs there's a line that reads: graph.AddNode(new PBRMasterNode()); but there isn't a shader type that is given to it.

    There have been a few comments on this thread from people saying that they've made their own master nodes to implement features that they want and it was relatively easy, so am I missing something here? How do you give a particular subshader to a master node? Do you have to do anything special for the new master node to appear in the shader graph editor?
     
    Aladine likes this.
  24. wonson

    wonson

    Joined:
    Apr 21, 2016
    Posts:
    5
    Is it possible that: Select multiple node in graph, and convert them to a custom node?
     
    VitruvianStickFigure likes this.
  25. Blitzkriegmlg

    Blitzkriegmlg

    Joined:
    May 1, 2013
    Posts:
    8
    Most of the nodes that have documentation pages have the code at the bottom that they use, so you could copy all of them and then put them all in a new custom node.
     
  26. EmirYsr

    EmirYsr

    Joined:
    Oct 12, 2016
    Posts:
    1
    I'm trying to make dynamic decal and projector shader, before unity 2018 update my shaders working, but after the lwrp my shaders couldn't work anymore, is it possible to make one of them ?
     
    Jokerminator likes this.
  27. HopelessHyena

    HopelessHyena

    Joined:
    May 26, 2015
    Posts:
    18
    @wyatttt @alexandral_unity In the LWRP Is there any (preferably straightforward way) to achieve very basic light transmission through a mesh? The use case is: I want to have rain (or fog) particles which, when lit from behind with a spotlight, will illuminate just as though the light were scattering through them.

    In the HDRP, you can achieve a very much more complicated effect with Subsurface Scattering which will alter the transmission based on a thickness map. I simply want to illuminate the rain/fog planes when light is shining on them from behind, AS WELL AS when the light is shining on them from the front. (The latter is obviously very easy to achieve, as it is default behaviour).

    Would anyone be able to provide an example of how to achieve this? Many thanks in advance!
     
    Last edited: Aug 5, 2018
    A132LW likes this.
  28. HopelessHyena

    HopelessHyena

    Joined:
    May 26, 2015
    Posts:
    18
    It seems that the "position" calculations are not evaluated first when it comes to processing order in the LWRP shader graph.

    As a result, in my "ocean" shader below (for which I have exaggerated the height of the waves to make it more obvious), the Fresnel effect is calculated as though there were no waves at all, based on the original sub-divided plane that I used for the ocean mesh.

    What I would be expecting to see here is red/green patches where red represents normals that I am looking directly at, and green represents normals which are at 90 degrees to my viewing angle.

    @wyatttt @alexandral_unity Are we supposed to be correcting for this manually through the shader (if so, how?), or should it be that the the "Position" (vertex position) is evaluated first so that the Fresnel effect and take this into account?



    P.S. Please see my question one above too!!

     
    sewy likes this.
  29. edino525

    edino525

    Joined:
    Mar 15, 2016
    Posts:
    2
    Hi guys, I'm using the LWRP, but I can't get the shadergraph to work, it's pink... other textures are fine And yes, I've got the LWRP selected in the settings. Thanks.
     
  30. Blitzkriegmlg

    Blitzkriegmlg

    Joined:
    May 1, 2013
    Posts:
    8
    Do you have shadergraph installed in the package manager?
     
  31. edino525

    edino525

    Joined:
    Mar 15, 2016
    Posts:
    2
    Yes I do, I've tried the version 0.1.17, 2.0.6 and 3.0.0 and the same results.
     
  32. MythrilMan51

    MythrilMan51

    Joined:
    Apr 24, 2017
    Posts:
    122
    .... Yeah... You are.... Try the split node, THEN multiply.
     
  33. metamorphling

    metamorphling

    Joined:
    Apr 27, 2017
    Posts:
    2
    Just studying shaders, wanted to try adding glow to a unity-chan model from asset store.
    If I put this shader as a second material it also applies albedo, which does break model looks.
    Can I somehow apply alpha to albedo only?(I need just emission channel)

    upload_2018-8-6_2-33-52.png upload_2018-8-6_2-34-32.png
     
  34. cAyouMontreal

    cAyouMontreal

    Joined:
    Jun 30, 2011
    Posts:
    279
    Hey there ! I've wanted to create a subgraph to simplify some part of the base graph (and fore re-usability, yeah !). The problem here is that a subgraph can only output a Vector4. In many cases, I only want to output only one value, and I wall have to split each time my result, which is the opposite of the goal I'm trying to achieve (less nodes, clearer graph).
    Is there any way to change that on a subgraph? Thanks !
     
  35. cAyouMontreal

    cAyouMontreal

    Joined:
    Jun 30, 2011
    Posts:
    279
    Another question: it looks like there is a limitation on the quantity of textures that can be added a shader using shadergraph. I've got this error:

    maximum ps_5_0 sampler register index (16) exceeded
    Compiling Fragment program with LIGHTLOOP_SINGLE_PASS USE_FPTL_LIGHTLIST
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_FULL_HDR

    But I'm using only 12 textures, so it shouldn't be an issue. Any idea?
     
  36. wyatttt

    wyatttt

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    287
    Great question! Off the top of my head, this is what I would try. If anyone has a better method of doing this, please chime in.

    I imagine that you could do it by passing some transform information of said Spotlight to the ShaderGraph (mainly position and the direction the light is pointing). You'd first have to detect if the light direction is pointed towards the back face of the plane used to render the rain particle AND if the ray from the spotlight + it's direction intersects the particle plane then you would do the lighting from behind. Otherwise, you would do the lighting for when the light is pointing at the front face. You could lerp between the two based on the angle between the light direction and plane normal.

    I'd start with detecting if the light is pointing in the same direction as the plane normal and color the particle based on that. Then you can do intersection tests and then the actual lighting. An even simpler starting point would be to treat the light as a point light (omni-directional) then later try doing the calcs for a spotlight.
     
  37. Clyde_Coulter

    Clyde_Coulter

    Joined:
    Jul 14, 2014
    Posts:
    57
    This is one busy place! :)

    In LWRP 2018.2.2f1, the PBR Master Node and Standard PBR Shader don't quite match up. Here are two pictures, one using a Material with the default PBR Shader and setting the metalic and smoothness very high (metallic 0.987, and smooth 1.0), and the other is using a material with a PBR Shader Graph that only has a PBR Master Node with the metallic and smoothing the same (also the albedo color of both is the same and the emission is black).


    LWRP Material using Standard PBR shader (above)


    LWRP Material using a Shader Graph with a PBR Master Node only (above)

    And, the following is the Script used to track the camera with a Reflection Probe that is anchored to the reflecting plane.


    [ExecuteInEditMode]
    public class ReflectionProbeFollow : MonoBehaviour
    {
    public Transform reflectingPlane;
    Camera mainCamera;
    private void Start()
    {
    mainCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Camera>();
    }
    private void Update()
    {
    Vector3 pos = mainCamera.transform.position;
    pos.y = -pos.y + (reflectingPlane.position.y * 2.0f);
    this.transform.position = pos;
    }
    }
     
    Last edited: Aug 7, 2018
  38. Euri

    Euri

    Joined:
    Sep 30, 2014
    Posts:
    7
    When I set a Master PBR (left) or Unlit (right) node to transparent and two sided I get this , some parts of the backfaces get in front of the front faces. In the Unlit master, the color imput is a simple 2d texture (if is a solid color, you can't notice the error). Does this happens to someone else? Is there a way to fix it?
    upload_2018-8-6_17-36-55.png
     
  39. Clyde_Coulter

    Clyde_Coulter

    Joined:
    Jul 14, 2014
    Posts:
    57
    Well, well.
    I installed the 3.0.0 preview of LWRP.core and the Shader Graph and those problems just a couple of posts up seem to be gone! More testing to do.
    Thanks, Unity guys and gals!
     
    Last edited: Aug 7, 2018
  40. Clyde_Coulter

    Clyde_Coulter

    Joined:
    Jul 14, 2014
    Posts:
    57
    Really, really, really close!
    This is acceptable for a water shader, though (if I were to perturbate the normals).


    Material using a Shader Graph with a single PBR Master Node only.
    (see my post about 3 post above for the settings and the code for the reflection probe to follow the camera)
     
  41. Luoyue

    Luoyue

    Joined:
    Jul 18, 2013
    Posts:
    3
    can you share your Custom node~please.I have been troubled for a long time.thk~
     
  42. MythrilMan51

    MythrilMan51

    Joined:
    Apr 24, 2017
    Posts:
    122
    Speaking of the devil... I will need this for a force field as well...
     
  43. Clyde_Coulter

    Clyde_Coulter

    Joined:
    Jul 14, 2014
    Posts:
    57
    I haven't seen any posts lately about string conversion to/from floating point values lately, perhaps the issue is solved.
    But, in my application, ColorMixer3DPX, I ended up going with "culture invariant" conversions. That forces everyone on the planet to use "." as a decimal separator, but solved all of the bug reports on it and I heard no complaints from any users out there. It helped that the other tools in the 3D gcode conversion path only supported "." as the decimal separator also, though.
     
    Last edited: Aug 7, 2018
  44. Euri

    Euri

    Joined:
    Sep 30, 2014
    Posts:
    7
    Hey, has this happened to someone else?
     
  45. metamorphling

    metamorphling

    Joined:
    Apr 27, 2017
    Posts:
    2
    Adding this for the record so that maybe somebody else will be looking for the same stuff.
    So, while I was looking for a useful button like "turn off albedo" I thought to myself "but what if I use pulsating fresnel as alpha channel data" and well, that basically cancelled albedo color out, leaving only emission. Have to get used to shaders, guess there is this 'click' moment to wrap your head around how things are done.
    Although I still have small barely visible albedo color stain(guess that's lighting), but it does not bother that much.
     
  46. Clyde_Coulter

    Clyde_Coulter

    Joined:
    Jul 14, 2014
    Posts:
    57
    (ShaderGraph and LWRP preview 3.0.0)
    Is there a way to expand the properties window within shader graph? It keeps getting shorter and shorter as I add properties.
    Also, with the Multiply Node, I had to replace one because the 2nd input (B) no longer displayed (it had no connection/edge at the time).
    Also, the problem has returned where clicking on a value (x, etc) changes to the left+right arrow cursor with no change to the value until you click off (empty space) and then after, when you move over it, the value changes without a mouse down.

    (above) notice the short properties window (labeled Displacement)

    (NOTE: I'm working on modifying the normal to match the change in vertex displacement using the cosine(s))
     
    Last edited: Aug 7, 2018
  47. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    571
    At the bottom right you can drag to resize it. Notice the little icon there (looks like this _ )
    You probably collapse the node with the arrow at the top right on the node. (The bottom arrow hides the preview and the top right one hides connections not in use)

    You have to hold ctrl then click and move left to right for it to update properly (Only way to do this right now that I know of).
     
    Clyde_Coulter likes this.
  48. Clyde_Coulter

    Clyde_Coulter

    Joined:
    Jul 14, 2014
    Posts:
    57
    Cool, that worked! Thanks.

    I may have. I never even noticed there was one at the top right (I'm partially colorblind, so a difference in intensity of the colors is what I have to lean on).

    I'll try this, thanks.
     
  49. madks13

    madks13

    Joined:
    May 8, 2016
    Posts:
    163
    Hello, before ShaderGraph, i was using ShaderForge, an asset. And although i love ShaderGraph, there is one tiny little feature from ShaderForge that i miss dearly and think would be nice to have :
    - Set/Get

    These nodes, as the name states, allow to store a value in a variable, and get it from one or multiple places. For example, if i need to use an input in several calculations, instead of having lines going haywire all over the place, i just use a set node to get the value i want, then for each node using said value i create one or multiple get nodes.


    This is purely visual in the interface, for clarity. It also allows to separate heavy calculations in neat little groups instead of having incomprehensible mess of nodes and node links.

    If you could add this feature, i think it would be great, for me and everyone else.
     
  50. Clyde_Coulter

    Clyde_Coulter

    Joined:
    Jul 14, 2014
    Posts:
    57
    You might accomplish the same sort of thing by creating a property (which can be made non-visible outside the shader) and then drag that node from the property window to as many places as you need to use it. (edit: I realize that you can't set it from within the shader nodes, but only use it as a constant if not visible outside the shader)
     
Thread Status:
Not open for further replies.