struct appdata_full { float4 vertex : POSITION; float3 normal : NORMAL; float4 tangent : TANGENT; float2 texcoord; }; float4x4 UNITY_MATRIX_IT_MV; float4x4 UNITY_MATRIX_MVP; fixed4 UNITY_LIGHTMODEL_AMBIENT; struct v2f { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float3 color : TEXCOORD1; float3 backContrib : TEXCOORD2; float3 nl : TEXCOORD3; float3 nh : TEXCOORD4; }; float4 _TerrainTreeLightColors[4]; sampler2D _MainTex; sampler2D _BumpSpecMap; sampler2D _TranslucencyMap; fixed _Cutoff; fixed3 _TranslucencyColor; fixed4 _SpecColor; fixed4 main (v2f i) : COLOR { fixed4 col = tex2D (_MainTex, i.uv); clip (col.a - _Cutoff); fixed3 albedo = col.rgb * i.color; half specular = tex2D (_BumpSpecMap, i.uv).r * 128.0; fixed4 trngls = tex2D (_TranslucencyMap, i.uv); half gloss = trngls.a; half3 light = UNITY_LIGHTMODEL_AMBIENT * albedo; half3 backContribs = i.backContrib * trngls.b; for (int j = 0; j < 3; j++) { half3 lightColor = _TerrainTreeLightColors[j].rgb; half3 translucencyColor = backContribs[j] * _TranslucencyColor; half nl = i.nl[j]; half nh = i.nh[j]; half spec = pow (nh, specular) * gloss; light += (albedo * (translucencyColor + nl) + _SpecColor.rgb * spec) * lightColor; } fixed4 c; c.rgb = light * 2.0; c.a = 1; return c; }