// hlsltool.py -I ../.. --auto-fix-vertex-halo --fix-unity-reflection --fix-unity-frustum-world --only-autofixed --fxc /home/Ryan/fxc.exe ba46c33c8682f6f3-vs_replace.txt
// 3DMigoto: ba46c33c8682f6f3 |    Unity headers extracted from Normal-Bumped.shader
//    Shader "Legacy Shaders/Bumped Diffuse" {
//      Properties {
//       _Color ("Main Color", Color) = (1,1,1,1)
//       _MainTex ("Base (RGB)", 2D) = "white" { }
//       _BumpMap ("Normalmap", 2D) = "bump" { }
//      }
//      Fallback "Legacy Shaders/Diffuse"
//      SubShader 1/1 {
//        LOD 300
//        Tags { "RenderType"="Opaque" }
//        Pass 1/5 {
//          Name "FORWARD"
//          Tags { "LIGHTMODE"="ForwardBase" "SHADOWSUPPORT"="true" "RenderType"="Opaque" }
//          GpuProgramID 38214
//          Program "vp" {
//            SubProgram "d3d11 " {
//              GpuProgramIndex 19
//            }
//          }
//        }
//      }
//    }
//
// Unity 5.3 headers extracted from Normal-Bumped.shader.decompressed:
//   API d3d11
//   Shader model vs_4_0
//   undeciphered1: 74 0 0
//   Keywords { "DIRECTIONAL" "SHADOWS_OFF" "LIGHTMAP_OFF" "DIRLIGHTMAP_OFF" "DYNAMICLIGHTMAP_OFF" "FOG_LINEAR" "VERTEXLIGHT_ON" }
//   undeciphered2: 1 0 4 0 0
//   undeciphered3: 143 5 0 0 2 1 1 2 3 4 7 8
//   ConstBuffer "$Globals" 176
//   Vector 48 [unity_ColorSpaceLuminance]
//   Vector 144 [_MainTex_ST]
//   Vector 160 [_BumpMap_ST]
//   ConstBuffer "UnityLighting" 720
//   Vector 32 [unity_4LightPosX0]
//   Vector 48 [unity_4LightPosY0]
//   Vector 64 [unity_4LightPosZ0]
//   Vector 80 [unity_4LightAtten0]
//   Vector 96 [unity_LightColor0]
//   Vector 112 [unity_LightColor1]
//   Vector 128 [unity_LightColor2]
//   Vector 144 [unity_LightColor3]
//   Vector 160 [unity_LightColor4]
//   Vector 176 [unity_LightColor5]
//   Vector 192 [unity_LightColor6]
//   Vector 208 [unity_LightColor7]
//   Vector 608 [unity_SHAr]
//   Vector 624 [unity_SHAg]
//   Vector 640 [unity_SHAb]
//   Vector 656 [unity_SHBr]
//   Vector 672 [unity_SHBg]
//   Vector 688 [unity_SHBb]
//   Vector 704 [unity_SHC]
//   ConstBuffer "UnityPerDraw" 352
//   Vector 336 [unity_WorldTransformParams]
//   Matrix 0 [glstate_matrix_mvp]
//   Matrix 192 [_Object2World]
//   Matrix 256 [_World2Object]
//   ConstBuffer "UnityFog" 32
//   Vector 16 [unity_FogParams]
//   BindCB "$Globals" 0
//   BindCB "UnityLighting" 1
//   BindCB "UnityPerDraw" 2
//   BindCB "UnityFog" 3
//
// Headers extracted with DarkStarSword's extract_unity53_shaders.py
// https://raw.githubusercontent.com/DarkStarSword/3d-fixes/master/extract_unity53_shaders.py

// ---- Created with 3Dmigoto v1.2.30 on Thu Aug 18 03:40:33 2016
cbuffer cb3 : register(b3)
{
  float4 cb3[2];
}

cbuffer cb2 : register(b2)
{
  float4 cb2[22];
}

cbuffer cb1 : register(b1)
{
  float4 cb1[45];
}

cbuffer cb0 : register(b0)
{
  float4 cb0[11];
}




// 3Dmigoto declarations
#define cmp -
Texture1D<float4> IniParams : register(t120);
Texture2D<float4> StereoParams : register(t125);


