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

Feature Request Swizzle Node Usability

Discussion in 'Shader Graph' started by grllle, Sep 28, 2019.

  1. grllle

    grllle

    Joined:
    May 4, 2015
    Posts:
    28
    The fact that the swizzle Node unlocks additional channels only if the input's are not zero makes it not usable for some cases. For example swizzling the Vertex Positions.

    I do a split & combine atm but it would be nice to fix this in some way...
     
    LooperVFX likes this.
  2. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,237
    I agree, I very often end up using Split+Combine.

    Amplify Shader Editor handles this really well, where the swizzle node can be configured to output a vector1/2/3/4.
     
  3. LandonTownsend

    LandonTownsend

    Unity Technologies

    Joined:
    Aug 21, 2019
    Posts:
    35
    This bug is known, for a workaround you can hide and reshow the preview at the bottom of the node (press the arrow at the top of the preview) to force the node to redraw and update the channel options.
     
  4. LooperVFX

    LooperVFX

    Joined:
    Dec 3, 2018
    Posts:
    176
    This usability bug and wonky workaround is not acceptable for a production ready tool. Shader Graph isn't in preview anymore, and this is is an easy fix. My Proposal: Don't overthink this right now, just fix it with a quick mitigation now (Suggestion A,) and then plan for a longer term solution as part of an overall improved UI/UX, most likely taking influence from the way Visual Effect Graph has already solved these issues. (Suggestions B and C.)


    Suggestion A: Simply have the drop down menus in the Swizzle node always list 4 channels. In the same way you can type any channel / component of a vector when swizzling in HLSL, and if that component doesn't exist in the input, you get an error. This also preserves the selection instead of potentially destroying selected channels.

    Why? This is the quick bug fix for the current UI which there is no reason not to do right now. We already have an output of a fixed size vector of 4 components, why not the input? Save yourselves the embarrassment of knowing that the node for Swizzling (a quintessential shader concept) is still broken and neglected for well over a year now. This doesn't require some major refactor either was a response on the issues tracker as to why this isn't being fixed anytime soon. This is a 10 to 15 minute fix in dev time, with minimal Testing / QA as you are eliminating code paths and edge cases :p. I'd have already sent you a pull request for it if I could.


    Suggestion B: Take a note from Visual Effect Graph's swizzle node, which simply lets you type a mask like yx, zxy, xyy, etc. and the output vector type is determined dynamically from the length of this mask. To further increase usability, also add support for rgba masks for Shader Graph and VFX Graph, VFX Graph currently only supports xyzw masks.

    Why? This would be more ideal and also improve usability and uniformity to the UI/UX across Unity's directed node graphs. It also isn't very difficult to implement --it's essentialy a string interpolant in the code gen. Worth mentioning that using this is must faster than clicking around on a bunch of clunky drop down menus that are laid out in reverse from the flow of the graph, i.e. nodes have input on the LEFT, output on the RIGHT, yet, in the dropdown UI of Shader Graph's Swizzle node, input channels are on the RIGHT, and output channels are on the LEFT. So, in context of the node graph, this layout is simply bad UI / UX.


    Suggestion C: As long as we are on the topic of UI/UX lessons that can be learned from Visual Effect Graph, notice that there is no split or combine node like Shader Graph, because it doesn't need them --the functionality to split and combine is included on every single node with a small triangle breadcrumb to expand / collapse the channels/components!

    Why? it's easy, and intuitive, it doesn't take searching documentation and forums to discover the swizzle node is broken and that there there are these 2 (split and combine) nodes for visual swizzling. a combine node is also needed for component reduction after swizzling with shader graph's already busted swizzle node. With Visual Effect Graph you have a swizzle node with a mask text field that is more intuitive for people that already know what swizzling is and have written a shader before. Then, for non-programmers that may prefer to visually swizzle by routing edges click by click --it's just naturally part of the node graph paradigm that users will discover on their own. Eliminating the need to learn from docs or a tutorial about some half-trick micro utility nodes to be littered all over incomprehensible shader graphs.


    I will leave you with this screenshot comparison to illustrate the above topics. Including a related UI/UX issue with vector notation: Shader graph refers to component vectors as rgba when swizzling even when they are being used for xyzw positions / transformations, etc. (even though the generic Vector constructor nodes are always xyzw notation, you'd think swizzling is a generic vector operation, not something just for rgba colors. in any case, Shader Graph's notation is inconsistent with itself and inconsistent with Visual Effect Graph.)

    From left to right, these examples show a "visual" swizzle with edge routing from a Color/Vector4 to a Position/Vector3, and then a swizzle using a Swizzle node from a Position/Vector3 to a Vector2.


    Shader Graph Swizzling
    shadergraph_swizzle_markup.png
    Visual Effect Graph Swizzling
    visualeffectgraph_swizzle_markup.png
     
    Last edited: May 5, 2020
    Qriva and florianBrn like this.
  5. LooperVFX

    LooperVFX

    Joined:
    Dec 3, 2018
    Posts:
    176
    Another common swizzle use case worth documenting the need for here is to output a larger vector than the input vector, e.g.
    MyVector2.xyxy
    MyRedGreen.rgr
    --the swizzle node's current design never allowed for in the first place.
     
  6. LooperVFX

    LooperVFX

    Joined:
    Dec 3, 2018
    Posts:
    176
    Arycama likes this.
  7. LooperVFX

    LooperVFX

    Joined:
    Dec 3, 2018
    Posts:
    176
    @LandonTownsend Hi Landon, it's Landon. :) Is there any update on the timeline for this being addressed?

    I know these issues are on your radar, some months ago Gytis in QA assured me the Shader Graph team will be addressing it an upcoming feature release (someday.)

    I'm asking because I've noticed that there is a new (Matrix) Swizzle node in the works https://github.com/Unity-Technologies/Graphics/pull/1615
    I was expecting a concurrent bug fix and redesign of the (Vector) Swizzle node to be underway with a consistent UI/UX workflow being planned alongside the Matrix Swizzle node. But, I haven't been able to find any evidence of this. Which leads me to wonder if these individual nodes are being developed in a vacuum or what the bigger picture is exactly.

    Presumably, a modest approach would be to replace the (Vector) Swizzle node's clunky dropdown menus for channel selection with text field(s,) and replace the broken output size detection with an enum that is set explicitly (both of which this Matrix Swizzle Node already has by design, kudos.) This would additionally maintain some UI/UX consistency among "the Swizzle nodes" of Shader Graph.

    (Leaving the reconciliation with Visual Effect Graph's more intuitive / discoverable / readable UI/UX workflow I have already detailed in this thread for a later date, which is fine.)

    Thanks much for your consideration. I'm seeing a lot of great improvements done, planned or underway, so I figure this can't be too far behind. :)
     
  8. LooperVFX

    LooperVFX

    Joined:
    Dec 3, 2018
    Posts:
    176
    Arycama likes this.
  9. Cameron_SM

    Cameron_SM

    Joined:
    Jun 1, 2009
    Posts:
    915