Unity 3D multiple UV sets

久未见 提交于 2020-05-10 03:37:42

问题


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:


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"
    }


来源:https://stackoverflow.com/questions/19136494/unity-3d-multiple-uv-sets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!