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

    empika

    Joined:
    Jul 12, 2012
    Posts:
    31
    Hi, any news on when stencil buffers will be supported? Perhaps it will come about with the new node API?
     
    Shorely likes this.
  2. empika

    empika

    Joined:
    Jul 12, 2012
    Posts:
    31
    ...or if stencils will not be available any time soon... is there an alternative method I could use?

    I would like to render particles only where there are other sprites. You can see the rain in the screenshot below is only rendered over the top of the world (sprites), not where there is the black of the camera background.



    Would it be possible to do something similar using depth? The scene is actually in 3D.

    Thanks
     
    Shorely likes this.
  3. darkydoodle

    darkydoodle

    Joined:
    Oct 27, 2018
    Posts:
    64
    Have the same problem here. The strange part is that in the current shadergraph github, the library of nodes still uses CodeFunctionNode, etc... I didn't dig very much though. Like you, I don't mind modifying my code, I already had to change parts of my rendering derivations after upgrading to 2019.1. I'll still stay in 2019.1 and wait because I'm waiting for other stuff like refraction for older cards (I have a 770M). But I'm surprised that, while 2019.1 is now beta, the custom node impossibility renders it completly broken.
     
    Shorely likes this.
  4. skilfuldriver

    skilfuldriver

    Joined:
    May 20, 2015
    Posts:
    19
    If sampling the depth gives you 1 for the background and less than 1 for the sprites then you could use the Comparison node to mask it. Plug the depth value into A and set it to Not Equal with B set to 1. Or you could use Less and B as whatever threshold works for you.
     
    empika likes this.
  5. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,195
    Do ShaderGraph shaders under HDRP work properly on full-screen overlay canvases?

    I've assigned an SG shader to a material, which I'm using on an image on a full-screen canvas. The result is some weird behavior where the canvas appears to slide through the world, and change rotation as the camera changes rotation. Here's some green sprite slicing through the world:

    upload_2019-1-30_17-0-26.png

    The shader is trivial:

    upload_2019-1-30_17-1-43.png

    Should this work? It seems I can use the shader on a world-space canvas, but screen space gets messed up.
     
  6. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,195
    Also, should Scene Color Node work in a subgraph? It seems to work fine in my normal graph, but if I place it in a subgraph all I get is black from it. If I wire Scene Color directly into the shader's Color, it works. But if I use it as a subgraph, like this, it doesn't:

    upload_2019-1-30_22-27-32.png
     
  7. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    503
    UI shaders like to have stencil information.

    On top of that, the SGE seems to prefer object space, there's a chance that might also be messing with it?

    Also, I'd like to request that someone please please change the Sample Cubemap node to NOT do the reflection math internally. Just Sample it with a single Vector3. Reflect is one node, two if you add in a new surface normal. By including it in the built-in node, we're limited in what can be done with cubemaps.
     
  8. DigitalSalmon

    DigitalSalmon

    Joined:
    Jul 29, 2013
    Posts:
    100
    Creating nodes is on right click -> Create node context menu? With all due respect that seems like an awful UX decision, could it be worth reconsidering?

    The window which shows properties and shader settings (name etc) seems to often go missing, is there some sort of hotkey to toggle it?

    Auto-recompilation all the time really, really slows down graph creation - Even if you know exactly the graph you're putting together, you have to wait for a few seconds every. single. node. Just an option to disable it temporarily would be a life save.

    Having gone from UDK, to Scrumpy, to UE4, to Shaderforge, to Amplify, to Shadergraph - It's great that were now in the age of HDRP etc, but could it not be at the expense of high quality user experience? Things like holding keyboard keys and clicking to create nodes? ShaderGraph is by far the slowest in terms of iteration time when up against the others listed above.

    The under the hood on SG seems excellent, it would be awesome if the front facing bits could be equally brilliant :)
     
    awesomedata and Shorely like this.
  9. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    789
    Create Node shortcut is Spacebar, Right Click is for options/context menu.

    This is being worked on, Async Compile for nodes in shader graph. Should be in a future update, it might be before 2019.1 beta ends.

    (Or it seems like it, I tested that branch yesterday and the nodes seemed to compile faster than usual for HDRP, LWRP always had faster compiling)
     
  10. Necronomicron

    Necronomicron

    Joined:
    Mar 4, 2015
    Posts:
    108
    @Kink3d
    @wyatttt
    Preview doesn't show up for transparent shader, although I see it in scene.
     

    Attached Files:

  11. jjobby

    jjobby

    Joined:
    Nov 28, 2009
    Posts:
    161
    Is it possible to do dithering effect that fade based on distance from camera view like in Amplify?
     
    Last edited: Feb 2, 2019
    URocks and Shorely like this.
  12. shredingskin

    shredingskin

    Joined:
    Nov 7, 2012
    Posts:
    242
    This is a very simple question, I'm trying to do a graph to replace the standard built in shader that substances use.
    I've tried to inverse the roughness map and map it to the smoothness output, but doesn't seem to take effect.
    Any ideas on what I'm doing wrong ?
     

    Attached Files:

  13. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    789
    For that, you want to use the One Minus node.

    upload_2019-2-2_12-39-33.png
     
    shredingskin likes this.
  14. Jick87

    Jick87

    Joined:
    Oct 21, 2015
    Posts:
    124
  15. jjobby

    jjobby

    Joined:
    Nov 28, 2009
    Posts:
    161
  16. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    Some people have been looking for intersection shader for SG so I took what @skilfuldriver showed here and modified it a bit to do this force field like thing:


    Here's the graph for it, make sure to enable double sided (and use latest SRP, either 4.9+ on 2018.3 or 5.3+ on 2019.1):
     
    URocks, awesomedata, bitinn and 5 others like this.
  17. crysicle

    crysicle

    Joined:
    Oct 24, 2018
    Posts:
    95
    Hello, i'm trying to create collision distortion via the shader graph on my clouds shader. The distortion is simple - subtract the distortion texture from the cloud texture and manipulate the various scaling values of the subtraction via code and feed those values into shader's properties.

    However, I can't seem to find any way to calculate multiple distortions at the same time as there doesn't seem to be a way to make arrays for vectors and sliders in the shader. Does anyone know of some kind of workaround for this? The only thing i've come up with is to make a crap load of properties and additional nodes for each possible collision and control them via collision cloud list inside a script, though that's a pretty silly idea as i'm thinking of having up to a maximum of 50 collisions and each collision requires 10 nodes inside the shader. I've also tried having multiple materials on the same GameObject, whoever, the shader effects do not interact with one another and just overlap. Much obliged.

    This is the effect in motion:
     
    Last edited: Feb 3, 2019
  18. Flow-Fire-Games

    Flow-Fire-Games

    Joined:
    Jun 11, 2015
    Posts:
    305
    Hey,

    Our SG keeps breaking and I found out that non-integer Vector 1 inputs completely break the Shader when using a Slider. I try to work around it but its extremely frustrating if you don't know what is happening. 2018.3, not sure if a new SG version is out
     
    Last edited: Feb 4, 2019
  19. discofhc

    discofhc

    Joined:
    Dec 18, 2017
    Posts:
    47
    Hi guys.

    Can someone please answer if we can expect being able to create a custom terrain shader using Shader Graph?

    I mean create a new "Terrain Lit Shader" using Shader Graph and then use it as Terrain Layer.

    It would be awesome!
     
  20. crysicle

    crysicle

    Joined:
    Oct 24, 2018
    Posts:
    95
    Suggestion:
    If possible, an option to disable "Compiling Preview Shaders". Currently working with 100+ nodes on a single shader with all previews collapsed, however still getting 1-5 second lag whenever i perform any action inside the shader due to previews being compiled.
     
  21. Jick87

    Jick87

    Joined:
    Oct 21, 2015
    Posts:
    124
    If you look in the directory where you have created your graph you can find a file with a .shadergraph extension. It is actually a readable text format if you view it in a text editor. As far as I'm aware you can share this file and it should work on other computers.
     
    Shorely likes this.
  22. wyattt_

    wyattt_

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    424
    Are you modifying the material through script at all? And the name modification persists even after exiting Play Mode correct?
     
  23. wyattt_

    wyattt_

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    424
    Ya, unfortunately we dont have any concepts of arrays (and for loops, which you may need for this) in SG yet. You're best bet is adding a ton of parameters or having a texture input to act as an array and then sample the data from that to do your collision tests.

    Or if you can manage to get the shader working with Graphics.Blit or CommnadBuffer.BlitFullscreenTriangle, you could do multiple passes for each collision object on screen.
     
  24. wyattt_

    wyattt_

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    424
    In what manner does it break?
     
  25. wyattt_

    wyattt_

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    424
    We're working on it!
     
  26. wyattt_

    wyattt_

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    424
    We're working on adding async shader compilation to ShaderGraph so this should help a lot
     
  27. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    503
    Is the emission supposed to be pre-multiplied with the albedo?

    I use it to do some debugging, and that means setting albedo to 0, etc so it blacks out all lighting info, and putting what I want into emission.

    And since the emission is HDR, if I try 1,1,1 into albedo and colour info into emissive, then it gets blown way out. I can get OK results with 0.25, 0.125, so I'm thinking the HDR is in the 0-4 or 0-8 range instead of the old 0-1 range?

    The top graph is what it should be like in the graph, but the bottom screenshot is what the output should be like.

    premultiplied_emissions_problem.png


    Also, because it's Thursday, I'd like to request that the SAMPLE CUBEMAP node drops the internal reflection calculation.

    I have the reflect node, and the normal/viewdir nodes, I just want cubemap at X direction that I can enter.
     
  28. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    503
    Also having this problem - some sort of precision error?

    The problematic bit is shown, you can see the seam in both images, a bit harder to spot in the top image but it's also there.

    The math is quite simple, and without the pow it's hard to see if the error is there at all. I tried multiplying instead of pow(a, 2) but that had the same problem, so it's in the position or distance functions somewhere.

    palm_tree_precision_error.jpg
     
  29. JacketPotatoeFan

    JacketPotatoeFan

    Joined:
    Nov 23, 2016
    Posts:
    34
  30. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    503

    Mask = Split. Basically, if you have a RGBA or UVW or whatever in the input side, you use the Split node to grab one channel.

    Append = Combine. It's the opposite of the above. You can grab channels and combine them together in whatever order you want.
     
    JacketPotatoeFan likes this.
  31. crysicle

    crysicle

    Joined:
    Oct 24, 2018
    Posts:
    95
    Hello again, I seem to have stumbled upon some poorly performing behaviour with the Shader Graph. But before I tell you what it is, I should explain what my shader does. I'm manipulating a few noise textures to create some nice cloud effects and some shadow effects for the clouds. On top of that, i have implemented collision detection for the shader, which acts as a subtraction from the cloud texture. The collision point and size values are controlled inside a script which i feed to the shader. Currently 40 maximum collisions can happen within the shader.

    Here's the problem:
    Upon starting the scene, the values for the collision point and size are 0. They produce minimal performance issues. When I start feeding the shader different values for the collisions, the scene lags a bit, which is expected. The issue is that once the values of the collision point and size reach back to their default 0 for all collisions, the shader lags more than at start of the scene.

    At first I thought it might be something to do with the script that I'm feeding the information into, however, once I removed the script at run-time, the FPS loss was still too high. Rougly 10-20 FPS being lost.

    Here's a video of the effect:


    Images of the shader:
    -https://i.imgur.com/qaGYgo8.png
    -https://i.imgur.com/4ilrmhK.png
    -https://i.imgur.com/NaMpGpE.png

    PS:
    Would still like some advice on how to do the same collision effect without resulting to making a lot of collision nodes in the shader.

    Unity version: 2018.3.0f2
    Shader Graph: 4.9.0
    HD pipeline: 4.9.0
     
  32. UnityUric

    UnityUric

    Joined:
    Jul 10, 2018
    Posts:
    1
    Hi, I have this issue when adjusting the Sample Gradient in the shader graph. The strange part is, when testing this shader on other's computers (same versions of unity and shader graph), it worked just fine tweaking the gradient, but on mine, it won't show up. Have been forced to use a workaround adjusting the gradient with a Power and a Multiply node.



    Tested on unity version: 2018.3.4f1 and three other versions between 2018.3.1.
    Shader graph: 4.9.0
    Other spec info: Windows 10, Acer Predator Helios 300
     
    LaurieAnnis likes this.
  33. JacketPotatoeFan

    JacketPotatoeFan

    Joined:
    Nov 23, 2016
    Posts:
    34
    Hey, thanks for the help.

    So the only node I can't figure out is the "Reflection Vector". From what searched about the old tutorial...

    "The Reflection Vector in UE4 works via World Space and can be found by 'ReflectionVectorWS,' it should be a red colored input node not the blue material function version. For this particular tutorial, you will need to do a 'Transform' from World to Tangent in order to get the Reflection to work as it did in UDK."

    Also saw this video about creating light rays in Unreal which look pretty simple but can't replicate it in Shader Graph...

    https://youtube.com/watch?v=gOdTrIB5te0&t=1066s


    I guess Shader Graph doesn't have Pixel Depth and Depth Fade nodes (or they are called something different)?

    Sorry, am still trying to figure stuff out.
     
    Flurgle likes this.
  34. id0

    id0

    Joined:
    Nov 23, 2012
    Posts:
    455
    I found some examples with hologramm shader, but I want him to cut off the inner polygons like in this old thread
    How can I do this?
     

    Attached Files:

    Last edited: Feb 11, 2019
  35. KongGameArtist

    KongGameArtist

    Joined:
    Feb 1, 2019
    Posts:
    10
    hey guys how can i add a function to existing shader ? i dont want to make a HDRP/Lit from stratch even with shader graphs it is too much.

    like, i want to add dissolve glow edge like in Brackeys's tutorial here


    not to a simple master Lit node, but to existing HDRP/Lit shader as a dupplicated HDRP/Dissolve Lit.
    how can i do that ?
     
  36. KongGameArtist

    KongGameArtist

    Joined:
    Feb 1, 2019
    Posts:
    10
    btw why the diffusion profile can't be convert to property so we can just change profile in the inspector ?
     
  37. magic9cube

    magic9cube

    Joined:
    Jan 30, 2014
    Posts:
    58
    Is there a way to use triplanar with texture array? triplanar takes a texture input but array has vec4 output.. so.. hmm .. what did i miss?
     
  38. AurelWu

    AurelWu

    Joined:
    Oct 11, 2013
    Posts:
    26
    Is there a way to expose the gradient node as property or some workaround?
     
  39. crysicle

    crysicle

    Joined:
    Oct 24, 2018
    Posts:
    95
    Workaround:
    Have the gradient inside a script, make it public and assign it in the inspector. Create a Vector4 inside the shader, make it a property. Feed the gradient's "Evaluate" values based on whatever time value you want into the Vector4 via "Gradient.Evaluate(0.1f).a" for example, in the order of RGBa for each Vector4 value.
     
  40. AurelWu

    AurelWu

    Joined:
    Oct 11, 2013
    Posts:
    26
    Thanks a lot , that sounds like it should work, just that I need all the gradient values at once (as I multiply them with the vertex color), so I guess I can just create multiple Vector3 (don't need transparency) as property and build my own gradient-like effect from them with some lerping around.
     
  41. Airship

    Airship

    Joined:
    Sep 10, 2011
    Posts:
    260
    Is there a way to create a shader that causes an object to render on top of everything in the scene using Shader Graph for LWRP?
     
  42. kong_unity

    kong_unity

    Joined:
    Feb 14, 2019
    Posts:
    6
    Shader Graph or any Graph in the future need the note just like the visual effect graph, pls add !
     
  43. FeedMyData

    FeedMyData

    Joined:
    Oct 19, 2013
    Posts:
    4
    Hi, it seems that the Shader Graph PBR master node is unable to handle shadow correctly on Android, although everything works fine in the editor :
    Depending on the shadow setting and scale of the object, either the object is fully recovered in shadow, even though nothing cast a shadow on it, or the shadow of non-moving object will move with the camera...
    I thought I did something wrong at first, and tried every possible solution i've found to fix it (changing scale of the scene, playing with shadow settings, changing the clipping plane from the camera). However, I realised that the lit shader was working perfectly fine whatever settings I used.
    Here is an example of the behavior:
    https://imgur.com/XJiMVsi
    In this case the object is receiving a shadow even though there is nothing to cast shadow on it, and the plane does not receive shadow from the cube.
    I am using Unity 2018.4.4f1 LWRP 4.9 and Shader Graph 4.9.
     
  44. laessnb

    laessnb

    Joined:
    Jun 10, 2014
    Posts:
    101
    That's excellent to hear and currently the highest priority for us. We easily hit 10-12 second "Compiling preview shaders" delays when rewiring a single input or output. It makes things unusable and it's unclear what will speed it up (converting to subgraphs? removing properties? not working on complex shaders at all?). I wouldn't even mind a simple toggle or maybe skipping the entire process if the previews are collapsed.
     
  45. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    A good trick is to hide game view/scene view panel. I find Shader Graph editor interface a lot more speedy with them hidden.
     
  46. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    Hi all,

    If anyone can give me a short primer on requirement constraints like RequiresPosition/RequiresNormal when making custom nodes, I would much appreciate.

    I have looked at existing nodes and some simply return things like NeededCoordinateSpace.World, while others loop over valid slots. I can't seem to figure out how these requirement are invoked and validated.

    Thx in advance.
     
  47. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,419
    Can it intersect with something using the same material it's using?
    Basically a double-shield or an explosion that doubles up with nearby explosions?

    Just curious if this is possible yet or not.

    Thanks for offering this cool shader to play with anyway. :)
     
  48. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    After writing custom master node for a while, I want to make a suggestion that is unlikely to benefit me, but perhaps will benefit future users of Shader Graph:

    - APIs from GraphUtil, ShaderGenerator are a pain to work with.
    - They are either too restrictive (not enough parameters) or too specific (too many parameters).
    - Sometimes they return more abstraction like SurfaceMaterialTags, SurfaceMaterialOptions, which does little beyond hiding the verbose ShaderStringBuilder.

    I ended up using ShaderStringBuilder directly most of the time, yes they are more verbose, but at least I get to control exactly what's generated, and don't need to hunt down abstraction details. This approach is much easier as I have some shader knowledge, and is using Shader Graph to speed up my prototyping workflow.

    Screen Shot 2019-02-20 at 16.32.22.png

    I am on Unity 2018 and SG 4.x so I don't expect any future changes will benefit me, but hey, you wanted some feedback on APIs right?
     
    Jick87, awesomedata and wyattt_ like this.
  49. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    the main issue with that is a) you'd need transparent material for this (so whole object would need to use transparent material) b) usually the shield effect would need to be tad bigger than the regular object to give the right illusion. Otherwise, you can stack whatever you want really (but I'd imagine this would be easier handled as special thing that only renders when needed).
     
  50. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    A bug report for SG 4.x: IMayRequireVertexColor and IMayRequireViewDirection interfaces are private.

    Since they are the only ones left private, I suspect it's an oversight as they are not directly used.
     
    Jick87 likes this.
Thread Status:
Not open for further replies.