// asmtool.py -I ../.. --auto-fix-vertex-halo --fix-unusual-halo-with-inconsistent-w-optimisation --fix-unity-reflection --fix-unity-frustum-world --only-autofixed fd1156adc4c9d20e-vs.txt
// 3DMigoto: fd1156adc4c9d20e | Matched 2 variants of 2 shaders: Kyoto/Characters/Human Skin, Kyoto/Standard/Metallic - Opaque
//
// 1:    Unity headers extracted from HumanSkin.shader
// 2:    Unity headers extracted from Metallic_Opaque.shader
// 1:    Shader "Kyoto/Characters/Human Skin" {
// 2:    Shader "Kyoto/Standard/Metallic - Opaque" {
//         Properties {
// 1:      [LM_TransparencyCutOff]  _Cutoff ("Alpha Cutoff", Range(0.000000,1.000000)) = 0.500000
// 1:      [HideInInspector]  _Mode ("__mode", Float) = 0.000000
// 1:      [HideInInspector]  _SrcBlend ("__src", Float) = 1.000000
// 1:      [HideInInspector]  _DstBlend ("__dst", Float) = 0.000000
// 1:      [HideInInspector]  _ZWrite ("__zw", Float) = 1.000000
//         [HideInInspector] [MaterialEnum( Off, 0 , Front, 1, Back, 2 )]  _Culling ("__cull", Float) = 2.000000
//         [HideInInspector] [MaterialEnum( Off, 0 , Front, 1, Back, 2 )]  _ShadowCulling ("__cull", Float) = 2.000000
// 1:      [HideInInspector]  _MaterialId ("_MaterialId", Float) = 0.666667
// 2:      [HideInInspector]  _MaterialId ("_MaterialId", Float) = 1.000000
//          _Color ("Color", Color) = (1.000000,1.000000,1.000000,1.000000)
//          _MainTex ("Albedo", 2D) = "white" { }
//          _GlossBiasUI ("Gloss Bias", Range(0.000000,1.000000)) = 0.000000
//          _GlossScaleUI ("Gloss Scale", Range(0.000000,1.000000)) = 1.000000
//         [HideInInspector]  _GlossParameters ("Gloss Parameters (Gloss, Bias)", Vector) = (1.000000,0.000000,0.000000,1.000000)
// 1:       _BumpScale ("Scale", Float) = 1.000000
//          _BumpMap ("Normal Map", 2D) = "bump" { }
// 1:       _EmissionColor ("Color", Color) = (0.000000,0.000000,0.000000,1.000000)
// 2:       _EmissionMap ("Emission", 2D) = "white" { }
// 2:       _BumpScaleUI ("Scale", Float) = 1.000000
// 1:       _EmissionScale ("Emission Scale", Float) = 1.000000
// 1:       _EmissionMap ("Emission", 2D) = "white" { }
// 2:       _OcclusionStrengthUI ("Strength", Range(0.000000,1.000000)) = 1.000000
// 2:       _EmissionScaleUI ("Emission Scale", Float) = 1.000000
// 2:      [HideInInspector]  _EmissionScale ("Emission Scale For Script Control", Float) = 1.000000
// 2:      [HideInInspector]  _ScaleParameters ("Scale Parameters (Normal, Occlusion, Emission)", Vector) = (1.000000,1.000000,1.000000,1.000000)
// 2:       _EmissionColor ("Color", Color) = (0.000000,0.000000,0.000000,1.000000)
//          _DetailAlbedoMap ("Detail Albedo x2", 2D) = "grey" { }
// 1:       _DetailCompMapScale ("Scale", Float) = 1.000000
//          _DetailCompMap ("Normal Map", 2D) = "bump" { }
// 1:       _DetailGlossScale ("Detail Gloss Scale", Range(0.000000,1.000000)) = 1.000000
// 2:       _DetailNormalScaleUI ("Detail Normal Scale", Float) = 1.000000
// 1:       _DetailOcclusionScale ("Detail Occlusion Scale", Range(0.000000,1.000000)) = 1.000000
// 2:       _DetailOcclusionScaleUI ("Detail Occlusion Scale", Range(0.000000,1.000000)) = 1.000000
// 2:       _DetailGlossScaleUI ("Detail Gloss Scale", Range(0.000000,1.000000)) = 1.000000
// 2:      [HideInInspector]  _DetailScaleParameters ("Detail Scale Parameters (Normal, Occlusion, Gloss)", Vector) = (1.000000,1.000000,1.000000,1.000000)
//          _UVPrime ("UV Set for primary textures", Float) = 0.000000
// 2:      [HideInInspector]  _UvConvolutionPrime0 ("", Vector) = (1.000000,0.000000,0.000000,0.000000)
// 1:      [HideInInspector]  _UvPrimeRotation0 ("", Color) = (1.000000,0.000000,0.000000,0.000000)
// 2:      [HideInInspector]  _UvConvolutionPrime1 ("", Vector) = (0.000000,1.000000,0.000000,0.000000)
// 1:      [HideInInspector]  _UvPrimeRotation1 ("", Color) = (0.000000,1.000000,0.000000,0.000000)
// 1:       _UVSec ("UV Set for secondary textures", Float) = 0.000000
// 2:      [HideInInspector]  _UvConvolutionPrime2 ("", Vector) = (0.000000,0.000000,0.000000,0.000000)
// 2:      [HideInInspector]  _UvConvolutionPrime3 ("", Vector) = (0.000000,0.000000,0.000000,0.000000)
// 1:      [HideInInspector]  _UvDetailRotation0 ("", Color) = (1.000000,0.000000,0.000000,0.000000)
// 2:       _UVSec ("UV Set for detail textures", Float) = 0.000000
// 1:      [HideInInspector]  _UvDetailRotation1 ("", Color) = (0.000000,1.000000,0.000000,0.000000)
// 1:       _SpecularStrength ("Specular Strength", Float) = 1.000000
// 2:      [HideInInspector]  _UvConvolutionDetail0 ("", Vector) = (1.000000,0.000000,0.000000,0.000000)
// 1:       _ThicknessStrength ("Thickness Strength", Float) = 1.000000
// 2:      [HideInInspector]  _UvConvolutionDetail1 ("", Vector) = (0.000000,1.000000,0.000000,0.000000)
// 1:       _SkinCompMap ("Specular", 2D) = "white" { }
// 2:      [HideInInspector]  _UvConvolutionDetail2 ("", Vector) = (0.000000,0.000000,0.000000,0.000000)
// 1:       _OcclusionStrength ("Strength", Range(0.000000,1.000000)) = 1.000000
// 2:      [HideInInspector]  _UvConvolutionDetail3 ("", Vector) = (0.000000,0.000000,0.000000,0.000000)
// 2:       _HeightBiasUI ("Heightmap Bias", Range(-1.000000,1.000000)) = 0.000000
// 2:       _HeightScaleUI ("Heightmap Scale", Range(-10.000000,10.000000)) = 0.000000
// 2:      [HideInInspector]  _HeightParameters ("Height Parameters (Bias, Scale)", Vector) = (1.000000,1.000000,1.000000,1.000000)
// 2:       _Metallic ("Metallic", Range(0.000000,1.000000)) = 1.000000
// 2:       _CompositeMap ("Comp Map", 2D) = "white" { }
// 2:       _NonMetalSpecular ("Non-metal specular", Color) = (0.000000,0.000000,0.000000,1.000000)
// 2:       _MetalDiffuse ("Metal diffuse specular", Color) = (0.000000,0.000000,0.000000,1.000000)
//         }
//         Fallback Off
//         SubShader 1/1 {
//           LOD 300
//           Tags { "RenderType"="Opaque" "PerformanceChecks"="False" }
//           Pass 2/2 {
//             Name "SHADOWCASTER"
//             Tags { "LIGHTMODE"="SHADOWCASTER" "SHADOWSUPPORT"="true" "RenderType"="Opaque" "PerformanceChecks"="False" }
//             Cull [_ShadowCulling]
// 1:          GpuProgramID 83973
// 2:          GpuProgramID 91693
//             Program "vp" {
//               SubProgram "d3d11 " {
// 1:              GpuProgramIndex 24
// 2:              GpuProgramIndex 48
//               }
//             }
//           }
//         }
//       }
//
// 1: Unity 5.3 headers extracted from HumanSkin.shader.decompressed:
// 2: Unity 5.3 headers extracted from Metallic_Opaque.shader.decompressed:
//      API d3d11
//      Shader model vs_4_0
//      undeciphered1: 201510240 43 0 0
//      Keywords { "SHADOWS_DEPTH" }
//      undeciphered2: 1 0 4 0 0 0
//      undeciphered3: 3 2 0 0 1 2
//      ConstBuffer "UnityLighting" 720
//      Vector 0 [_WorldSpaceLightPos0]
//      ConstBuffer "UnityShadows" 416
//      Vector 80 [unity_LightShadowBias]
//      ConstBuffer "UnityPerDraw" 352
//      Matrix 0 [glstate_matrix_mvp]
//      Matrix 192 [unity_ObjectToWorld]
//      Matrix 256 [unity_WorldToObject]
//      ConstBuffer "UnityPerFrame" 272
//      Matrix 128 [unity_MatrixVP]
//      BindCB "UnityLighting" 0
//      BindCB "UnityShadows" 1
//      BindCB "UnityPerDraw" 2
//      BindCB "UnityPerFrame" 3
//
// Headers extracted with DarkStarSword's extract_unity53_shaders.py
// https://github.com/DarkStarSword/3d-fixes

