// hlsltool.py -I ../112 --auto-fix-vertex-halo --fix-unity-reflection --only-autofixed --no-validate --ignore-other-errors af94ff93b3ed5a02-vs_replace.txt
// 3DMigoto: af94ff93b3ed5a02 | Matched 17 variants of 4 shaders: Beautiful Dissolves/Standard Dissolve, Beautiful Dissolves/Standard Dissolve (Specular setup), Beautiful Dissolves/Standard Dissolve NoCull Fixed, Standard (Specular setup)
//
// 18000:    Unity headers extracted from Standard-Dissolve NoCull Fixed.shader
// 00007:    Unity headers extracted from Standard-Dissolve.shader
// 00038:    Unity headers extracted from Standard-DissolveSpecular.shader
// 07fc0:    Unity headers extracted from StandardSpecular.shader
// 00038:    Shader "Beautiful Dissolves/Standard Dissolve (Specular setup)" {
// 18000:    Shader "Beautiful Dissolves/Standard Dissolve NoCull Fixed" {
// 00007:    Shader "Beautiful Dissolves/Standard Dissolve" {
// 07fc0:    Shader "Standard (Specular setup)" {
//             Properties {
//              _Color ("Color", Color) = (1,1,1,1)
//              _MainTex ("Albedo", 2D) = "white" { }
//              _Cutoff ("Alpha Cutoff", Range(0,1)) = 0.5
//              _Glossiness ("Smoothness", Range(0,1)) = 0.5
// 07ff8:       _SpecColor ("Specular", Color) = (0.2,0.2,0.2,1)
// 18007:      [Gamma]  _Metallic ("Metallic", Range(0,1)) = 0
// 18007:       _MetallicGlossMap ("Metallic", 2D) = "white" { }
// 07ff8:       _SpecGlossMap ("Specular", 2D) = "white" { }
//              _BumpScale ("Scale", Float) = 1
//              _BumpMap ("Normal Map", 2D) = "bump" { }
//              _Parallax ("Height Scale", Range(0.005,0.08)) = 0.02
//              _ParallaxMap ("Height Map", 2D) = "black" { }
//              _OcclusionStrength ("Strength", Range(0,1)) = 1
//              _OcclusionMap ("Occlusion", 2D) = "white" { }
//              _EmissionColor ("Color", Color) = (0,0,0,1)
//              _EmissionMap ("Emission", 2D) = "white" { }
//              _DetailMask ("Detail Mask", 2D) = "white" { }
//              _DetailAlbedoMap ("Detail Albedo x2", 2D) = "grey" { }
//              _DetailNormalMapScale ("Scale", Float) = 1
//              _DetailNormalMap ("Normal Map", 2D) = "bump" { }
//             [Enum(UV0,0,UV1,1)]  _UVSec ("UV Set for secondary textures", Float) = 0
// 1803f:       _DissolveMap ("Dissolve Map", 2D) = "white" { }
// 1803f:       _DissolveAmount ("Dissolve Amount", Range(0,1)) = 0.5
// 1803f:       _GlowColor ("Glow Color", Color) = (0.2588,0.4118,0.8588,1)
// 1803f:       _GlowIntensity ("Glow Intensity", Float) = 1
// 1803f:       _OuterEdgeColor ("Outer Edge Color", Color) = (0,0.5,1,1)
// 1803f:       _InnerEdgeColor ("Inner Edge Color", Color) = (1,1,0,1)
// 1803f:       _OuterEdgeThickness ("Outer Edge Thickness", Range(0,1)) = 0.02
// 1803f:       _InnerEdgeThickness ("Inner Edge Thickness", Range(0,1)) = 0
//             [HideInInspector]  _Mode ("__mode", Float) = 0
//             [HideInInspector]  _SrcBlend ("__src", Float) = 1
//             [HideInInspector]  _DstBlend ("__dst", Float) = 0
//             [HideInInspector]  _ZWrite ("__zw", Float) = 1
//             }
//             Fallback "VertexLit"
//             SubShader 2/2 {
//               LOD 150
//               Tags { "RenderType"="Opaque" "PerformanceChecks"="False" }
//               Pass 1/3 {
//                 Name "FORWARD"
//                 Tags { "LIGHTMODE"="ForwardBase" "SHADOWSUPPORT"="true" "RenderType"="Opaque" "PerformanceChecks"="False" }
//                 ZWrite [_ZWrite]
// 1803f:          Cull Off
//                 Blend [_SrcBlend] [_DstBlend]
// 18007:          GpuProgramID 360648
// 07fc0:          GpuProgramID 388109
// 00038:          GpuProgramID 389932
//                 Program "vp" {
//                   SubProgram "d3d11_9x " {
// 00040:              GpuProgramIndex 1461
// 00080:              GpuProgramIndex 1473
// 00100:              GpuProgramIndex 1485
// 00200:              GpuProgramIndex 1497
// 00400:              GpuProgramIndex 1509
// 00800:              GpuProgramIndex 1521
// 01000:              GpuProgramIndex 1533
// 02000:              GpuProgramIndex 1545
// 04000:              GpuProgramIndex 1557
// 08000:              GpuProgramIndex 261
// 10000:              GpuProgramIndex 273
// 00008:              GpuProgramIndex 325
// 00010:              GpuProgramIndex 337
// 00020:              GpuProgramIndex 349
// 00001:              GpuProgramIndex 421
// 00002:              GpuProgramIndex 433
// 00004:              GpuProgramIndex 445
//                   }
//                 }
//               }
//             }
//           }
//
// 18000: Unity 5.3 headers extracted from Standard-Dissolve NoCull Fixed.shader.decompressed:
// 00007: Unity 5.3 headers extracted from Standard-Dissolve.shader.decompressed:
// 00038: Unity 5.3 headers extracted from Standard-DissolveSpecular.shader.decompressed:
// 07fc0: Unity 5.3 headers extracted from StandardSpecular.shader.decompressed:
//          API d3d11_9x
//          Shader model vs_4_0_level_9_1
//          undeciphered1: 201509030 49 0 0
// 04000:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "LIGHTMAP_OFF" "DIRLIGHTMAP_OFF" "DYNAMICLIGHTMAP_OFF" "_ALPHABLEND_ON" }
// 02000:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "LIGHTMAP_OFF" "DIRLIGHTMAP_OFF" "DYNAMICLIGHTMAP_OFF" "_ALPHATEST_ON" }
// 00200:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "LIGHTMAP_OFF" "DIRLIGHTMAP_OFF" "DYNAMICLIGHTMAP_OFF" "_DETAIL_MULX2" "_SPECGLOSSMAP" }
// 00080:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "LIGHTMAP_OFF" "DIRLIGHTMAP_OFF" "DYNAMICLIGHTMAP_OFF" "_DETAIL_MULX2" }
// 01000:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "LIGHTMAP_OFF" "DIRLIGHTMAP_OFF" "DYNAMICLIGHTMAP_OFF" "_EMISSION" "_DETAIL_MULX2" "_SPECGLOSSMAP" }
// 00004:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "LIGHTMAP_OFF" "DIRLIGHTMAP_OFF" "DYNAMICLIGHTMAP_OFF" "_EMISSION" "_METALLICGLOSSMAP" }
// 00820:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "LIGHTMAP_OFF" "DIRLIGHTMAP_OFF" "DYNAMICLIGHTMAP_OFF" "_EMISSION" "_SPECGLOSSMAP" }
// 10412:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "LIGHTMAP_OFF" "DIRLIGHTMAP_OFF" "DYNAMICLIGHTMAP_OFF" "_EMISSION" }
// 00100:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "LIGHTMAP_OFF" "DIRLIGHTMAP_OFF" "DYNAMICLIGHTMAP_OFF" "_SPECGLOSSMAP" }
// 08049:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "LIGHTMAP_OFF" "DIRLIGHTMAP_OFF" "DYNAMICLIGHTMAP_OFF" }
//          undeciphered2: 1 0 4 0 0
//          undeciphered3: 27 4 0 0 1 2 3 4 4 5
// 07fc0:   ConstBuffer "$Globals" 240
// 1803f:   ConstBuffer "$Globals" 320
//          Vector 160 [_MainTex_ST]
//          Vector 176 [_DetailAlbedoMap_ST]
//          Float 216 [_UVSec]
//          ConstBuffer "UnityPerCamera" 144
//          Vector 64 [_WorldSpaceCameraPos] 3
//          Vector 80 [_ProjectionParams]
//          ConstBuffer "UnityLighting" 720
//          Vector 608 [unity_SHAr]
//          Vector 624 [unity_SHAg]
//          Vector 640 [unity_SHAb]
//          Vector 656 [unity_SHBr]
//          Vector 672 [unity_SHBg]
//          Vector 688 [unity_SHBb]
//          Vector 704 [unity_SHC]
//          ConstBuffer "UnityPerDraw" 352
//          Matrix 0 [glstate_matrix_mvp]
//          Matrix 192 [_Object2World]
//          Matrix 256 [_World2Object]
//          BindCB "$Globals" 0
//          BindCB "UnityPerCamera" 1
//          BindCB "UnityLighting" 2
//          BindCB "UnityPerDraw" 3
//
// 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:32:04 2017
cbuffer cb3 : register(b3)
{
  float4 cb3[22];
}

