Search Unity

1 mesh for 2 uvs, is it even a thing ?

Discussion in 'General Discussion' started by dams01, Oct 11, 2022.

  1. dams01

    dams01

    Joined:
    Oct 11, 2022
    Posts:
    1
    I spent hours trying to make it work. Now, at this point, I'm even doubting unity works this way.

    All I'm trying to do, is to have a shader, wich lets me use my second UV for my 3D mesh, and apply a second texture on this same 3D mesh, with a multiply effect on it for instance, to handle a merged effect of those 2 textures.

    I already have a shader like this. The problem is, I constantly have nothing displaying on my second UV ( or technically UV1, because in unity, the first UV set is in a slot named UV0 )

    I read online that second UV is suppose to be used for lightmap, and that's why I want to use this process to have my own uv + own texture.

    Here a picture for more context

     
  2. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,573
    Yes.
     
  3. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,639
    One obvious example of using two UVs on one mesh is how Unity handles light-mapping. 3d meshes typically use one set of UVs for texture mapping (according to the shader), but unity also assigns light map texturing coordinates to a second set of UVs. That way each model can have it's own detailed texture maps, but still be part of a big atlas with much lower texel density.

    In fact, Unity provides two additional UV sets (so there are 4 in all). These other two are not often used. You can use all four UV sets for anything you want to, you'd just need to write your own shader that handles them.
     
    KRGraphics likes this.
  4. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,467
    Interesting. I was thinking about this the other day for a possible update to my hair and fur shader, where I can sample the texture from another object and use it to project colour onto my hair (similar to how hair is done in offline renders).