2
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.8 KiB
Plaintext

Shader "Custom/Terrain"
{
Properties {
_Color ("Color", Color) = (1,1,1,1)
_BlendMin("BlendMin", Range(0,1)) = 0.5
_BlendMax("BlendMax", Range(0,1)) = 0.6
_MainTex ("MainTexture", 2D) = "white" {}
_MudTex ("Mud", 2D) = "white" {}
_GrassTex ("Grass", 2D) = "white" {}
_NoiseTex ("Noise", 2D) = "white" {}
}
SubShader {
Tags { "RenderType" = "Opaque" }
CGPROGRAM
#pragma surface surf Lambert
#pragma target 3.0
sampler2D _MainTex;
fixed4 _Color;
fixed _BlendMin;
fixed _BlendMax;
sampler2D _MudTex;
sampler2D _GrassTex;
sampler2D _NoiseTex;
struct Input
{
float2 uv_MainTex;
float2 uv_MudTex;
float2 uv_GrassTex;
float2 uv_NoiseTex;
};
void surf (Input IN, inout SurfaceOutput o) {
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
fixed4 mud = tex2D(_MudTex, IN.uv_MudTex);
fixed4 grass = tex2D(_GrassTex, IN.uv_GrassTex);
fixed2 uvNoise = IN.uv_NoiseTex;
uvNoise.x += 0.01*_Time.y;
fixed4 noise = tex2D(_NoiseTex, uvNoise);
fixed3 col =float3(1,1,1);
if(c.r<_BlendMin){
col=grass.rgb;
}
else if(c.r>_BlendMax){
col=mud.rgb;
}
else{
col = lerp(grass.rgb, mud.rgb,(c.r-_BlendMin)/(_BlendMax-_BlendMin));
}
if(noise.r<0.5){
col *=noise*2;
}
o.Albedo = col;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}