I’ve got this shader for combining up to 4 textures in 1:
Shader "Custom/TexCombinations" {
Properties {
_Cutoff ("Cutoff", Range(0,1)) = 0.5
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Tex", 2D) = ""
_MainTex1 ("Tex1", 2D) = ""
_MainTex2 ("Tex2", 2D) = ""
_MainTex3 ("Tex3", 2D) = ""
}
SubShader {
Tags{ "Queue"="AlphaTest" "RenderType"="TransparentCutout" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert alphatest:_Cutoff
sampler2D _MainTex;
fixed4 _Color;
struct Input { float2 uv_MainTex; };
void surf (Input IN, inout SurfaceOutput o) {
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
CGPROGRAM
#pragma surface surf Lambert alphatest:_Cutoff
sampler2D _MainTex1;
fixed4 _Color;
struct Input { float2 uv_MainTex; };
void surf (Input IN, inout SurfaceOutput o) {
fixed4 c = tex2D(_MainTex1, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
CGPROGRAM
#pragma surface surf Lambert alphatest:_Cutoff
sampler2D _MainTex2;
fixed4 _Color;
struct Input { float2 uv_MainTex; };
void surf (Input IN, inout SurfaceOutput o) {
fixed4 c = tex2D(_MainTex2, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
CGPROGRAM
#pragma surface surf Lambert alphatest:_Cutoff
sampler2D _MainTex3;
fixed4 _Color;
struct Input { float2 uv_MainTex; };
void surf (Input IN, inout SurfaceOutput o) {
fixed4 c = tex2D(_MainTex3, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
Fallback "TransparentDiffuse"
}
TransparentDiffuse shader
Shader "TransparentDiffuse"
{
Properties
{
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
}
SubShader
{
Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"}
blend SrcAlpha OneMinusSrcAlpha
LOD 200
ZWrite Off
CGPROGRAM
#pragma surface surf Lambert exclude_path:prepass
sampler2D _MainTex;
fixed4 _Color;
struct Input
{
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o)
{
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
SubShader
{
Pass
{
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
Material
{
Diffuse [_Color]
Ambient [_Color]
}
Lighting On
SetTexture [_MainTex]
{
Combine texture * primary DOUBLE, texture * primary
}
}
}
Fallback "VertexLit"
}
For this result (two planes. one with this shader):
Any idea about how to do this faster? Im noob at shading so I feel like doing something is wrong here.