// hlsltool.py -I ../.. --auto-fix-vertex-halo --fix-unity-reflection --fix-unity-frustum-world --only-autofixed --fxc /home/Ryan/fxc.exe 761df64c35526057-vs_replace.txt
// 3DMigoto: 761df64c35526057 |    Unity headers extracted from Reflect-VertexLit.shader
//    Shader "Legacy Shaders/Reflective/VertexLit" {
//      Properties {
//       _Color ("Main Color", Color) = (1,1,1,1)
//       _ReflectColor ("Reflection Color", Color) = (1,1,1,0.5)
//       _MainTex ("Base (RGB) RefStrength (A)", 2D) = "white" { }
//       _Cube ("Reflection Cubemap", CUBE) = "_Skybox" { }
//      }
//      Fallback "Legacy Shaders/VertexLit"
//      SubShader 1/1 {
//        LOD 150
//        Tags { "RenderType"="Opaque" }
//        Pass 1/4 {
//          Name "BASE"
//          Tags { "LIGHTMODE"="Always" "RenderType"="Opaque" }
//          GpuProgramID 6413
//          Program "vp" {
//            SubProgram "d3d11 " {
//              GpuProgramIndex 1
//            }
//          }
//        }
//      }
//    }
//
// Unity 5.3 headers extracted from Reflect-VertexLit.shader.decompressed:
//   API d3d11
//   Shader model vs_4_0
//   undeciphered1: 27 0 0
//   undeciphered2: 1 0 3 0 0
//   undeciphered3: 11 3 0 0 1 2 3 4
//   ConstBuffer "$Globals" 128
//   Vector 96 [_MainTex_ST]
//   ConstBuffer "UnityPerCamera" 144
//   Vector 64 [_WorldSpaceCameraPos] 3
//   ConstBuffer "UnityPerDraw" 352
//   Matrix 0 [glstate_matrix_mvp]
//   Matrix 192 [_Object2World]
//   Matrix 256 [_World2Object]
//   BindCB "$Globals" 0
//   BindCB "UnityPerCamera" 1
//   BindCB "UnityPerDraw" 2
//
// 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:38:54 2016
cbuffer cb2 : register(b2)
{
  float4 cb2[22];
}

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

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




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



cbuffer UnityPerDraw : register(b11) {
	float4x4 glstate_matrix_mvp;
	float4x4 glstate_matrix_modelview0;
	float4x4 glstate_matrix_invtrans_modelview0;
	#define UNITY_MATRIX_MVP glstate_matrix_mvp
	#define UNITY_MATRIX_MV glstate_matrix_modelview0
	#define UNITY_MATRIX_IT_MV glstate_matrix_invtrans_modelview0

	uniform float4x4 _Object2World;
	uniform float4x4 _World2Object;
	uniform float4 unity_LODFade; // x is the fade value ranging within [0,1]. y is x quantized into 16 levels
	uniform float4 unity_WorldTransformParams; // w is usually 1.0, or -1.0 for odd-negative scale transforms
}


#include <matrix.hlsl>

void main( 
  float4 v0 : POSITION0,
  float4 v1 : TANGENT0,
  float3 v2 : NORMAL0,
  float4 v3 : TEXCOORD0,
  out float4 o0 : SV_POSITION0,
  out float4 o1 : TEXCOORD0,
  out float3 o2 : TEXCOORD1)
{
  float4 r0,r1;
  uint4 bitmask, uiDest;
  float4 fDest;

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

// Unity reflection/specular 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 761df64c35526057-vs_replace.txt
float4 _WorldSpaceCameraPos = cb1[4];
float4 clip_space_adj = float4(-separation * convergence, 0, 0, 0);
float4 local_space_adj = mul(inverse(glstate_matrix_mvp), clip_space_adj);
float4 world_space_adj = mul(_Object2World, local_space_adj);
_WorldSpaceCameraPos.xyz -= world_space_adj.xyz;

  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;
  o0.xyzw = cb2[3].xyzw * v0.wwww + r0.xyzw;
  o1.xy = v3.xy * cb0[6].xy + cb0[6].zw;
  r0.x = cb2[16].x * v2.x;
  r0.y = cb2[17].x * v2.x;
  r0.z = cb2[18].x * v2.x;
  r1.x = cb2[16].y * v2.y;
  r1.y = cb2[17].y * v2.y;
  r1.z = cb2[18].y * v2.y;
  r0.xyz = r1.xyz + r0.xyz;
  r1.x = cb2[16].z * v2.z;
  r1.y = cb2[17].z * v2.z;
  r1.z = cb2[18].z * v2.z;
  r0.xyz = r1.xyz + r0.xyz;
  r0.w = dot(r0.xyz, r0.xyz);
  r0.w = rsqrt(r0.w);
  r0.xyz = r0.xyz * r0.www;
  r1.xyz = cb2[13].xyz * v0.yyy;
  r1.xyz = cb2[12].xyz * v0.xxx + r1.xyz;
  r1.xyz = cb2[14].xyz * v0.zzz + r1.xyz;
  r1.xyz = cb2[15].xyz * v0.www + r1.xyz;
  r1.xyz = _WorldSpaceCameraPos.xyz + -r1.xyz;
  r0.w = dot(-r1.xyz, r0.xyz);
  r0.w = r0.w + r0.w;
  o2.xyz = r0.xyz * -r0.www + -r1.xyz;
  return;
}

/****************************** COMPILE WARNINGS ******************************
X:\SteamLibrary\steamapps\common\I am weapon Revival\ShaderFixes\761df64c35526057-vs_replace.txt(97,14-15): warning X3578: Output value 'o1' is not completely initialized

****************************** COMPILE WARNINGS ******************************/
