// hlsltool.py -I ../112 --auto-fix-vertex-halo --fix-unity-reflection --only-autofixed --no-validate --ignore-other-errors 0f7a8f2f85c8ad10-vs_replace.txt
// 3DMigoto: 0f7a8f2f85c8ad10 | Matched 24 variants of 4 shaders: MK4/MetalWithLayerOnTop Metalness Simple, MK4/MetalWithLayerOnTop Simple, MK4/Rock, MK4/Rock Simple
//
// 00003f:    Unity headers extracted from MetalWithLayerOnTop Metalness Simple.shader
// 000fc0:    Unity headers extracted from MetalWithLayerOnTop Simple.shader
// 03f000:    Unity headers extracted from Rock.shader
// fc0000:    Unity headers extracted from Rock_simple.shader
// 00003f:    Shader "MK4/MetalWithLayerOnTop Metalness Simple" {
// 000fc0:    Shader "MK4/MetalWithLayerOnTop Simple" {
// fc0000:    Shader "MK4/Rock Simple" {
// 03f000:    Shader "MK4/Rock" {
//              Properties {
// 000fff:       _Color ("Color", Color) = (0.501961,0.501961,0.501961,1)
// fff000:       _Metallic ("Metallic", Range(0,1)) = 0
// fff000:       _Gloss ("Gloss", Range(0,1)) = 0
// 000fff:       _MainTex ("MainTex", 2D) = "white" { }
// 000fff:       _BumpScale ("BumpScale", Range(0,2)) = 1
// fff000:       _Color ("Color", Color) = (0.501961,0.501961,0.501961,1)
// fff000:       _Aldebo ("Aldebo", 2D) = "white" { }
// 000fff:       _BumpMap ("BumpMap", 2D) = "bump" { }
// 000fc0:       _Metallic ("Metallic", Range(0,1)) = 0
// 00003f:       _MetallicGlossMap ("MetallicGlossMap", 2D) = "white" { }
// 03f000:       _NormalmapInt ("Normalmap Int", Range(0,2)) = 1
// 000fc0:       _Glossiness ("Glossiness", Range(0,1)) = 0
// 00003f:       _Metallic ("Metallic", Range(0,1)) = 1
// fff000:       _Normalmap ("Normalmap", 2D) = "bump" { }
// fff000:       _AOPower ("AO Power", Range(0,3)) = 1
// 00003f:       _Glossiness ("Glossiness", Range(0,1)) = 1
// fff000:       _AO ("AO", 2D) = "white" { }
// 000fff:       _MaskColor ("Mask Color", Color) = (0.7,0.7,0.7,1)
// fff000:       _MaskColor ("Mask Color", Color) = (1,1,1,1)
// 000fff:       _MaskPower ("Mask Power", Range(0,1.5)) = 0.554
// 000fff:       _MaskBumpInt ("Mask Bump Int", Range(0,2)) = 0.24
// fc0000:       _MaskPower ("Mask Power", Range(0,1.5)) = 1
// 03f000:       _MaskPower ("Mask Power", Range(0,1.5)) = 1.5
// 03f000:       _MaskBumpInt ("Mask Bump Int", Range(0,2)) = 1
// 000fff:       _Maskscale ("Mask scale", Range(0,20)) = 8
// fff000:       _Maskscale ("Mask scale", Range(0,20)) = 2
// 03f000:      [MaterialToggle]  _SmoothBlend ("Smooth Blend", Float) = 0
//               _MaskRGBA ("Mask RGBA", 2D) = "white" { }
// 03ffff:       _MaskBump ("Mask Bump", 2D) = "bump" { }
// fff000:       _DetailDiffInt ("Detail Diff Int", Range(0,1)) = 0
// 03f000:       _DetailBumpInt ("Detail Bump Int", Range(0,2)) = 1
// fff000:       _Detailscale ("Detail scale", Range(0,20)) = 2
// fff000:      [MaterialToggle]  _DetailBlendDodge ("Detail Blend Dodge", Float) = 0
// fff000:       _Detail ("Detail", 2D) = "white" { }
// 03f000:       _DetailBump ("Detail Bump", 2D) = "bump" { }
//              }
//              Fallback "Diffuse"
//              SubShader 1/1 {
//                Tags { "RenderType"="Opaque" }
//                Pass 2/3 {
//                  Name "FORWARD"
//                  Tags { "LIGHTMODE"="ForwardBase" "SHADOWSUPPORT"="true" "RenderType"="Opaque" }
// 03f000:          GpuProgramID 102596
// 00003f:          GpuProgramID 124438
// fc0000:          GpuProgramID 128230
// 000fc0:          GpuProgramID 81035
//                  Program "vp" {
//                    SubProgram "d3d11 " {
// 041041:              GpuProgramIndex 51
// 082082:              GpuProgramIndex 55
// 104104:              GpuProgramIndex 59
// 208208:              GpuProgramIndex 63
// 410410:              GpuProgramIndex 67
// 820820:              GpuProgramIndex 71
//                    }
//                  }
//                }
//              }
//            }
//
// 00003f: Unity 5.3 headers extracted from MetalWithLayerOnTop Metalness Simple.shader.decompressed:
// 000fc0: Unity 5.3 headers extracted from MetalWithLayerOnTop Simple.shader.decompressed:
// 03f000: Unity 5.3 headers extracted from Rock.shader.decompressed:
// fc0000: Unity 5.3 headers extracted from Rock_simple.shader.decompressed:
//           API d3d11
//           Shader model vs_4_0
//           undeciphered1: 201509030 37 0 0
// 208208:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "LIGHTMAP_OFF" "DIRLIGHTMAP_OFF" "DIRLIGHTMAP_COMBINED" "DYNAMICLIGHTMAP_OFF" "VERTEXLIGHT_ON" }
// 104104:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "LIGHTMAP_OFF" "DIRLIGHTMAP_OFF" "DIRLIGHTMAP_COMBINED" "DYNAMICLIGHTMAP_OFF" }
// 820820:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "LIGHTMAP_OFF" "DIRLIGHTMAP_OFF" "DIRLIGHTMAP_SEPARATE" "DYNAMICLIGHTMAP_OFF" "VERTEXLIGHT_ON" }
// 410410:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "LIGHTMAP_OFF" "DIRLIGHTMAP_OFF" "DIRLIGHTMAP_SEPARATE" "DYNAMICLIGHTMAP_OFF" }
// 082082:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "LIGHTMAP_OFF" "DIRLIGHTMAP_OFF" "DYNAMICLIGHTMAP_OFF" "VERTEXLIGHT_ON" }
// 041041:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "LIGHTMAP_OFF" "DIRLIGHTMAP_OFF" "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:24:37 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,
  out float4 o8 : TEXCOORD10)
{
  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 0f7a8f2f85c8ad10-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;
  o8.xyzw = float4(0,0,0,0);
  return;
}
