Shader "Triplanar3BlendVertexColor" {
Properties {
[Header(Not use model UV mapping)]
[Space]
_bright("Brightness value", Range(0,3)) = 1
_TintColor ("TintColor", Color) = (1,1,1,1)
[Header(Y direction mapping)]
_Y1Scale("Tiling", float) = 1
[NoScaleOffset]_MainTex ("Terrain Base Texture", 2D) = "white" {}
[Header(XZ direction mapping)]
_XScale("Tiling", float) = 1
[NoScaleOffset]_MainTex1 ("XZ Texture", 2D) = "white" {}
_Blend("XZ Blend Range", Range(1,2)) = 1.2
[Space(20)]
[Header(Vertex Color)]
_Y2Scale("R Tiling", float) = 1
_Factor1("R Intensity", Range(0,1.0)) = 1
[NoScaleOffset]_MainTex2 ("Vertex R Texture", 2D) = "white" {}
}
SubShader
{
Tags{ "RenderType" = "Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Unlit interpolateview halfasview noambient noforwardadd nodirlightmap noforwardadd nodynlightmap noshadow novertexlights
fixed4 LightingUnlit(SurfaceOutput s, half3 lightDir, half atten) {
return fixed4(s.Albedo,1);
}
sampler2D _MainTex1;
sampler2D _MainTex;
sampler2D _MainTex2;
fixed _XScale;
fixed _Y1Scale;
fixed _Y2Scale;
fixed _Factor1;
fixed4 _TintColor;
fixed _Blend, _bright;
struct Input {
float3 worldPos;
float3 worldNormal;
fixed4 color:Color;
};
void surf (Input IN, inout SurfaceOutput o) {
float3 projNormal = saturate(pow(IN.worldNormal * _Blend, 2));
//caculate x,y,z direction mapping
fixed3 x = tex2D(_MainTex1, float2(IN.worldPos.zy * _XScale * 0.01)) * abs(IN.worldNormal.x);
fixed3 z = tex2D(_MainTex1, float2(IN.worldPos.xy * _XScale * 0.01)) * abs(IN.worldNormal.z);
fixed3 y = tex2D(_MainTex, float2(IN.worldPos.zx * _Y1Scale * 0.01)) * abs(IN.worldNormal.y);
//blend vertex color channel
fixed3 y1 = lerp (y, tex2D(_MainTex2, float2(IN.worldPos.zx * _Y2Scale * 0.01)) * abs(IN.worldNormal.y), IN.color.r * _Factor1);
//if scale value decide depend on object world scale.
o.Albedo = (z + x) * 0.8;
o.Albedo = lerp(o.Albedo, y1, projNormal.y) * _TintColor * _bright;
}
ENDCG
}
}
'Technical Report > Unity Shader' 카테고리의 다른 글
Unity Stencil buffer Alpha 처리 Shader (0) | 2017.05.12 |
---|---|
Unity 각 Blend Property에 따른 결과 비교 (0) | 2017.04.27 |
Unity Shader Property attributes and drawers (0) | 2017.02.22 |
Unity OpenGL Core Details (1) | 2017.01.23 |
Monitor 그리고, Gamma의 이해 (0) | 2016.12.21 |