// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' Shader "Custom/TwoFaceShader" { Properties { _MainTex_1 ("贴图1", 2D) = "white" {} _MainTex_2 ("贴图2",2D) = ""{} } SubShader { Pass { Tags{"LightMode" = "ForwardBase"} LOD 100 //在这个通道内剔除背面渲染 Cull Back CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" struct appdata { float4 vertex:POSITION; float2 uv:TEXCOORD0; }; struct v2f{ float4 vertex:SV_POSITION; float2 uv:TEXCOORD0; }; sampler2D _MainTex_1; //使用TRANSFORM_TEX时需要定义一个 _贴图的变量名_ST 用来供给系统使用 float4 _MainTex_1_ST; v2f vert(appdata v){ v2f o; o.vertex = UnityObjectToClipPos(v.vertex); o.uv = TRANSFORM_TEX(v.uv,_MainTex_1); return o; } fixed4 frag(v2f v):SV_TARGET{ fixed4 col= tex2D(_MainTex_1,v.uv); return col; } ENDCG } Pass{ Tags{"LightMode" = "ForwardBase"} Cull Front CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" struct appdata{ float4 vertex:POSITION; float2 uv:TEXCOORD0; }; struct v2f{ float4 vertex:SV_POSITION; float2 uv:TEXCOORD0; }; sampler2D _MainTex_2; float4 _MainTex_2_ST; v2f vert(appdata v){ v2f o; o.vertex = UnityObjectToClipPos(v.vertex); o.uv = TRANSFORM_TEX(v.uv,_MainTex_2); return o; } fixed4 frag(v2f v):SV_TARGET { fixed4 col = tex2D(_MainTex_2,v.uv); return col; } ENDCG } } FallBack "Diffuse" }