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

    mosaic_school

    Joined:
    Dec 12, 2012
    Posts:
    73
    EEVEE NPR ! - Blender 2.8 Code Quest


    Awesome feature!. It would be so cool if there would be something equivalent in the Unity ShaderGraph that will allow us to use it for things like Toon shading.
     
  2. sand_lantern

    sand_lantern

    Joined:
    Sep 15, 2017
    Posts:
    51
    I'm trying to figure out if there's a way to turn a vector4 into a texture. It doesn't appear that there is any functionality like that. Specifically what I'm doing is applying a Power Function to a Texture, I'd then like to feed that back into another texture. Is this a limitation in the shader graph, or just an inherently stupid request on my part?
     

    Attached Files:

    • Want.png
      Want.png
      File size:
      214.7 KB
      Views:
      417
    MR-Heavy likes this.
  3. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    483
    In that example, why not just plug the UV stuff into the left hand lava texture sampler?

    The sampler really only exists to change how you would sample a texture, like accessing a mip, filtering modes (bilinear, etc) or whatever; properties of the texture file that already exist. It doesn't make sense to ask for that information, or give it to, a vector4 or anything else.
     
  4. LuizBeenoculus

    LuizBeenoculus

    Joined:
    May 17, 2018
    Posts:
    5
    Hello, how i can get just one value from a Vector4 output?
     
  5. GameDevCouple_I

    GameDevCouple_I

    Joined:
    Oct 5, 2013
    Posts:
    1,762
    just swizzle?

    so if it is a Vector4/Float4 called someVector, and you want the "x" or "y" or "z" or "w" part, you just do

    someVector.x

    or someVector.y

    or someVector.z

    or someVector.w

    and can combine in any order (swizzle) such as

    Vector2 xy = someVector.xy;

    or

    Vector2 xw = someVector.xw;

    can even do

    Vector4 xzxz = someVector.xzxz;
     
  6. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    5,231
    Unless there is better option to get xyzw, or by index, then:
    Not the best solution, but I think you could try for now, to multiply (Math>Basic) Vector4 by another Vector4 lets say ( 1, 0, 0, 0) to get x. And then, get the Distance (Math>Vector) from that vector, to Vector4.zero.
     
  7. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    5,231
    Channel > Swizzle seams do the job.
    Would Channel > Split work in this case as well (appears to be simpler {cheaper?} method)?
     
    GameDevCouple_I likes this.
  8. sand_lantern

    sand_lantern

    Joined:
    Sep 15, 2017
    Posts:
    51
    Sure, I guess this was sort of a simplified test case though. I ran into another situation where I wanted to use a noise generation effect and feed that in as uv map chanels (please excuse me if I'm using incorrect terminology, I'm a programmer not an artist!)

    As you can see in this example, I have two noise textures, that I offset over time. Originally I tried to do this by using the built in noise generators, but I was unable to actually get them to connect to the texture nodes. I ended up having to make them externally and link them in. What I would like (I think) is one of two things:

    1) Be able to turn a vector4 back into a texture so that I can apply a UV map to it.

    2) Be able to offset things without using a UV map, you can see all the extra work this shader takes in order to just slide a texture around that eventually gets turned back into a UV again.

    https://imgur.com/a/lRDIZa3
     
    Last edited: May 17, 2018
  9. Luckymouse

    Luckymouse

    Joined:
    Jan 31, 2010
    Posts:
    481
    A little request, Can we have a "Vertex interpolator" node in later update version?;)
     
    MR-Heavy likes this.
  10. FreeGameDev

    FreeGameDev

    Joined:
    Dec 1, 2015
    Posts:
    65
    It does not appear that shadows are being cast from shadergraph materials. Using 1.1.6.

    Ignore the texture in the standard shader, just showing shadow.
     
  11. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    535
    Might want to update then
    I'm on 1.1.8 and shadows are fine for me. I didn't use 1.1.6 so I'm not sure if shadows are broken in that version or not.
     
  12. FreeGameDev

    FreeGameDev

    Joined:
    Dec 1, 2015
    Posts:
    65
    Where is 1.1.8? In the packages the highest is 1.1.6.
    I think I'm using the latest beta 2018.2.0b4?
     
  13. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    535
    You have to use the staging registry in the manifest file for the project because these aren't fully released packages

    Add this to the file - "registry": "https://staging-packages.unity.com"

    Code (csharp):
    1.  
    2. {
    3.   "registry": "https://staging-packages.unity.com",
    4.   "dependencies": {
    5.     "com.unity.render-pipelines.lightweight": "1.1.8-preview",
    6.   }
    7. }
    8.  
     
  14. FreeGameDev

    FreeGameDev

    Joined:
    Dec 1, 2015
    Posts:
    65
    great thanks, will give it a try.
     
  15. asa989

    asa989

    Joined:
    Dec 18, 2015
    Posts:
    29
    I dont have blackboard to make properties and it was following my mouse before it disappear. i cant use textures and all setting are in picture. any thoughts?! :) i think im missing something simple!!

    Edit: If i make new project, everything is gonna be fine.(problem will remain in previews projects) but after couple minutes the blackboard will be disappear.
     

    Attached Files:

    Last edited: May 18, 2018
  16. FreeGameDev

    FreeGameDev

    Joined:
    Dec 1, 2015
    Posts:
    65
    no dice. Same thing... I even tried the master branch of shader graph, again no change.
    Although... I have shadows when it first loads. But after I select the fern it disappears.
     
    Last edited: May 18, 2018
  17. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    483
    While I can't really offer 100% advice because the pic is too small, I can say this:

    Noise is fed UV channels, so if you want to generate 'distorted noise' you generate the distortion (be it noise or some other means), then plug that into the UV channels of the noise generator you want to distort.

    I know it's a bit weird, but if you remember that noise is just a math operation on whatever coordinated it's fed (usually plain old UVs), by distorting what it's fed, you distort the output in the same, predictable way.
     
  18. GameDevCouple_I

    GameDevCouple_I

    Joined:
    Oct 5, 2013
    Posts:
    1,762
    It might do, I have not actually tried!
     
  19. scheidtventureestate

    scheidtventureestate

    Joined:
    Nov 28, 2017
    Posts:
    33
    I also do not have a blackboard otherwise I can compose a shader.... though that is pointless without access to parameters... meh
     
  20. Boolai

    Boolai

    Joined:
    Nov 13, 2014
    Posts:
    5
    Features that I would like to see. Vertex manipulation. Outline node such as in some toon shaders. A default toon node such as in shader graph's
     
  21. sand_lantern

    sand_lantern

    Joined:
    Sep 15, 2017
    Posts:
    51

    Ah sorry about that. Making gifs is a major pain... The thing I was trying to detail was not distorted noise, but instead scrolled noise. Essentially you have one set of noise that continually scrolls upwards, that way you have blips that stay consistent. Here's hopefully a higher quality gif to better illustrate what I'm trying to accomplish.

    https://imgur.com/a/1TzvExD
     
  22. irenya

    irenya

    Joined:
    Nov 22, 2017
    Posts:
    6
    I managed to make it stay by never resizing the shader editor window.
    It does follow the mouse a lot, seemingly at random times. It's quite annoying
     
    asa989 likes this.
  23. JustinRossL

    JustinRossL

    Joined:
    May 19, 2018
    Posts:
    3
    Hi, I have just started using shader graphs, i have a dissolve shader working. However it just keeps repeating the dissolve effect, is there a method to only have this effect happen once on loading the game?
     
  24. andydbc

    andydbc

    Joined:
    Jan 25, 2014
    Posts:
    17
    Expose the dissolve amount with a parameter and control it from a script.
     
  25. JustinRossL

    JustinRossL

    Joined:
    May 19, 2018
    Posts:
    3
    How do you access the material or shader properties through script?
     
  26. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    5,231
    look in Material properties

    i.e.
    Code (CSharp):
    1. MeshRenderer meshRenderer = this.GetComponent <MeshRenderer> () ;
    2. meshRenderer.materials [0].SetFloat ( "_shaderPropertyName", someValue ) ;
    for _shaderPropertyName look in shader compiled script, and properties with underscore, and some numbers.

    For example
    Code (CSharp):
    1. Properties {
    2. Vector1_4D391D98 ("Opacity", Range(0.000000,1.000000)) = 0.500000
    3. }
    so in C# you use
    Code (CSharp):
    1. meshRenderer.materials [0].SetFloat ( "Vector1_4D391D98", someValue ) ;
     
  27. JustinRossL

    JustinRossL

    Joined:
    May 19, 2018
    Posts:
    3
    That worked perfectly! Thank You!
     
  28. hazukiaoi

    hazukiaoi

    Joined:
    Mar 6, 2015
    Posts:
    2
    I have an idea.
    I think Shader Graph allow get GBuffer and use it.It will make create VFX and custom Post Processing easy.
     
  29. MR-Heavy

    MR-Heavy

    Joined:
    Jan 1, 2016
    Posts:
    14
    Any news or ETA on tessellation?
     
  30. Andy-Touch

    Andy-Touch

    A Moon Shaped Bool Unity Technologies

    Joined:
    May 5, 2014
    Posts:
    1,009
    hippocoder, rizu, NeatWolf and 2 others like this.
  31. GameDevCouple_I

    GameDevCouple_I

    Joined:
    Oct 5, 2013
    Posts:
    1,762
  32. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    7,002
    This is somewhat nonsensical request, but I understand what you're trying to ask. The short answer is no. The longer answer is yes, but not with Shader Graph, or any one shader.

    For a direct answer to 1, a Vector4 value is essentially a single pixel's worth of data, and to make this a texture to sample again would be pointless as it would make a texture with a single pixel, or a single value across all of it's pixels because it is a single value.

    What you're really asking to do is to take all values of a texture, apply some math to it, and save it out as a new texture. That is possible, but that requires using a script that calls a Blit and writes to a render texture. You would have a shader that would have the code of sampling the initial texture with the uv offset (or not), and applying any of the modifications you'd want to that value. Then you would have your second shader that would sample that texture. Certainly many post process effects work this way for various reasons, like doing a separable blur in two passes can be faster than doing the same blur in a single pass, or letting you do the work at a lower resolution than the final use case (also common with blurs and bloom effects).

    "All the extra work" amounts to about 1 or 2 instructions on the GPU. Unity's existing forward rendering path Standard Shader is somewhere between 100 and 200 instructions per forward pass, and the new HD pipeline likely closer to 1000+ effective instructions when using multiple lights and the forward+ path. There are a few shaders that ship with the Post Processing Stack that have tens of thousands of instructions. Saving 2 instructions for offsetting the UV in one shader to add far more overhead on both the GPU and CPU to do it in a blit isn't going to make it any more efficient. Generally you need to be saving several tens or hundreds of of millions of instructions (counting the instructions from every pixel to be rendered across the entire screen) for it to make sense to go this direction. GPUs are very, very fast.

    Plus panning a texture in this fashion would result in some really bad artifacts. It's basically an aliasing / nyquist limit problem.
     
  33. GameDevCouple_I

    GameDevCouple_I

    Joined:
    Oct 5, 2013
    Posts:
    1,762
    @bgolus I just wanted to say I really appreciate the fact that you take the time to give a detailed answer, it really helps us who are learning!


    FYI everyone, there has been some tasty merges happening over last 24h at https://github.com/Unity-Technologies/ScriptableRenderPipeline/commits/master
    me thinks a package is incoming!
     
    Egil-Sandfeld likes this.
  34. Deadcow_

    Deadcow_

    Joined:
    Mar 13, 2014
    Posts:
    101
    I've got the problem with Shader Graph in our project. When I try to create some simple shaders I've got error message "Shader is not supported on this GPU"

    First of all I imported and set up Lightweight Render Pipeline:

    Then Shadergraph in Package manager. Latest versions I use:

    But at some point shader is breaks and I've got this errors







    Also I tried same graph in the new project with Lightweight RP template and it shows well.
    How to set up existing project to work with Shader Graph?
     
  35. Estecka

    Estecka

    Joined:
    Oct 11, 2013
    Posts:
    62
    Coming from ShaderForge, I find shadergraph to be too limited for me on some aspects.

    Will it be possible to output shaderlab code out of a shadergraph ?
    Back in shaderforge, when there was something I couldn't do in the graph, it was usually something I still could do by tweaking the code afterward. (Like merging the passes from multiple graphs into a single shader.)

    I don't know how to write CG code, but I still have an understanding of how the less code intensive bits, (passes, tags, blending, testing...), do work. It's mostly these bits I wish shadergraph would do more in-depth; I could do without, but that's what I'd need the final code for.

    On the good hands, I love subgraph assets. Being able to reuse a graph across multiple shaders is going to be great; that would be the tool I'll use the most.
     
  36. MythrilMan51

    MythrilMan51

    Joined:
    Apr 24, 2017
    Posts:
    122
    Same here.. THIS TIME, I see pink EVERYWHERE... And before I updated.
     
  37. AurelWu

    AurelWu

    Joined:
    Oct 11, 2013
    Posts:
    26
    can you check if your decimal delimiter might be something different than "." - I had exactly the same
    Can you both check if the decimal delimiter in unity shows up as something different than a "." . I had the exact same problem because for some reason unity used "," as decimal limiter (because of german language settings - even with overridden decimal delimiter in the windows settings).

    Edit: in one of the screenshots I can somewhat clearly make out that there is "," as decimal delimiter. I am quite sure shader graph then puts that "," into the generated code instead of a "." which causes all the problems.

    The only fix I found so far for that problem is to change the language in windows to a language which uses "." by default. Using a language which uses something else by default and then changing the delimiter did sadly not work for me.
     
    IARI likes this.
  38. wyatts

    wyatts

    Joined:
    Apr 15, 2014
    Posts:
    12
    Is there a way to duplicate procedural shapes (other than tiling) with the shader graph? Like multiple copies of a shape randomly placed on a sphere? Also would that be possible with clamped textures as well?
     
    Last edited: May 24, 2018
  39. Andy-Touch

    Andy-Touch

    A Moon Shaped Bool Unity Technologies

    Joined:
    May 5, 2014
    Posts:
    1,009
    Right click the master node, copy the shader and paste it in a text editor of your choice. :)
     
    interpol_kun and Estecka like this.
  40. Andy-Touch

    Andy-Touch

    A Moon Shaped Bool Unity Technologies

    Joined:
    May 5, 2014
    Posts:
    1,009
    For Clamped Textures, use a SS nodes that inputs into the Texture 2D Sampler.
     
  41. TimonSpringlab

    TimonSpringlab

    Joined:
    Apr 16, 2018
    Posts:
    3
    Can anyone assist me creating a custom node?
    I have also asked this on Unity Answers, probably more appropriate there.

    Overall I am really liking the shader graph. Gives a bit of insight as to how things work but it is extremely accessible.

    I'm new to shaders in general and I'm trying to achieve a Dilate effect combined with other visuals available through nodes already.
    I got the desired effect I want minus the Dilate effect which I've got in a separate shader made by user poisoned_banana here: http://answers.unity.com/answers/1495613/view.html

    I want to turn this Dilate effect into a node so I can apply it together with the effect I've created using Shader graph. I tried this myself using the Custom Node API/Tutorial, but I can't get it to compile, I'm not quite sure which part of the shader I can put into the shader string and which variables to assign to which slots.

    I've illustrated the problem I have in the following image.

    Outside red is my current effect which I want to combine with a custom Dilate effect node to get a sort of outline shader with effects.

    So recap: Is it possible to turn the Dilate effect from http://answers.unity.com/answers/1495613/view.html into a custom node, or is there another way to achieve the same effect (dilated black/white image + effect).
     
    Last edited: May 24, 2018
  42. Deadcow_

    Deadcow_

    Joined:
    Mar 13, 2014
    Posts:
    101
    No luck :( The only place it pushes "," instead of "." is Smoothness setting. This time I made new shader from scratch with Smoothness set to 0 and all breaks again
     
  43. AurelWu

    AurelWu

    Joined:
    Oct 11, 2013
    Posts:
    26
    For me it always breaks if I add a property like vector2 or similar and enter a value which includes a decimal delimiter. And once it is broken it seems to stay broken and you need to create a new shader graph.

    Have you tried setting your language the English (UK) in your operating system (requires unity restart to affect it). At least my problems vanish when doing that.
     
    IARI likes this.
  44. izym

    izym

    Unity Technologies

    Joined:
    Jul 27, 2013
    Posts:
    24
    Hi everyone,

    (First and foremost, anyone still having issues with the blackboard not appearing, try updating to 1.1.9-preview. It contains a fix for it.)

    We've been busy behind the scenes for the past few weeks. First and foremost, the ShaderGraph repository has been moved inside the ScriptableRenderPipeline repository. This makes it a lot easier for us to do integration with Lightweight and HD pipelines, and to move faster.

    On that note, we've also been doing a directory re-organization in the ScriptableRenderPipeline repository. Previously you had to clone it into your Assets folder. That is no longer the case -- in fact, it's not possible anymore. Instead, you must now clone it outside of your Assets folder (where exactly does not matter). You then modify the package manifest.json of your project to locally refer to the packages, like this:
    Code (JavaScript):
    1. {
    2.     "dependencies": {
    3.         "com.unity.postprocessing": "file:../SRP/com.unity.postprocessing",
    4.         "com.unity.render-pipelines.core": "file:../SRP/com.unity.render-pipelines.core",
    5.         "com.unity.shadergraph": "file:../SRP/com.unity.shadergraph",
    6.         "com.unity.render-pipelines.high-definition": "file:../SRP/com.unity.render-pipelines.high-definition",
    7.         "com.unity.render-pipelines.lightweight": "file:../SRP/com.unity.render-pipelines.lightweight"
    8.     }
    9. }
    10.  
    In this case I've cloned the ScriptableRenderPipeline repository just outside of my assets folder. The file paths are relative to the manifest.json file.

    For users, this makes it much easier to try out the latest and greatest version from GitHub, as the process now is to simply clone the repository and modify the manifest.json file to look like the above. That's it. It also means that our development setup will be a lot more similar to using Shader Graph as a package, and that should allow us to early on experience more of the pain points that users are hitting.

    The master branch currently targets 2018.2 and up, and will continue to do so for a while. We also just branched off into the 2018.2 branch, which is where we will be stabilizing the package that goes into the 2018.2 Editor. As such, the 2018.2 branch will mostly get bug fixes backported.

    Currently in master and 2018.2 branch, you will find new goodies like HD support, vertex position, gradient nodes, editable reference names, not-exposed properties (think _MainTex), 3D textures and 2D texture arrays. This will be going out into a package targeting 2018.2 next week.

    Finally, we've moved to exclusively use the good old Unity Issue Tracker for tracking issues. That means that GitHub Issues are no longer used for this. The latter worked well for us during development, but as we've gone public preview we've run into various limitations.
     
    elbows, Razmot and Jacob_Unity like this.
  45. wyatts

    wyatts

    Joined:
    Apr 15, 2014
    Posts:
    12
    Hey Andy, thanks for the reply, but while the Sampler State gives me a clamped texture, I still have no way to duplicated it without tiling. I just wanted to make sure I wasn't missing something as I'm new to shader graphs in general.

    Thanks.
     
  46. mathias234

    mathias234

    Joined:
    Sep 9, 2012
    Posts:
    239
    Is there any way to change the internal property name, currently i only see a way to change the display name but the actual property becomes something like Texture_90788A98 which is really not nice in a script to change the properties.
     
  47. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    535
    I know for a fact this is present in the recent GitHub master branch but not sure if it's in the latest package release 1.1.9. It if not it will probably be released next week with the next package


     
    mathias234 likes this.
  48. mathias234

    mathias234

    Joined:
    Sep 9, 2012
    Posts:
    239
    That is good to hear! Its definitly not in the package yet
     
  49. scheidtventureestate

    scheidtventureestate

    Joined:
    Nov 28, 2017
    Posts:
    33
    oh nice !!!
     
    izym likes this.
  50. scheidtventureestate

    scheidtventureestate

    Joined:
    Nov 28, 2017
    Posts:
    33
    I just did this with a simple Vuforia project running on 2018.2.0b5 on Windows 10 and the Webcam is black. I would file an issue, but there seems to already be one: https://issuetracker.unity3d.com/is...ection-method-with-srp-records-a-black-screen

    upload_2018-5-27_15-30-0.png

    Using the packages bundled with Beta 2018.2.0b5, this issue does not occour... so what is this, ah beta bug a package bug ? And how would we file it now?
     
Thread Status:
Not open for further replies.