Search Unity

Question Custom SubGraph default parameter

Discussion in 'Shader Graph' started by alkaitagi, Jan 15, 2020.

  1. alkaitagi

    alkaitagi

    Joined:
    Dec 8, 2016
    Posts:
    87
    I have created a subgraph that, among other ones, takes a Vector2 as a parameter meant for UV input. But quite often that parameter is left assigned to a UV0 node that I create. Is there a way to make the subgraph's parameter by default to be assigned to a UV0 the way this is done with SameplTexture2D or TilingAndOffset nodes?
     
  2. alkaitagi

    alkaitagi

    Joined:
    Dec 8, 2016
    Posts:
    87
    This is what I have now: upload_2020-1-15_10-47-37.png

    And this is what I would like to have:
    upload_2020-1-15_10-47-53.png
     
  3. alkaitagi

    alkaitagi

    Joined:
    Dec 8, 2016
    Posts:
    87
    Found out it is called Port Binding but still did not get how to apply it.
     
  4. alexandral_unity

    alexandral_unity

    Unity Technologies

    Joined:
    Jun 18, 2018
    Posts:
    163
    This is not currently supported but it's a feature request we know about and want to work on in the future.
     
    Garrafote and alkaitagi like this.
  5. Garrafote

    Garrafote

    Joined:
    Jun 13, 2013
    Posts:
    48
    +1 for this request!

    It'd be pretty cool to be able to mark Vector2 inputs as a UV channel by default
     
  6. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    738
    Last edited: Oct 11, 2022
  7. fkoehne

    fkoehne

    Joined:
    Jul 25, 2017
    Posts:
    1
    Hey, we would love to use this feature, but aren't sure how to? Is it actually released?

    Edit: Currently when building a Subgraph with a custom UV you provide as a SubGraph-Parameter the preview inside of ShaderGraph is completely unusable, because the UV is always 0,0 for every pixel.
    This makes SubGraphs really hard to debug as soon as you want to use anything but the default UV as input.
     
    Last edited: Jun 1, 2023
    leohilbert likes this.
  8. MirzaBeig

    MirzaBeig

    Joined:
    Dec 27, 2014
    Posts:
    602
    In case it helps anyone, here's how you can set the default for an input port on a sub-graph in Shader Graph when there's nothing connected.

    The image below shows how to use the Branch On Input Connection node.
    You simply pass the input node -> both the input and Connected ports, and set NotConnected to your default.

    In my case I want the default to be centered UVs for a custom Circle SDF node.

    upload_2023-10-7_20-56-35.png

    So without anything connected to UVs it correctly shows the default centered UVs.
    The default label also displays.

    upload_2023-10-7_20-57-54.png

    If I actually connect to the uv port, we know it's now taking the non-centered UV that's connected.

    upload_2023-10-7_21-2-12.png
     
  9. FariAnderson

    FariAnderson

    Joined:
    Jan 20, 2020
    Posts:
    37
    my input(p) node would not connect to anything

    upload_2023-11-23_18-24-13.png

    Unity 2022.3.0 - BuildInRP
     
  10. FariAnderson

    FariAnderson

    Joined:
    Jan 20, 2020
    Posts:
    37
    I just found that i should enable Custom Binding for the Input

    upload_2023-11-23_18-33-53.png

    obviously i didn't quite pay attention to the Mirza's post :)
     
    Last edited: Nov 23, 2023
    Celezt and MarcAllozaAyxendri like this.