// hlsltool.py -I ../112 --auto-fix-vertex-halo --fix-unity-reflection --only-autofixed --no-validate --ignore-other-errors 66b6cc03847f94b6-vs_replace.txt
// 3DMigoto: 66b6cc03847f94b6 | Matched 2 variants of 2 shaders: Effects/Distortion/CullBack, Effects/Distortion/CullOff
//
// 1:    Unity headers extracted from DistortionCullBack.shader
// 2:    Unity headers extracted from DistortionCullOff.shader
// 1:    Shader "Effects/Distortion/CullBack" {
// 2:    Shader "Effects/Distortion/CullOff" {
//         Properties {
//          _TintColor ("Tint Color", Color) = (1,1,1,1)
//          _MainTex ("Base (RGB) Gloss (A)", 2D) = "black" { }
//          _BumpMap ("Normalmap", 2D) = "bump" { }
//          _ColorStrength ("Color Strength", Float) = 1
//          _BumpAmt ("Distortion", Float) = 10
//          _InvFade ("Soft Particles Factor", Range(0,10)) = 1
//         }
//         Fallback "Effects/Distortion/Free/CullOff"
//         SubShader 1/1 {
//           Tags { "QUEUE"="Transparent" "IGNOREPROJECTOR"="true" "RenderType"="Opaque" }
//           GrabPass {
//             Name "BASE"
//             Tags { "LIGHTMODE"="Always" }
//            }
//           Pass 1/1 {
//             Name "BASE"
//             Tags { "LIGHTMODE"="Always" "QUEUE"="Transparent" "IGNOREPROJECTOR"="true" "RenderType"="Opaque" }
//             ZWrite Off
// 2:          Cull Off
//             Blend SrcAlpha OneMinusSrcAlpha
//             GpuProgramID 10951
//             Program "vp" {
//               SubProgram "d3d11 " {
//                 GpuProgramIndex 4
//               }
//             }
//           }
//         }
//       }
//
// 1: Unity 5.3 headers extracted from DistortionCullBack.shader.decompressed:
// 2: Unity 5.3 headers extracted from DistortionCullOff.shader.decompressed:
//      API d3d11
//      Shader model vs_4_0
//      undeciphered1: 201509030 17 0 0
//      Keywords { "SOFTPARTICLES_ON" }
//      undeciphered2: 1 0 3 0 0
//      undeciphered3: 13 3 0 0 2 1 3 4
//      ConstBuffer "$Globals" 192
//      Vector 144 [_BumpMap_ST]
//      Vector 160 [_MainTex_ST]
//      ConstBuffer "UnityPerCamera" 144
//      Vector 80 [_ProjectionParams]
//      ConstBuffer "UnityPerDraw" 352
//      Matrix 0 [glstate_matrix_mvp]
//      Matrix 64 [glstate_matrix_modelview0]
//      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:28:41 2017
cbuffer cb2 : register(b2)
{
  float4 cb2[8];
}

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

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,
  float2 v1 : TEXCOORD0,
  float4 v2 : COLOR0,
  out float4 o0 : SV_Position0,
  out float4 o1 : TEXCOORD0,
  out float2 o2 : TEXCOORD1,
  out float2 p2 : TEXCOORD2,
  out float4 o3 : COLOR0,
  out float4 o4 : TEXCOORD3)
{
  float4 r0,r1;
  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 66b6cc03847f94b6-vs_replace.txt
if (r0.w != 1.0) { r0.x += separation * (r0.w - convergence); }

  r1.xy = r0.xy * float2(1,-1) + r0.ww;
  o1.xy = float2(0.5,0.5) * r1.xy;
  o1.zw = r0.zw;
  o4.w = r0.w;
  o2.xy = v1.xy * cb0[9].xy + cb0[9].zw;
  p2.xy = v1.xy * cb0[10].xy + cb0[10].zw;
  o3.xyzw = v2.xyzw;
  r0.y = cb1[5].x * r0.y;
  r0.xz = float2(0.5,0.5) * r0.xw;
  r0.w = 0.5 * r0.y;
  o4.xy = r0.xw + r0.zz;
  r0.x = cb2[5].z * v0.y;
  r0.x = cb2[4].z * v0.x + r0.x;
  r0.x = cb2[6].z * v0.z + r0.x;
  r0.x = cb2[7].z * v0.w + r0.x;
  o4.z = -r0.x;
  return;
}
