Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Multiple UV channels?

Discussion in 'Universal Render Pipeline' started by ridethefader, Jan 29, 2021.

  1. ridethefader

    ridethefader

    Joined:
    Jun 17, 2019
    Posts:
    44
    I need to create a shader that has 3 UV sets total to use in my URP project. The 3 UV channels would be for texture 1, texture 2, and lightmap. I dont know code, so using something like the Shader Graph would probably be best. Can anyone point me in the right direction?
     
  2. Jonas-Mortensen

    Jonas-Mortensen

    Unity Technologies

    Joined:
    Jan 3, 2020
    Posts:
    98
    Hi!
    When sampling a texture in Shader Graph you are free to specify which UV set the sampler will use. With a dropdown up to 4 different UV maps of your mesh can be selected. Only thing to remember is that Unity uses the second set for light-mapping so you will need to reserve it for that.

    I have this example of a picture frame model where the picture content can easily be changed. In blender I have these maps set up:
    Blender.png

    I'm afraid this shader graph is a bit daunting but I've tried to highlight the UV channel selection:
    Graph.png

    With this shader I can then create materials with a specific property for the picture content
    Material.png

    And easily create variants

    Result.png

    I hope this helps! :)
     
  3. ridethefader

    ridethefader

    Joined:
    Jun 17, 2019
    Posts:
    44
  4. kayronjm

    kayronjm

    Joined:
    Jun 15, 2019
    Posts:
    34
    Hi @Jonas-Mortensen, thanks for this. I'm trying to replicate this in Unity 2021.2.6f1 HDRP but it's not working. I've tried your Shader Graph with and without the Vertex Color, Split and Lerp nodes (without involves just plugging in the output of the Blend node straight into Base Color).

    Your textures indicate that your UV maps for the frame and for the picture are different entirely. As in you UV unwrapped just the frame faces for the frame UV map and just the picture faces for the picture UV map. Is this correct? I've tried this, having the same UV maps for both and also having the picture UV map looking identical to the frame UV map but with the frame faces sized down to 0 and placed outside the UV map bounds. I also tried painting the picture face in plain red as per your Vertex Color, Split and Lerp nodes (at least what I thought they were for).

    Anyway, the result is that the entire mesh has a blend of both textures all over the place. The faces I want aren't blended as intended - the whole mesh is. It's been a few hours of attempts and I'm at a loss unfortunately. I also used Blender to prepare everything, with FBX exports into Unity. Thank you for any help you can provide.