Shader "OZONE_RAPID/VTX/OZ_VTXFourLayerBlend"
{
Properties
{
_BlackTex ("Base Texture", 2D) = "white"{}
_RedTex ("Second Texture", 2D) = "white"{}
_GreenTex ("Third Texture", 2D) = "white"{}
_BlueTex ("Four Texture", 2D) = "white"{}
}
SubShader
{
Tags { "RenderType"="Opaque"}
LOD 200
CGPROGRAM
#pragma surface surf VTXTwoLayer vertex:vert
#pragma target 3.0
sampler2D _BlackTex;
sampler2D _RedTex;
sampler2D _GreenTex;
sampler2D _BlueTex;
struct VTXSurfaceOutput
{
fixed3 Albedo;
fixed3 Normal;
fixed3 Emission;
half Specular;
fixed Gloss;
fixed Alpha;
};
struct Input
{
float2 uv_BlackTex;
float2 uv_RedTex;
float2 uv_GreenTex;
float2 uv_BlueTex;
float4 vertColor;
};
void vert (inout appdata_full v, out Input o)
{
UNITY_INITIALIZE_OUTPUT(Input,o);
o.vertColor = v.color;
}
inline fixed4 LightingVTXTwoLayer(VTXSurfaceOutput s, fixed3 lightDir, half3 viewDir, fixed atten)
{
fixed diff = max (0, dot (s.Normal, lightDir));
fixed4 c;
c.rgb = s.Albedo * _LightColor0.rgb * (diff * atten * 2);
c.a = s.Alpha;
return c;
}
void surf (Input IN, inout VTXSurfaceOutput o)
{
//Get texture info
fixed4 baseTex = tex2D(_BlackTex, IN.uv_BlackTex);
fixed4 secondTex = tex2D(_RedTex, IN.uv_RedTex);
fixed4 thirdTex = tex2D(_GreenTex, IN.uv_GreenTex);
fixed4 fourTex = tex2D(_BlueTex, IN.uv_BlueTex);
//Blend textures
fixed4 finalTexture = lerp(baseTex, secondTex, IN.vertColor.r);
finalTexture = lerp(finalTexture, thirdTex, IN.vertColor.g);
finalTexture = lerp(finalTexture, fourTex, IN.vertColor.b);
o.Albedo = finalTexture.rgb;
}
ENDCG
}
FallBack "Diffuse"
}
Shader “OZONE_RAPID/VTX/OZ_VTXFourLayerBlend”
{
Properties
{
[NoScaleOffset]_BlackTex (“Base Texture”, 2D) = “white”{}
_BlackSO(“Black Scale Offset”,Vector)=(1,1,0,0)
[NoScaleOffset]_RedTex (“Second Texture”, 2D) = “white”{}
_RedSO(“Red Scale Offset”,Vector)=(1,1,0,0)
[NoScaleOffset]_GreenTex (“Third Texture”, 2D) = “white”{}
_GreenSO(“Green Scale Offset”,Vector)=(1,1,0,0)
[NoScaleOffset]_BlueTex (“Four Texture”, 2D) = “white”{}
_BlueSO(“Blue Scale Offset”,Vector)=(1,1,0,0)
}
SubShader
{
Tags { “RenderType”=“Opaque”}
LOD 200
CGPROGRAM
#pragma surface surf VTXTwoLayer vertex:vert
#pragma target 2.0
sampler2D _BlackTex;
sampler2D _RedTex;
sampler2D _GreenTex;
sampler2D _BlueTex;
float4 _BlackSO;
float4 _RedSO;
float4 _GreenSO;
float4 _BlueSO;
struct VTXSurfaceOutput
{
fixed3 Albedo;
fixed3 Normal;
fixed3 Emission;
half Specular;
fixed Gloss;
fixed Alpha;
};
struct Input
{
float4 vUVW:texcoord;
float4 vertColor;
};
void vert (inout appdata_full v, out Input o)
{
UNITY_INITIALIZE_OUTPUT(Input,o);
o.vUVW = v.texcoord;
o.vertColor = v.color;
}
inline fixed4 LightingVTXTwoLayer(VTXSurfaceOutput s, fixed3 lightDir, half3 viewDir, fixed atten)
{
fixed diff = max (0, dot (s.Normal, lightDir));
fixed4 c;
c.rgb = s.Albedo * _LightColor0.rgb * (diff * atten * 2);
c.a = s.Alpha;
return c;
}
void surf (Input IN, inout VTXSurfaceOutput o)
{
//Get texture info
fixed4 baseTex = tex2D(_BlackTex, IN.vUVW * _BlackSO.xy + _BlackSO.zw);
fixed4 secondTex = tex2D(_RedTex,IN.vUVW *_RedSO.xy + _RedSO.zw);
fixed4 thirdTex = tex2D(_GreenTex, IN.vUVW *_GreenSO.xy + _GreenSO.zw);
fixed4 fourTex = tex2D(_BlueTex,IN.vUVW *_BlueSO.xy + _BlueSO.zw);
//Blend textures
fixed4 finalTexture = lerp(baseTex, secondTex, IN.vertColor.r);
finalTexture = lerp(finalTexture, thirdTex, IN.vertColor.g);
finalTexture = lerp(finalTexture, fourTex, IN.vertColor.b);
o.Albedo = finalTexture.rgb;
}
ENDCG
}
FallBack “Diffuse”
}
Thanks so much
You’re awesome
no problem