//
// Generated by Microsoft (R) D3D Shader Disassembler
//
//   using 3Dmigoto v1.3.12 on Thu Dec 06 16:59:12 2018
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// POSITION                 0   xyzw        0     NONE   float   xyz
// NORMAL                   0   xyz         1     NONE   float   xyz
// TEXCOORD                 0   xy          2     NONE   float
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION              0   xyzw        0      POS   float   xyzw
//
vs_4_0
dcl_constantbuffer cb0[1], immediateIndexed
dcl_constantbuffer cb1[6], immediateIndexed
dcl_constantbuffer cb2[19], immediateIndexed
dcl_constantbuffer cb3[12], immediateIndexed
dcl_input v0.xyz
dcl_input v1.xyz
dcl_output_siv o0.xyzw, position
dcl_temps 4

// 3DMigoto StereoParams:
dcl_resource_texture2d (float,float,float,float) t125

ld_indexable(texture2d)(float,float,float,float) r3.xyzw, l(0, 0, 0, 0), t125.xyzw

mul r0.x, v1.x, cb2[16].x
mul r0.y, v1.x, cb2[17].x
mul r0.z, v1.x, cb2[18].x
mul r1.x, v1.y, cb2[16].y
mul r1.y, v1.y, cb2[17].y
mul r1.z, v1.y, cb2[18].y
add r0.xyz, r0.xyzx, r1.xyzx
mul r1.x, v1.z, cb2[16].z
mul r1.y, v1.z, cb2[17].z
mul r1.z, v1.z, cb2[18].z
add r0.xyz, r0.xyzx, r1.xyzx
dp3 r0.w, r0.xyzx, r0.xyzx
rsq r0.w, r0.w
mul r0.xyz, r0.wwww, r0.xyzx
mul r1.xyz, v0.yyyy, cb2[13].xyzx
mad r1.xyz, cb2[12].xyzx, v0.xxxx, r1.xyzx
mad r1.xyz, cb2[14].xyzx, v0.zzzz, r1.xyzx
add r1.xyz, r1.xyzx, cb2[15].xyzx
mad r2.xyz, -r1.xyzx, cb0[0].wwww, cb0[0].xyzx
dp3 r0.w, r2.xyzx, r2.xyzx
rsq r0.w, r0.w
mul r2.xyz, r0.wwww, r2.xyzx
dp3 r0.w, r0.xyzx, r2.xyzx
mad r0.w, -r0.w, r0.w, l(1.000000)
sqrt r0.w, r0.w
mul r0.w, r0.w, cb1[5].z
mad r0.xyz, -r0.xyzx, r0.wwww, r1.xyzx
mul r1.xyzw, r0.yyyy, cb3[9].xyzw
mad r1.xyzw, cb3[8].xyzw, r0.xxxx, r1.xyzw
mad r0.xyzw, cb3[10].xyzw, r0.zzzz, r1.xyzw
add r0.xyzw, r0.xyzw, cb3[11].xyzw
mul r1.xyzw, v0.yyyy, cb2[1].xyzw
mad r1.xyzw, cb2[0].xyzw, v0.xxxx, r1.xyzw
mad r1.xyzw, cb2[2].xyzw, v0.zzzz, r1.xyzw
add r1.xyzw, r1.xyzw, cb2[3].xyzw
ne r2.x, cb1[5].z, l(0.000000)
movc r0.xyzw, r2.xxxx, r0.xyzw, r1.xyzw

// Relocated to here with asmtool.py
mov o0.xyw, r0.xyxw

// Automatic vertex shader halo fix inserted with DarkStarSword's asmtool.py:
// asmtool.py -I ../.. --auto-fix-vertex-halo --fix-unusual-halo-with-inconsistent-w-optimisation --fix-unity-reflection --fix-unity-frustum-world --only-autofixed fd1156adc4c9d20e-vs.txt
ne r3.w, r0.w, l(1.0)
if_nz r3.w
  add r3.w, r0.w, -r3.y
  mad r0.x, r3.w, r3.x, r0.x
endif

div r1.x, cb1[5].x, r0.w
max r1.x, r1.x, l(-1.000000)
min r1.x, r1.x, l(0.000000)
add r0.z, r0.z, r1.x
min r1.x, r0.w, r0.z

// mov o0.xyw, r0.xyxw // Relocated from here with asmtool.py

add r0.x, -r0.z, r1.x
mad o0.z, cb1[5].y, r0.x, r0.z
ret
// Approximately 0 instruction slots used