#include <metal_stdlib>
#pragma clang diagnostic ignored "-Wparentheses-equality"
using namespace metal;
struct xlatMtlShaderInput {
  float4 _inVertex [[attribute(0)]];
  half3 _inNormal [[attribute(1)]];
  float4 _uv0 [[attribute(2)]];
  float4 _uv1 [[attribute(3)]];
  half4 _color [[attribute(4)]];
};
struct xlatMtlShaderOutput {
  float4 gl_Position [[position]];
  float2 xlv_TEXCOORD0;
  half4 xlv_TEXCOORD1;
};
struct xlatMtlShaderUniform {
  float _Bias;
  float _BlinkingTimeOffsScale;
  float4 _Color;
  float _FadeOutDistFar;
  float _FadeOutDistNear;
  float _MaxGrowSize;
  float _Multiplier;
  float _NoiseAmount;
  float _SizeGrowEndDist;
  float _SizeGrowStartDist;
  float4 _Time;
  float _TimeOffDuration;
  float _TimeOnDuration;
  float _VerticalBillboarding;
  float4x4 _World2Object;
  float3 _WorldSpaceCameraPos;
  float4x4 glstate_matrix_mvp;
};
vertex xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]], constant xlatMtlShaderUniform& _mtl_u [[buffer(0)]])
{
  xlatMtlShaderOutput _mtl_o;
  float3 tmpvar_1 = 0;
  float4 tmpvar_2 = 0;
  tmpvar_1 = float3(_mtl_i._inNormal);
  tmpvar_2 = float4(_mtl_i._color);
  half4 tmpvar_3 = 0;
  float noiseWave_4 = 0;
  float noiseTime_5 = 0;
  float wave_6 = 0;
  float time_7 = 0;
  float3 BBLocalPos_8 = 0;
  float3 localDir_9 = 0;
  float3 centerLocal_10 = 0;
  float3 centerOffs_11 = 0;
  float3 tmpvar_12 = 0;
  tmpvar_12.z = 0.0;
  tmpvar_12.xy = (float2(0.5, 0.5) - tmpvar_2.xy);
  centerOffs_11 = (tmpvar_12 * _mtl_i._uv1.xyy);
  centerLocal_10 = (_mtl_i._inVertex.xyz + centerOffs_11);
  float4 tmpvar_13 = 0;
  tmpvar_13.w = 1.0;
  tmpvar_13.xyz = _mtl_u._WorldSpaceCameraPos;
  localDir_9 = ((_mtl_u._World2Object * tmpvar_13).xyz - centerLocal_10);
  localDir_9.y = (localDir_9.y * _mtl_u._VerticalBillboarding);
  float tmpvar_14 = 0;
  tmpvar_14 = sqrt(dot (localDir_9, localDir_9));
  float3 dir_15 = 0;
  dir_15 = (localDir_9 / tmpvar_14);
  float tmpvar_16 = 0;
  tmpvar_16 = abs(dir_15.y);
  float3 tmpvar_17 = 0;
  if ((tmpvar_16 > 0.999)) {
    tmpvar_17 = float3(0.0, 0.0, 1.0);
  } else {
    tmpvar_17 = float3(0.0, 1.0, 0.0);
  };
  float3 tmpvar_18 = 0;
  tmpvar_18 = normalize(((tmpvar_17.yzx * dir_15.zxy) - (tmpvar_17.zxy * dir_15.yzx)));
  float3 tmpvar_19 = 0;
  tmpvar_19 = ((dir_15.yzx * tmpvar_18.zxy) - (dir_15.zxy * tmpvar_18.yzx));
  float tmpvar_20 = 0;
  tmpvar_20 = min ((max (
    (tmpvar_14 - _mtl_u._SizeGrowStartDist)
  , 0.0) / _mtl_u._SizeGrowEndDist), 1.0);
  BBLocalPos_8 = ((centerLocal_10 - (
    (tmpvar_18 * centerOffs_11.x)
   + 
    (tmpvar_19 * centerOffs_11.y)
  )) + ((
    (tmpvar_18 * tmpvar_1.x)
   + 
    (tmpvar_19 * tmpvar_1.y)
  ) * (
    (tmpvar_20 * tmpvar_20)
   * 
    (_mtl_u._MaxGrowSize * tmpvar_2.w)
  )));
  time_7 = (_mtl_u._Time.y + (_mtl_u._BlinkingTimeOffsScale * tmpvar_2.z));
  float y_21 = 0;
  y_21 = (_mtl_u._TimeOnDuration + _mtl_u._TimeOffDuration);
  float tmpvar_22 = 0;
  tmpvar_22 = (time_7 / y_21);
  float tmpvar_23 = 0;
  tmpvar_23 = (fract(abs(tmpvar_22)) * y_21);
  float tmpvar_24 = 0;
  if ((tmpvar_22 >= 0.0)) {
    tmpvar_24 = tmpvar_23;
  } else {
    tmpvar_24 = -(tmpvar_23);
  };
  float tmpvar_25 = 0;
  tmpvar_25 = clamp ((tmpvar_24 / (_mtl_u._TimeOnDuration * 0.25)), 0.0, 1.0);
  float edge0_26 = 0;
  edge0_26 = (_mtl_u._TimeOnDuration * 0.75);
  float tmpvar_27 = 0;
  tmpvar_27 = clamp (((tmpvar_24 - edge0_26) / (_mtl_u._TimeOnDuration - edge0_26)), 0.0, 1.0);
  wave_6 = ((tmpvar_25 * (tmpvar_25 * 
    (3.0 - (2.0 * tmpvar_25))
  )) * (1.0 - (tmpvar_27 * 
    (tmpvar_27 * (3.0 - (2.0 * tmpvar_27)))
  )));
  noiseTime_5 = (time_7 * (6.28319 / _mtl_u._TimeOnDuration));
  noiseWave_4 = ((_mtl_u._NoiseAmount * (
    sin(noiseTime_5)
   * 
    ((0.5 * cos((
      (noiseTime_5 * 0.6366)
     + 56.7272))) + 0.5)
  )) + (1.0 - _mtl_u._NoiseAmount));
  float tmpvar_28 = 0;
  if ((_mtl_u._NoiseAmount < 0.01)) {
    tmpvar_28 = wave_6;
  } else {
    tmpvar_28 = noiseWave_4;
  };
  wave_6 = (tmpvar_28 + _mtl_u._Bias);
  float4 tmpvar_29 = 0;
  tmpvar_29.w = 1.0;
  tmpvar_29.xyz = BBLocalPos_8;
  float ffadeout_30 = 0;
  float nfadeout_31 = 0;
  float tmpvar_32 = 0;
  tmpvar_32 = clamp ((tmpvar_14 / _mtl_u._FadeOutDistNear), 0.0, 1.0);
  ffadeout_30 = (1.0 - clamp ((
    max ((tmpvar_14 - _mtl_u._FadeOutDistFar), 0.0)
   * 0.2), 0.0, 1.0));
  ffadeout_30 = (ffadeout_30 * ffadeout_30);
  nfadeout_31 = (tmpvar_32 * tmpvar_32);
  nfadeout_31 = (nfadeout_31 * nfadeout_31);
  nfadeout_31 = (nfadeout_31 * ffadeout_30);
  tmpvar_3 = half4(((nfadeout_31 * _mtl_u._Color) * (_mtl_u._Multiplier * wave_6)));
  _mtl_o.gl_Position = (_mtl_u.glstate_matrix_mvp * tmpvar_29);
  _mtl_o.xlv_TEXCOORD0 = _mtl_i._uv0.xy;
  _mtl_o.xlv_TEXCOORD1 = tmpvar_3;
  return _mtl_o;
}


