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

    kubog

    Joined:
    Feb 1, 2018
    Posts:
    3
    Hello,
    Is there a way how can I get SV_VertexID in Shader Graph? I cannot find any node, and in CustomNodeAPI there is no documentation on that so I can not create a custom node either. Any ideas?
     
  2. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,372
    So how to do this in shadergraph?
    Code (csharp):
    1.  
    2. Y=X<0?A:B
    3.  
     
  3. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    542
  4. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,372
  5. wyatttt

    wyatttt

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    260
    could do it based on a lerp to avoid conditionals (i think the conditional node is a ternary + lerp in the generated code)

    float t = max(sign(-x), 0); // t is 1 if X is negative and t is 0 if X is 0 or positive
    Y = lerp(B, A, t);
     
    Reanimate_L likes this.
  6. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,372
    Oh i got it already, using the Comparison and Branch node. Apparently i misscalculate the x value :D.
     
    wyatttt likes this.
  7. Jick87

    Jick87

    Joined:
    Oct 21, 2015
    Posts:
    124
    @wyatttt I wanted to follow up on this. Is this something that is/will be possible?
     
  8. wyatttt

    wyatttt

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    260
    I don't believe there is currently unless you rendered the object positions into a buffer and sampled the texture in your graph as a baking step or a separate material pass at runtime
     
  9. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,372

    The latest update of HDRP are nice in term of shadergraph integration, finally proper depthbuffer and colorbuffer access nodes . Just need tesselation support in SG, but i can live with that limitation for now :D
     
    Lex4art, Rowlan, awesomedata and 6 others like this.
  10. briank

    briank

    Joined:
    Mar 25, 2017
    Posts:
    67
    Any way to label or group nodes, for the sake of organizing the graph? Without code comments and variable names, it's hard to do anything complicated without expending a massive amount of brain power.
     
    Shorely likes this.
  11. elettrozero

    elettrozero

    Joined:
    Jun 19, 2016
    Posts:
    216
    Your water is super.
    May I ask you to share how you used the Scene Depth node? I tried to recreate the Depth Fade node from ASE but is not that good.
     
    awesomedata and Shorely like this.
  12. elettrozero

    elettrozero

    Joined:
    Jun 19, 2016
    Posts:
    216
    Quick question. Can we make a custom shader to be used as a decal?

    --

    I tried making a graph with all the required properties.
    I went for transparent.
    Now it gives me the error: "RenderingCommandBuffer: invalid pass index 4 in DrawMeshInstanced"
    Any ways to make it work?
     
    Last edited: Jan 20, 2019
  13. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,372
    upload_2019-1-20_19-51-33.png
    Note : you need to use the latest HDRP, they fixed the DepthBuffer node uv
    Also might be easier just to create subgraph for this only with one input node, the depth fade value
     
    Last edited: Jan 20, 2019
  14. elettrozero

    elettrozero

    Joined:
    Jun 19, 2016
    Posts:
    216
    It's people like you that make this world a better place.
    Thanks!
     
  15. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,372
    skilfuldriver likes this.
  16. elettrozero

    elettrozero

    Joined:
    Jun 19, 2016
    Posts:
    216
    If I stick this inside a Sub-Graph...
    upload_2019-1-20_15-55-37.png
    upload_2019-1-20_16-4-0.png
    ...doesn't work.

    What do I do wrong?
     
  17. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,372
  18. elettrozero

    elettrozero

    Joined:
    Jun 19, 2016
    Posts:
    216
    Yes, but I'm not sure it is related to that.
    Does it work for you in a sub graph?
     
  19. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,372
    Works fine for me with subGraph
     
  20. ghtx1138

    ghtx1138

    Joined:
    Dec 11, 2017
    Posts:
    113
    I'm trying to recreate @Reanimate_L (very nice) HDRPWaves but I don't seem to have the same nodes available - are these custom nodes? I'm on Unity 2018.3.0f2, HDRP 4.8.0 and SG 4.8.0.

    Admittedly I am just starting out with SG and have no mortal idea of what I am doing - trying to recreate part of a node setup pic from Nov 2018 and mashing that with the partial node pic just a few posts back.

    I'm missing the following nodes: Smoothness, Distortion, Scale, Fade and Normal Map

    In addition I cannot convert the Normal Strength node to a property.

    Should this be reported as feedback or have I misunderstood what nodes are available? I understand SG is in an evolutionary flux vortex.

    Thanks

    Reanimate_L2.png
     
  21. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    551
    Those are all values converted to properties just like you have the color property as a node.

    Smoothness - Vector 1 node (same for Distortion, scale, and fade)
    Normal - Texture 2D node

    You can add these by using the Plus button you see on the Blackboard or creating the set nodes (Vector 1, Color, etc) right click on them and convert to property.
     
  22. ghtx1138

    ghtx1138

    Joined:
    Dec 11, 2017
    Posts:
    113
    @Grimreaper358 thanks for your reply. I've been playing with SG for a couple of hours and now I understand what you are saying. :) Cheers
     
  23. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,372
    Oh wait, hold up. Putting them into subgraph the result are glitched, somehow it randomly break. Well this is weird.
    @wyatttt i think we found a bug
    WithSubGraph
    upload_2019-1-21_22-23-19.png
    Without SubGraph
    upload_2019-1-21_22-23-51.png
    The SubGraph
    upload_2019-1-21_22-24-58.png
     
    Last edited: Jan 21, 2019
  24. elettrozero

    elettrozero

    Joined:
    Jun 19, 2016
    Posts:
    216
    Ok thanks for the confirmation.
    I believe sub graphs have problem with inputs.
     
  25. ghtx1138

    ghtx1138

    Joined:
    Dec 11, 2017
    Posts:
    113
    When developing ShaderGraph shaders I'd like to check out a number of different combinations of values. Is there a component I could get to save "combinations of preset property values"?

    For example I have a shader that looks good from a distance but looks like garbage close up with the same property values - I'd like to be able to switch between different combinations of values for different camera locations, lighting conditions, etc. And also save new property combinations while testing.

    Thanks
     
    Shorely likes this.
  26. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    542
    Not from within the Shader Graph, AFAIK, but from Material Editor:

    Screen Shot 2019-01-22 at 15.49.22.png

    The second button so allow you to save the current shader property and hopefully reuse it.

    Also it might be a good idea to use "Camera" node in your shader graph then you don't have to keep different camera position as static data.
     
  27. ghtx1138

    ghtx1138

    Joined:
    Dec 11, 2017
    Posts:
    113
    Hey thanks @bitinn That works great.

    I don't understand what you mean use Camera node. The material preset doesn't seem to save the camera - unless that is what you mean? I can save big distance and close distance for the camera in different material presets? Wow.

    Thanks and Cheers
     
  28. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    542
    I was referring to calculating the camera distance in your shader graph so that your shader can behave differently depending on how close your object is. But if the preset solution works then no need to make it more complex.
     
  29. ghtx1138

    ghtx1138

    Joined:
    Dec 11, 2017
    Posts:
    113
  30. TheBricktop

    TheBricktop

    Joined:
    Sep 3, 2012
    Posts:
    25
    Okay, started unity 2018.3.2 and downloaded packages for subgraph and lwrp, but where is tesselation node/output/option?
     
  31. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    1,937
    Is there any better approach, other than simply following this thread, to get a sense of what the ShaderGraph team is working on, and what's in the works for future releases? Or, to put it another way, is there a formal roadmap for ShaderGraph? There are some features I'm hoping to see at some point, and it would be nice to know if they're on the horizon, or not expected to be an option. For example:
    • Will there every be something like GrabPass that works under HDRP? This has been discussed off and on, but I was never clear on whether it's something that's being worked on or not.
    • Are multiple passes going to be supported?
     
    Shorely likes this.
  32. elettrozero

    elettrozero

    Joined:
    Jun 19, 2016
    Posts:
    216
    Maybe you're intersted in this: https://github.com/Unity-Technologi...render-pipelines.high-definition/CHANGELOG.md
     
    dgoyette likes this.
  33. elettrozero

    elettrozero

    Joined:
    Jun 19, 2016
    Posts:
    216
    As for grab pass HDRP has distortion that works good. Also transparent things now receive shadows.
     
  34. ghtx1138

    ghtx1138

    Joined:
    Dec 11, 2017
    Posts:
    113
    Well ShaderGraph is a lot of fun. Messing around with HDRP ocean waves.



    SOAL.png
     
  35. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,372
    GrabPass in ShaderGraph are called SceneColor node, it works with HDRP now
     
    dgoyette and wyatttt like this.
  36. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    1,937
  37. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,372
  38. Miguel-Herrero

    Miguel-Herrero

    Joined:
    Jan 19, 2015
    Posts:
    18
    I have a small suggestion:

    I used the [Header(Section Name)] attribute a lot when writting shaders, to separate material parameters into sections. I would love to be able to add labels or "headers" to the Shader Graph parameter window the so that the materials are easier to edit and more organized.

    Also, we use a lot of console defines (like SHADER_API_SWITCH) so that certain features of a shader depend on the platform (The Switch hardware doesn´t like big UV numbers, so we have to wrap the values for our planar mappings, for example).

    Is there anyway to achieve this with a builtin node, or should a create a custom node that returns the define value?

    And a final question: is it possible to use instanced parameters? I would like to modify certain values through MaterialPropertyBlock.
     
    awesomedata likes this.
  39. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    542
    Assuming you are on LWRP:

    Most properties are instanced by default. (wrapped in CBUFFER)

    Shader variant / Keyword support is much requested, AFAIK you need to export Shader Graph to a plain shader and add it manually yourself.
     
  40. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    1,937
    What am I missing? When I try to use Scene Color under HDRP/ShaderGraph 4.8, I just get black. Am I missing something that needs to exist in the scene? Or some HDRP setting to enable this feature?

    Edit: Nevermind, a few more Saves and suddenly it started working.
     
  41. SGFX

    SGFX

    Joined:
    Mar 25, 2014
    Posts:
    24
    Not sure if its changed in a newer version, but please make the texture and value outputs apply automatically (and apply the proper names directly!) like in Shader forge or Amplify Shader, its just so clunky and slow setting it all manually and renaming them on top. Just looking at shader graph gives me a sense of burn-out where I don't even want to start, while I was always very keen on jumping in in those other shader editors.
     
    Shorely likes this.
  42. o2co2

    o2co2

    Joined:
    Aug 9, 2017
    Posts:
    11
    Unity shader graph Can I add a geometry shader?
     
  43. pointcache

    pointcache

    Joined:
    Sep 22, 2012
    Posts:
    525
    What happened to CodeFunctionNode, its now private and internal, all my nodes are broken.
     
    Giles-Coope likes this.
  44. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    551
    There's a new Custom node API being worked on for Shader Graph to be released with Unity 2019.1
    This may be the reason why it's now internal
    upload_2019-1-27_9-42-11.png
     
  45. pointcache

    pointcache

    Joined:
    Sep 22, 2012
    Posts:
    525
    What sense does it make to remove existing api before shipping replacement?
     
  46. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    551
    Not sure which version they cut it out of (Guessing you're using a 5.x.x version with 2019.1 alpha) but the only reason I can see why they would do this is so that people don't continue or start to use the old API when there is a new one coming.

    So most likely to lower confusion or maybe it's already active and that's what they are building on now. Currently, every node in Shader Graph was built the same way as CodeFunstionNode on the same API that's now internal. If it's switched then the nodes would have already be converted to the new API or maybe they just restrict user access and the nodes are still using the Old API? (your nodes should still work if this was the case)

    Either way, this will surely cause some discomfort to most people who used the old/current API but this is all still in Preview and stated to be changed at any time. So it makes sense that they lean towards setting up everything for the release with 2019.1
     
  47. pointcache

    pointcache

    Joined:
    Sep 22, 2012
    Posts:
    525
    Doesn't make any sense lets be honest. Im stuck with nodes that wont compile and can't be removed from the project because graphs depend on them. I could fix that if there was a way to swap out new api, manually upgrade, whatever, but there is none but to downgrade, so yeah i assume it's just a mistake.
     
    darkydoodle, sand_lantern and Shorely like this.
  48. MlleBun

    MlleBun

    Joined:
    Sep 19, 2017
    Posts:
    21
    Hello everyone. A newbie question about some weird messages that I'm getting on my character material.

    upload_2019-1-28_21-40-21.png

    I have two materials on two different gameobjects made from one shadergraph. And (Instance) next to the material name keeps incrementing when I run the game :confused: Above is a screenshot while I ran three times the project. I was wondering if I was doing something wrong here or is this normal.

    Thanks!
     
  49. Blobinet

    Blobinet

    Joined:
    May 4, 2015
    Posts:
    18
    I see the generated shader code contains a function called PopulateVertexData, is there a way to write a custom node that adds to this function, like we can with PopulateSurfaceData ?
    Or is there another way to write a node that modifies the vertex function in any way ?
     
  50. Pivetta

    Pivetta

    Joined:
    Oct 11, 2013
    Posts:
    13
    Greets,
    I came up to a small issue.
    I am making some custom shaders for a Cardboard VR project.
    I made some simple 3 planes parallax system on an Unlit shader using Offsets.

    I found out:
    Camera>Direction is not rendering on android devices (at least with my settings - But all other Unlit shaders are working)

    Instead I am using ViewDirection(World).
    I wanted to ask what's the difference between the two, Camera>Direction gave me an inverted and slightly lower output than ViewDirection(World), but I do not notice other visible differences.

    Thanks for the awesome work
    (I am excited for the light direction, shadow and lightmap nodes - then the tool will be complete for my needs)
     
Thread Status:
Not open for further replies.