Search Unity

Question More than 4 UV sets in Shader Graph?

Discussion in 'Shader Graph' started by Brad-Newman, Apr 27, 2019.

  1. Brad-Newman

    Brad-Newman

    Joined:
    Feb 7, 2013
    Posts:
    185
    The "Tiling and Offset node" is restricted to 4 UV sets (UV0, UV1, UV2, UV3). Is there a way to use more than 4? I tried inputing a Vector2 into "Tiling and Offset" UV(2) input parameter, but wasn't successful.
     
    burningmime likes this.
  2. Horus_Sungod42

    Horus_Sungod42

    Joined:
    Oct 30, 2014
    Posts:
    99
    Does Unity have a limit of 4 UVs? If so, it would not be a question of Shader Graph but of import settings.

    For example, I can put a large number of vertex color layers on an object, but Unity seems to only read the first one. (The fbx exporter can export several vertex color layers). It may do the same for UV sets.
     
    burningmime likes this.
  3. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    Unity has a limit of 8 UVs, but Shader Graph only exposes the first 4. FBX importing handles all 8 just fine, though does limit itself to only importing the first two components of the UV rather than all 3 components that FBX actually holds. This is for a good reason as the vast majority of use cases don't ever use the W of a UVW, but modelling programs and FBX don't really have a way to denote that W isn't being used, though it would be nice to have it as an option. Unity itself is able to hold a Vector4/float4 in each UV set, as that's what GPUs accept. Early versions of Shader Graph didn't expose all 4 components, only the first 2, even though the actual shader code being generated had access to all 4. Again, for most use cases this is all anyone would need, but it's quite common to use the full float4 for various visual effects related stuff, and indeed Unity's own particle systems can make ample use of those extra components, so enough people asked for it and it was added.

    I'm sure the limit to the first 4 UVs is a similar "surely no one uses more that the first 4" oversight, and is something they could trivially include support for.
     
    Last edited: Apr 29, 2019
  4. BayernMaik

    BayernMaik

    Joined:
    Oct 15, 2019
    Posts:
    20
    Is there a way to access further UV layers with a custom node?
    Asking for a friend
     
  5. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    Nope.

    Until Unity addresses this themselves, there's nothing you can do. Shader Graph only ever passes the first 4 UVs from the vertex shader to the fragment shader, and the input to the vertex shader only ever gets up to the first 4 UVs because the Shader Graph itself has been programmed to only get that many. Nodes can only access the data that Shader Graph itself has exposed, and without direct control over the vertex and fragment shader semantics there's no way to get those extra UV sets.
     
    Last edited: Sep 11, 2020
    BayernMaik likes this.
  6. BayernMaik

    BayernMaik

    Joined:
    Oct 15, 2019
    Posts:
    20
    Ok thx alot, saved me a lot of time of pointless trial and error
     
  7. cultureulterior

    cultureulterior

    Joined:
    Mar 15, 2015
    Posts:
    68
  8. BayernMaik

    BayernMaik

    Joined:
    Oct 15, 2019
    Posts:
    20
    Nice, thx for the hint
     
  9. Francoimora

    Francoimora

    Joined:
    Aug 1, 2013
    Posts:
    68
    Under consideration since 2 years probably means they don't care about this. This is the reason why we switched to Amplify and can't go back to Shader Graph. Such a trivial feature should be done without the need to think about it for several years.
     
  10. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    864
    "8 texture coordinates" is still "under consideration" on the roadmap for ShaderGraph. I've read that SkinnedMeshRenderer stores previous position for motion vector computation in texcoord4. Would be nice to be able to access it.
     
    OleksandrMartysh likes this.
  11. warpfx

    warpfx

    Joined:
    Feb 10, 2020
    Posts:
    14
    2024 here ;)
     
  12. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,514
    What would make this feature technically difficult for Unity?
     
  13. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,314
    Nothing, they just don't care. Other features got more votes I guess.