Search Unity

HDRP and multiple UV channels

Discussion in 'High Definition Render Pipeline' started by mariusgeorge, Aug 5, 2019.

  1. mariusgeorge

    mariusgeorge

    Joined:
    Jan 29, 2016
    Posts:
    18
    Hi everyone,

    I'm having some difficulty understanding which UV channels are used by Unity, and which ones are free to be populated by data coming from the art pipeline.

    Doing some research, I've come across this general consensus:

    First UV channel: free to use by art pipeline.
    Second UV channel: used by Unity lightmap baking.
    Third UV channel: used by Unity realtime GI.
    Fourth UV channel: free to use by art pipeline.

    The trouble starts when I have a mesh coming in that uses UV0 and UV3 (first and fourth), in conjunction with choosing the "Generate Lightmap UVs" option in the mesh import settings. My understanding is that selecting this option will overwrite UV1 (second channel). UV2 (third) is off-limits regardless (realtime GI). However - selecting this option is overwriting/destroying UV3 (the fourth channel).

    Context: using Shader graph that uses UV0 and UV3. Everything is great until "Generate Lightmap UVs" is selected, in which case the UV3 input in shader graph produces garbage. This is using HDRP 6.9.1 and Unity 2019.2, although the same issue exists in 2019.1 and HDRP 5.x.

    I can provide some screenshots of mesh, shader graph, etc. if that would help, but above should hopefully be enough to explain the situation.

    Any help or insights greatly appreciated!
     
    Neogene likes this.
  2. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    569
    Bump. Any Unity insiders care to respond?
     
    Neogene likes this.
  3. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    According to this document HDRP samples from three sources to create the final base blend:
    Source 1: either uv0, uv1, uv2 or uv3
    Source 2: Planar (top to bottom) ... local or world space?
    Source 3: Triplanar over X, Y and Z directions

    https://docs.unity3d.com/Packages/c...es.high-definition@7.2/manual/Lit-Shader.html

    What I can't find though is information about what channels HDRP expects our lightmap uv's to reside in if at all - maybe it is expected/advised to always let Unity generate them on mesh import?
    Can we pack more than one uv set into the mesh like the OP asked? How would we need to name them in Maya? I cannot find that general consensus @mariusgeorge is talking about when it comes to the HDRP.

    @SebLagarde
    @KEngelstoft
    @Kuba
    @Aras

    Care to shed some light onto this? Sorry for pinging you all - nah, if there was a doorbell for UT as a whole I might have pressed that instead :D
     
  4. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    In the standard pipeline unity packs lightmap data into UV1.xy and UV2.xy, but you can still use UV1.zw and UV2.zw to store custom data. As I believe none of the SRP's currently support realtime GI, I'm betting UV2.xy is open right now, but that it might changes if UVs are needed for whatever their eventual solution is.

    It would be nice if Unity documented anything about the internals of their shaders and didn't give "Look at the code, which will change every week" as an answer.
     
  5. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    Nice. Thanks for the info with UV1.zw and UV2.zw.