Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Searching For Nodes

Discussion in 'Shader Graph' started by konsic, Apr 12, 2019.

  1. konsic

    konsic

    Joined:
    Oct 19, 2015
    Posts:
    995
    In Unreal there are 2 nodes called Mask (RGB) and PixelNormalWS.

    Which are equivalent SG nodes?
     
  2. Horus_Sungod42

    Horus_Sungod42

    Joined:
    Oct 30, 2014
    Posts:
    99
    Perhaps describing these nodes a bit could help the community answer, if someone is not super versed in Unreal.
    :)
     
  3. konsic

    konsic

    Joined:
    Oct 19, 2015
    Posts:
    995


     
  4. grobonom

    grobonom

    Joined:
    Jun 23, 2018
    Posts:
    335
    use the split node ^^
     
    konsic likes this.
  5. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,329
    Shader Graph doesn’t have a single node for masking components, you have to chain two together.
    Split > Combine

    For PixelNormalWS, if you have a normal map, pipe the output of the sample texture into a Transform node, and use from:Tangent to:World.
     
    konsic likes this.
  6. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    501
    In Shader Forge, there was actually a node that does this, it's the Normal Direction node, with a tickbox called 'Perturbed' and if checked gives the normal-map-affected output. Any change we could get that into SGE as a sort of shorthand? Potentially save a lot of time, and makes for a less messy graph.

    In the meantime, it seems there's no real way to emulate that with a subgraph because it'd still have to reference the modified Normal data.
     
  7. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,329
    I'm confused, you want to replace an existing single node solution with a new single node solution?

    The PixelNormalWS node adds a ton of weird complexity since if you're using it as part of the graph that modifies the normals you're creating a feedback loop of sorts. I don't know how Shader Graph handles this, but at one point Unreal handled it by crashing the editor ... then eventually just making the material pink. Not sure what they do now.
     
  8. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    501
    Here's an example of it (in shader forge) in use:

    fresnel_calcs.png
    This outputs the reflection coefficient (0-1 of how much light is reflected vs refracted) for a transparent surface with given index of refraction. It needs the per-pixel normals (otherwise small normals-only ripples wouldn't be considered).

    And it fits nicely in its own little area in the graph. SF didn't have subgraphs, but in theory it's exactly the kind of section I would put as a subgraph in SGE.


    As for feedback loops, plugging the perturbed normal vector into the normal slot on the Master Node definitely sounds like something I would have done, but I can't remember what happened.

    I assume it would revert to vertex normals because the per-pixel normal hadn't yet been set at that particular line of code? But then for using it with the smoothness/alpha/whatever calculations, it would then require that normals were calculated pretty early on.
     
  9. konsic

    konsic

    Joined:
    Oct 19, 2015
    Posts:
    995
    Yes. mask RGB in Unreal for Unity's equivalent.
     
  10. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,329
    I was saying that in reference to the PixelNormalWS node, but yeah, I find needing two nodes cumbersome too. Maybe the existing Swizzle node could have the same (4) (3) (2) outputs.
     
  11. Davis3DUE4

    Davis3DUE4

    Joined:
    Aug 24, 2020
    Posts:
    1
    I used "Normal Vector" and set it to "World" to get what i needed. Not sure if its the same for what you need