#version 300 es
out mediump vec4 _fragData;
uniform sampler2D _CameraDepthTexture;
uniform sampler2D _CameraNormalsTexture;
uniform highp mat4 _CameraToWorld;
uniform highp vec4 _LightColor;
uniform highp mat4 _LightMatrix0;
uniform highp vec4 _LightPos;
uniform highp vec4 _LightPositionRange;
uniform highp vec4 _LightShadowData;
uniform lowp samplerCube _LightTexture0;
uniform sampler2D _LightTextureB0;
uniform highp vec4 _ProjectionParams;
uniform lowp samplerCube _ShadowMapTexture;
uniform highp vec3 _WorldSpaceCameraPos;
uniform highp vec4 _ZBufferParams;
uniform highp vec4 unity_LightmapFade;
in highp vec4 xlv_TEXCOORD0;
in highp vec3 xlv_TEXCOORD1;
void main ()
{
  mediump vec4 res_1;
  highp float spec_2;
  mediump vec3 h_3;
  highp float atten_4;
  mediump vec3 lightDir_5;
  highp vec3 tolight_6;
  highp vec3 wpos_7;
  highp float depth_8;
  mediump vec3 normal_9;
  mediump vec4 nspec_10;
  highp vec2 uv_11;
  uv_11 = (xlv_TEXCOORD0.xy / xlv_TEXCOORD0.w);
  lowp vec4 tmpvar_12;
  tmpvar_12 = texture (_CameraNormalsTexture, uv_11);
  nspec_10 = tmpvar_12;
  normal_9 = ((nspec_10.xyz * 2.0) - 1.0);
  normal_9 = normalize(normal_9);
  lowp vec4 tmpvar_13;
  tmpvar_13 = texture (_CameraDepthTexture, uv_11);
  depth_8 = tmpvar_13.x;
  highp float tmpvar_14;
  tmpvar_14 = (1.0/(((_ZBufferParams.x * depth_8) + _ZBufferParams.y)));
  depth_8 = tmpvar_14;
  highp vec4 tmpvar_15;
  tmpvar_15.w = 1.0;
  tmpvar_15.xyz = ((xlv_TEXCOORD1 * (_ProjectionParams.z / xlv_TEXCOORD1.z)) * tmpvar_14);
  wpos_7 = (_CameraToWorld * tmpvar_15).xyz;
  tolight_6 = (wpos_7 - _LightPos.xyz);
  highp vec3 tmpvar_16;
  tmpvar_16 = normalize(tolight_6);
  lightDir_5 = -(tmpvar_16);
  highp vec2 tmpvar_17;
  tmpvar_17 = vec2((dot (tolight_6, tolight_6) * _LightPos.w));
  lowp vec4 tmpvar_18;
  tmpvar_18 = texture (_LightTextureB0, tmpvar_17);
  atten_4 = tmpvar_18.w;
  highp float mydist_19;
  mydist_19 = (sqrt(dot (tolight_6, tolight_6)) * _LightPositionRange.w);
  mydist_19 = (mydist_19 * 0.97);
  highp vec4 shadowVals_20;
  highp vec3 vec_21;
  vec_21 = (tolight_6 + vec3(0.0078125, 0.0078125, 0.0078125));
  highp vec4 packDist_22;
  lowp vec4 tmpvar_23;
  tmpvar_23 = texture (_ShadowMapTexture, vec_21);
  packDist_22 = tmpvar_23;
  shadowVals_20.x = dot (packDist_22, vec4(1.0, 0.00392157, 1.53787e-05, 6.22737e-09));
  highp vec3 vec_24;
  vec_24 = (tolight_6 + vec3(-0.0078125, -0.0078125, 0.0078125));
  highp vec4 packDist_25;
  lowp vec4 tmpvar_26;
  tmpvar_26 = texture (_ShadowMapTexture, vec_24);
  packDist_25 = tmpvar_26;
  shadowVals_20.y = dot (packDist_25, vec4(1.0, 0.00392157, 1.53787e-05, 6.22737e-09));
  highp vec3 vec_27;
  vec_27 = (tolight_6 + vec3(-0.0078125, 0.0078125, -0.0078125));
  highp vec4 packDist_28;
  lowp vec4 tmpvar_29;
  tmpvar_29 = texture (_ShadowMapTexture, vec_27);
  packDist_28 = tmpvar_29;
  shadowVals_20.z = dot (packDist_28, vec4(1.0, 0.00392157, 1.53787e-05, 6.22737e-09));
  highp vec3 vec_30;
  vec_30 = (tolight_6 + vec3(0.0078125, -0.0078125, -0.0078125));
  highp vec4 packDist_31;
  lowp vec4 tmpvar_32;
  tmpvar_32 = texture (_ShadowMapTexture, vec_30);
  packDist_31 = tmpvar_32;
  shadowVals_20.w = dot (packDist_31, vec4(1.0, 0.00392157, 1.53787e-05, 6.22737e-09));
  bvec4 tmpvar_33;
  tmpvar_33 = lessThan (shadowVals_20, vec4(mydist_19));
  highp vec4 tmpvar_34;
  tmpvar_34 = _LightShadowData.xxxx;
  highp float tmpvar_35;
  if (tmpvar_33.x) {
    tmpvar_35 = tmpvar_34.x;
  } else {
    tmpvar_35 = 1.0;
  };
  highp float tmpvar_36;
  if (tmpvar_33.y) {
    tmpvar_36 = tmpvar_34.y;
  } else {
    tmpvar_36 = 1.0;
  };
  highp float tmpvar_37;
  if (tmpvar_33.z) {
    tmpvar_37 = tmpvar_34.z;
  } else {
    tmpvar_37 = 1.0;
  };
  highp float tmpvar_38;
  if (tmpvar_33.w) {
    tmpvar_38 = tmpvar_34.w;
  } else {
    tmpvar_38 = 1.0;
  };
  mediump vec4 tmpvar_39;
  tmpvar_39.x = tmpvar_35;
  tmpvar_39.y = tmpvar_36;
  tmpvar_39.z = tmpvar_37;
  tmpvar_39.w = tmpvar_38;
  mediump float tmpvar_40;
  tmpvar_40 = dot (tmpvar_39, vec4(0.25, 0.25, 0.25, 0.25));
  atten_4 = (atten_4 * tmpvar_40);
  highp vec4 tmpvar_41;
  tmpvar_41.w = 1.0;
  tmpvar_41.xyz = wpos_7;
  lowp vec4 tmpvar_42;
  highp vec3 P_43;
  P_43 = (_LightMatrix0 * tmpvar_41).xyz;
  tmpvar_42 = texture (_LightTexture0, P_43);
  atten_4 = (atten_4 * tmpvar_42.w);
  highp vec3 tmpvar_44;
  tmpvar_44 = normalize((lightDir_5 - normalize(
    (wpos_7 - _WorldSpaceCameraPos)
  )));
  h_3 = tmpvar_44;
  mediump float tmpvar_45;
  tmpvar_45 = pow (max (0.0, dot (h_3, normal_9)), (nspec_10.w * 128.0));
  spec_2 = tmpvar_45;
  spec_2 = (spec_2 * clamp (atten_4, 0.0, 1.0));
  res_1.xyz = (_LightColor.xyz * (max (0.0, 
    dot (lightDir_5, normal_9)
  ) * atten_4));
  mediump vec3 c_46;
  c_46 = _LightColor.xyz;
  res_1.w = (spec_2 * dot (c_46, vec3(0.22, 0.707, 0.071)));
  highp float tmpvar_47;
  tmpvar_47 = clamp ((1.0 - (
    (tmpvar_15.z * unity_LightmapFade.z)
   + unity_LightmapFade.w)), 0.0, 1.0);
  res_1 = (res_1 * tmpvar_47);
  _fragData = exp2(-(res_1));
}


