#include <metal_stdlib>
#pragma clang diagnostic ignored "-Wparentheses-equality"
using namespace metal;
struct xlatMtlShaderInput {
  float2 xlv_TEXCOORD0;
  float3 xlv_TEXCOORD1;
  float3 xlv_TEXCOORD2;
  float3 xlv_TEXCOORD3;
  float3 xlv_TEXCOORD4;
};
struct xlatMtlShaderOutput {
  half4 _fragData [[color(0)]];
};
struct xlatMtlShaderUniform {
  half4 UNITY_LIGHTMODEL_AMBIENT;
  half _Cutoff;
  half4 _SpecColor;
  float4 _TerrainTreeLightColors[4];
  half3 _TranslucencyColor;
};
fragment xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]], constant xlatMtlShaderUniform& _mtl_u [[buffer(0)]]
  ,   texture2d<half> _BumpSpecMap [[texture(0)]], sampler _mtlsmp__BumpSpecMap [[sampler(0)]]
  ,   texture2d<half> _MainTex [[texture(1)]], sampler _mtlsmp__MainTex [[sampler(1)]]
  ,   texture2d<half> _TranslucencyMap [[texture(2)]], sampler _mtlsmp__TranslucencyMap [[sampler(2)]])
{
  xlatMtlShaderOutput _mtl_o;
  half4 c_1;
  half nh_2;
  half nl_3;
  half3 lightColor_4;
  half3 backContribs_5;
  half3 light_6;
  half gloss_7;
  half specular_8;
  half3 albedo_9;
  half4 tmpvar_10;
  tmpvar_10 = _MainTex.sample(_mtlsmp__MainTex, (float2)(_mtl_i.xlv_TEXCOORD0));
  half x_11;
  x_11 = (tmpvar_10.w - _mtl_u._Cutoff);
  if ((x_11 < (half)0.0)) {
    discard_fragment();
  };
  albedo_9 = half3(((float3)tmpvar_10.xyz * _mtl_i.xlv_TEXCOORD1));
  half4 tmpvar_12;
  tmpvar_12 = _BumpSpecMap.sample(_mtlsmp__BumpSpecMap, (float2)(_mtl_i.xlv_TEXCOORD0));
  specular_8 = (tmpvar_12.x * (half)128.0);
  half4 tmpvar_13;
  tmpvar_13 = _TranslucencyMap.sample(_mtlsmp__TranslucencyMap, (float2)(_mtl_i.xlv_TEXCOORD0));
  gloss_7 = tmpvar_13.w;
  light_6 = (_mtl_u.UNITY_LIGHTMODEL_AMBIENT.xyz * albedo_9);
  backContribs_5 = half3((_mtl_i.xlv_TEXCOORD2 * (float)tmpvar_13.z));
  lightColor_4 = half3(_mtl_u._TerrainTreeLightColors[0].xyz);
  nl_3 = half(_mtl_i.xlv_TEXCOORD3.x);
  nh_2 = half(_mtl_i.xlv_TEXCOORD4.x);
  light_6 = (light_6 + ((
    (albedo_9 * ((backContribs_5.x * _mtl_u._TranslucencyColor) + nl_3))
   + 
    (_mtl_u._SpecColor.xyz * (pow (nh_2, specular_8) * gloss_7))
  ) * lightColor_4));
  lightColor_4 = half3(_mtl_u._TerrainTreeLightColors[1].xyz);
  nl_3 = half(_mtl_i.xlv_TEXCOORD3.y);
  nh_2 = half(_mtl_i.xlv_TEXCOORD4.y);
  light_6 = (light_6 + ((
    (albedo_9 * ((backContribs_5.y * _mtl_u._TranslucencyColor) + nl_3))
   + 
    (_mtl_u._SpecColor.xyz * (pow (nh_2, specular_8) * gloss_7))
  ) * lightColor_4));
  lightColor_4 = half3(_mtl_u._TerrainTreeLightColors[2].xyz);
  nl_3 = half(_mtl_i.xlv_TEXCOORD3.z);
  nh_2 = half(_mtl_i.xlv_TEXCOORD4.z);
  light_6 = (light_6 + ((
    (albedo_9 * ((backContribs_5.z * _mtl_u._TranslucencyColor) + nl_3))
   + 
    (_mtl_u._SpecColor.xyz * (pow (nh_2, specular_8) * gloss_7))
  ) * lightColor_4));
  c_1.xyz = (light_6 * (half)2.0);
  c_1.w = half(1.0);
  _mtl_o._fragData = c_1;
  return _mtl_o;
}


// stats: 35 alu 4 tex 1 flow
// inputs: 5
//  #0: xlv_TEXCOORD0 (high float) 2x1 [-1]
//  #1: xlv_TEXCOORD1 (high float) 3x1 [-1]
//  #2: xlv_TEXCOORD2 (high float) 3x1 [-1]
//  #3: xlv_TEXCOORD3 (high float) 3x1 [-1]
//  #4: xlv_TEXCOORD4 (high float) 3x1 [-1]
// uniforms: 5 (total size: 104)
//  #0: UNITY_LIGHTMODEL_AMBIENT (low float) 4x1 [-1] loc 0
//  #1: _Cutoff (low float) 1x1 [-1] loc 8
//  #2: _SpecColor (low float) 4x1 [-1] loc 16
//  #3: _TerrainTreeLightColors (high float) 4x1 [4] loc 32
//  #4: _TranslucencyColor (low float) 3x1 [-1] loc 96
// textures: 3
//  #0: _BumpSpecMap (low 2d) 0x0 [-1] loc 0
//  #1: _MainTex (low 2d) 0x0 [-1] loc 1
//  #2: _TranslucencyMap (low 2d) 0x0 [-1] loc 2
