// hlsltool.py -I ../112 --auto-fix-vertex-halo --fix-unity-reflection --only-autofixed --no-validate --ignore-other-errors a4f3ec3ad32ec45d-vs_replace.txt
// 3DMigoto: a4f3ec3ad32ec45d | Matched 12 variants of 4 shaders: MK4/MetalWithLayerOnTop Metalness Simple, MK4/MetalWithLayerOnTop Simple, MK4/Rock, MK4/Rock Simple
//
// 007:    Unity headers extracted from MetalWithLayerOnTop Metalness Simple.shader
// 038:    Unity headers extracted from MetalWithLayerOnTop Simple.shader
// 1c0:    Unity headers extracted from Rock.shader
// e00:    Unity headers extracted from Rock_simple.shader
// 007:    Shader "MK4/MetalWithLayerOnTop Metalness Simple" {
// 038:    Shader "MK4/MetalWithLayerOnTop Simple" {
// e00:    Shader "MK4/Rock Simple" {
// 1c0:    Shader "MK4/Rock" {
//           Properties {
// 03f:       _Color ("Color", Color) = (0.501961,0.501961,0.501961,1)
// fc0:       _Metallic ("Metallic", Range(0,1)) = 0
// fc0:       _Gloss ("Gloss", Range(0,1)) = 0
// 03f:       _MainTex ("MainTex", 2D) = "white" { }
// 03f:       _BumpScale ("BumpScale", Range(0,2)) = 1
// fc0:       _Color ("Color", Color) = (0.501961,0.501961,0.501961,1)
// fc0:       _Aldebo ("Aldebo", 2D) = "white" { }
// 03f:       _BumpMap ("BumpMap", 2D) = "bump" { }
// 038:       _Metallic ("Metallic", Range(0,1)) = 0
// 007:       _MetallicGlossMap ("MetallicGlossMap", 2D) = "white" { }
// 1c0:       _NormalmapInt ("Normalmap Int", Range(0,2)) = 1
// 038:       _Glossiness ("Glossiness", Range(0,1)) = 0
// 007:       _Metallic ("Metallic", Range(0,1)) = 1
// fc0:       _Normalmap ("Normalmap", 2D) = "bump" { }
// fc0:       _AOPower ("AO Power", Range(0,3)) = 1
// 007:       _Glossiness ("Glossiness", Range(0,1)) = 1
// fc0:       _AO ("AO", 2D) = "white" { }
// 03f:       _MaskColor ("Mask Color", Color) = (0.7,0.7,0.7,1)
// fc0:       _MaskColor ("Mask Color", Color) = (1,1,1,1)
// 03f:       _MaskPower ("Mask Power", Range(0,1.5)) = 0.554
// 03f:       _MaskBumpInt ("Mask Bump Int", Range(0,2)) = 0.24
// e00:       _MaskPower ("Mask Power", Range(0,1.5)) = 1
// 1c0:       _MaskPower ("Mask Power", Range(0,1.5)) = 1.5
// 1c0:       _MaskBumpInt ("Mask Bump Int", Range(0,2)) = 1
// 03f:       _Maskscale ("Mask scale", Range(0,20)) = 8
// fc0:       _Maskscale ("Mask scale", Range(0,20)) = 2
// 1c0:      [MaterialToggle]  _SmoothBlend ("Smooth Blend", Float) = 0
//            _MaskRGBA ("Mask RGBA", 2D) = "white" { }
// 1ff:       _MaskBump ("Mask Bump", 2D) = "bump" { }
// fc0:       _DetailDiffInt ("Detail Diff Int", Range(0,1)) = 0
// 1c0:       _DetailBumpInt ("Detail Bump Int", Range(0,2)) = 1
// fc0:       _Detailscale ("Detail scale", Range(0,20)) = 2
// fc0:      [MaterialToggle]  _DetailBlendDodge ("Detail Blend Dodge", Float) = 0
// fc0:       _Detail ("Detail", 2D) = "white" { }
// 1c0:       _DetailBump ("Detail Bump", 2D) = "bump" { }
//           }
//           Fallback "Diffuse"
//           SubShader 1/1 {
//             Tags { "RenderType"="Opaque" }
//             Pass 3/3 {
//               Name "FORWARD_DELTA"
//               Tags { "LIGHTMODE"="ForwardAdd" "SHADOWSUPPORT"="true" "RenderType"="Opaque" }
//               Blend One One
// 007:          GpuProgramID 131229
// 038:          GpuProgramID 145282
// 1c0:          GpuProgramID 146877
// e00:          GpuProgramID 158533
//               Program "vp" {
//                 SubProgram "d3d11 " {
// 492:              GpuProgramIndex 123
// 924:              GpuProgramIndex 149
// 249:              GpuProgramIndex 97
//                 }
//               }
//             }
//           }
//         }
//
// 007: Unity 5.3 headers extracted from MetalWithLayerOnTop Metalness Simple.shader.decompressed:
// 038: Unity 5.3 headers extracted from MetalWithLayerOnTop Simple.shader.decompressed:
// 1c0: Unity 5.3 headers extracted from Rock.shader.decompressed:
// e00: Unity 5.3 headers extracted from Rock_simple.shader.decompressed:
//        API d3d11
//        Shader model vs_4_0
//        undeciphered1: 201509030 37 0 0
// 492:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "LIGHTMAP_OFF" "DIRLIGHTMAP_COMBINED" "DYNAMICLIGHTMAP_OFF" }
// 249:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "LIGHTMAP_OFF" "DIRLIGHTMAP_OFF" "DYNAMICLIGHTMAP_OFF" }
// 924:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "LIGHTMAP_OFF" "DIRLIGHTMAP_SEPARATE" "DYNAMICLIGHTMAP_OFF" }
//        undeciphered2: 1 0 2 0 0
//        undeciphered3: 187 6 0 0 1 2 3 4 4 5 5 6 7 8
//        ConstBuffer "UnityPerCamera" 144
//        Vector 80 [_ProjectionParams]
//        ConstBuffer "UnityPerDraw" 352
//        Matrix 0 [glstate_matrix_mvp]
//        Matrix 192 [_Object2World]
//        Matrix 256 [_World2Object]
//        BindCB "UnityPerCamera" 0
//        BindCB "UnityPerDraw" 1
//
// 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:31:34 2017
cbuffer cb1 : register(b1)
{
  float4 cb1[19];
}

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




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


void main( 
  float4 v0 : POSITION0,
  float3 v1 : NORMAL0,
  float4 v2 : TANGENT0,
  float4 v3 : TEXCOORD0,
  float4 v4 : TEXCOORD1,
  float2 v5 : TEXCOORD2,
  out float4 o0 : SV_POSITION0,
  out float2 o1 : TEXCOORD0,
  out float2 p1 : TEXCOORD1,
  out float4 o2 : TEXCOORD2,
  out float4 o3 : TEXCOORD3,
  out float4 o4 : TEXCOORD4,
  out float4 o5 : TEXCOORD5,
  out float4 o6 : TEXCOORD6,
  out float4 o7 : TEXCOORD7)
{
  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 = cb1[1].xyzw * v0.yyyy;
  r0.xyzw = cb1[0].xyzw * v0.xxxx + r0.xyzw;
  r0.xyzw = cb1[2].xyzw * v0.zzzz + r0.xyzw;
  r0.xyzw = cb1[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 a4f3ec3ad32ec45d-vs_replace.txt
if (r0.w != 1.0) { r0.x += separation * (r0.w - convergence); }

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