- Home /
can you use 3 or more UV sets
So far it seems UNITY reserves UV1 for the main texture, and UV2 for its lightmap. I would like to create a UV3 as like a grim map and so on. I can set it up in my 3d program. But Im wondering how to access this in UNITY.
Answer by michael 4 · Feb 07, 2012 at 04:33 PM
I found out it is possible by editing the shader, you can tell it to use 3 or more UV sets by adding adding the following to the shader:
struct Input {
float2 uv_MainTex: Texcoord0; // use UV set 1
float2 uv_DetailTex: Texcoord2; // use UV set 3
float2 uv_DecalTex: Texcoord3; // use uv set 4
};
if you want to use uv set 5 and so on, use Texcoord4 and up.
Then when your shader is defining how it displays each texture map, make sure your tex2d() function is applying the right texture coordinates.
fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
fixed4 dtl = tex2D(_DetailTex, IN.uv_DetailTex);
fixed4 dcl = tex2D(_DecalTex, IN.uv_DecalTex);
Also remember to leave UV set 2 alone if you plan on lightmapping
can you explain this please? where can i modify the shader as described above and how can i assign the additional uv channels to the mesh?
This would not work yet; there's no way to actually have a mesh with more than 2 UV sets in Unity (in Unity 4.2 or earlier at least).