Shader "Custom/4textureBlend"
{
Properties
{
_BlendTex ("Blend (RGB)", 2D) = "white" {} // маска
_1Tex ("Blend (ZERO)", 2D) = "white" {}
_2Tex ("Blend (R)", 2D) = "white" {}
_3Tex ("Blend (G)", 2D) = "white" {}
_4Tex ("Blend (B)", 2D) = "white" {}
_MainTex ("Fallback For GLES1", 2D) = "white" {} // для мобилок с Gles < 2.0
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert noforwardadd
sampler2D _BlendTex, _1Tex, _2Tex, _3Tex, _4Tex;
struct Input
{
fixed2 uv_BlendTex;
fixed2 uv_1Tex;
fixed2 uv_2Tex;
fixed2 uv_3Tex;
fixed2 uv_4Tex;
};
void surf (Input IN, inout SurfaceOutput o)
{
fixed3 _BT = tex2D (_BlendTex, IN.uv_BlendTex).rgb ;
fixed3 _1T = tex2D (_1Tex, IN.uv_1Tex).rgb;
fixed3 _2T = tex2D (_2Tex, IN.uv_2Tex).rgb;
fixed3 _3T = tex2D (_3Tex, IN.uv_3Tex).rgb;
fixed3 _4T = tex2D (_4Tex, IN.uv_4Tex).rgb;
fixed Z = 1 - (_BT.r + _BT.g + _BT.b); // вычисляем черный цвет
fixed3 c =
_1T * Z
+ _2T * _BT.r
+ _3T * _BT.g
+ _4T * _BT.b;
o.Albedo = c;
o.Alpha = 1;
}
ENDCG
}
Fallback "Mobile/VertexLit" // для мобилок с Gles < 2.0
}