cbuffer cb2 : register(b2)
{
  float4 cb2[45];
}

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

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




// 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,
  float3 v1 : NORMAL0,
  float4 v2 : TEXCOORD0,
  float2 v3 : TEXCOORD1,
  out float4 o0 : SV_POSITION0,
  out float4 o1 : TEXCOORD0,
  out float4 o2 : TEXCOORD1,
  out float4 o3 : TEXCOORD2,
  out float4 o4 : TEXCOORD3,
  out float4 o5 : TEXCOORD4,
  out float4 o6 : TEXCOORD5,
  out float4 o7 : TEXCOORD6)
{
  float4 r0,r1,r2,r3,r4;
  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 ../112 --auto-fix-vertex-halo --fix-unity-reflection --only-autofixed --no-validate --ignore-other-errors af94ff93b3ed5a02-vs_replace.txt
float4 _WorldSpaceCameraPos = cb1[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;

  r0.xyzw = cb3[1].xyzw * v0.yyyy;
  r0.xyzw = cb3[0].xyzw * v0.xxxx + r0.xyzw;
  r0.xyzw = cb3[2].xyzw * v0.zzzz + r0.xyzw;
  r0.xyzw = cb3[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 af94ff93b3ed5a02-vs_replace.txt
if (r0.w != 1.0) { r0.x += separation * (r0.w - convergence); }

  r1.x = cmp(cb0[13].z == 0.000000);
  r1.xy = r1.xx ? v2.xy : v3.xy;
  o1.zw = r1.xy * cb0[11].xy + cb0[11].zw;
  o1.xy = v2.xy * cb0[10].xy + cb0[10].zw;
  r1.xyz = cb3[13].xyz * v0.yyy;
  r1.xyz = cb3[12].xyz * v0.xxx + r1.xyz;
  r1.xyz = cb3[14].xyz * v0.zzz + r1.xyz;
  r1.xyz = cb3[15].xyz * v0.www + r1.xyz;
  r1.xyz = -_WorldSpaceCameraPos.xyz + r1.xyz;
  r1.w = dot(r1.xyz, r1.xyz);
  r1.w = rsqrt(r1.w);
  o2.xyz = r1.xyz * r1.www;
  o3.xyzw = float4(0,0,0,0);
  o4.xyzw = float4(0,0,0,0);
  r1.x = cb3[16].x * v1.x;
  r1.y = cb3[17].x * v1.x;
  r1.z = cb3[18].x * v1.x;
  r2.x = cb3[16].y * v1.y;
  r2.y = cb3[17].y * v1.y;
  r2.z = cb3[18].y * v1.y;
  r1.xyz = r2.xyz + r1.xyz;
  r2.x = cb3[16].z * v1.z;
  r2.y = cb3[17].z * v1.z;
  r2.z = cb3[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;
  o5.xyz = r1.xyz;
  o5.w = 0;
  r2.x = r1.y * r1.y;
  r2.x = r1.x * r1.x + -r2.x;
  r3.xyzw = r1.xyzz * r1.yzzx;
  r4.x = dot(cb2[41].xyzw, r3.xyzw);
  r4.y = dot(cb2[42].xyzw, r3.xyzw);
  r4.z = dot(cb2[43].xyzw, r3.xyzw);
  r2.xyz = cb2[44].xyz * r2.xxx + r4.xyz;
  r1.w = 1;
  r3.x = dot(cb2[38].xyzw, r1.xyzw);
  r3.y = dot(cb2[39].xyzw, r1.xyzw);
  r3.z = dot(cb2[40].xyzw, r1.xyzw);
  r1.xyz = r3.xyz + r2.xyz;
  r1.xyz = max(float3(0,0,0), r1.xyz);
  r1.xyz = log2(r1.xyz);
  r1.xyz = float3(0.416666657,0.416666657,0.416666657) * r1.xyz;
  r1.xyz = exp2(r1.xyz);
  r1.xyz = r1.xyz * float3(1.05499995,1.05499995,1.05499995) + float3(-0.0549999997,-0.0549999997,-0.0549999997);
  o6.xyz = max(float3(0,0,0), r1.xyz);
  o6.w = 0;
  r0.y = cb1[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;
}
