Hello! I have this custom terrain shader that works great in the standard render pipeline, but doesn’t support more than 4 terrain textures (after 4 they just don’t show up). Is there an easy way to add the multi-pass support that doesn’t involve invoking the built-in terrain shader splat/cgincs?
Shader "Tome/Tome Terrain"
{
Properties
{
[Header(Greyscale Area)]
_GreyMin ("Grey Min", Range(0,1)) = 0.05
_GreyMax ("Grey Max", Range(0,1)) = 0.5
}
SubShader
{
Tags { "RenderType"="Opaque" "TerrainCompatible"="True"}
LOD 200
CGPROGRAM
#pragma surface surf Lambert fullforwardshadows
#pragma target 3.0
#include "TomeGrey.cginc"
//Splat Map
sampler2D _Control;
// Splat Textures
sampler2D _Splat0, _Splat1, _Splat2, _Splat3;
float4 _Splat0_ST, _Splat1_ST, _Splat2_ST, _Splat3_ST;
sampler2D _Normal0, _Normal1, _Normal2, _Normal3;
float _NormalScale0, _NormalScale1, _NormalScale2, _NormalScale3;
float _GreyMin, _GreyMax;
struct Input
{
float2 uv_Control;
float3 worldPos;
float3 worldNormal;
INTERNAL_DATA
};
fixed4 ApplySplats(Input IN, inout SurfaceOutput o)
{
fixed4 splatControl = tex2D(_Control, IN.uv_Control);
fixed4 col = splatControl.r * tex2D (_Splat0, IN.uv_Control * _Splat0_ST.xy);
col += splatControl.g * tex2D(_Splat1, IN.uv_Control * _Splat1_ST.xy);
col += splatControl.b * tex2D (_Splat2, IN.uv_Control * _Splat2_ST.xy);
col += splatControl.a * tex2D (_Splat3, IN.uv_Control * _Splat3_ST.xy);
o.Normal = splatControl.r * UnpackNormalWithScale(tex2D(_Normal0, IN.uv_Control * _Splat0_ST.xy), _NormalScale0);
o.Normal += splatControl.g * UnpackNormalWithScale(tex2D(_Normal1, IN.uv_Control * _Splat1_ST.xy), _NormalScale1);
o.Normal += splatControl.b * UnpackNormalWithScale(tex2D(_Normal2, IN.uv_Control * _Splat2_ST.xy), _NormalScale2);
o.Normal += splatControl.a * UnpackNormalWithScale(tex2D(_Normal3, IN.uv_Control * _Splat3_ST.xy), _NormalScale3);
return col;
}
void surf (Input IN, inout SurfaceOutput o)
{
fixed4 col = ApplySplats(IN, o);
col = GreyscaleArea(col, IN.worldPos, _Time.y, _GreyMin, _GreyMax);
o.Albedo = col.rgb;
o.Alpha = col.a;
}
ENDCG
}
FallBack "Diffuse"
}