void main( 
  float4 v0 : POSITION0,
  float4 v1 : TANGENT0,
  float3 v2 : NORMAL0,
  float4 v3 : TEXCOORD0,
  float4 v4 : TEXCOORD1,
  float4 v5 : TEXCOORD2,
  float4 v6 : TEXCOORD3,
  float4 v7 : COLOR0,
  out float4 o0 : SV_POSITION0,
  out float4 o1 : TEXCOORD0,
  out float4 o2 : TEXCOORD1,
  out float4 o3 : TEXCOORD2,
  out float4 o4 : TEXCOORD3,
  out float3 o5 : TEXCOORD4,
  out float p5 : TEXCOORD6)
{
  float4 r0,r1,r2,r3,r4,r5;
  uint4 bitmask, uiDest;
  float4 fDest;

float4 stereo = StereoParams.Load(0);
float separation = stereo.x, convergence = stereo.y, eye = stereo.z;

  r0.xyzw = cb2[1].xyzw * v0.yyyy;
  r0.xyzw = cb2[0].xyzw * v0.xxxx + r0.xyzw;
  r0.xyzw = cb2[2].xyzw * v0.zzzz + r0.xyzw;
  r0.xyzw = cb2[3].xyzw * v0.wwww + r0.xyzw;
  o0.xyzw = r0.xyzw;

// Automatic vertex shader halo fix inserted with DarkStarSword's hlsltool.py:
// hlsltool.py -I ../.. --auto-fix-vertex-halo --fix-unity-reflection --fix-unity-frustum-world --only-autofixed --fxc /home/Ryan/fxc.exe ba46c33c8682f6f3-vs_replace.txt
if (r0.w != 1.0) { r0.x += separation * (r0.w - convergence); }

  p5.x = r0.z * cb3[1].z + cb3[1].w;
  o1.xy = v3.xy * cb0[9].xy + cb0[9].zw;
  o1.zw = v3.xy * cb0[10].xy + cb0[10].zw;
  r0.xyz = cb2[13].yzx * v1.yyy;
  r0.xyz = cb2[12].yzx * v1.xxx + r0.xyz;
  r0.xyz = cb2[14].yzx * v1.zzz + r0.xyz;
  r0.w = dot(r0.xyz, r0.xyz);
  r0.w = rsqrt(r0.w);
  r0.xyz = r0.xyz * r0.www;
  o2.x = r0.z;
  r0.w = cb2[21].w * v1.w;
  r1.x = cb2[16].x * v2.x;
  r1.y = cb2[17].x * v2.x;
  r1.z = cb2[18].x * v2.x;
  r2.x = cb2[16].y * v2.y;
  r2.y = cb2[17].y * v2.y;
  r2.z = cb2[18].y * v2.y;
  r1.xyz = r2.xyz + r1.xyz;
  r2.x = cb2[16].z * v2.z;
  r2.y = cb2[17].z * v2.z;
  r2.z = cb2[18].z * v2.z;
  r1.xyz = r2.xyz + r1.xyz;
  r1.w = dot(r1.xyz, r1.xyz);
  r1.w = rsqrt(r1.w);
  r1.xyz = r1.xyz * r1.www;
  r2.xyz = r1.zxy * r0.xyz;
  r2.xyz = r1.yzx * r0.yzx + -r2.xyz;
  r2.xyz = r2.xyz * r0.www;
  o2.y = r2.x;
  o2.z = r1.x;
  r3.xyz = cb2[13].xyz * v0.yyy;
  r3.xyz = cb2[12].xyz * v0.xxx + r3.xyz;
  r3.xyz = cb2[14].xyz * v0.zzz + r3.xyz;
  r3.xyz = cb2[15].xyz * v0.www + r3.xyz;
  o2.w = r3.x;
  o3.x = r0.x;
  o4.x = r0.y;
  o3.y = r2.y;
  o4.y = r2.z;
  o3.z = r1.y;
  o3.w = r3.y;
  o4.w = r3.z;
  o4.z = r1.z;
  r0.x = r1.y * r1.y;
  r0.x = r1.x * r1.x + -r0.x;
  r2.xyzw = r1.xyzz * r1.yzzx;
  r4.x = dot(cb1[41].xyzw, r2.xyzw);
  r4.y = dot(cb1[42].xyzw, r2.xyzw);
  r4.z = dot(cb1[43].xyzw, r2.xyzw);
  r0.xyz = cb1[44].xyz * r0.xxx + r4.xyz;
  r1.w = 1;
  r2.x = dot(cb1[38].xyzw, r1.xyzw);
  r2.y = dot(cb1[39].xyzw, r1.xyzw);
  r2.z = dot(cb1[40].xyzw, r1.xyzw);
  r0.xyz = r2.xyz + r0.xyz;
  r2.xyz = max(float3(0,0,0), r0.xyz);
  r2.xyz = log2(r2.xyz);
  r2.xyz = float3(0.416666657,0.416666657,0.416666657) * r2.xyz;
  r2.xyz = exp2(r2.xyz);
  r2.xyz = r2.xyz * float3(1.05499995,1.05499995,1.05499995) + float3(-0.0549999997,-0.0549999997,-0.0549999997);
  r2.xyz = max(float3(0,0,0), r2.xyz);
  r0.w = cmp(cb0[3].w == 0.000000);
  r0.xyz = r0.www ? r2.xyz : r0.xyz;
  r0.xyz = max(float3(0,0,0), r0.xyz);
  r2.xyzw = cb1[3].xyzw + -r3.yyyy;
  r4.xyzw = r2.xyzw * r1.yyyy;
  r2.xyzw = r2.xyzw * r2.xyzw;
  r5.xyzw = cb1[2].xyzw + -r3.xxxx;
  r3.xyzw = cb1[4].xyzw + -r3.zzzz;
  r4.xyzw = r5.xyzw * r1.xxxx + r4.xyzw;
  r1.xyzw = r3.xyzw * r1.zzzz + r4.xyzw;
  r2.xyzw = r5.xyzw * r5.xyzw + r2.xyzw;
  r2.xyzw = r3.xyzw * r3.xyzw + r2.xyzw;
  r3.xyzw = rsqrt(r2.xyzw);
  r2.xyzw = r2.xyzw * cb1[5].xyzw + float4(1,1,1,1);
  r2.xyzw = float4(1,1,1,1) / r2.xyzw;
  r1.xyzw = r3.xyzw * r1.xyzw;
  r1.xyzw = max(float4(0,0,0,0), r1.xyzw);
  r1.xyzw = r1.xyzw * r2.xyzw;
  r2.xyz = cb1[7].xyz * r1.yyy;
  r2.xyz = cb1[6].xyz * r1.xxx + r2.xyz;
  r1.xyz = cb1[8].xyz * r1.zzz + r2.xyz;
  r1.xyz = cb1[9].xyz * r1.www + r1.xyz;
  o5.xyz = r1.xyz + r0.xyz;
  return;
}
