// hlsltool.py -I ../112 --auto-fix-vertex-halo --fix-unity-reflection --only-autofixed --no-validate --ignore-other-errors 0e68f3673a2adc14-vs_replace.txt
// 3DMigoto: 0e68f3673a2adc14 |    Unity headers extracted from SpaceStation_PBR_Basic.shader
//    Shader "Sci-Fi Space Station/PBR Basic" {
//      Properties {
//       _Color ("Color", Color) = (1,1,1,1)
//       _MainTex ("Albedo (RGB)", 2D) = "white" { }
//       _Glossiness ("Smoothness", Range(0,2)) = 1
//       _Metallic ("Metallic", Range(0,1)) = 0
//       _MetallicGlossMap ("Metallic (RGB) Gloss (A)", 2D) = "black" { }
//       _OcclusionStrength ("Occlusion Strength", Range(0,1)) = 1
//       _EmissionColor ("Emission Color", Color) = (1,1,1,1)
//       _EmissionMap ("Emissive", 2D) = "black" { }
//       _EmissionFactor ("Emissive Factor", Float) = 1
//       _BumpScale ("Normal Factor", Float) = 1
//       _BumpMap ("Normal Map", 2D) = "bump" { }
//       _ColorMask ("Color Mask  (RGB)", 2D) = "black" { }
//       _MaskedColorA ("Masked Color 1 (R)", Color) = (1,0,0,1)
//       _MaskedColorB ("Masked Color 2 (G)", Color) = (0,1,0,1)
//       _MaskedColorC ("Masked Color 3 (B)", Color) = (0,0,1,1)
//      }
//      Fallback "Specular"
//      SubShader 1/1 {
//        LOD 200
//        Tags { "RenderType"="Opaque" }
//        Pass 2/3 {
//          Name "FORWARD"
//          Tags { "LIGHTMODE"="ForwardAdd" "SHADOWSUPPORT"="true" "RenderType"="Opaque" }
//          ZWrite Off
//          Blend One One
//          GpuProgramID 91803
//          Program "vp" {
//            SubProgram "d3d11 " {
//              GpuProgramIndex 25
//            }
//          }
//        }
//      }
//    }
//
// Unity 5.3 headers extracted from SpaceStation_PBR_Basic.shader.decompressed:
//   API d3d11
//   Shader model vs_4_0
//   undeciphered1: 201509030 36 0 0
//   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" }
//   undeciphered2: 1 0 3 0 0
//   undeciphered3: 143 5 0 0 2 1 1 2 3 4 7 8
//   ConstBuffer "$Globals" 256
//   Vector 240 [_MainTex_ST]
//   ConstBuffer "UnityPerCamera" 144
//   Vector 80 [_ProjectionParams]
//   ConstBuffer "UnityPerDraw" 352
//   Vector 336 [unity_WorldTransformParams]
//   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.38 on Thu Feb 09 12:24:34 2017
cbuffer cb2 : register(b2)
{
  float4 cb2[22];
}

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

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




// 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 float4 o5 : TEXCOORD4,
  out float4 o6 : TEXCOORD5)
{
  float4 r0,r1,r2,r3;
  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 ../112 --auto-fix-vertex-halo --fix-unity-reflection --only-autofixed --no-validate --ignore-other-errors 0e68f3673a2adc14-vs_replace.txt
if (r0.w != 1.0) { r0.x += separation * (r0.w - convergence); }

  o1.xy = v3.xy * cb0[15].xy + cb0[15].zw;
  r1.y = cb2[16].x * v2.x;
  r1.z = cb2[17].x * v2.x;
  r1.x = cb2[18].x * v2.x;
  r2.y = cb2[16].y * v2.y;
  r2.z = cb2[17].y * v2.y;
  r2.x = cb2[18].y * v2.y;
  r1.xyz = r2.xyz + r1.xyz;
  r2.y = cb2[16].z * v2.z;
  r2.z = cb2[17].z * v2.z;
  r2.x = 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;
  o2.z = r1.y;
  r2.xyz = cb2[13].yzx * v1.yyy;
  r2.xyz = cb2[12].yzx * v1.xxx + r2.xyz;
  r2.xyz = cb2[14].yzx * v1.zzz + r2.xyz;
  r1.w = dot(r2.xyz, r2.xyz);
  r1.w = rsqrt(r1.w);
  r2.xyz = r2.xyz * r1.www;
  r3.xyz = r2.xyz * r1.xyz;
  r3.xyz = r1.zxy * r2.yzx + -r3.xyz;
  r1.y = cb2[21].w * v1.w;
  r3.xyz = r3.xyz * r1.yyy;
  o2.y = r3.x;
  o2.x = r2.z;
  o3.z = r1.z;
  o4.z = r1.x;
  o3.x = r2.x;
  o4.x = r2.y;
  o3.y = r3.y;
  o4.y = r3.z;
  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;
  o5.xyz = cb2[15].xyz * v0.www + r1.xyz;
  r0.y = cb1[5].x * r0.y;
  r1.xzw = float3(0.5,0.5,0.5) * r0.xwy;
  o6.zw = r0.zw;
  o6.xy = r1.xw + r1.zz;
  return;
}
