Skip to content

Instantly share code, notes, and snippets.

@disjukr
Created April 1, 2013 16:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save disjukr/5286051 to your computer and use it in GitHub Desktop.
Save disjukr/5286051 to your computer and use it in GitHub Desktop.
unity3d shader for terrain
Shader "Custom/SplattingTerrain"
{
Properties
{
_R ("R channel Image", 2D) = "white" {}
_G ("G channel Image", 2D) = "white" {}
_B ("B channel Image", 2D) = "white" {}
_A ("A channel Image", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf Lambert
struct Input
{
float2 uv_R;
float2 uv_G;
float2 uv_B;
float2 uv_A;
float4 color:COLOR;
};
sampler2D _R;
sampler2D _G;
sampler2D _B;
sampler2D _A;
void surf(Input IN, inout SurfaceOutput o)
{
o.Albedo = tex2D(_R, IN.uv_R).rgb * IN.color.r;
o.Albedo += tex2D(_G, IN.uv_G).rgb * IN.color.g;
o.Albedo += tex2D(_B, IN.uv_B).rgb * IN.color.b;
o.Albedo += tex2D(_A, IN.uv_A).rgb * IN.color.a;
o.Alpha = 1;
}
ENDCG
}
FallBack "Diffuse"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment