Unity 3D multiple UV sets

2020-05-29 06:38发布

I have created an object that has the texture and an AO , they are on different UV sets in maya(with Layered Texture) and in maya the mash looks ok.

How do i achive the same effect in Unity3D?

I can not make unity use the 2nd UV set.

1条回答
混吃等死
2楼-- · 2020-05-29 07:18

You'll need to write a shader that does this. Here's a very minimal example, but you'd probably need to have a more elaborate setup for things specular, etc.

    Shader "Custom/twotex" {
        Properties {
            _MainTex ("Base (RGB)", 2D) = "white" {}
            _AoTex ("AO (RGB)", 2D) = "white" {}

        }
        SubShader {
            Tags { "RenderType"="Opaque" }
            LOD 200

            CGPROGRAM
            #pragma surface surf Lambert

            sampler2D _MainTex;
            sampler2D _AoTex;


            struct Input {
                float2 uv_MainTex : TEXCOORD0;
                float2 uv_AoTex :   TEXCOORD1;
            };

            void surf (Input IN, inout SurfaceOutput o) {
                half4 c = tex2D (_MainTex, IN.uv_MainTex.xy);
                half4 ao = tex2D (_AoTex, IN.uv_AoTex.xy);
                o.Albedo = c.rgb * ao.rgb;
                o.Alpha = c.a;
            }
            ENDCG
        } 
        FallBack "Diffuse"
    }
查看更多
登录 后发表回答