// stats: 95 alu 0 tex 3 flow
// inputs: 5
//  #0: _inVertex (high float) 4x1 [-1] loc 0
//  #1: _inNormal (medium float) 3x1 [-1] loc 1
//  #2: _uv0 (high float) 4x1 [-1] loc 2
//  #3: _uv1 (high float) 4x1 [-1] loc 3
//  #4: _color (low float) 4x1 [-1] loc 4
// uniforms: 17 (total size: 240)
//  #0: _Bias (high float) 1x1 [-1] loc 0
//  #1: _BlinkingTimeOffsScale (high float) 1x1 [-1] loc 4
//  #2: _Color (high float) 4x1 [-1] loc 16
//  #3: _FadeOutDistFar (high float) 1x1 [-1] loc 32
//  #4: _FadeOutDistNear (high float) 1x1 [-1] loc 36
//  #5: _MaxGrowSize (high float) 1x1 [-1] loc 40
//  #6: _Multiplier (high float) 1x1 [-1] loc 44
//  #7: _NoiseAmount (high float) 1x1 [-1] loc 48
//  #8: _SizeGrowEndDist (high float) 1x1 [-1] loc 52
//  #9: _SizeGrowStartDist (high float) 1x1 [-1] loc 56
//  #10: _Time (high float) 4x1 [-1] loc 64
//  #11: _TimeOffDuration (high float) 1x1 [-1] loc 80
//  #12: _TimeOnDuration (high float) 1x1 [-1] loc 84
//  #13: _VerticalBillboarding (high float) 1x1 [-1] loc 88
//  #14: _World2Object (high float) 4x4 [-1] loc 96
//  #15: _WorldSpaceCameraPos (high float) 3x1 [-1] loc 160
//  #16: glstate_matrix_mvp (high float) 4x4 [-1] loc 176
