// hlsltool.py -I ../.. --auto-fix-vertex-halo --fix-unity-reflection --fix-unity-frustum-world --only-autofixed --fxc /home/rshan/fxc.exe 43af1f11d5ce2b72-vs_replace.txt
// 3DMigoto: 43af1f11d5ce2b72 |    Unity headers extracted from Core.shader
//    Shader "Alloy/Core" {
//      Properties {
//       _Mode ("'Rendering Mode' {RenderingMode:{Opaque:{_Cutoff}, Cutout:{}, Fade:{_Cutoff}, Transparent:{_Cutoff}}}", Float) = 0
//       _SrcBlend ("__src", Float) = 0
//       _DstBlend ("__dst", Float) = 0
//       _ZWrite ("__zw", Float) = 1
//      [LM_TransparencyCutOff]  _Cutoff ("'Alpha Cutoff' {Min:0, Max:1}", Float) = 0.5
//       _Lightmapping ("'GI' {LightmapEmissionProperty:{}}", Float) = 1
//       _MainTextures ("'Main Textures' {Section:{126, 41, 41}}", Float) = 0
//      [LM_Albedo] [LM_Transparency]  _Color ("'Tint' {}", Color) = (1,1,1,1)
//      [LM_MasterTilingOffset] [LM_Albedo]  _MainTex ("'Base Color(RGB) Opacity(A)' {Visualize:{RGB, A}}", 2D) = "white" { }
//       _MainTexVelocity ("Scroll", Vector) = (0,0,0,0)
//       _MainTexUV ("UV Set", Float) = 0
//      [LM_Metallic]  _SpecTex ("'Metal(R) AO(G) Spec(B) Rough(A)' {Visualize:{R, G, B, A}, Parent:_MainTex}", 2D) = "white" { }
//      [LM_NormalMap]  _BumpMap ("'Normals' {Visualize:{NRM}, Parent:_MainTex}", 2D) = "bump" { }
//       _BaseColorVertexTint ("'Vertex Color Tint' {Min:0, Max:1}", Float) = 0
//       _MainPhysicalProperties ("'Main Physical Properties' {Section:{126, 66, 41}}", Float) = 0
//      [LM_Metallic]  _Metal ("'Metallic' {Min:0, Max:1}", Float) = 1
//       _Specularity ("'Specularity' {Min:0, Max:1}", Float) = 1
//       _Roughness ("'Roughness' {Min:0, Max:1}", Float) = 1
//       _Occlusion ("'Occlusion Strength' {Min:0, Max:1}", Float) = 1
//       _BumpScale ("'Normal Strength' {}", Float) = 1
//      [Toggle(_PARALLAX_ON)]  _ParallaxT ("'Parallax' {Feature:{109, 126, 41}}", Float) = 0
//      [KeywordEnum(Parallax, POM)]  _BumpMode ("'Mode' {Dropdown:{Parallax:{_MinSamples, _MaxSamples}, POM:{}}}", Float) = 0
//       _ParallaxMap ("'Heightmap(G)' {Visualize:{G}, Parent:_MainTex}", 2D) = "black" { }
//       _Parallax ("'Height' {Min:0, Max:0.08}", Float) = 0.02
//       _MinSamples ("'Min Samples' {Min:1}", Float) = 4
//       _MaxSamples ("'Max Samples' {Min:1}", Float) = 20
//      [Toggle(_AO2_ON)]  _AO2 ("'AO2' {Feature:{83, 126, 41}}", Float) = 0
//       _Ao2Map ("'AO2(G)' {Visualize:{RGB}}", 2D) = "white" { }
//       _Ao2MapUV ("UV Set", Float) = 1
//       _Ao2Occlusion ("'Occlusion Strength' {Min:0, Max:1}", Float) = 1
//      [Toggle(_DETAIL_ON)]  _DetailT ("'Detail' {Feature:{57, 126, 41}}", Float) = 0
//       _DetailMask ("'Mask(A)' {Visualize:{A}, Parent:_MainTex}", 2D) = "white" { }
//      [Enum(Mul, 0, MulX2, 1)]  _DetailMode ("'Color Mode' {Dropdown:{Mul:{}, MulX2:{}}}", Float) = 0
//       _DetailAlbedoMap ("'Color(RGB)' {Visualize:{RGB}}", 2D) = "white" { }
//       _DetailAlbedoMapVelocity ("Scroll", Vector) = (0,0,0,0)
//       _DetailAlbedoMapUV ("UV Set", Float) = 0
//       _DetailMaterialMap ("'AO(G) Variance(A)' {Visualize:{G, A}, Parent:_DetailAlbedoMap}", 2D) = "white" { }
//       _DetailNormalMap ("'Normals' {Visualize:{NRM}, Parent:_DetailAlbedoMap}", 2D) = "bump" { }
//       _DetailWeight ("'Weight' {Min:0, Max:1}", Float) = 1
//       _DetailOcclusion ("'Occlusion Strength' {Min:0, Max:1}", Float) = 1
//       _DetailNormalMapScale ("'Normal Strength' {}", Float) = 1
//      [Toggle(_TEAMCOLOR_ON)]  _TeamColor ("'Team Color' {Feature:{41, 126, 50}}", Float) = 0
//       _TeamColorMaskMap ("'Masks(RGBA)' {Visualize:{R, G, B, A}, Parent:_MainTex}", 2D) = "black" { }
//       _TeamColorMasksAsTint ("'Masks as Tint?' {Toggle:{On:{_TeamColorMasks, _TeamColor0, _TeamColor1, _TeamColor2, _TeamColor3}, Off:{}}}", Float) = 0
//       _TeamColorMasks ("'Mask' {Vector:Mask}", Vector) = (1,1,1,0)
//       _TeamColor0 ("'Tint R' {}", Color) = (1,0,0,1)
//       _TeamColor1 ("'Tint G' {}", Color) = (0,1,0,1)
//       _TeamColor2 ("'Tint B' {}", Color) = (0,0,1,1)
//       _TeamColor3 ("'Tint A' {}", Color) = (0.5,0.5,0.5,1)
//      [Toggle(_DECAL_ON)]  _Decal ("'Decal' {Feature:{41, 126, 75}}", Float) = 0
//       _DecalColor ("'Tint' {}", Color) = (1,1,1,1)
//       _DecalTex ("'Base Color(RGB) Opacity(A)' {Visualize:{RGB, A}}", 2D) = "black" { }
//       _DecalTexUV ("UV Set", Float) = 0
//       _DecalWeight ("'Weight' {Min:0, Max:1}", Float) = 1
//       _DecalSpecularity ("'Specularity' {Min:0, Max:1}", Float) = 0.5
//       _DecalAlphaVertexTint ("'Vertex Alpha Tint' {Min:0, Max:1}", Float) = 0
//      [Toggle(_EMISSION)]  _Emission ("'Emission' {Feature:{41, 126, 101}}", Float) = 0
//      [HDR] [LM_Emission]  _EmissionColor ("'Tint' {}", Color) = (1,1,1,1)
//      [LM_Emission]  _EmissionMap ("'Mask(RGB)' {Visualize:{RGB}, Parent:_MainTex}", 2D) = "white" { }
//       _IncandescenceMap ("'Effect(RGB)' {Visualize:{RGB}}", 2D) = "white" { }
//       _IncandescenceMapVelocity ("Scroll", Vector) = (0,0,0,0)
//       _IncandescenceMapUV ("UV Set", Float) = 0
//      [Gamma]  _EmissionWeight ("'Weight' {Min:0, Max:1}", Float) = 1
//      [Toggle(_RIM_ON)]  _Rim ("'Rim Emission' {Feature:{41, 125, 126}}", Float) = 0
//      [HDR]  _RimColor ("'Tint' {}", Color) = (1,1,1,1)
//       _RimTex ("'Effect(RGB)' {Visualize:{RGB}}", 2D) = "white" { }
//       _RimTexVelocity ("Scroll", Vector) = (0,0,0,0)
//       _RimTexUV ("UV Set", Float) = 0
//      [Gamma]  _RimWeight ("'Weight' {Min:0, Max:1}", Float) = 1
//      [Gamma]  _RimBias ("'Fill' {Min:0, Max:1}", Float) = 0
//       _RimPower ("'Falloff' {Min:0.01}", Float) = 4
//      [Toggle(_DISSOLVE_ON)]  _Dissolve ("'Dissolve' {Feature:{41, 100, 126}}", Float) = 0
//      [HDR]  _DissolveGlowColor ("'Glow Tint' {}", Color) = (1,1,1,1)
//       _DissolveTex ("'Glow Color(RGB) Opacity(A)' {Visualize:{RGB, A}}", 2D) = "white" { }
//       _DissolveTexUV ("UV Set", Float) = 0
//       _DissolveCutoff ("'Cutoff' {Min:0, Max:1}", Float) = 0
//      [Gamma]  _DissolveGlowWeight ("'Glow Weight' {Min:0, Max:1}", Float) = 1
//       _DissolveEdgeWidth ("'Glow Width' {Min:0, Max:1}", Float) = 0.01
//      }
//      Fallback "VertexLit"
//      SubShader 1/1 {
//        LOD 300
//        Tags { "RenderType"="Opaque" "PerformanceChecks"="False" }
//        Pass 2/4 {
//          Name "FORWARD_DELTA"
//          Tags { "LIGHTMODE"="ForwardAdd" "SHADOWSUPPORT"="true" "RenderType"="Opaque" "PerformanceChecks"="False" }
//          ZWrite Off
//          Blend [_SrcBlend] One
//          GpuProgramID 114915
//          Program "vp" {
//            SubProgram "d3d11 " {
//              GpuProgramIndex 183
//            }
//          }
//        }
//      }
//    }
//
// Unity 5.3 headers extracted from Core.shader.decompressed:
//   API d3d11
//   Shader model vs_4_0
//   undeciphered1: 41 0 0
//   Keywords { "DIRECTIONAL" "SHADOWS_OFF" }
//   undeciphered2: 1 0 3 0 0
//   undeciphered3: 159 6 0 0 2 1 1 2 3 4 4 5 7 8
//   ConstBuffer "UnityPerCamera" 144
//   Vector 64 [_WorldSpaceCameraPos] 3
//   ConstBuffer "UnityLighting" 720
//   Vector 0 [_WorldSpaceLightPos0]
//   ConstBuffer "UnityPerDraw" 352
//   Vector 336 [unity_WorldTransformParams]
//   Matrix 0 [glstate_matrix_mvp]
//   Matrix 64 [glstate_matrix_modelview0]
//   Matrix 192 [_Object2World]
//   Matrix 256 [_World2Object]
//   BindCB "UnityPerCamera" 0
//   BindCB "UnityLighting" 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.30 on Wed Oct 26 06:14:44 2016
cbuffer cb2 : register(b2)
{
  float4 cb2[22];
}

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

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




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



