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

    MythrilMan51

    Joined:
    Apr 24, 2017
    Posts:
    146
    Good question.
     
  2. ssartell

    ssartell

    Joined:
    May 21, 2018
    Posts:
    14
    I seem to have a problem with the Branch node. If you have a division by 0 going into the False input of a Branch node, you never get the True value regardless of the Predicate. Here's a simple example:



    I'm aware that dividing by 0 is a big no-no and leads to unpredictable things, but it's also hard to tell when it happens in shader graph.
     
    Last edited: Jun 21, 2018
  3. pjwaixingren

    pjwaixingren

    Joined:
    Dec 22, 2013
    Posts:
    2
    upload_2018-6-21_13-10-13.png Why?? I can`t see the node
     
  4. ssartell

    ssartell

    Joined:
    May 21, 2018
    Posts:
    14
    Do you have one of the scriptable render pipelines installed and running in your project?
     
  5. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    That is odd, given that the scene view is right click to drag. Here's hoping they switch it to right click, middle click drag is slightly awkward, especially with carpal tunnel.
     
  6. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    789
    Not sure how your keys are different but the default for the Scene View is middle click to pan/drag and right click to rotate

    I guess if you're on a laptop then this might be a little different. For desktop, this is pretty standard for a lot of programs like this.
     
  7. mathias234

    mathias234

    Joined:
    Sep 9, 2012
    Posts:
    239
    @ssartell
    Hi, i tried to do this with my shader but i only get redefinition of the _CameraDepthTexture, https://prnt.sc/jxod8c
     
  8. ShakuX

    ShakuX

    Joined:
    Jun 21, 2018
    Posts:
    2
    I have a problem to connect my position offset subgraph into the position port of the master node. Without the subgraph the nodes work fine. But as soon as I convert them to a subgraph they cant be used anymore.

    Here is an example: the subgraph contains a Position Node, Add and a Vector3 property so nothing fancy.



    Any ideas what's going on?
     
  9. ssartell

    ssartell

    Joined:
    May 21, 2018
    Posts:
    14
    Try connecting the Screen Position node to your UVs input.
     
  10. alexandral_unity

    alexandral_unity

    Unity Technologies

    Joined:
    Jun 18, 2018
    Posts:
    163
    We have a known bug that subgraphs can't be connected to the Position output. We're working on both fixing the bug and updating the documentation to make that clearer.
     
    ShakuX and ssartell like this.
  11. ShakuX

    ShakuX

    Joined:
    Jun 21, 2018
    Posts:
    2
    Ah ok, good to know.
     
  12. mathias234

    mathias234

    Joined:
    Sep 9, 2012
    Posts:
    239
    Ok, So that was not the issue, after alot of testing i found that it was because i was using hd pipeline, removing that also removes the redefinition error, this is probably a bug
     
  13. vProject

    vProject

    Joined:
    Sep 11, 2013
    Posts:
    8
    I have encountered an error while trying to change a texture2d reference to _MainTex on an unlit graph. It allows me to use _MainTex as a reference in a PBR graph with no errors. Same preoblem occurs ona completely blank project with a completely blank graph (other than a single texture 2d in the blackboard).

    Using 2018.2.0b9 lightweight renderpipeline 2.0.3 - preview

     
  14. FGPArthurVII

    FGPArthurVII

    Joined:
    Jan 5, 2015
    Posts:
    106
    On PBR Shader, by setting the surface to "Transparent" and Makring "Two Sided", It stays like this:

     
    Heimlink likes this.
  15. febucci

    febucci

    Joined:
    Sep 3, 2015
    Posts:
    19
    I've found a way to make the shadergraph work with sprites!
    (Like a normal shader written in the past.. I didn't expect it haha!)

    Here you have how to set up the "sprites-diffuse", hope it helps:
    Flip-x, Flip-y and the Color are working!

     
  16. StarWafle

    StarWafle

    Joined:
    Jun 12, 2018
    Posts:
    3
    Any news about tessellation?
     
  17. febucci

    febucci

    Joined:
    Sep 3, 2015
    Posts:
    19
    Will be possible to add the tag "disable batching" ?

    At the moment I'm copying the shader each time and I'm adding it manually
     
  18. ChaseRLewis73003

    ChaseRLewis73003

    Joined:
    Apr 23, 2012
    Posts:
    85
    Couple things

    1. autoconverter doesn't seem very good. Lots of items fail, including probuilder assets. Not entirely unexpected but I'd make sure that at least the default materials that ship with supported unity packages and default materials could make the conversion if that's a planned shippable feature. I entirely get not having 'custom' shaders converting properly, but having to go into packages to find what materials need recreation is awkward and should work with the other supported unity packages (but maybe that's just temporary).

    2. Sampler State dropdowns don't appear to render correctly.
    upload_2018-6-24_18-15-11.png

    3. No way to rename the shader so it appears under different menu contexts rather than just under graphs? Clicked around the blackboard where I saw the name and couldn't find out how to rename.

    4. Tried to set the dropdown under a color item on the blackboard and it locked me in drag state for the blackboard forcing me to close the graph and reopen to continue working.

    5. Keyboard shortcuts? Having done some unreal this is absolutely required. I noticed when I was clicking w, e, r, etc it still toggled the main window rotation, position, etc though the focus was on the graph window ... that seems off.

    Probably a lot more, but that is from the first 15 min or so.
     
    Last edited: Jun 25, 2018
  19. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    789
    If you are using an older version/not a version from the package manager then it will fail to display the proper materials on Probuilder models. All materials in a project that used the standard shader will convert properly once you select upgrade materials to the pipeline in use, anything custom shaders won't convert


    You double-click the blank window with the underscore _

    upload_2018-6-24_20-49-12.png


    Known bug that will be fixed.


    Hopefully, more shortcuts are coming soon. Currently, it's just Space to quickly open the node menu.
     
  20. Zwer99

    Zwer99

    Joined:
    Oct 24, 2013
    Posts:
    24
    For those who are interested in:
    I figured out how to use Lightmaps in Unlit shaders.

    Here's the early alpha-result (there are lots of improvements necessary):


    Add two editor-scripts to your project:
    1. Lightmap-Node:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEditor.Graphing;
    4. using UnityEditor.ShaderGraph;
    5. using UnityEngine;
    6. [Title("Input", "Scene", "Lightmap")]
    7. public class LightmapNode : AbstractMaterialNode
    8. {
    9.     const string kOutputSlotName = "LightmapST";
    10.     public const int OutputSlotId = 0;
    11.     public LightmapNode()
    12.     {
    13.         name = "Lightmap";
    14.         UpdateNodeAfterDeserialization();
    15.     }
    16.     public sealed override void UpdateNodeAfterDeserialization()
    17.     {
    18.         AddSlot(new ColorRGBMaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector4.zero));
    19.         RemoveSlotsNameNotMatching(new[] { OutputSlotId });
    20.     }
    21.     public override string GetVariableNameForSlot(int slotId)
    22.     {
    23.         switch (slotId)
    24.         {
    25.             case OutputSlotId:
    26.             default:
    27.                 return "unity_LightmapST";
    28.         }
    29.     }
    30. }
    2. SampleLightmapNode:
    Code (CSharp):
    1. using UnityEditor.Graphing;
    2. using UnityEditor.ShaderGraph;
    3. using UnityEngine;
    4. [Title("Input", "Scene", "Sample Lightmap")]
    5. public class SampleLightmap : AbstractMaterialNode, IGeneratesBodyCode, IMayRequireMeshUV
    6. {
    7.     public const int OutputSlotRGBAId = 0;
    8.     public const int LightmapInput = 1;
    9.     public const int UVInput = 2;
    10.     public const int NormalsInput = 3;
    11.     const string kOutputSlotRGBAName = "RGBA";
    12.     const string kLightmapInputName = "Lightmap";
    13.     const string kUVInputName = "UV";
    14.     const string kNormalsInputName = "Normals";
    15.     public override bool hasPreview { get { return true; } }
    16.     public SampleLightmapNew()
    17.     {
    18.         name = "Sample Lightmap";
    19.         UpdateNodeAfterDeserialization();
    20.     }
    21.     public sealed override void UpdateNodeAfterDeserialization()
    22.     {
    23.         AddSlot(new Vector4MaterialSlot(OutputSlotRGBAId, kOutputSlotRGBAName, kOutputSlotRGBAName, SlotType.Output, Vector4.zero, ShaderStage.Fragment));
    24.         AddSlot(new Vector3MaterialSlot(LightmapInput, kLightmapInputName, kLightmapInputName, SlotType.Input, Vector3.one));
    25.         AddSlot(new UVMaterialSlot(UVInput, kUVInputName, kUVInputName, UVChannel.UV1));
    26.         AddSlot(new NormalMaterialSlot(NormalsInput, kNormalsInputName, kNormalsInputName, CoordinateSpace.World));
    27.         RemoveSlotsNameNotMatching(new[] { OutputSlotRGBAId, LightmapInput, UVInput, NormalsInput });
    28.     }
    29.    
    30.     public virtual void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode)
    31.     {
    32.         var lightmapName = GetSlotValue(LightmapInput, generationMode);
    33.         var uvName = GetSlotValue(UVInput, generationMode);
    34.         var normalsName = GetSlotValue(NormalsInput, generationMode);
    35.        
    36.         var result = string.Format(@"
    37. #if _SAMPLE_GI
    38.    half4 {0} = half4(SampleLightmap({1}.xy * {2}.xy + {2}.zw, {3}), 1);
    39. #else
    40.    half4 {0} = half4(1,1,1,1);
    41. #endif",
    42.             GetVariableNameForSlot(OutputSlotRGBAId),
    43.             uvName,
    44.             lightmapName,
    45.             normalsName);
    46.         visitor.AddShaderChunk(result, true);
    47.     }
    48.     public bool RequiresMeshUV(UVChannel channel)
    49.     {
    50.         s_TempSlots.Clear();
    51.         GetInputSlots(s_TempSlots);
    52.         foreach (var slot in s_TempSlots)
    53.         {
    54.             if (slot.RequiresMeshUV(channel))
    55.                 return true;
    56.         }
    57.         return false;
    58.     }
    59. }
    And here's how your ShaderGraph may look like:


    Attention: you need to active the keyword _SAMPLE_GI on every material which uses the Lightmap! Sadly I couldn't find a way to specify a custom GUI for ShaderGraph shaders (except in the Debug view, but it is deleted after altering the shader). You can set the keyword in the Debug-view for each material:


    But if you have a lot of materials I recommend you to write an editor script which sets the keyword for all materials using a specific shader. So we ended up writing a little EditorWindow:
     
    Blitzkriegmlg, Mauri and SUBZERO8K like this.
  21. VeganApps

    VeganApps

    Joined:
    Jun 30, 2006
    Posts:
    263
    How can I access ( get ) the shader's time ( _Time ) from C# ?
     
  22. Tinovdk

    Tinovdk

    Joined:
    Nov 28, 2013
    Posts:
    83
    Hi. Shader Graph is looking great! I'm currently in the process of recreating shaders made in Shader Forge by using Shader Graph and I can't find how to set the render queue so that the shader renders like an overlay. Is this supported?
     
  23. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    504
    For all the people that think that these graph editors are limited, pretty much everything in these shots was made with one. Not just the particles, but the masks that spawn the particles, the terrain, the stars, the oceans, the impostors for the reflection probe to pick up instead of the fireworks.
    Those dissolve shaders you've seen on YouTube? The molten planet is just a much more complex version of that, with normal-mapped procedural noise, blackbody-emitting lava and all 64 shader-generated asteroid shapes.

    fireworks.png
    Asteroids.png
     
    asdzxcv777, Mauri, hwaet and 2 others like this.
  24. Tinovdk

    Tinovdk

    Joined:
    Nov 28, 2013
    Posts:
    83
    In case someone stumbles across this question and looking for a way to modify a Shader Graph shader to render as an overlay until Shader Graph supports this option out of the box:
    • Right click on the Master node in the Shader Graph of the shader you want as an overlay.
    • Select 'Copy shader'
    • Create a new shader in the project and hit 'ctrl + v' to paste the shader code
    • Search for 'ZTest LEqual' and change it to 'ZTest Always'
    Below is the effect it had for me.
    Unity_2018-06-27_10-47-40.png Unity_2018-06-27_10-47-53.png
     
    DarkestDay and Azirell like this.
  25. Deleted User

    Deleted User

    Guest

    Anyone got Texture#D working in Shader Graph. Only thing that I get is gray texture.
     
  26. Pr0x1d

    Pr0x1d

    Joined:
    Mar 29, 2014
    Posts:
    46
    Alpha Clip Problem

    Today I started working on grass shader in unity shader graph, after I made the vertex offset and everything got working I found the problem where the alpha on the quad deleting shadows of other objects plus its still casting quad shadows not the masked shadows from shader.

    what do I mean by this? screenshot:
    upload_2018-6-27_17-37-50.png
     

    Attached Files:

  27. alexandral_unity

    alexandral_unity

    Unity Technologies

    Joined:
    Jun 18, 2018
    Posts:
    163
    @Pr0x1d This is a known bug, we've got a fix for it in the works.
     
  28. Pr0x1d

    Pr0x1d

    Joined:
    Mar 29, 2014
    Posts:
    46
    Thanks for response, looking forward to seeing it fixed.
     
  29. cfree

    cfree

    Joined:
    Sep 30, 2014
    Posts:
    72
    Hey @alexandral_unity !

    Many users already question it, maybe you please can answer us :) : any news on tessellation / POM options for the Shader Graph?

    Great job so far on Shader Graph!!!!!
     
    discofhc likes this.
  30. discofhc

    discofhc

    Joined:
    Dec 18, 2017
    Posts:
    47
    In this very thread a Unity folk told us Tessellation needs to be implemented specifically per Render Pipeline.
    Maybe @SebLagarde could share some info about it on HD Pipeline...
    There are plans to add Tesselation / POM in the Shader Graph for the HD Pipeline? Any time soon?
    Thanks!
     
    cfree likes this.
  31. ItsAaron

    ItsAaron

    Joined:
    Aug 24, 2016
    Posts:
    5
    I'm currently making a simple sprite shader graph which has a Texture on the blackboard. However when I create a material from this and set this material to multiple sprite renderers in my scene, changing the texture parameter in one of my game objects changes it to the same texture in all the others using this material. Am I missing something fairly obvious? Like some way to make material instances for example?
    Thanks in advance!
     
  32. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    789
    Yea, the extra shading options we have in HDRP will come to Shader Graph for HDRP sometime in the future, we just have to wait for it. Pretty sure it won't be in all at once so this will be an "overtime" thing as the different options/features roll out.
     
  33. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    789
    You create a different material (which will use the same shader) for each one you want to use a different texture.
     
  34. ItsAaron

    ItsAaron

    Joined:
    Aug 24, 2016
    Posts:
    5
    Fair enough. Shame there isn't a way to make material instances though so I don't have to make a new material for every different texture.
     
  35. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    789
    It's basically the same as a material instance, it's just different engines handle it differently. So for Unity what you are looking for is duplicating the material and you can do that with Ctrl+D
     
  36. cfree

    cfree

    Joined:
    Sep 30, 2014
    Posts:
    72
    It will be the same draw call for every material that share the same shader, even if the textures used are different?
     
  37. Deleted User

    Deleted User

    Guest

    Is there anyway to accomplish this vertex light shading effect with Shader Graph?

     
    awesomedata likes this.
  38. Giles-Coope

    Giles-Coope

    Joined:
    Jan 5, 2015
    Posts:
    50
    I started a Github repository with some custom Shader Graph nodes I've created.

    https://github.com/gilescoope/shader-graph-nodes

    Firstly there is a library for doing quaternion mathematics inside a shader, it includes a very performant method for rotating a vector by a quaternion.

    Secondly there is a library for rendering pixel-wide lines and shapes. They will be pixel perfect no matter the camera distance or perspective.

    I've also submitted these as packages to the asset store. I would be very happy to get any feedback on this.

    Cheers
     
    Last edited: Jul 2, 2018
    hwaet likes this.
  39. John1515

    John1515

    Joined:
    Nov 29, 2012
    Posts:
    248
    First, I love shader graph,
    Second, I want to use it with the standard render pipeline. I'm interested in high end graphics on high end mobile (Apple A11 and up, hi end AR apps) and feel that the Lightweight pipeline is therefore not really what I'm looking for.
    Since the heavyweight is not available for mobile, I can't use the shader graph? :confused:
     
  40. Giles-Coope

    Giles-Coope

    Joined:
    Jan 5, 2015
    Posts:
    50
    Lightweight Render Pipeline should be good for high end mobile graphics. What features do you want that it doesn't provide?

    I added a set of halftone shader nodes to the collection, allows stuff like this with just one node.

     

    Attached Files:

    Last edited: Jul 2, 2018
  41. xrooshka

    xrooshka

    Joined:
    Mar 5, 2014
    Posts:
    59
    Hi there! Trying this cool tool and found the interesting Normal Create node. It can be very useful to reproduce what I'm allready doing in Substance Designer with the damaged wall texture, but in realtime with no texture blending artifacts! :)

    Now I have an issue with some height depth artifacts. My height is 16bit png, compressing is off
    srceen.jpg
    This is the texture
    https://drive.google.com/file/d/11xm_Cgam8OyvqInD4RDtzkGOdOWssOAC/view?usp=sharing

    I'm also generating the normal map right in SD. It looks fine in Unity, so the heightmap should be fine too.

    Maybe I'm doing something wrong?
     
  42. Aladine

    Aladine

    Joined:
    Jul 31, 2013
    Posts:
    195
    Hi, is this still not possible yet ? I am more interested into creating image effects that apply either on all pixels on screen or a set of specific objects based on certain conditions (like the x-ray vision effect), thanks!
     
    Blitzkriegmlg likes this.
  43. xrooshka

    xrooshka

    Joined:
    Mar 5, 2014
    Posts:
    59
    Well, I was faced with T2 input of the Normal Create node, so I can't create some procedural height right in shader then create the normal map. Maybe it can be changed? With this strange height compression, looking like a node bug :) Or maybe I can try to write my own node?
     
    Last edited: Jun 30, 2018
  44. mrcostard

    mrcostard

    Joined:
    Nov 8, 2017
    Posts:
    4
    Do we know when it will be compatible with de HD render pipeline ?!
     
  45. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    789
    You can already use Shader Graph with HDRP. Update to the latest version 2.0.4
     
    xrooshka likes this.
  46. Green11001

    Green11001

    Joined:
    Apr 14, 2018
    Posts:
    397
    There is a small glitch where the shader's graph doesn't show up
     
  47. RoughSpaghetti3211

    RoughSpaghetti3211

    Joined:
    Aug 11, 2015
    Posts:
    1,708
    Hey TorusGames, just wondering if you found a solution for this issue where scaling up geometry breaks the normal maps, I’m currently running into the same thing :(
     

    Attached Files:

  48. xrooshka

    xrooshka

    Joined:
    Mar 5, 2014
    Posts:
    59
    Hi there! I've been working with Shader Graph with my solution to the damaged surfaces. Looks quite awesome :)
    upload_2018-7-1_2-24-36.png
    I was reproduced the Substance Desigher prototype and faced with strange work of the Remap node. 0..0,(6) in SD looks like 0,4 in SG, 0.(3) in SD looks like 0.1. It's kinda disappointing.
    [UPD]
    My mistake. I remaped the sRGB texture and unchecking the sRGB flag from it was fixed all the look.

    Also working with Vertex Paint node is very unuseful. It gives you white result in the tumbnail so you can't debug your result untill you apply. And with any troubles in mask generation you have no put the mask result to diffuse once again and pick the values blindly.

    I'm very like the space bar workflow. It works the same as Substance Desigher. I think SG don't need some Node Library panels as it's not the workflow speedup but another distrbing pannel on the screen. Will be great if we can collapse the Black Board as the shader preview because it's disturbing sometimes.

    As I understand, there is no mechanics to make the custom Inspector UI for SG shaders except copying the code and implementing it there. It will be cool to have the instruments to create custom UI looking like Standart Shader for SG shaders. Old Style looks bad for me.

    I very miss the default texture color feature. The color that outputs when no texture is assigned to the slot. Maybe someon has fixed the issue with not assigned textures allready with some logical nodes?
     
    Last edited: Jul 1, 2018
  49. RoughSpaghetti3211

    RoughSpaghetti3211

    Joined:
    Aug 11, 2015
    Posts:
    1,708
    Hey Xrooshka, just wondering if u ran into any issues with your normal maps, try scaling the geometry up and see if it break the normal maps
     
  50. RoughSpaghetti3211

    RoughSpaghetti3211

    Joined:
    Aug 11, 2015
    Posts:
    1,708
    Overall the shadergraph is really powerful and easy to use. My main concerns with it currently is bugs. I keep running into an issue where a node would get stuck at the end of my mouse pointer, seems to happen when I change a property to slider with min and max values. The copy paste is not consistent, sometimes it will copy all the nodes selected and other times only a few. The past and create new node will randomly place the nodes making them hard to find. The big production stopper for me is the normal map issues. Whenever I scale my geometry up the normal maps break, now this might be user error but even the most basic example I put together suffers the form this issue.

    Overall I’m really excited about the shader graph and feel it going in a good direction. Thank you Unity for this awesome tool
    46847387-231A-4318-B176-74A829238E77.png
     
Thread Status:
Not open for further replies.