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

    reflectingb0t

    Joined:
    Apr 10, 2018
    Posts:
    18
    Hi, thanks for giving us the opportunity to create own shaders with shader graph, I really like it so far! I have a few questions / suggestions.

    1) is the Append node available by now? I'm on Unity 2018.2.0b11 with HD Render Pipeline v. 3.0.0 and I only have a Combine Node. Is this equivalent to Append or not?

    2) Also I think theres something wrong with the Channel Mask Node? Or at least I don't understand how / when to use it. I would expect it to output a vector 1 e.g. if I input a vector 2 and mask one channel, but it still outputs a vector 2.

    upload_2018-7-18_23-40-58.png
    the green channel doesn't seem to be masked properly, combine shows no green information

    upload_2018-7-18_23-44-3.png
    how I would it expect to behave, combine now has red and green information

    upload_2018-7-18_23-45-8.png
    same functions in Unreal Engine

    3) I know some others already asked for this before. I really would welcome some organizing tools inside the shader graph: Reroute node, able to write comments on selected nodes and frame node groups.

    Thanks,
    Lea
     

    Attached Files:

  2. mflux

    mflux

    Joined:
    Oct 19, 2017
    Posts:
    7
    How are you guys making shaders? I can't even get the graph working at all:

     
  3. mflux

    mflux

    Joined:
    Oct 19, 2017
    Posts:
    7
    Ah, after much mucking about I finally realized it was because I didn't have an SRP installed. That was not made clear at all from someone who doesn't follow these updates so closely. At the least installing Shader Graph it should warn you that it would only work with the new shader pipeline, and here you go install it for you.

    After all of that I still could not get it working on the HDR pipeline. This issue: https://issuetracker.unity3d.com/is...h-errors-when-changing-graphics-api-to-vulkan

    Now that it's become clear I must choose a render pipeline... I guess I won't use it? Because if I want to make an asset I need to either make two versions of all shaders, or simply abandon customers on the asset store who chose a different pipeline than the one I chose. Yikes. Why would I want this? Just installed Amplify Shader Editor and moved on with life...
     
  4. Laurens-Paladin-Studios

    Laurens-Paladin-Studios

    Joined:
    Apr 25, 2015
    Posts:
    49
    Allright, I did also post the question on the SRP forum because i thought it might also be a LWRP issue.

    But does it meen that the issue of the incorrect realtime shadowcasting has been worked on but not yet resolved?
     
  5. Dudledok

    Dudledok

    Joined:
    Oct 24, 2013
    Posts:
    110
    Any suggestions @ssartell @wyatttt ?
     
  6. sewy

    sewy

    Joined:
    Oct 11, 2015
    Posts:
    46
    Yes please, using HDRP (still in 3.0.0) - see attachment - made it just to show the problem.

    EDIT: same problem with 'UNITY_MATRIX_IT_MV' and 'UNITY_MATRIX_T_MV', other ones are ok.
     

    Attached Files:

  7. TheBricktop

    TheBricktop

    Joined:
    Sep 3, 2012
    Posts:
    20
    Is Matrix4x4 property input planned for next shadergraph update?
     
  8. M_R

    M_R

    Joined:
    Apr 15, 2015
    Posts:
    450
    I get compilation erorrs, probably due to my locale being Italian (uses comma as decimal separator) (Case 1062108).

    it produces stuff like this:
    Code (hlsl):
    1.  Properties
    2.     {
    3.         Vector1_18CCAFDA("Speed", Float) = 0,1
    4. Vector2_AC44E617("Center", Vector) = (0,25,0,25,0,0)
    5. Color_BE3B3BB3("PaintColor_01", Color) = (0,1137255,0,627451,0,8352941,0)
    6. Color_5D3E96B5("PaintColor_02", Color) = (0,04561231,0,144953,0,3867925,0)
     
  9. ssartell

    ssartell

    Joined:
    May 21, 2018
    Posts:
    14
    @HopelessHyena @Dudledok Here's a basic example:



    You must create a property called "_CameraOpaqueTexture" with that as the reference name and "exposed" set to false. You sample the texture using the screen position. Also, you have to change the "Surface" on your output node to "transparent".

    This setup works with _CameraDepthTexture as well, but you need to do more stuff to work with the value. I created my own subgraph that replicates the LinearEyeDepth function so I could work with the depth values. You can compare it with the Z position (in view space) to find out how deep into the shape your surface is. Or I was also able to use the value to do a projection shader. Here's the LinearEyeDepth subgraph: https://i.imgur.com/YZCsmMZ.png

     
    Reshima, hwaet, SMendez and 4 others like this.
  10. zacharyd890

    zacharyd890

    Unity Technologies

    Joined:
    Apr 18, 2018
    Posts:
    4
    Hey all!

    @leakronenberger

    1) Combine should be equivalent to append, with the exception that you will need to split vector 2s/3s before inserting them. You could also just use Vector 2/3/4 node instead of combine. If you would really like an append node I could talk to a developer about it.

    2) The Channel Mask zeroes out the channels that aren't set. So in the case of your first picture the Channel Mask is outputting (0.0, 1.0), and your plugging that into a Vector1 input which will only read the first value of the Vector2 which is 0.0.

    3) We are looking into it! Thanks!

    @mflux

    Sorry about the confusion. If you are using the most recent Shader Graph package you should see a warning like this:
    PipelineCompatilibityError.gif
    We are happy to hear of more ways to make this clear in the future, such as warning you when you install the package.

    Shader Graph should be a relatively easy way to make shaders for different pipelines, with more support for supporting pipeline differences coming in the future.
     
  11. MythrilMan51

    MythrilMan51

    Joined:
    Apr 24, 2017
    Posts:
    122
    Bet everyone's yelling about this... but.....

    My other projects are fine.... for some reason.
     
  12. MythrilMan51

    MythrilMan51

    Joined:
    Apr 24, 2017
    Posts:
    122
    Or not.... False alarm
     
  13. wyatttt

    wyatttt

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    250
    Hey @MR-Heavy! Not really a good way but I can tell ya how to do it! I was actually curious about this myself so I am glad you asked.

    First, some questions for ya:
    1. How are you making your Material that you reference in your script?
    2. Is this for an image/post effect? If so, are you making it using the PostProcessing stack or using OnRenderImage?

    Now to answer (most of) your question:
    The first issue is that, as far as I know, shadergraph assets won't work by themselves (unless you maybe make a material out of them from the Editor and pass that to your script via the Inspector for use in the Blit. If you don't do this, keep reading).

    1. You'll have to open the graph, right-click on the Master Node and select "Copy Shader".




    2. Paste that into an actual .shader file. Then at the top, where it probably says "Unlit Master", you will want to change that string to whatever you want your shader to be referenced as (ie. when you call Shader.Find to load the shader).




    3. Then, in the first shader Pass, where it says "Cull Back", "ZTest LEqual", and "Zwrite Off", change those 3 lines to "Cull Off ZWrite Off ZTest Always". This is necessary for certain blit operations (ie when using PostProcessing and CommandBuffer.BlitFullscreenTriangle) but should work without it for most Graphics.Blit operations.



    4. Then you should be able to create a Material out of it via scripting and use it with Graphics.Blit like so:


    Code (CSharp):
    1. public class MyMonoBehaviour : MonoBehaviour
    2. {
    3.     private static Material m_Mat;
    4.     private static Material mat
    5.     {
    6.         get
    7.         {
    8.             if(m_Mat == null)
    9.             {
    10.                    // replace Custom/Red with the name of your shader from Step 2, above
    11.                    m_Mat = new Material(Shader.Find("Custom/Red"));
    12.            }
    13.  
    14.             return m_Mat;
    15.         }
    16.     }
    17.  
    18.     override void OnRenderImage(RenderTexture source, RenderTexture destination)
    19.     {
    20.        Graphics.Blit(source, destination, mat, 0);
    21.     }
    22. }

    5. Then you'll have to hook it up to whatever system you are working with (ie PostProcessing, OnRenderImage, etc). If you give me some more details on what you are trying to do with it, I may be able to give you some more info if that's something you're interested in.

    Hopefully that works! I did a quick test with the PostProcessing stack on mine end and ended up with this using shader code from a basic ShaderGraph. In theory, this should work in a similar fashion with Graphics.Blit



    You may be able to get around all the copy and pasting if you create a Material out of the ShaderGraph and pass that to your script because then you won't have to call Shader.Find for a shader that might not be named what you think it is (like how the default name was "Unlit Master"). Haven't tested that yet.

    EDIT:
    Ok tested it by creating a Material out of the ShaderGraph asset like so



    and loading that Material via script instead of using Shader.Find and it worked.

    Cheers!
     
    Last edited: Jul 20, 2018
    A132LW and PixelMind like this.
  14. Dudledok

    Dudledok

    Joined:
    Oct 24, 2013
    Posts:
    110
    Unfortunately that's literally exactly what I tried as a starting point:
    upload_2018-7-20_9-56-25.png
    As you can see I'm not getting the opaque pass from that property. Using 2018.2.0f2 and latest ShaderGraph, version 2.0.5 through the package manager.

    Edit:
    I just noticed there's a new version so upgraded LWRP and ShaderGraph to 3.0.0, still no dice (as expected as it was added in 2.0.0).

    Also, is there a code sample for how to use it? GrabPass was a nice easy one liner :)

    Edit 2:
    I have done the same in the sample scene, same issue. If I use the reference _CameraDepthTexture it goes black instead of grey, if I don't plug in a texture to the sampler it's white, and anything else I write for the texture 2D reference it's grey.
     
    Last edited: Jul 20, 2018
  15. vladstorm_

    vladstorm_

    Joined:
    Nov 26, 2013
    Posts:
    174
    Hi everyone,

    I've been making shaders in unity for the last 5 years and now I'm trying to use this new awesome ShaderGraph to recreate some ideas. It's pretty cool in general but it's missing some node types. Please, tell me whether you are going to implement them

    So, here's what it would be cool to have

    1. node name ( i think this is the most important one, it's the same like variable names. without it it's hard to understand what's going on )
    2. node description (comments)
    3. comments (extra node with comments to explain several parts of the shader )
    4. light direction. maybe i didn't find it tho, but i existed in the shader default variables before. same with current reflection probe
    5. compute buffer input (for me it's one of the most important ones coz I'm using shaders to render generative geometry which is coming from the compute shader passes. I have a compute buffer with vertices in the end which i feed to a surface shader for example. )
    6. if
    7. for and other loops
    8. functions ( shader sub graphs probably supposed to work as functions... hmm)

    it would be really cool to hear your opinion about each node type.
    also, i didnt get why it doesnt work outside SRP. the first project i made as a default 3D project and it said ShaderGraph is not supported which is frustrating.
     
    eXecutex likes this.
  16. TheWanderingBen

    TheWanderingBen

    Joined:
    Nov 3, 2015
    Posts:
    50
    Sorry if this has been mentioned elsewhere, though I couldn't see it in the 22 pages of this thread, nor in Unity's forum search:

    Has the Shader Graph roadmap been made public?

    I would love to know when to expect certain features. Currently really missing the following:
    • Front face culling
    • Vertex offset
    • Multiple Passes
    Aside: those features would be nice in general, but right now I'm just trying to write a simple outline shader. I only know how to do it with the aforementioned features, but if anyone has a Shader Graph alternative, I'd love to hear it!
     
  17. interpol_kun

    interpol_kun

    Joined:
    Jul 28, 2016
    Posts:
    72
  18. FaizanDurrany

    FaizanDurrany

    Joined:
    Dec 25, 2014
    Posts:
    24
    Same problem, Unity 2018.2.0f2 ShaderGraph 3.0.0

    EDIT: Okay I got it to sorta work by enabling "Opaque Texture" in the LWRP asset under Assets/Settings (inside the default project that is created by selecting "LightWeight Render Pipeline" when creating the project)

    The problem now is that it projects the scene camera rather than the game camera

     
    Last edited: Jul 21, 2018
  19. ssartell

    ssartell

    Joined:
    May 21, 2018
    Posts:
    14
    @FaizanDurrany You're totally right about the settings in LWRP. I forgot about those. I don't know why yours isn't working on the game and scene camera though as mine does. I'm on Unity 2018.2.0b7 which might be the difference, but seems unlikely.

    Edit: It looks like in the newest version of LWRP you have to enable the depth and opaque textures manually per camera. To do so, go to your camera and add a "Lightweight Additional Camera Data" component and enable "Requires Depth Texture" or "Requires Color Texture". That did the trick for me
     
    Last edited: Jul 21, 2018
    Dudledok and FaizanDurrany like this.
  20. FaizanDurrany

    FaizanDurrany

    Joined:
    Dec 25, 2014
    Posts:
    24
    Yep that did the trick. though is there any way I can get similar functionality to _CameraOpaqueTexture but also get the rendered UI?
     
  21. ssartell

    ssartell

    Joined:
    May 21, 2018
    Posts:
    14
  22. FaizanDurrany

    FaizanDurrany

    Joined:
    Dec 25, 2014
    Posts:
    24
    @ssartell Was trying to make a blur shader.

    Also any news on when _MainTex and _Color will be fixed for Unlit Subgraph?
     
  23. HopelessHyena

    HopelessHyena

    Joined:
    May 26, 2015
    Posts:
    18
    Thank you SO much for this. Worked perfectly. Very much appreciated - very best regards.
     
  24. HopelessHyena

    HopelessHyena

    Joined:
    May 26, 2015
    Posts:
    18
    It would be very nice to have a Blur node, which takes an input RGBA and blurs it (in a fast manner!). I believe unreal has something similar?
     
    eXecutex likes this.
  25. eXecutex

    eXecutex

    Joined:
    Mar 23, 2018
    Posts:
    3
    Yeah totally agree with you. At this point it makes me go back to photoshop and blur something manually. Would be nice to have a blur node added to the filter category .
     
  26. Giles-Coope

    Giles-Coope

    Joined:
    Jan 5, 2015
    Posts:
    48
    I think there's no way of doing a generic blur inside a shader, as it requires access to the other pixels' data. The best you can do is

    - render to a texture then do the blur on the cpu/in a compute shader
    - use DDX/DDY data to blur (will only be 2 pixels wide)
    - blur a texture being sampled by doing multiple lookups or a LOD
     
    HopelessHyena likes this.
  27. MR-Heavy

    MR-Heavy

    Joined:
    Jan 1, 2016
    Posts:
    14
    Ok, it was nice additional info, but, don't fix my problem.

    So, first: "RenderPipeline" = "HDRenderPipeline" - working with this...
    second:

    I'm run 2 materials with 100% same settings for check ("goodMaterial" - material with "Unlit/Texture" shader)

    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class BlitProblemScript : MonoBehaviour
    4. {
    5.     public Texture2D texIn;
    6.  
    7.     public Material goodMaterial;
    8.     public Material badMaterial;
    9.  
    10.     public RenderTexture goodResult;
    11.     public RenderTexture badResult;
    12.  
    13.     void Start ()
    14.     {
    15.         CalculateTextures();
    16.     }
    17.  
    18.     void CalculateTextures()
    19.     {
    20.         Graphics.Blit(texIn, goodResult, goodMaterial);
    21.         Graphics.Blit(texIn, badResult, badMaterial);
    22.     }
    23. }
    24.  
    As result, i'm looking on both "RenderTexture" and on line with "Unlit/Texture" - got result, allways. But with shader graph way - still don't get anything.

    m1.PNG

    I try this thing with copy shader and make new one and set "Cull Off ZWrite Off ZTest Always" - still nothing.

    Goal was - get on "public RenderTexture badResult;" result of run "texIn" through "shader graph's shader", and it's still a "black nothing" on it.
     
    A132LW likes this.
  28. Voldeath

    Voldeath

    Joined:
    Jun 7, 2013
    Posts:
    5
    Is there any way of referencing a Matrix (since there are no properties for that)? I'm trying to get a reference to unity_Projector.
     
  29. Giles-Coope

    Giles-Coope

    Joined:
    Jan 5, 2015
    Posts:
    48
    I think at the moment the best way is to split it into vectors then recombine them in the shader.
     
  30. HopelessHyena

    HopelessHyena

    Joined:
    May 26, 2015
    Posts:
    18
    @zacharyd890 and @wyatttt I think it would be good to have a LinearEyeDepth equivalent subgraph so that one doesn't have to implement it oneself every time. (See above). This would make producing refractive/defractive/depth based shares a lot easier :)
     
    Luoyue and wyatttt like this.
  31. wyatttt

    wyatttt

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    250
    I agree! I will bring that up with the team in case it hasn't come up yet
     
    Korindian, ssartell and HopelessHyena like this.
  32. MR-Heavy

    MR-Heavy

    Joined:
    Jan 1, 2016
    Posts:
    14
    Yo @wyatttt ! So, problem with "Graphics.Blit" still exist. As the worst part of it - each time for test, i'm run same code for "Unlit/Texture" shader, and get working result into second render texture... Or i made a stupid mistake somewhere, or, problem is little bit deeper than a "Cull Off ZWrite Off ZTest Always".
     
  33. Dudledok

    Dudledok

    Joined:
    Oct 24, 2013
    Posts:
    110
    Thanks, needed the camera component!
     
    Last edited: Jul 23, 2018
  34. eXecutex

    eXecutex

    Joined:
    Mar 23, 2018
    Posts:
    3
    Are there any news on the Tesselation for Shader Graph?
    Also are there plans for a Roadmap or still no info ?
    When will the Shader Graph come out of preview approximately? Is it going to come into release as the HDRP next year or is it different ?

    Thanks for the answer^
     
  35. sewy

    sewy

    Joined:
    Oct 11, 2015
    Posts:
    46
    After updating to HDRP 2.0.5. and above (2.0.4 preview.1 was OK) I am getting this
    Code (CSharp):
    1. cannot implicitly convert from 'const float3' to 'float4'
    when using "Position Node" with "View" mode - any other mode is OK.

    Anyone having problem with "Position Node" with "View" mode? Image only to show the problem.
     

    Attached Files:

  36. wyatttt

    wyatttt

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    250
    @HopelessHyena There is (or will be) a SampleDepth node
     
    ssartell and HopelessHyena like this.
  37. wyatttt

    wyatttt

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    250
    @MR-Heavy I'll try it out again
     
  38. Zwer99

    Zwer99

    Joined:
    Oct 24, 2013
    Posts:
    24
    Hello!

    ShaderGraph isn't working anymore after installing 3.0.0-preview. Sadly reverting back to 2.0.6 doesn't make the shaders working again.
    With the new version, it's very "hard" to get a functioning shader - it is kind of unpredictable. One time it's working, one time it's not. Also, all of my old shaders built with ShaderGraph are destroyed.

    I always get the following error: Shader is not supported on this GPU (none of subshaders/fallbacks are suitable)

     
  39. DocLovepeace

    DocLovepeace

    Joined:
    Dec 13, 2016
    Posts:
    9
    I have done a lot with Shadergraph and Lights for Tile map in the past view weeks.
    Aiming to publish a Tutorial.
    Will there be a possibility to enhance the number of Pixel Lights soon?
    For now it seems to be limited to 4 with no possiblity for change in the Quality Settings :-(

     
  40. Zwer99

    Zwer99

    Joined:
    Oct 24, 2013
    Posts:
    24
    I think I found the bug: is it possible, that a "," is inserted instead of a "." for floating point values in the properties list? Unity always converts my 1.5 to a 1,5:



    When I copy the shader (by right-clicking on the master node and selecting copy shader) and paste it into a shader-file the properties are also given as values with "," instead of ".":

     
  41. MythrilMan51

    MythrilMan51

    Joined:
    Apr 24, 2017
    Posts:
    122
    You can always bake them.... If you only need them all on.
     
    DocLovepeace likes this.
  42. eXecutex

    eXecutex

    Joined:
    Mar 23, 2018
    Posts:
    3
    Can someone explain to me how that Reference works in the Property of any kind ? And also what does Exposed mean ?
     
  43. wyatttt

    wyatttt

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    250
    @eXecutex

    • "Reference"
      • is the name of the variable in the generated shader.
      • It is the reference type (vector, texture, etc) + some hash/id.
      • You can override it with your own string value
        • This is useful if you are modifying it via script with SetFloat, SetTexture, etc.
    • "Exposed"
      • means whether or not the property shows up on the Material Inspector for you to edit by hand in the Editor
     
    Last edited: Jul 24, 2018
    eXecutex likes this.
  44. wyatttt

    wyatttt

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    250
    @Zwer99 Might be an issue with locale. Do you know what yours is set to? (English, Russian, Italian, etc)
     
  45. Korindian

    Korindian

    Joined:
    Jun 25, 2013
    Posts:
    437
    @wyatttt Really appreciate you responding on this thread. Do you know if the Shader Graph will eventually support the following?

    1. GPU instancing on HDRP shaders
    2. Custom Decal shaders in HDRP.
    3. Custom UI shaders in HDRP.
    4. Multiply/Add/etc. nodes that allow more than 2 inputs? Kind of like how Amplify Shader Editor does it.

    Thanks for your time.
     
  46. Adam-Bailey

    Adam-Bailey

    Joined:
    Feb 17, 2015
    Posts:
    229
    Not if you want specular highlights. The specular lightmapping option is gone and the official word for those cases is to use realtime lights.
     
  47. Zwer99

    Zwer99

    Joined:
    Oct 24, 2013
    Posts:
    24
    It should be set to English. How can I check that?
     
  48. Dudledok

    Dudledok

    Joined:
    Oct 24, 2013
    Posts:
    110
    It doesn't seem like we can use the opaque pass for any real multi pass effects in LWRP, e.g. glass / water diffraction. Any approximate timeline for support for this?
     
  49. MythrilMan51

    MythrilMan51

    Joined:
    Apr 24, 2017
    Posts:
    122
    Also... What types of references could we use?
     
  50. MythrilMan51

    MythrilMan51

    Joined:
    Apr 24, 2017
    Posts:
    122
    Like.... Is there a list of references somewhere?
     
Thread Status:
Not open for further replies.