cbuffer UnityPerDraw : register(b11) {
	float4x4 glstate_matrix_mvp;
	float4x4 glstate_matrix_modelview0;
	float4x4 glstate_matrix_invtrans_modelview0;
	#define UNITY_MATRIX_MVP glstate_matrix_mvp
	#define UNITY_MATRIX_MV glstate_matrix_modelview0
	#define UNITY_MATRIX_IT_MV glstate_matrix_invtrans_modelview0

	uniform float4x4 _Object2World;
	uniform float4x4 _World2Object;
	uniform float4 unity_LODFade; // x is the fade value ranging within [0,1]. y is x quantized into 16 levels
	uniform float4 unity_WorldTransformParams; // w is usually 1.0, or -1.0 for odd-negative scale transforms
}


#include <matrix.hlsl>

void main( 
  float4 v0 : POSITION0,
  float4 v1 : TEXCOORD0,
  float2 v2 : TEXCOORD1,
  float3 v3 : NORMAL0,
  float4 v4 : TANGENT0,
  float4 v5 : COLOR0,
  out float4 o0 : TEXCOORD0,
  out float4 o1 : 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 : SV_POSITION0)
{
  float4 r0,r1,r2;
  uint4 bitmask, uiDest;
  float4 fDest;

float4 stereo = StereoParams.Load(0);
float separation = stereo.x, convergence = stereo.y, eye = stereo.z;

// Unity reflection/specular fix inserted with DarkStarSword's hlsltool.py:
// hlsltool.py -I ../.. --auto-fix-vertex-halo --fix-unity-reflection --fix-unity-frustum-world --only-autofixed --fxc /home/rshan/fxc.exe 43af1f11d5ce2b72-vs_replace.txt
float4 _WorldSpaceCameraPos = cb0[4];
float4 clip_space_adj = float4(-separation * convergence, 0, 0, 0);
float4 local_space_adj = mul(inverse(glstate_matrix_mvp), clip_space_adj);
float4 world_space_adj = mul(_Object2World, local_space_adj);
_WorldSpaceCameraPos.xyz -= world_space_adj.xyz;

  o0.xy = v1.xy;
  o0.zw = v2.xy;
  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;
  o1.w = -r0.x;
  r0.xyzw = cb2[13].xyzw * v0.yyyy;
  r0.xyzw = cb2[12].xyzw * v0.xxxx + r0.xyzw;
  r0.xyzw = cb2[14].xyzw * v0.zzzz + r0.xyzw;
  r0.xyzw = cb2[15].xyzw * v0.wwww + r0.xyzw;
  o1.xyz = _WorldSpaceCameraPos.xyz + -r0.xyz;
  o5.xyzw = r0.xyzw;
  r0.xyz = cb2[13].xyz * v4.yyy;
  r0.xyz = cb2[12].xyz * v4.xxx + r0.xyz;
  r0.xyz = cb2[14].xyz * v4.zzz + r0.xyz;
  r0.w = dot(r0.xyz, r0.xyz);
  r0.w = rsqrt(r0.w);
  r0.xyz = r0.xyz * r0.www;
  o2.xyz = r0.xyz;
  o2.w = 0;
  r1.x = cb2[16].x * v3.x;
  r1.y = cb2[17].x * v3.x;
  r1.z = cb2[18].x * v3.x;
  r2.x = cb2[16].y * v3.y;
  r2.y = cb2[17].y * v3.y;
  r2.z = cb2[18].y * v3.y;
  r1.xyz = r2.xyz + r1.xyz;
  r2.x = cb2[16].z * v3.z;
  r2.y = cb2[17].z * v3.z;
  r2.z = cb2[18].z * v3.z;
  r1.xyz = r2.xyz + r1.xyz;
  r0.w = dot(r1.xyz, r1.xyz);
  r0.w = rsqrt(r0.w);
  r1.xyz = r1.xyz * r0.www;
  r2.xyz = r1.zxy * r0.yzx;
  r0.xyz = r1.yzx * r0.zxy + -r2.xyz;
  o4.xyz = r1.xyz;
  r0.w = cb2[21].w * v4.w;
  o3.xyz = r0.xyz * r0.www;
  o3.w = 0;
  o4.w = 1;
  r0.xyz = v5.xyz * float3(0.305306017,0.305306017,0.305306017) + float3(0.682171106,0.682171106,0.682171106);
  r0.xyz = v5.xyz * r0.xyz + float3(0.0125228781,0.0125228781,0.0125228781);
  o6.xyz = v5.xyz * r0.xyz;
  o6.w = v5.w;
  o7.xyzw = cb1[0].xyzz;
  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;
  o8.xyzw = cb2[3].xyzw * v0.wwww + r0.xyzw;
  return;
}