// stats: 62 alu 8 tex 4 flow
// inputs: 2
//  #0: xlv_TEXCOORD0 (high float) 4x1 [-1]
//  #1: xlv_TEXCOORD1 (high float) 3x1 [-1]
// uniforms: 10 (total size: 0)
//  #0: _CameraToWorld (high float) 4x4 [-1]
//  #1: _LightColor (high float) 4x1 [-1]
//  #2: _LightMatrix0 (high float) 4x4 [-1]
//  #3: _LightPos (high float) 4x1 [-1]
//  #4: _LightPositionRange (high float) 4x1 [-1]
//  #5: _LightShadowData (high float) 4x1 [-1]
//  #6: _ProjectionParams (high float) 4x1 [-1]
//  #7: _WorldSpaceCameraPos (high float) 3x1 [-1]
//  #8: _ZBufferParams (high float) 4x1 [-1]
//  #9: unity_LightmapFade (high float) 4x1 [-1]
// textures: 5
//  #0: _CameraDepthTexture (low 2d) 0x0 [-1]
//  #1: _CameraNormalsTexture (low 2d) 0x0 [-1]
//  #2: _LightTexture0 (low cube) 0x0 [-1]
//  #3: _LightTextureB0 (low 2d) 0x0 [-1]
//  #4: _ShadowMapTexture (low cube) 0x0 [-1]
