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

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    552
    Answer my own question: Right-click on the master node and Copy shader (or Show Generated Code).

    Looking at the generated code, it seems a lot more is happening inside the shader that's not related to my custom shader logic. It would be great for Shader Graph to mark the graph logic clearly or wrap them in some pre-defined block, so we don't have to hunt down changes all over the shader.
     
  2. iamarugin

    iamarugin

    Joined:
    Dec 17, 2014
    Posts:
    208
    Right click on output node -> Open Source Code or Copy Shader
     
  3. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,379
    @skilfuldriver Wow, that is a weird way just to sample the depth buffer.
    @wyatttt is this the only way to sample a scene depth buffer?

    Speaking about water, if you are in HDRP why not using density volume? you can get localize fog with it
    WaterDepth.png
    also a bonus by using it you can get automatically half underwater and anisotropic fog
    HalfSub.png

    but yeah still need the depth blend alpha tho

    @Kink3d any chance we can get a shader graph support for decal?
     
    Last edited: Oct 23, 2018
    P_Jong, skilfuldriver and wyatttt like this.
  4. amritt_unity

    amritt_unity

    Joined:
    Jul 30, 2018
    Posts:
    13
    Does Single Pass Instanced work with Shader Graph?
     
  5. wyatttt

    wyatttt

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    288
    Super cool! As for sampling the depth buffer, there's a node for it now in one of the latest package releases
     
  6. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,379
    in 401?
     
  7. E2R_Ben

    E2R_Ben

    Joined:
    Oct 30, 2009
    Posts:
    143
    Hey guys, ive got an alpha sorting problem. Is it possible to write to the z / depth buffer using shader graph and LWRP (3.0.0.0)? I did this with shader forge and it worked perfectly.
    I need to keep this model as it is and it will be the only set of objects on screen in an AR app. I would ideally like to do some more effects like have its fade in and out, but cant do that if the transparency is like this.

    upload_2018-10-25_12-28-53.png
     
    OfficialHermie likes this.
  8. AndrewKaninchen

    AndrewKaninchen

    Joined:
    Oct 30, 2016
    Posts:
    89
    Is there any wahy to create an inline code snippet Node in shadergraph? I was trying to makes a shader yesterday with a friend and we realized some very simples logical operations taken waaay too much space in the graph. It got even worse when we realized Subgraphs don't support logical outputs, so we has to copy and paste all of that twice.
     
  9. Tekksin

    Tekksin

    Joined:
    Oct 20, 2013
    Posts:
    32
    might be random, but shader graph using Hd pipeline isn't shwoing the animation result on the preview. kinda annoying.
     
  10. Immu

    Immu

    Joined:
    Jun 18, 2013
    Posts:
    150
    upload_2018-10-26_10-36-22.png upload_2018-10-26_10-36-34.png
    Hi, I'm getting strange 'Material property is found in another cbuffer than 'UnityPerMaterial' for all almost all my shaders
    made with shadergraph, and always on what seems like a random property picked within the list of properties.

    I think that started to appear with latest 2018.3.b7 (though I don't see the link). Never saw that before and no clue how to fix it @_@. And it only displays the info when property node is linked.

    Any thought?

    (Im on latest package manager's LWRP & ShaderGraph)

    Unless it's only an info warning related to the uncompatibility to SRP Batcher ? The feedback isn't clear.
     
    Last edited: Oct 26, 2018
    AKA009, longtu_wl and OfficialHermie like this.
  11. MTAU

    MTAU

    Joined:
    Oct 26, 2018
    Posts:
    2
    The billboard shader I made by multiplying the position node set to object by the transformation matrix set to transpose model view isn't working in hdrp. It's broken my shader and thrown a wrench in my plans. And why are the wind ,distortions, subsurf scattering and other such functions not on the pbr master node?
     
  12. Glaswyll

    Glaswyll

    Joined:
    Feb 13, 2014
    Posts:
    84
    Please add alt+right-click to zoom functionality to keep it consistent with the navigation scheme of other Unity panels.
     
  13. PixelLifetime

    PixelLifetime

    Joined:
    Mar 30, 2017
    Posts:
    52
    Has the support for generation of a meta pass for the GI been added to Shader Graph already? I didn't know that was the issue and I was working with emission a lot and wondering what did I do wrong, though, I am glad to hear that it could be that it is not supported yet.
     
  14. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    2,061
    Sorry if some/all of this is duplication of what might already have been posted. This is a very long thread at this point, so it's hard to be sure. Here's some feedback after a couple of days of working with Shader Graph. So far, very enjoyable to work with.

    • Documentation: I'd like to be able to add comments to specific nodes, to remind myself why I'm performing a certain operation. "We're subtracting the radius here because..." Also, I'd like to be able to put comments around a group of nodes, "This section deals with offsetting the UV based on a noise pattern". Right now it's pretty difficult to look at the graph at times.
    • Live Preview: Although preview nodes update in realtime, the Master Preview does not, which is really unfortunate. I literally have to run the game to see if the shader looks right.
    • Undo: Although Shader Graph supports Undo, it seems the undo buffer is cleared when entering play mode. That is, after entering playmode, stopping playmode, and returning to my shader graph window, I can no longer undo anything.
    • Auto-set property reference name: If I add a new Vector1 property to my shader, its initial name will be Vector1, and its reference name will be something like "Vector1_E3EA3C0E". Ideally, when I change the name of this property from "Vector1" to "RotationSpeed" (or whatever name I choose), the reference name would change to RotationSpeed, or _RotationSpeed. Leaving it the auto-generated property name is annoying, as I need to change it every time. Maybe prompt for a property name before adding it, so you can set the name and reference from the initial value entered?
    • Numeric Preview - For preview nodes, I don't usually find the black/white/color values for vectors to be particularly helpful when I'm doing math stuff. Maybe an option for a numeric preview, where numbers are shown, instead of only a color?
    • It seems that SubGraphs still can't be connected to Position?
     
    Jick87 likes this.
  15. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    2,061
    Another issue I'm seeing. I have a few Texture2D properties on my shader. They are, BaseColor, Normal, Emission, and Roughness. I've assigned a Default value to each of them. The textures I'm using are generated from a Substance SBSAR. Assigning them works fine. But as soon as I enter play mode and return to shader graph, all of the Default textures get changed to point to "Rift_BaseColor", which perhaps is happening because that's the first generated texture in the SBSAR? Just guessing. Either way, if I assign a normal texture as the default, it "sticks", and doesn't change. But if I use Substance textures, it seems Shader Graph replaces the default with the first generated texture. Here's a screenshot that shows my properties, and the textures that I'm assigning into the different defaults.

    upload_2018-10-27_21-39-13.png
     
  16. dandepeched

    dandepeched

    Joined:
    Feb 22, 2016
    Posts:
    30
    For all my Graphs on Android with OpenGL2 I'm getting following error:
    Unsupported: 'Graph_Name' - Pass 'ShadowCaster' has no vertex shader

    How to fix it?
     
  17. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    2,061
    Does Shader Graph support user-defined keywords at this point? In one of my shaders, I use a keyword toggle:
    Code (CSharp):
    1. [HideInInspector][Toggle(_RIFT_DEFORM_ACTIVE_TOGGLE)] _RiftDeformActive ("Is Deforming", Int) = 0
    which I then use to conditionally include some other code within my vert function:

    Code (CSharp):
    1. #ifdef _RIFT_DEFORM_ACTIVE_TOGGLE
    2.             DoSomeExpensiveThing(v);
    3.             #endif
    The point of the toggle is to avoid calling DoSomeExpensiveThing most of the time. I realize I can use a branch node in shader graph, but the branch node still executed both halves.
     
  18. wyatttt

    wyatttt

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    288
    Yup! But it is specific to the Lightweight Render Pipeline
     
  19. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,379
    Ah so that's why it broken in HDRP
     
  20. wyatttt

    wyatttt

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    288
    Not at the moment. Only way to do something like that is to make a custom node and if you find yourself reusing a portion of the graph often, you can convert it to a Sub Graph
     
  21. wyatttt

    wyatttt

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    288
    Can you share an image of your graph?
     
  22. AndrewKaninchen

    AndrewKaninchen

    Joined:
    Oct 30, 2016
    Posts:
    89
    Yeah, we though of using Sub Graphs (and tried to, before changing back to copy-pasting in frustration), but as I said, logical outputs don't seem to be a thing. Sort of defeats the purpose.
     
    sand_lantern likes this.
  23. sand_lantern

    sand_lantern

    Joined:
    Sep 15, 2017
    Posts:
    57
    This is definitely something I'd be interested. I was looking at this tutorial this morning, and found his drawn in colored boxes with labels to be a very apealing way to organize things. https://connect.unity.com/p/zelda-inspired-toon-shading-in-shadergraph

    Barring that, some way to highlight a border on nodes to a certain color with maybe a key tab attached to the same box as variables are stored in would be nice. Something like this:
     
    wyatttt and CyberFox01 like this.
  24. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    2,061
    I'm seeing some unexpected behavior with respect to the Time Node. Per the documentation (https://github.com/Unity-Technologies/ShaderGraph/wiki/Time-Node), the "Time" output of node is supposed to be equivalent to the ShaderLab value "_Time.y". And according to that documentation (https://docs.unity3d.com/Manual/SL-UnityShaderVariables.html), _Time.y is equivalent to "Time.timeSinceLevelLoad".

    Under shader graph, however, it appears that using either the Time Node's Time output, or even using "_Time.y" within a custom code node, uses the equivalent of "Time.unscaledTime" rather than "Time.timeSinceLevelLoad". Is this an intended change? Or is this accidental?

    To confirm this, I simply created a Polygon node in Shader Graph, and set Sides equal time Time.Time:

    upload_2018-10-29_14-44-27.png

    When running my scene, from the moment I press Play to the moment the game actually starts running, it takes about 7 seconds. Note in my screenshot below that I'm Debug.Logging both Time.timeSinceLevelLoad, and Time.unscaledTime. Also note that the number of sides on the cube is just over 7, consistent with the Time.unscaledTime value.

    upload_2018-10-29_14-46-38.png


    So, is this a bug in shader graph? Or an intentional change from earlier use of _Time.y in HDRP?

    And importantly, this means that my Shader Graph shaders using Time no longer take Time.timeScale into account. So, when my game is paused, the shader keeps on playing. Is there an option for Time to be timeScale dependent in Shader Graph?

    Thanks.
     
    Last edited: Oct 29, 2018
  25. Chadobado

    Chadobado

    Joined:
    Oct 19, 2016
    Posts:
    6
    Loved Shader Graph so far, but been very stumped for the last several days. Really appreciate any help to get me unstuck.

    I'm trying to bake/capture the output of my shader to use on my model later. Seems like it should be bonehead simple.

    I've tried several approaches including Blitting, _CameraOpaqueTexture, applying projection matricies in my graph, modifying the generated shader, DrawMesh (noticed it here), etc, etc. Just can't get it to work.

    Is it possible, using vertex displacement (or other means), to unwrap the resulting UV texture to screen space so I can capture it w/ a secondary camera and use the resulting RenderTexture elsewhere?

    Thanks in advance!
     
  26. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    483
    In theory, yes. Kind of.

    Assuming you have non-overlapping UVs, you should be able to set vertex position to offset them to something that's basically a flat plane in world space. You will probably get some weird effects where polys are stretched over themselves at UV seams.

    From the start, you have position. Your model is positioned at 0,0,0 and scaled 1,1,1 for simplicity. Using the world position, you get the XYZ position of the vert. Now, for the UV output, you want a plane, that's in 0-1 U and 0-1 V and 0 Z position. Therefore, by sampling the UV coords, you have the desired position of the vert.

    Thus, the movement you want is (desired) - (current) position. But, that's in world space, so you might want to check whether you're in tangent space (z it 'out' from the mesh) local space (z is 'forward') or world space.

    This will probably break something else, like lighting or specular or shadows or SSAO or something absurd.

    Another option you have, is to bake position in something like XNormal, then use a CustomRenderTexture (like a render texture that takes a material+shader) and manually do lighting in the graph.
     
  27. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    572
    Andy did a post on twitter a while back about the UV part that you can see here.

    Video of it working
    https://twitter.com/andytouch/status/1019925625258291200?lang=en

    View of the Graph
     
    larex39 likes this.
  28. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    458
    Maybe it's not within the scope of the shader graph but I really hope I can have the power of tweaking and generating all kinds of textures like normal map, mask map and etc without going out Unity and using any third party software.
     
  29. GameDevCouple_I

    GameDevCouple_I

    Joined:
    Oct 5, 2013
    Posts:
    2,139
    I dont think the aim is to recreate substance designer, which is what you are basically describing. But you could actaully easily do this procedurally already using the nodes that are there if you wanted. Look at some of the samples that generate shapes and patterns. If your a user of substance designer then youll know what to do with those to turn them into textures (such as applying warps and blends etc until getting desired efffect)
     
  30. SpyChar

    SpyChar

    Joined:
    Jul 15, 2012
    Posts:
    11
    Having something like Unreal's Pixel depth offset would be really handy
     
    Flurgle and awesomedata like this.
  31. MTAU

    MTAU

    Joined:
    Oct 26, 2018
    Posts:
    2
    Glitch.png
     
    Last edited: Nov 1, 2018
  32. Draex

    Draex

    Joined:
    Jul 9, 2017
    Posts:
    3
    Anyone experienced a weird almost macro blocking style issue with Shadergraph based shaders in standalone builds that's not present in the Unity Editor? I built the same shader for HD Lit and PBR graphs and get the same result. I put together a picture to show the issue along with the graph. Somewhat scratching my head here.

    The issue seams to resolve itself when further from the object with the shader applied.

    problem.jpg
     
    Last edited: Nov 2, 2018
  33. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    483
    That's weird - the blocks are in screenspace! I thought it might be a texture compression issue but that's not the case...

    Does it do the same without the opacity slot plugged into anything? And the normal map slot?
     
  34. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    2,061
    I created a few CustomFunctionNodes, and noticed that my build now fails. The error:

    Code (CSharp):
    1. Assets/Materials/Shaders/Shader Graph/Nodes/RiftDeformVertex.cs(4,19): error CS0234: The type or namespace name `ShaderGraph' does not exist in the namespace `UnityEditor'. Are you missing an assembly reference?
    2.  
    Will all CustomFunctionNodes need to be wrapped with `#if UNITY_EDITOR`? Or is there a better way to keep these out of the build?
     
  35. Draex

    Draex

    Joined:
    Jul 9, 2017
    Posts:
    3
    The issue persists with one or both of the channels disconnected. I updated the above image showing the results of disconnecting the channels anyways.
     
  36. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    483
    Damn, something's completely borked there.

    The screenspace blocks make me think it could be related to some sort of tiled rendering system? I don't know off-hand whether there's some sort of resolution value visible (32x32pix tiles) so whether you could check using that I'm not sure. If you can change tile size does that make a difference?

    Now, the obvious (sorry). You're up-to-date with the SRP, LWRP and SGE packages?
     
  37. Draex

    Draex

    Joined:
    Jul 9, 2017
    Posts:
    3
    I tried playing with the texture sizes and object scale to no effect (not sure if that is what your referring to, pretty new to unity still.) Everything was up to date as of the release of HDRP 4.0.1. (I am not running LWRP) and have not updated to 4.10 yet.

    Exact versions are HDRP (4.0.1) Post-processing 2.0.16-preview, Shadergraph 4.0.1.

    I do not have Render-Pipelines.Core or Render-Pipelines.Lightweight installed.

    I can try an update if you think that will help.

    **UPDATE**

    I stumbled onto the solution but I am not aware of which setting specifically fixed it. I turned on most of the disabled options in the HDRenderPipeline Asset (with exception of Increase SSS, Volumetric Resolution, Only Forward, MSAA) And the issue seams to have corrected itself.

    Guess I will try disabling them one at a time until the issue reappears.

     
    Last edited: Nov 2, 2018
  38. Zipe92

    Zipe92

    Joined:
    Mar 5, 2015
    Posts:
    26
    Hello,
    is it possible to use _CameraOpaqueTexture in HDRP? My shader in LWRP works correctly, while in HDRP I cannot find "Requires Color Texture" in Additional Camera Data
     
  39. Satansama

    Satansama

    Joined:
    Jul 21, 2015
    Posts:
    5
    Hey everyone, I tried looking through the posts here but I wasn't able to figure out my problem.

    Can I make a water edge foam shader using the depth buffer and if so how, or did any of you figured this out already and would point me in the right direction. I tried using custom nodes but after 2 hours of trying I gave up. Thanks for any help in advance
     
    curveddesign and DJ_JW like this.
  40. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,379
    @wyatttt can we get a way to lock the black board position on left or right side please? resizing the shadergraph window and then you find out the blackboard move around it's getting annoying :(
     
  41. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    2,061
    I submitted this as a bug (https://fogbugz.unity3d.com/default.asp?1097192_ukhb3gfr30ubfrce), but figured it might help others if they run into this.

    I was getting a crash every time I ran the player after doing a build. The error was: "Read from location 0000000000000000 caused an access violation."

    This ended up being because I was including at least one Shader Graph shader in the "Always Include Shaders" section of the graphics options. It seems that including even a trivial Shader Graph shader there will result in a player that immediately crashes.

    The workaround was simply to avoid placing any shader graph shaders in Always Include Shaders. You can always place an object in a scene you include in your build that uses that shader to ensure your shader graph shader is included in the build.
     
  42. Necronomicron

    Necronomicron

    Joined:
    Mar 4, 2015
    Posts:
    90
    I have some issue with ShaderGraph. If I use float values and press Save Asset, I get error:
    Assertion failed on expression: 'success'
    UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)


    Same problem with color components that are fractions.
    I have no troubles if I use integer values, I can save shaders and they work, but testing turns into slight butthurt when I need fractions or different colors.

    Maybe this is related, after some Unity update all float numbers in Editor started to show up with commas instead of periods, although I always type periods myself.
     

    Attached Files:

  43. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    2,061
    Another thing I find myself wanting, just for organization purposes, are Layout tools for the editor window. For example, Align Left, Align Middle, etc, to line up nodes on the canvas. I admit it's a pretty low priority, but maybe the sort of thing that's easy because it's all "front-end", and doesn't require or depend on graphics features.
     
    Jick87 and reflectingb0t like this.
  44. jestermaximusJr

    jestermaximusJr

    Joined:
    Jan 12, 2013
    Posts:
    14
    Hello, I'm trying to use Shadergraph to make terrains look like a topographic map, and occasionally get this error message: "Fatal Error! CheckDisalowAllocation. Allocating memory when it is not allowed to allocate memory." I'm replicating someone's shader forge graph shown here. Using the lightweight render pipleline, I wire up the graph, apply the shader to a custom material, then assign that custom material to a terrain object. It displays properly, but when I start editing the terrain, I will occasionally get the Fatal Error, crashing the Editor. Has anyone run into this before? Any idea why this is happening? Would switching to the other render pipeline help at all? Thank you!
     
  45. DevMaxima

    DevMaxima

    Joined:
    Jan 24, 2017
    Posts:
    4
    Hello everyone, I have tried learning shadergraph
    I want to make a transparent background shader from the photo.

    like this picture I want to make the background gray to be transparent alpha

    I have tried shadergraph but the results are not good. if a solid white backgournd might work. but, results photo from camera with low light it becomes gray background and cannot be good result.


    anyone can help me??
    Thanks
     
  46. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    2,061

    I expect that's going to be kind of hard, because the background you're trying to mask out isn't a consistent shade. Honestly, at this point, I'd just bring that image into Gimp and process it there.

    But because I'm still learning Shader Graph, I decided to see if I could get a better result than you. Not really better, though. That "grey" background is too many shades.

    upload_2018-11-6_0-28-58.png

    Here's what I tried:

    upload_2018-11-6_0-29-53.png
     
  47. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    483
    Background isn't defined just by colour, but often by pattern, features, or detail, or lack thereof.

    So, you're not just talking about a specific RGB colour for your background white/gray, you can also look at things like lack of detail (dive the DDXY nodes a go). Basically, compare the image to a copy of itself shifted one pixel up/down/left/right. If there's no difference, or little difference due to image noise / etc then you're on the right track.

    This might false-positive in sections like the orange dress, so you have to use it in combination with a colour replacement method (isn't there a colour replace node?). You can also try using a 'difference' between (image) and (colour), and if the difference is below (float, say 0.03) then you use that as a mask.
     
  48. amilton

    amilton

    Joined:
    Jul 19, 2013
    Posts:
    12
    Hey guys,

    I noticed that is not possible to change the Master Node's normal input from tangent space to world space.

    Which is unfortunate in many cases, like a custom triplanar mapping for example, It's just easier to work directly with world space normals and avoid redundant conversions to tangent space, since the lighting calculation will be done in world space after all.

    I would like to see more options in the Master Node, like this world space normals.

    Another thing that bugs me, is that I have no idea if the nodes are running in the vertex or fragment shader. Is there a way to see and tweak that?

    Overall, the editor is great, it improves a lot your production, but I feel that I miss some control over the performance, compared to writing shaders by hand, or even Unreal's material editor.
     
  49. slim_trunks

    slim_trunks

    Joined:
    Dec 31, 2017
    Posts:
    41
    Hi all,
    I just wanted to know if there is a way to get Textures out of Shader Graph?
    As in: write to a Texture that you can then you use in other shaders.

    I know that there was some talk here about blitting but that's not exactly what I want to do.
    Instead, I want to extract the Texture data at any point of the graph.

    Is there any way to write a custom node that would do that?

    Edit: As this is a feedback thread; my feedback would be that such a node would be very welcome.
    It would make Shader Graph even more powerful than it already is.
     
  50. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    483
    I think blitting is really the only option.

    Otherwise you'd be allowing scripts to access shaders halfway through completion at any time, which could be a mass I think.

    Another option is a CustomRenderTexture, they're like a rendertexture but with a material + shader. See if that helps, and post results!
     
Thread Status:
Not open for further replies.