Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    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. DoYouRockBaby

    DoYouRockBaby

    Joined:
    May 21, 2018
    Posts:
    9
    Hi everyone,

    I'm trying to build my first shader but i think i misunderstood something with normal maps, or i followed an outdated tutorial. I have a strange behaviour with normal with a very simple shader.

    If someone has a solution, it would be really nice.

    I built this shader, it is basic :
    Capture.PNG

    But it gives me this strange result, at the left you can see the result with the standard Lightweight material.

    Capture2.PNG
     
    konsic likes this.
  2. Kink3d

    Kink3d

    Unity Technologies

    Joined:
    Nov 16, 2015
    Posts:
    45
    Apologies, there is currently a bug with booleans in subgraphs. We have a fix for it already but it missed the 2.0.1 cutoff. It will be fixed in the next version.
     
    Paddington_Bear and ssartell like this.
  3. Amir-hm

    Amir-hm

    Joined:
    Oct 29, 2013
    Posts:
    5
    hi shader graph is really nice, i have question, can i blend two textures with completelly replace the pixel color by 0-1? thank you
     
  4. iamthwee

    iamthwee

    Joined:
    Nov 27, 2015
    Posts:
    2,055
    I wanna see moar lurvely shaders pics guys!
     
  5. febucci

    febucci

    Joined:
    Sep 3, 2015
    Posts:
    18
    Hello!
    Trying to make a shader that works with sprite atlas and sprite renderers

    it gives a shader error: "Redefinition of _MainTex"

    _MainTex is needed for sprite atlas...so, what can I do ?

    upload_2018-6-13_12-35-32.png

    Thank you and have a nice day!

    EDIT: works with PBRMaster, doesn't work with unlit
    EDIT2: PBR or Unlit, FlipX on the sprite renderer makes the sprite invisible
     
    Last edited: Jun 14, 2018
  6. petersx

    petersx

    Joined:
    Mar 5, 2015
    Posts:
    218
    In this version of Shader Graph is possible to make subsurface scattering shader ?
     
  7. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    869
    @Kink3d

    Access to depth buffer and being able to write the "pixel depth offset" too?-- We really need access to these to make a proper mesh-blending effect, and cannot achieve true mesh-blending at all without them.

    About "pixel depth offset" here --


    Any news on these? -- Are these coming soon? -- Any ETA on either of these yet?
     
    SpyChar, idkartist3D, konsic and 2 others like this.
  8. Paddington_Bear

    Paddington_Bear

    Joined:
    Dec 9, 2012
    Posts:
    274
    This requires pixel depth and dithering right? I don't think it's all that difficult to achieve, I would expect UT at least wants a comparable tool (to Unreals) and this seems essential given, given the applications outside of just mesh-to-terrain blending.

    Could somebody with a bit more technical knowhow explain why pixel offsetting is (I assume) quite expensive?
     
    awesomedata likes this.
  9. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    869
    In and of itself, I wouldn't think it is more or less expensive than writing to a texture -- I think the only "expense" is the flexibility to the answer to the question "At what point in the pipeline do we get access to (and/or) write to the depth-buffer" since it is pretty much hardware-level, and one has to consider materials such as glass or reflections in the answer to that as well.

    I'm not a shader guru, but this is what I know as of right now.
     
  10. ssartell

    ssartell

    Joined:
    May 21, 2018
    Posts:
    14
    Moar shaders? I built an intersection shader using _CameraDepthTexture. I couldn't get a substitute for LinearEyeDepth working well in shader graph, so I ended up building a custom node for it.

     
  11. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    1,907
    Last edited: Jun 13, 2018
  12. Paddington_Bear

    Paddington_Bear

    Joined:
    Dec 9, 2012
    Posts:
    274
    Now that is interesting. The _camDepthTex takes the depth info from the camera and uses it to tell the object it's point of intersection/tangency? Is that right?

    So, if it's storing this information in the G-buffer, then relaying it to the shader on a per-object basis, this might be a more efficient solution than asking each object for a pixel offset right?

    Give me some leg room here, i'm definitely no technical artist, but it would seem to me that performing mesh blending using the cameras depth texture is bound to be a more efficient solution, as you can just stop requesting past a certain point in your depth.

    Does that make a whit of sense to anyone but me?
     
  13. IARI

    IARI

    Joined:
    May 8, 2014
    Posts:
    10
    Unity Employees:
    @AurelWu has mentioned the bug with floating-point separator being used in the compiled shader code on german systems already on page 15 of this thread

    Related to this I have opened a github issue:
    https://github.com/Unity-Technologies/ScriptableRenderPipeline/issues/1519.
    Betting that string conversion is done improperly in shadergraph code as described in the issue.

    Please fix this in the upcoming release, as the bug makes shadergraph unusable on any german systems.
    At least pretty much unusable - the only workaround I that I have found to be working, is to just not use floating point values in shader properties - i.e. use only white or black in case of colors and integer values for vectorX values.
     
    Paddington_Bear likes this.
  14. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,409
    As I commented on in this thread a few weeks back, I believe they already fixed this issue. Its in the changelog for shadergraph (very near the end):

    https://github.com/Unity-Technologi...lob/master/com.unity.shadergraph/CHANGELOG.md
    • Your system locale can no longer cause incorrect commands due to full stops being converted to commas.
     
    IARI likes this.
  15. iamthwee

    iamthwee

    Joined:
    Nov 27, 2015
    Posts:
    2,055
    Can someone explain the advantages of using unity 2018.x and shader graph over say lux framework?

    That'd be cool.
     
  16. Paddington_Bear

    Paddington_Bear

    Joined:
    Dec 9, 2012
    Posts:
    274
    None at the moment. Pretty much all the node based shader composers out there have a better feature-set. But knowing UT and their past efforts, Shadergraph will be a really well documented, well supported and stable tool. At the moment we're just arsing about and giving the team feedback.
     
    iamthwee likes this.
  17. unity_5fpsmegasupergiperprogramer

    unity_5fpsmegasupergiperprogramer

    Joined:
    Dec 1, 2017
    Posts:
    101
    Shader forge > Shader graph.
    Sorry, your instrument useless.
    I install unity 2017 and use Shader forge. Working in unity 2018!
     
  18. Paddington_Bear

    Paddington_Bear

    Joined:
    Dec 9, 2012
    Posts:
    274
    Give it time. SG isn't supposed to compete with complete solutions out there, yet.
     
  19. Franolich

    Franolich

    Joined:
    Feb 12, 2013
    Posts:
    6
    A very nice tool. During my first use of shader graph I experienced the following problems. Apologies if these have been already covered but I do not currently have the time to read everyone else's experiences.
    • After using a drop-down menu when editing a property in the property panel, any mouse movement within the shader graph window makes the property panel follow the mouse pointer around. Giving focus to anything else - clicking a node or even clicking on the main editor window and back again - makes no difference. The only fix seems to be closing the shader graph window and reopening it.

    • I just noticed there is a known bug to do with boolean properties in sub graphs but didn't spot any details. In my case, if I had a boolean property in a sub graph I could no longer create nodes in other shader graph assets, even if they did not reference the sub graph. When clicking on Create Node, nothing would happen in the shader graph window. Instead there was an error message in the console window:

      ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
      UnityEditor.ShaderGraph.SubGraphNode.UpdateSlots () (at C:/Users/XXX/AppData/Local/Unity/cache/packages/packages.unity.com/com.unity.shadergraph@1.1.9-preview/Editor/Data/Nodes/Utility/SubGraphNode.cs:206)


      For once I braved looking at some source code and actually found a fix by simply adding the following 3 lines of code to the long switch statement at the line mentioned in the error:

      Code (CSharp):
      1. switch (propType)
      2. {
      3.     case PropertyType.Color:
      4.         slotType = SlotValueType.Vector4;
      5.         break;
      6.     // cases for all other types except boolean...
      7.     // new code start
      8.     case PropertyType.Boolean:
      9.         slotType = SlotValueType.Boolean;
      10.         break;
      11.     // new code end
      12.     default:
      13.         throw new ArgumentOutOfRangeException();
      14. }

      I assume the forthcoming fix mentioned in a previous post is along these lines (at least in part). So for anyone impatient like me, the above is easy to apply for now.
    • I could no longer run my game within the editor if "maximise on play" was selected. The only fix I could find was to choose "reset factory settings" in the layout menu - rather annoying. I've forgotten the exact error message - and don't want to try and reproduce it now it's fixed! - but I believe it related to a GraphView editor window during a call to a function like FinalLayoutBeforePlay().

    • I created a dissolve effect using the Alpha channel and AlphaClipThreshold on the output node with an opaque surface with alpha blend. The trouble was when an object using this shader was partially/totally dissolved, the complete object shadow was still there as if the object was still completely solid.
    By the way I'm running Unity on Windows 7 (64-bit) laptop with NVIDIA GeForce 675M and 32GB RAM. I'm running Unity 2018.1.0f2 with the latest versions of the shader graph / SRP core / LWRP packages that I could get via the package manger earlier today.

    Some feature requests
    • It would be extremely useful if there was a way to see the shader code generated by shader graph. This could help in learning to code shaders and/or be the starting point before adding more complex code not support by shader graph. Having a "show generated code" button in the inspector of shader graph assets (as for normal shaders) would do nicely.

    • Support for stencil buffers.

    • I could not find a way to change the type of an output slot on a sub graph. I would have thought this was pretty essential to maximise the usefulness of sub graphs.

    • When using an instance of a sub graph in a parent graph it would be nice if:
      • There was a quick way to duplicate the inputs (properties) of the sub graph and make them properties of the parent graph.
      • When creating properties in this way, could one inherit defaults from the sub graph. In other words the Mode drop down could include the option Inherit in addition to Default, Slider, etc.

    • Right clicking on any input port could show an option to create a corresponding property of the correct type and then automatically connect it.

    • It would be nice to be able to group nodes within a graph i.e. select some nodes and make them children of a group node which could have a customisable heading. Very useful in any node editing tool.
     
    Last edited: Jun 14, 2018
  20. scheidtventureestate

    scheidtventureestate

    Joined:
    Nov 28, 2017
    Posts:
    33
    That is included. Make sure to test the new Shader Graph 2.0.1 (Changelog here) — ships with Unity 2018.2.0b7

    I reverted back to 1.9 due to extreme performance issues. Unite Berlin is next week — I think until then the team is quite overloaded for tackling issues.
     
  21. Franolich

    Franolich

    Joined:
    Feb 12, 2013
    Posts:
    6
    I thought I was probably not at the bleeding edge of development. Great to see how well things are progressing/improving.
     
  22. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    483
    Has anyone been able to replicate this in the new update?
     
  23. PolyToots

    PolyToots

    Joined:
    Mar 15, 2014
    Posts:
    14
    Sorry if this is the wrong thread for this, but I keep getting re-directed here while searching for my issue.

    I'm trying to create a basic vertex shader to use with particle systems (using a mesh renderer). By default, when using a mesh renderer you can't do things like fade the particle. I used to use ShaderForge so this was a simple thing to do, but for the life of me I can't work out how to access the alpha property of the vertex colour node in the Unity Graph system. Any ideas?
     
  24. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    483
    Vertex Colour > split > Alpha channel
     
    PolyToots likes this.
  25. Alexy89

    Alexy89

    Joined:
    Mar 3, 2017
    Posts:
    2
    I was wondering if it's possible to export this shader graph into a proper shader so i can move it into another project/version of unity, and then use it there?? That would be amazing!
     
  26. ssartell

    ssartell

    Joined:
    May 21, 2018
    Posts:
    14
    @Kink3d _CameraDepthTexture works exactly like you said. Should _CameraDepthNormalsTexture also work? It's not working for me even though I updated the DepthTextureMode on the camera.

    Edit: Seems like it's a Lightweight Render Pipeline thing. (And maybe me being new to Unity).
     
    Last edited: Jun 17, 2018
  27. Zwer99

    Zwer99

    Joined:
    Oct 24, 2013
    Posts:
    24
    I created an Unlit Shader with the Shader Graph.
    Is it possible to make it use Lightmaps?
     
  28. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    577
    Right click the master node for the graph and select Show Generated Code or Copy Shader

    Show Generated Code - opens the code in your IDE, or text editor
    Copy Shader - copies the code and you will have to paste it in your IDE, or text editor
     
  29. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    483
    Probably not.

    An unlit graph would probably be treated as if it was emissive by the lightmapper, but I can't see how the lightmap would affect the unlit shader. Unless what you're thinking of is to do ALL the lighting information in the lightmapping process and display that, without calculating lights, but you're still going to have to combine the unlit color and the lightmap in some way?
     
  30. Zwer99

    Zwer99

    Joined:
    Oct 24, 2013
    Posts:
    24
    Yea, that's actually what was in my mind. Look at this shader: https://gist.github.com/jimfleming/5937437
    I guess it's an unlit shader which combines the texture color with the lightmap color.

    I wonder if I can write custom shader nodes to make it possible to use Lightmaps within the shader graph?
    Or are there other possibilities?
     
  31. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    1,907
    If you want to do any manipulation with lighting at the moment you need to write a custom master node and point it to your own script template with your custom lighting. I did something like this today (for my fog of war shader) and it only took a couple of hours to figure it out.
     
  32. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    869

    Seems like the best time to support this feature is now.

    I've seen some really cool shaders using the pre-calculated lightmapping of the engine to manage cast shadows for special blending stuff. @Unity -- I'm not sure a 3rd party plugin could do this as well as you guys could, so maybe you will consider it (even if it's just a screen-space thing)?
     
    Last edited: Jun 18, 2018
  33. MythrilMan51

    MythrilMan51

    Joined:
    Apr 24, 2017
    Posts:
    122
    Any tutorials on writing custom nodes?
     
  34. alexandral_unity

    alexandral_unity

    Unity Technologies

    Joined:
    Jun 18, 2018
    Posts:
    103
    sand_lantern likes this.
  35. ssartell

    ssartell

    Joined:
    May 21, 2018
    Posts:
    14
    @hwaet, I took a less than perfect pass at that water shader tutorial you posted. It doesn't look nearly as good as the water in Slime Rancher, but it's not horrible. Needs depth blur, better edge foam, and some other stuff. Here it is in motion: https://i.imgur.com/C24nYEK.gifv

     
  36. hwaet

    hwaet

    Joined:
    Mar 21, 2015
    Posts:
    23
    @ssartell That is well done, thanks for sharing! It's really exciting to see these examples come together :)

    I'm curious, how did you retrieve the background for the distortioneffect? Is there a scene/camera sample node in SRP that I'm missing out on?
     
    Last edited: Jun 19, 2018
  37. ssartell

    ssartell

    Joined:
    May 21, 2018
    Posts:
    14
    You can create a variable and set the reference to "_CameraOpaqueTexture" and uncheck "exposed". Same thing for "_CameraDepthTexture". I'm using both of those for the water.
     
  38. cfree

    cfree

    Joined:
    Sep 30, 2014
    Posts:
    68
    Hi! Any news on tesellation? I am using Shader Graph on the HD Pipeline...
    Thanks a lot!
     
  39. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,041
    Please allow right click drag, pressing the alt key is very annoying
     
    awesomedata likes this.
  40. wyatts

    wyatts

    Joined:
    Apr 15, 2014
    Posts:
    14
    Is it possible to get a ShaderGraph shader to work as a Skybox Material?
     
  41. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    483
    should be.

    You'd make a shader, assign it to a material, and stick that as the skybox mat in the lighting tab like always.

    If you're going to use a cubemap, you'd just use 'view direction' as the input direction for the cubemap.

    Bonus Round: Assign the material to a cube in your scene. This is how the source games like CS:GO do their 'solid skyboxes'.
     
  42. discofhc

    discofhc

    Joined:
    Dec 18, 2017
    Posts:
    41
    There is one problem i found with the Shader Graph on HD Pipeline (Unity 2018.2.0b9).
    Using the nodes "Time - sine time" and "Remap" connected to the AlphaClipThreshold (with a Simple Noise in the Alpha) results in NO material animation.
    Using LW Pipeline it works fine.
     
  43. KillHour

    KillHour

    Joined:
    Oct 25, 2015
    Posts:
    27
    I ended up using this the other day to remake some shaders I had previously written by hand for the HD Rendering Pipeline. The biggest piece of feedback I have is that I was using the Shader.SetGlobalFloat function to adjust some properties in my shaders on the fly, and it took me a while to realize that this only works if you uncheck the "exposed" option for the property. I feel like there could be a better way to handle that. Other than that, great tool!
     
  44. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    869
    Even middle-click would be okay. D:

    I agree, two hands just to move around the graph is pretty annoying.
     
  45. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    869
    @alexandral_unity

    Sorry for the double-post, but I also have two questions --


    First:

    Is there an equivalent to the "Depth Fade" node from ASE in the works?

    Second:

    Can we yet cast shadows on the surface of partially-transparent (alpha-blended) materials? -- I would like to blend multiple objects together via transparency (while letting that transparent object blend with other transparent objects of the same material), but I am currently unable to do it using the old shader system.

    Any plans for this style of blending being supported?
     
    rr_unity3 likes this.
  46. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    577
    The default is middle click and drag, at least on PC/Windows
     
    awesomedata likes this.
  47. FGPArthurVII

    FGPArthurVII

    Joined:
    Jan 5, 2015
    Posts:
    68
    How do you add Refraction?
     
  48. FGPArthurVII

    FGPArthurVII

    Joined:
    Jan 5, 2015
    Posts:
    68
    Also, I think there would be nice to have a n operands multiply, for example: x * y * z in one multiply block or how many it's wanted.
     
  49. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    869
    Nice to know -- the other guy's post had me concerned for a moment.

    I have seen some goofy "design" moves pulled by Unity before, and I've not played much with Shader Graph for anything serious yet, so I was quick on the trigger there, but thanks for clarifying for me and anyone else who might have had concerns like I did about that particular guy's comment.


    So far I'm loving everything I've seen about Shader Graph -- Eventually I'll actually get time to play around with it myself!
     
  50. wyatts

    wyatts

    Joined:
    Apr 15, 2014
    Posts:
    14
    I attempted a ShaderGraph shader as a Skybox in a lightweight render pipeline project. LWRPshadergraphSkyboxx.png
    It does work on objects though.

    I'm assuming there needs to be a specific master node developed that identifies the shader as a Skybox?
     
Thread Status:
Not open for further replies.