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

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    I maybe wrong, but I think Shader Graph support 4 channels on uv0 (you don't get float4, but you got half4, which I believe is still more than enough for most Texture 2D Array use case)

    Here is quick test:

    Code (CSharp):
    1.         var filter = GetComponent<MeshFilter>();
    2.         var mesh = filter.mesh;
    3.         var uv = mesh.uv;
    4.         var uvs = new List<Vector3>();
    5.         for (int i = 0; i < uv.Length; i++) {
    6.             uvs.Add(new Vector3(uv[i].x, uv[i].y, i));
    7.         }
    8.         mesh.SetUVs(0, uvs);
    Screen Shot 2019-01-09 at 1.13.27.png Screen Shot 2019-01-09 at 1.14.01.png

    I don't have a texture 2d array at hand but at least this shows the value is on uv0.z is being read correctly.
     
    andywatts likes this.
  2. Norpyx

    Norpyx

    Joined:
    Dec 20, 2018
    Posts:
    1
    This is still an issue. Emissions from Shader Graph are not baking.

     
  3. KnightPista

    KnightPista

    Joined:
    May 18, 2015
    Posts:
    40
    When I update shader graph from my coworker, inputs of subgraph nodes in the graph get disconnected, causing the shader to malfunction. I've looked into editor.log and found following messages:

    Removing Invalid MaterialSlot: <integer>

    I've looked into the shader graph source code and the warning is spawned from the AbstractMaterialNode.cs : RemoveSlotsNameNotMatching function. All other coworkers have the graph working and nodes connected. We are all on the same Unity version, and I've also tried to delete Library folder and do a complete reimport, but without success.

    Do anybody have any clue what's going on here? Is there a way I can debug shadergraph code, so maybe I can try to find why the (I guess asset parsing) fails? Thanks for any help.

    EDIT: Fixed: looks like deleting just the Library and Temp folders was not enough. I've deleted the whole project folder and re-downloaded it clean from repo and the shader graphs are now parsed correctly.
     
    Last edited: Jan 9, 2019
  4. spikar1

    spikar1

    Joined:
    Oct 21, 2015
    Posts:
    1
    Hi!

    I was wondering if it'll ever be possible to render several vertex passes with shadergraph?
    I would love to be able to produce outline effects with just shadergraph
     
  5. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    504
    Upgrading from 2018.2f to 2018.3f and the 4.6 versions of the SRP, HDRP, SGE, etc.

    Most shaders broke, that's understandable. Had to re-compile sub-shaders, then the main shaders (do it in that order for best results).

    However, one of the unlit shaders stopped working. Fixed the problem by going from the Unlit to the Lit and PBR Master nodes and sticking it in emissive. The Unlit Master node seems to be the problem.

    Error posted below, it simply pinks out the shader.

    unlit_error.png
     
  6. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,195
    That's supposedly a known issue in 4.6, which I believe/hope is fixed in 4.7. 4.7 isn't out yet, but hopefully it's released soon.
     
  7. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    504
    Ah ok.

    For any SGE devs watching; please please please SampleCubemap node WITHOUT reflection math pre-included. Just give me an option to feed it XYZ and Mip level.
     
  8. Muffty

    Muffty

    Joined:
    Nov 4, 2016
    Posts:
    8
    You are right - it seems to work in your case. But I do not see why it does not work for me. Any comments on my graph?
     
  9. elettrozero

    elettrozero

    Joined:
    Jun 19, 2016
    Posts:
    216
    Quick question, please, quick answer: how do I get the Depth Buffer Texture inside a custom node?
    _CameraDepthTexture is not recognized and other solutions like SHADERGRAPH_SAMPLE_SCENE_DEPTH return the piramid as Vector1 and I cannot load the LOD.

    Many thanks
     
  10. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    I can't say for sure as I am not using Texture Array, but to isolate the issue further, have you confirmed my simple graph doesn't work as expected in your case?

    If so then your problem probably isn't Texture Array node, but perhaps something from UV node or even LWRP.
     
  11. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    Scene Depth node sounds like what you want.

    https://bitinn.github.io/ScriptableRenderPipeline/ShaderGraph/Scene-Depth-Node/

    OH wait, you did mention this node.

    If it doesn't work as expected, check if you can write a custom node to achieve it.

    By the way this is the LWRP implementation of Screen Depth node.

    If you want LOD then a custom node like Screen Depth isn't that hard to write.
     
    Last edited: Jan 11, 2019
  12. elettrozero

    elettrozero

    Joined:
    Jun 19, 2016
    Posts:
    216
    I was aware of the Scene Depth Node, in fact, in this thread has been discussed already how useless it is.
    My question was specific about writing a custom node that uses the Depth Texture (which contains the full pyramid) and extracts the LOD0.

    As written in the post, using _CameraDepthTexture, doesn't work

    I'm basically stuck and I need a way to reach the _CameraDepthTexture or to sample as texture the SHADERGRAPH_SAMPLE_SCENE_DEPTH.

    Questions about this has been posted all over this and other threads so I need now a clean answer from Unity staff or someone who's been thru this.
     
  13. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    Getting antsy over this isn't going to make this faster:

    As I said, SHADERGRAPH_SAMPLE_SCENE_DEPTH is defined by each SRP, on LWRP it's shadergraph_LWSampleSceneDepth. Which means I was posting the exact code of what Scene Depth node does.

    It doesn't offer you a way to not skip the "Linear01Depth" conversion, you can't get the raw depth.

    What could you do? Well, write a custom node that replace it with your own code.

    It's not a "quick" answer, but AFAIK this is the only way for now, for Shader Graph at least.

    OR if you don't mind some performance lost, convert it to LinearEyeDepth, see this post:

    https://forum.unity.com/threads/feedback-wanted-shader-graph.511960/page-30#post-3798496
     
    Last edited: Jan 11, 2019
  14. elettrozero

    elettrozero

    Joined:
    Jun 19, 2016
    Posts:
    216
    Giving untried solutions and not reading the question is not helpful.
    I dind't want to smap over this post again and you're making me.

    -------------------------------------------------------------------------------

    I'm making a custom node (as said) because (as pointed elsewhere) SceneDepth returns the Pyramid without the possibility of having the LOD0 (at least for my knowledge) as said.
    The solution with Screen Hack is not acceptable (for me at least) because it's broken when changing the screen size in an unpredictable way.

    In my custom node I end up having:
    undeclared identifier '_CameraDepthTexture'
    or
    undeclared identifier 'SampleCameraDepth'

    (Something to import, somehow, is missing?)

    The only compiling thing is using SHADERGRAPH_SAMPLE_SCENE_DEPTH(UV) just like the well know Node again having the full pyramid of the depth texture and I don't know how to extact the LOD0 from it.

    At this point the answer I want is either:

    How to use _CameraDepthTexture or SampleCameraDepth or anything valid in my custom node
    How to extract LOD0 (with LOAD_TEXTURE2D_LOD maybe?) FROM SceneDepth or SHADERGRAPH_SAMPLE_SCENE_DEPTH or anything valid

    If none of the above is possible I'll wait for a fix from Unity.
     
  15. elettrozero

    elettrozero

    Joined:
    Jun 19, 2016
    Posts:
    216
  16. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    OK you are using HDRP, I apologize as my focus is on LWRP, and AFAIK HDRP has been broken for a while on various front, and if you are using Unity 2018.x instead of 2019.x alpha, then even more so as they need to back port fixes from 5.x to 4.x

    But it would be great for everyone to:

    - List your SRP and package version (same node can perform different things based on them).
    - Show the relevant code.
    - And perhaps some screenshot etc.

    Unity team post here maybe once a week and so if you don't have everything ready they might just ignore or ask you for more info.

    Anyway, glad to see a fix is coming.
     
    Last edited: Jan 11, 2019
    wyattt_ likes this.
  17. elettrozero

    elettrozero

    Joined:
    Jun 19, 2016
    Posts:
    216
    Totally agree, probably the solution has been on it's way for weeks and I struggled to find a workaround pointlessly jumping from one thread to another and spending hours of coding.
     
  18. wyattt_

    wyattt_

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    424
    This would be most helpful!
     
  19. vberd

    vberd

    Joined:
    Jul 3, 2017
    Posts:
    1
    Can anybody help me?
    I try to add Custom data from particle system to the vertex displacement (vertex position), and I can't understand why shader doesn't work...
    upload_2019-1-12_20-2-5.png

    If I add info from Custom data to the Color shader works correctly
    upload_2019-1-12_20-1-7.png
    shadergraph_customdata_color.gif

    If I add info from Vector1(value from Property) to the Position shader works correctly
    upload_2019-1-12_20-43-13.png
    shadergraph_nocustomdata_value.gif

    And if I add info from particles Custom data to the Position shader doesn't work




    Tell me where did I make a mistake?
     
  20. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    Hey, just wondering, has issue case 1108669 been worked on by Shader Graph team? I reported 1 month ago with repro sample and in this thread, but has received no triage from QA team so far.

    I honestly don't know if it's fixed in 5.x or whether it will be backported to 4.x
     
  21. elettrozero

    elettrozero

    Joined:
    Jun 19, 2016
    Posts:
    216
    Hey, do you confirm 4.7.0 is out?
     
  22. elettrozero

    elettrozero

    Joined:
    Jun 19, 2016
    Posts:
    216
    Hey, it's party time!!!
     
  23. elettrozero

    elettrozero

    Joined:
    Jun 19, 2016
    Posts:
    216
    Last edited: Jan 14, 2019
  24. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    I assume 4.7.0 are not released on PM yet?
     
  25. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    Quick note: don't use GitHub release that wasn't released officially on Package Manager unless you know the package like the back of your hand.

    Reason: there are times they haven't past the QA test, meaning, only consider the Package Manager version to be final.
     
    MadeFromPolygons likes this.
  26. Spacew00t

    Spacew00t

    Joined:
    Mar 24, 2013
    Posts:
    21
    Ok here's a weird one in 4.6.0, I think ShaderGraph breaks when switching to the new C# runtime. I get a lot of strange errors like "_Color already defined" when trying to compile with shader graph. These disappear when I go back to the old C# runtime and reimport my shaders. I can provide more details if this can't be reproduced by simply compiling unlit shaders with the new runtime.
     
  27. sewy

    sewy

    Joined:
    Oct 11, 2015
    Posts:
    150
    SamplerState in Custom Node still not working, even though it was reported on fogbugz half a year ago (deleted my bookmark, because nobody was reacting to it). Still the same error. Are we missing something?

    Unity 2018.3.1f1 HDRP 4.6.0 ShaderGraph 4.6.0
     
  28. wyattt_

    wyattt_

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    424
    I believe so. Issue was that the preview on the Master Node was being rendered on top of the Preview for the Shader Graph. The Master Node preview was removed

    Most likely fixed in 5.x
     
  29. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    Only fixing this in 5.x does not help me and many others though: I am using 4.x and Unity 2018 for the foreseeable future. If no backport is happening please let us know.
     
  30. elettrozero

    elettrozero

    Joined:
    Jun 19, 2016
    Posts:
    216
    No I got it because I enabled the experimental versions.
    Scene Depth is fixed at least and it's a key feature when you're story is center around a beach and it's not a mobile game. :)
     
  31. elettrozero

    elettrozero

    Joined:
    Jun 19, 2016
    Posts:
    216
    I'm porting the ASE Depth Fade node and I copied this:

    Code (CSharp):
    1. float4 ase_screenPosNorm = UV / UV.w;
    2.     ase_screenPosNorm.z = ( UNITY_NEAR_CLIP_VALUE >= 0 ) ? ase_screenPosNorm.z : ase_screenPosNorm.z * 0.5 + 0.5;
    3.     float screenDepth5 = LinearEyeDepth( SHADERGRAPH_SAMPLE_SCENE_DEPTH( UV.xy/UV.w ).r,_ZBufferParams);
    4.     float distanceDepth5 = abs( ( screenDepth5 - LinearEyeDepth( ase_screenPosNorm.z,_ZBufferParams ) ) / ( Distance ) );
    5.     float3 temp_cast_0 = (distanceDepth5).xxx;
    6.     Out = temp_cast_0;
    Instead of SHADERGRAPH_SAMPLE_SCENE_DEPTH, originally, SampleCameraDepth function is used; would that make any differences?
     
  32. empika

    empika

    Joined:
    Jul 12, 2012
    Posts:
    31
    Hi,

    Any news on when stencil buffers will be implemented in the shader graph?

    Thanks!
     
    Jesus and pbhogan like this.
  33. wyattt_

    wyattt_

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    424
    Turns out this was a bug with the Editor code and not ShaderGraph. It was fixed for 2019.1 but not 2018.3. I requested a backport for it
     
    bitinn likes this.
  34. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    384
  35. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    504
    I'll third the request for stencil buffer support.


    Also, the local Variable thing is pretty useful. In Shader Forge it's the Set/Get nodes, and I used them all the time for doing large blocks of math that plugged into multiple places along the graph, without generating a lot of overlapping connections. Didn't want everything looking like a pile of spaghetti.
     
  36. elettrozero

    elettrozero

    Joined:
    Jun 19, 2016
    Posts:
    216
    A couple of request/suggestions (pretty obvious, I know) the node adding/saving is so slow, can it be improved?
    Also, a really cool thing, would be to have the node ports to be dynamically placed not just at the left of the node but also top and bottom so to make a workflow that develops not just horizontally.
     
  37. MythrilMan51

    MythrilMan51

    Joined:
    Apr 24, 2017
    Posts:
    146
    What WOULD be the purpose of north/south side nodes? I know left's input while right's output.
     
  38. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    384
    Along these lines, someone asked me about support for ztest/zwrite customization too. I hope more of these options can be added to the master nodes soon.

    Something else I just thought of... I was using the Split node and it really should pick up from its input what is coming in and switch the output labels to XYZW instead of RGBA when appropriate.

    By the way, it's a real pity you guys moved the issues reporting away from Github and into Fogbugz or whatever you use internally. Feature requests and discussion through the Unity bug reporter is just way too painful and makes feedback difficult. A forum thread is hardly ideal either.
     
    bitinn and Jick87 like this.
  39. Spacew00t

    Spacew00t

    Joined:
    Mar 24, 2013
    Posts:
    21
    I see that 4.8.0 was released, any idea where to find the change log? I can see they cleaned up a useless error from appearing in the console when opening, so yay for that!

    I think rather than have north/south nodes they should just make the behavior of connecting lines better. Right now they're pretty much direct connections, when sometimes they should have 90 degree turns. I made an illustration to show some options:



    I wouldn't necessarily get rid of the current behavior entirely, but I think the ability to switch between styles would be nice. Bonus points if it can detect when to switch automatically.

    Additionally I've seen some node based editors have a concept of "stickiness" for their lines, where they'll like to run along next to each other in busses until splitting off. If we're talking about dream features, this would be one, it would make your shader look a lot less like spaghetti (or at least like uncooked spaghetti instead of cooked, ha!)

     
    LooperVFX, TextusGames, sewy and 3 others like this.
  40. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,761
    Why have master nodes been locked down? We've been using a custom master node to provide optional lighting depending if an object is within our fog of war or not.

    Instead of using package manager, we now need to pull the package from git, load it into the /Packages folder and modify the AssemblyInfo to give internal access to our project.

    Is there meant to be an alternative? This worked fine up to 4.6 and then was changed at some point.

    -edit-

    just read this: https://forum.unity.com/threads/una...customfunctionnode-class.586876/#post-4113604
     
    Last edited: Jan 18, 2019
  41. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    Wow, are you saying custom master node was possible? I have been trying to do it for ages.

    (Also I would say it's possible to achieve your goal even without a custom master node, right?)
     
  42. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,761
    Yeah used a custom master node in both LWRP before switching to HDRP since 3.x and managed to keep it updated through a lot of changes.

    I don't believe what I want to do is possible without a custom master node. Shader graph as far as I'm aware does not give me access to the lighting path unless something has changed recently.

    I use the master node to load a custom ShaderPassForward.hlsl and add a fog of war check.

    Code (CSharp):
    1.         float3 worldSpacePosition = GetAbsolutePositionWS(input.positionRWS);
    2.         float fow = FoWIntensity(worldSpacePosition);
    3.         outColor.rgb = outColor.rgb * fow;
    This needs to happen after lighting is applied.
     
    Last edited: Jan 18, 2019
  43. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    I agree Shader Graph package has been bad at adding relevant changelog.

    https://github.com/Unity-Technologi....0-preview/com.unity.shadergraph/CHANGELOG.md

    But I have looked at the repo, there are no recent changes to the 4.x package besides a recent fix related to SRP batcher and some naming changes for consistency with SRP.

    AFAIK if you are seeing changes they are likely due to changes in SRP packages, not SG package.
     
  44. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    By lighting path do you mean light direction and other light data? Or that you need to inject the fog after PBR lighting?

    (I mostly build from Unlit master node so don't have that problem)

    Still, I am interested to hear how you manage to do a custom master node. I couldn't get them to work despite copying and modifying relevant files for the Unlit master node.
     
  45. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,761
    After PBR lighting.

    Anyway this is all i duplicated and edited.

    upload_2019-1-18_14-32-34.png

    I haven't tried with unlit node, but I just copied those nodes (remove the Fog naming obviously) and just changed the references within. The only thing I can think of is make sure you update your GUID under GetSubShader to reference your sub shader.
     
  46. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    Thx, yeah I did that, and somehow it still tries to open the original LightWeightUnlitSubShader when I create a shader graph and double-click on it, not my modified sub shader.

    How did you make sure OnOpenAsset open the correct file? Or does it just work?

    (I am on LWRP so it might be different but I doubt it.)
     
  47. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,761
    It was an easier process for LWRP than HDRP when I did it (LWRP was a while ago now though.)

    It just works. From memory, as I said before make sure you change the GUID to match your sub shader and make sure you create a new interface and setup the attributes correct.
     
    bitinn likes this.
  48. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    Thx, I did it! I finally realize the problem is I didn't change this line:

    Code (CSharp):
    1. public class NeoUnlitMasterNode : MasterNode<IUnlitSubShader>, IMayRequirePosition
    It needs to be:

    Code (CSharp):
    1. public class NeoUnlitMasterNode : MasterNode<INeoUnlitSubShader>, IMayRequirePosition
    Otherwise both Unlit Graph and my custom Unlit Graph will try to load the incorrect sub shader.

    Screen Shot 2019-01-18 at 14.44.41.png
     
    tertle likes this.
  49. elettrozero

    elettrozero

    Joined:
    Jun 19, 2016
    Posts:
    216
  50. elettrozero

    elettrozero

    Joined:
    Jun 19, 2016
    Posts:
    216
    I'm suggesting "floating" ports because, after using Shader Forge, Amplify Shader Editor and Shader Graph the most annoying thing I've always facing is the developing of the graph horizontally only and lack of elasticity when connecting nodes below/above.You'll always end up having the S pattern in connecting nodes that are placed vertically and you'll waist a lot of space.

    Btw cool graph :)
     
Thread Status:
Not open for further replies.