Created
April 1, 2013 16:37
-
-
Save disjukr/5286051 to your computer and use it in GitHub Desktop.
unity3d shader for terrain
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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