Search Unity

Feedback Wanted: Shader Graph

Discussion in 'Graphics Experimental Previews' started by Kink3d, Jan 10, 2018.

Thread Status:
Not open for further replies.
  1. xrooshka

    xrooshka

    Joined:
    Mar 5, 2014
    Posts:
    57
    I can't reproduce the issue with normal on scalled up objects. I'm working with HDRP and github SRP downloaded two days ago from there.
    upload_2018-7-1_11-30-1.png
    The right one is not scaled. Maybe it's allready fixed on Github version?
     
  2. xrooshka

    xrooshka

    Joined:
    Mar 5, 2014
    Posts:
    57
    My custom ShaderGUI for the ShaderGraph shader. It's not quite SG shader. I copied the shader graph code, then modified the header and added CustomEditor property. So in fact it's an another shader :) Will be cool if we at least could specify CustomEditor property in SG. And it will be awesome if we could configure our own inspercors the visual way.
    upload_2018-7-1_16-12-31.png
    [UPD]
    Can't make the TextureScaleOffsetProperty work with my shader. I tried to make it last hours but nothing works.
     
    Last edited: Jul 1, 2018
    m4d and francois85 like this.
  3. MythrilMan51

    MythrilMan51

    Joined:
    Apr 24, 2017
    Posts:
    122
    Now the next thing would be decals and projectors...
     
  4. francois85

    francois85

    Joined:
    Aug 11, 2015
    Posts:
    644
    Can someone explain to me the Sampler input on the tripplaner Node.

    Basically I’m wanting my texture to rotate accross the surface of a sphere but instead it rotating the texture per face.
     
  5. floorpeas_CA

    floorpeas_CA

    Joined:
    May 14, 2018
    Posts:
    3
    Personally I find having to rclick and then select create node before being able to search for nodes slows me down and adds an extra click that could be removed. The search functionality could be present on the initial rclick menu.

    Secondly we need an Object ID output on the Object Node. This would enable the shaders to use a static but unique output for the Random Range node and any other function needing a Seed input.
     
  6. floorpeas_CA

    floorpeas_CA

    Joined:
    May 14, 2018
    Posts:
    3
    If you use the rotate node, you are able to rotate the UVs by a specified axis point. If you have unwrapped the sphere symmetrically you will be able to rotate the UVs about the center point.

    Or use the UV settings and set the offset in X with a time or animate a slider input to have the texture scroll. (You will need to create a vec2 and input time / slider into X only) If the sphere has default unwrap values from 3dsmax (and I believe Maya) this will rotate the texture around the north and south poles of the sphere.

    The triplannar and sample state nodes look to be doing something differently, unless you are trying to create UVs for the model specified
     
    Last edited: Jul 2, 2018
  7. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    550
    There's already a shortcut for that. Spacebar opens on the create node menu and defaults to the search field.
     
  8. MythrilMan51

    MythrilMan51

    Joined:
    Apr 24, 2017
    Posts:
    122
    Red.png
    Let's say... I'm trying to make a shader for a mesh... That is its pure color alone...
    Mask.png
    But if it, yet, meets another mesh of its own kind... It fuses masks...
    Yellow.png
    To combine as another color altogether....
    Final Mask.png
    I know that's EASILY done with the power of Premultiply... But how do I fuse masks? Would that be a script, or....?
     
  9. MythrilMan51

    MythrilMan51

    Joined:
    Apr 24, 2017
    Posts:
    122
    Oh... And an extra image while we're at it...
    Red Blue Green.png
     
    Last edited: Jul 3, 2018
  10. Giles-Coope

    Giles-Coope

    Joined:
    Jan 5, 2015
    Posts:
    48
    Added some geometric pattern nodes.

    dots.gif roundwaves.gif spiral.gif whirl.gif zigzags.gif

    I also created a little asset for rendering perfect spheres very cheaply using shader graph and the scriptable render pipeline. https://github.com/gilescoope/perfect-spheres

    Spheres can be rendered using just a quad and are perfectly round with anti aliased sides.
     
    Last edited: Jul 2, 2018
  11. S4UC1SS0N

    S4UC1SS0N

    Joined:
    May 29, 2014
    Posts:
    30
    While testing the new "Position" attribute on the PBR master node, i can't figure out why some Vector3 are accepted as input and some aren't ?


    If my final Vector3 is linked to the Position attribute, i can't build it using a procedural shape (or a texture channel) ouput, but i can use a noise output...
     
  12. 305BigMoney

    305BigMoney

    Joined:
    Sep 19, 2014
    Posts:
    3
    Hey guys i have a quick question, i just added the shader graph to my project but i want to convert my existing shader so that the shader graph works with it is this possible ?

    bellow is the shader file that i would like to convert
     

    Attached Files:

  13. Korindian

    Korindian

    Joined:
    Jun 25, 2013
    Posts:
    441
    @Andy-Touch Hi, I was just going through the Shader Graph example repository and was wondering if the Shader Graph will support the Unity UI?

    For example, the Procedural-Shape-Ring shader works when set as a material on a Canvas Image, but doesn't get properly masked by a Rect 2D Mask or regular Mask component.

    Some of the included example shapes work amazingly well for resolution independent UIs that scale with screen size. Is there some way to get masking to work? If not, will UI support be added in the future? Thanks.
     
  14. Liakos89

    Liakos89

    Joined:
    Nov 27, 2016
    Posts:
    3
    Hello

    I converted an old 2D project of mine to the new pipeline , for use with Shader Graph

    I came across the following problem working the Shader Graph with Sprite Renderers

    The thing is that if I got it right, the Sprite Renderer expects a default texture with the internal name "_MainTex",
    so if you go and name the property on the shader graph like this.. still doesn't work

    The problem is on a closer look that the names given by the GraphShader on the actual code are generated, and not the ones you type (only used as labels)

    The only work around I found is, to after making the shader in the Graph , copy it as code, and then creating a new shader, pasting the code, and manually changing the texture property name to "_MainTex"

    That is really painful to test , and too slow

    Is there any other solution? Unity could you guys add an option "Use for Sprite" - bool, and if true, giving the correct internal name?
     
  15. Liakos89

    Liakos89

    Joined:
    Nov 27, 2016
    Posts:
    3
    Thats not very efficient ,

    besides the problem is really simple,
    the Sprite Renderer expects a property texture with a specific name "_MainTex",
    and the thing is that Shader Graph , no matter how you name a texture,
    the real name in the code is generated, so you can't change it via Shader Graph Window

    However you can copy the shader code from Shader Graph, create a new shader, paste the code, and then find the actual name of the texturer property you use, and replace it everywhere with "_MainTex"
     
  16. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    550
    You can change the name from the Blackboard in Shader Graph (It's in the later versions of Shader Graph so if you are on an older version you might want to update your pipeline and get the latest version of shader graph)

     
    Liakos89 likes this.
  17. Giles-Coope

    Giles-Coope

    Joined:
    Jan 5, 2015
    Posts:
    48
    I added a new set of nodes to my collection.

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

    These ones are for doing Truchet tiling procedurally in the shader. You can simply supply a Texture2dArray, choose the appropriate tiling and apply to a mesh.

    Here's a square tiling with two types of tile.

    Square.PNG

    Here's a hexagonal tiling.

    Hexagon.PNG

    Here's a tiling UV used on some rotating rectangles.

    animated.gif

    As always feedback is very welcome.
     
    idkartist3D, hwaet and awesomedata like this.
  18. Liakos89

    Liakos89

    Joined:
    Nov 27, 2016
    Posts:
    3
    I have the latest version from manager

    Still i cant expose the property, the only dropdown option of the texture in the blackboard is the texture image reference
    =(]
     
  19. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    550
    Are you using Unity 2018.1?
    The latest version of SRP/Shader Graph for 2018.2 is 2.0.4 and 2018.1 is locked to 1.11.1 because of changes to the editor source code, so the latest version of SRP and Shader Graph isn't compatible with 2018.1
     
    Liakos89 likes this.
  20. xrooshka

    xrooshka

    Joined:
    Mar 5, 2014
    Posts:
    57
    I want parallax occlusion node
     
    Last edited: Jul 4, 2018
  21. jonaskohl

    jonaskohl

    Joined:
    Jun 7, 2018
    Posts:
    1
    I have a problem that I can't plug in values from an image into the Position parameter of the PBR Master node. It's hard to explain, so I created a screen capture of my problem. Am I missing something or is this a bug?

    Unity version: 2018.2.0b11 Personal
    Shader graph version: 3.0.0-preview

     
    Ericsheng likes this.
  22. Giles-Coope

    Giles-Coope

    Joined:
    Jan 5, 2015
    Posts:
    48
    Hey there, I couldn't find it either, so I made a "Composite" node that does just this (along with all the Porter Duff mixes) and added it to my repository. Just select "Over" to alpha blend two layers equivalent to Normal in Photoshop.

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

    composite.gif

    The faint colors are just from .gif compression and don't appear when using the node.
     
  23. MythrilMan51

    MythrilMan51

    Joined:
    Apr 24, 2017
    Posts:
    122
    HOWEVER... I DO wonder... could you tag specific objects in you you could use them in Unity's shader graph? If THAT wasn't thought of... Let THIS be a suggestion.
     
  24. MythrilMan51

    MythrilMan51

    Joined:
    Apr 24, 2017
    Posts:
    122
    ALSO... You could try multiply... Red's already taken... LIKE what you see in the video.
     
  25. online_frog

    online_frog

    Joined:
    Dec 27, 2012
    Posts:
    2
    Like many other people in this thread I've been having problems with normal maps in shadergraph on the LWRP. This was the case in version in 2018.1.2f1 using the latest shadergraph available in the package manager, as well as 2018.2.0b9 using the latest build on the SRP repo as of today.

    Here's what my shader looks like simply with a normal map hooked to the normal input of the PBR Master node.



    My workaround: putting it through a Normal Strength node set to 0.0005 strength:



    Unfortunately this workaround doesn't work when a Normal Blend is thrown into the mix.

    Not really sure what's going on here, some people are saying it has to do with the object scale? Overall it seems like a small subset of people using shadergraph are getting this issue. I hope it gets addressed sometime soon!
     
    francois85 and awesomedata like this.
  26. MythrilMan51

    MythrilMan51

    Joined:
    Apr 24, 2017
    Posts:
    122
    I bet I'm looking for that for a shader I'm graphing... I think.
     

    Attached Files:

  27. Giles-Coope

    Giles-Coope

    Joined:
    Jan 5, 2015
    Posts:
    48
    I'm not sure it's exactly what you want...If I understand correctly you want to have two different meshes combining colors in a non standard way? It's not an easy thing to do, once one of the meshes has been rendered to the screen there's no real way of extracting the color of that mesh from the background pixel it's been blended with.

    To do this kind of things inside a shader you need to find a way of rendering all of these "meshes" in the same pass, or render them all to a render texture and then use that (expensive).
     
    Last edited: Jul 5, 2018
  28. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    814
    Anyone at @Unity up for yet another technical challenge?

    Yes, this involves "blending" too.

    I'm working on a "complex blending" shader to blend multiple objects together that, according to the developer of "Amplify Shader Editor", is currently not possible with ASE (due to the way it handles depth-buffer).

    I, being the kind of person who doesn't follow the "not possible" train of thought, really prefer this to be possible in Unity via the new Shader Graph system!



    The "problem shader" (as it currently stands):


    depthfadeBIG.png

    depthfadeBIGblend.png

    As you can see above, the green (x 2) and the white monkey-heads share the same shader. The shader makes the two "blend" with the surface geometry of any other mesh.

    The major problem is -- the monkey-heads don't blend with each other!


    I understand this is a particularly complicated shader concept, but I plan to work with it by designating 2-3 transparent "layers" that let you can blend with any other transparent (and non-transparent) "layer" that's not your OWN transparent "layer" essentially.

    This might require separate "depth" buffers -- and any object NOT on the "main" transparent "layer" (i.e. the default "depth buffer" layer) -- would get "subtracted" automatically from the default depth-buffer so that it can be added, manually, later on, via the node-graph (by the user!)

    As you can see above by the blue "blending" areas, this is really only a list of objects stamped to 2-3 (somewhat-persistent) depth textures (with an integer ID to represent the depth "layer" set by the user to assign to a particular "depth" texture). Each "layer" temporarily renders itself to a particular depth texture, and "ignores" the main depth layer until it is manually added in later. Each "layer" would also have the ability to write itself to the "main" depth layer (as well as the "transparent" layer too) as entirely black/white or based on its local "depth" mask.



    I don't know about you, but a shader like this seems like a pretty solid "flexibility test" for Shader Graph's new "blending" functionality -- before it officially arrives.
     
  29. Uteki

    Uteki

    Joined:
    Apr 17, 2017
    Posts:
    5
    Quick question:
    It is possible to specify output from sub graph?
    I want to output Vector1 not Vector4 as it chooses automatically.
     

    Attached Files:

  30. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    7,153
    Yeah, this is a pretty significant bug. Unity isn't normalizing the normal or tangent vector in the LWRP PBR Master Shader Graph's vertex function, but is normalizing the bitangent ... which shouldn't even be needed especially if they were properly normalizing the other two.

    Looking at the generated code for a basic PBR node graph you should be able to find this:
    Code (csharp):
    1.                 float3 WorldSpaceNormal = mul(v.normal,(float3x3)UNITY_MATRIX_I_M);
    2.                 float3 WorldSpaceTangent = mul((float3x3)UNITY_MATRIX_M,v.tangent.xyz);
    3.                 float3 WorldSpaceBiTangent = normalize(cross(WorldSpaceNormal, WorldSpaceTangent.xyz) * v.tangent.w);
    That bit of code should look like this:
    Code (csharp):
    1.                 float3 WorldSpaceNormal = normalize(mul(v.normal,(float3x3)UNITY_MATRIX_I_M));
    2.                 float3 WorldSpaceTangent = normalize(mul((float3x3)UNITY_MATRIX_M,v.tangent.xyz));
    3.                 float3 WorldSpaceBiTangent = cross(WorldSpaceNormal, WorldSpaceTangent.xyz) * v.tangent.w;
    This was seen in lightweight 2.0.4 The HDRP doesn't appear to have the issue.
     
    francois85 and online_frog like this.
  31. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    7,153
    This is pretty far outside the wheelhouse for a shader graph system, at least for real time shaders. You'd need to be rendering to multiple render targets with one as a read / write depth buffer, and would only really work well if the order of the objects being rendered is consistent so you can't do distance sorting. Basically this kind of effect with the features you're looking for require pipeline level changes. You could do this by writing your own custom render pipeline, or writing vertex fragment shaders and carefully controlling the draw order and render targets with command buffers ... but it's not really something I can see happening in the built in HDRP.

    Again, it is possible, but the Shader Graph just generates a shader, and you're asking for new pipeline features, not just a new node in the graph.

    It's also a potentially really expensive feature.
     
  32. mflux

    mflux

    Joined:
    Oct 19, 2017
    Posts:
    7
    Latest version of Unity (2018.1.6f1) 64Bit

    Can't get ShaderGraph to work at all:

    Code (CSharp):
    1. Assertion failed: Assertion failed on expression: 'success'
    2. UnityEditor.ShaderGraph.Drawing.MaterialGraphEditWindow:Initialize(String)
    3. ShaderGraphImporterEditor:ShowGraphEditWindow(String) (at C:/Users/Flux/AppData/Local/Unity/cache/packages/packages.unity.com/com.unity.shadergraph@1.1.9-preview/Editor/Importers/ShaderGraphImporterEditor.cs:42)
    4. ShaderGraphImporterEditor:OnOpenAsset(Int32, Int32) (at C:/Users/Flux/AppData/Local/Unity/cache/packages/packages.unity.com/com.unity.shadergraph@1.1.9-preview/Editor/Importers/ShaderGraphImporterEditor.cs:51)
    5. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    6.  
     
  33. MythrilMan51

    MythrilMan51

    Joined:
    Apr 24, 2017
    Posts:
    122
    upload_2018-7-6_8-43-21.png
    ACTUALLY... I think I found out how...

    Now if I could sample my SVG's in Unity's Shader graph.... I would be set.
     
  34. Giles-Coope

    Giles-Coope

    Joined:
    Jan 5, 2015
    Posts:
    48
    Ok I think I see what you want. You want to pass all of the rings positions to the shader at once and render them all together, combining the colors if they overlap. It's totally possible, but unless you do some culling yourself every extra ring you add will create another texture lookup, which might get expensive.

    When you do the combining you will need to premultiply the colors by the alpha before adding them together, then divide the whole thing by the final alpha. This calculation of the alpha isn't quite right, but it's close enough probably.
     

    Attached Files:

  35. MythrilMan51

    MythrilMan51

    Joined:
    Apr 24, 2017
    Posts:
    122
    THAT.... Actually helps... Thanks... Now all I need's to put that in action.
     
  36. massivebacon

    massivebacon

    Joined:
    Apr 24, 2014
    Posts:
    15
    Just found a bug when writing custom nodes that's easily reproducible. Declaring a fixed4 makes the shader fail (the assert doesn't pass), but declaring a half4 or float4 makes it work. Based on this help article here it seems like fixed4 should work even if it's basically a semantic difference. Same for fixed3 as well.
     
  37. MythrilMan51

    MythrilMan51

    Joined:
    Apr 24, 2017
    Posts:
    122
    upload_2018-7-6_21-18-3.png AND...
     
    tinyant likes this.
  38. francois85

    francois85

    Joined:
    Aug 11, 2015
    Posts:
    644
    Please let me know if you find a solution,this is killing my project :(
     
  39. francois85

    francois85

    Joined:
    Aug 11, 2015
    Posts:
    644
    Do you know if there is an issues opens for this bug ? For the life of me I can navigate that thing :(
     
  40. myroomtm

    myroomtm

    Joined:
    Nov 15, 2012
    Posts:
    7
    Is there someone who can tell me how to use fog node? T.T
    Or can i get some example to use for fog node?
     
    Last edited: Jul 7, 2018
  41. unity_fqaYB9sB-JK-LA

    unity_fqaYB9sB-JK-LA

    Joined:
    May 3, 2018
    Posts:
    9
    Can you use structuredBuffers in the shader graph? If not, would it be simple to add?
     
  42. sewy

    sewy

    Joined:
    Oct 11, 2015
    Posts:
    48

    Not sure if it was reported but it is still not working.


    Another similar bug is when using 'Transformation matrix' in 'Model View' mode..
    Code (CSharp):
    1. undeclared identifier 'UNITY_MATRIX_MV'
    2. UnityEditor.EditorApplication:Internal_CallUpdateFunctions()
    Another is when using 'Reflection probe'
    Code (CSharp):
    1. undeclared identifier 'unity_SpecCube0'
    2. UnityEditor.EditorApplication:Internal_CallUpdateFunctions()
    I would be more than happy to report it as a bug, but i see no reason to provide so much info about the PC to report thing, that is not connected with my PC.
    Please, could you make simple bug report option with no PC scan? (For bugs like that or typos etc.)
     
    Last edited: Jul 9, 2018
  43. sewy

    sewy

    Joined:
    Oct 11, 2015
    Posts:
    48
    I would love to be able to group nodes with name (comment) and be able to choose if shader should be Auto updated - because sometimes you need to switch connection for example, but you have to wait after every change for it to recompile.
     
  44. alexandral_unity

    alexandral_unity

    Unity Technologies

    Joined:
    Jun 18, 2018
    Posts:
    96
  45. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    814
    Seems like this could use something similar to how lighting is calculated on a per-pixel level to calculate depth (i.e. 3 depth textures) and the alpha would determine the distance from front to back of the screen. What would prevent layers that overlap from being added to the final "depth buffer"?

    Is there really no way to take three (persistent) black textures, render each object that "picks" from these textures onto the chosen texture, then finally add them up or multiply them, etc.?

    They have something like this depth sorting in Amplify (that doesn't rely on depth-buffer), but it cannot be used for a custom depth-buffer due to the fact that Unity can't seem to grab global materials inside the shader (as far as I'm aware -- I may be wrong though):

    http://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Shader_Editor/Surface_Depth

    I'm not sure this would be quite as expensive as it sounds. Unreal does something like this using a more "global" shader editor that can take into account all the other materials in the project and combine them at runtime. Not sure if Unity's shader editor is going to account for this, but giving access to some form of "global" textures would be highly useful for something like this.
     
  46. Ericsheng

    Ericsheng

    Joined:
    Dec 9, 2016
    Posts:
    7
    I find this problem, too. It works fine with input value from vertex color though. With image input, it won't let me plug into the Position parameter.
     
  47. Korindian

    Korindian

    Joined:
    Jun 25, 2013
    Posts:
    441
    @alexandral_unity Hi, do you know if eventually the Shader Graph will support custom UI shaders (which get properly masked), as well as custom HDRP Decal shaders? Thanks!
     
  48. sewy

    sewy

    Joined:
    Oct 11, 2015
    Posts:
    48
    I would love to, but as I've said, I see no reason to provide so much info about the PC to report thing, that is not connected with it. (For bugs like 'undeclared identifier' or typos etc.)
     
  49. unity_fqaYB9sB-JK-LA

    unity_fqaYB9sB-JK-LA

    Joined:
    May 3, 2018
    Posts:
    9
  50. Micz84

    Micz84

    Joined:
    Jul 21, 2012
    Posts:
    232
    In LWRP there are shaders with PBR, Simple Lighting and Unlight but shader graph has only PBR and Unlight. Is it possible to add Simple Lighting as an option for shader graph shaders?
     
Thread Status:
Not open for further replies.