// hlsltool.py -I ../.. --fix-unity-reflection --only-autofixed --fxc /home/Ryan/fxc.exe 8ca3049789707080-ps_replace.txt
// 3DMigoto: 8ca3049789707080 |    Unity headers extracted from SpecGrayscaleAdvReflSkinBurnTimeSF.shader
//    Shader "Shader Forge/SpecGrayscaleAdvReflSkinBurnTimeSF" {
//      Properties {
//       _Diffuse ("Diffuse", 2D) = "white" { }
//       _DiffColor ("DiffColor", Color) = (1,1,1,1)
//       _NormalMap ("NormalMap", 2D) = "bump" { }
//       _Shining ("Shining", 2D) = "black" { }
//       _Cubemap ("Cubemap", CUBE) = "_Skybox" { }
//       _CubeColor ("CubeColor", Color) = (0.5,0.5,0.5,1)
//       _GlossHigh ("GlossHigh", Range(0,1)) = 0.71696
//       _HighSpecColor ("HighSpecColor", Color) = (1,1,1,1)
//       _GlossLow ("GlossLow", Range(0,1)) = 0.166634
//       _LowSpecColor ("LowSpecColor", Color) = (0.0735294,0.0735294,0.0735294,1)
//       _IllumText ("IllumText", 2D) = "white" { }
//       _IllumColor ("IllumColor", Color) = (0,0,0,1)
//       _HighSpecMultiplayerN ("HighSpecMultiplayerN", Range(0,6)) = 1
//       _CubemapBlured ("CubemapBlured", CUBE) = "_Skybox" { }
//       _RoughContrast ("RoughContrast", Float) = 1
//       _MetCubeMultiplayer ("MetCubeMultiplayer", Float) = 4
//       _MetallnessMap ("MetallnessMap", 2D) = "white" { }
//       _MetallnessMultiplayer ("MetallnessMultiplayer", Float) = 0
//       _Translucent ("Translucent", Color) = (1,0,0,1)
//       _TranslucentIntens ("TranslucentIntens", Range(0,6)) = 1
//       _TranslucentText ("TranslucentText", 2D) = "black" { }
//       _TranslucentRange ("TranslucentRange", Range(-5,5)) = 0
//       _PushFactor ("PushFactor", Float) = 0
//       _BurnTexture ("BurnTexture", 2D) = "black" { }
//       _BurnRangeMax ("BurnRangeMax", Float) = 1
//       _BurnRangeMin ("BurnRangeMin", Float) = 0
//       _BurnMask ("BurnMask", 2D) = "black" { }
//       _CoalTexture ("CoalTexture", 2D) = "white" { }
//       _CoalMaskRange ("CoalMaskRange", Float) = 0
//       _LifeSpan ("LifeSpan", Float) = 0
//       _LifespanSpeed ("LifespanSpeed", Float) = 1
//      [HideInInspector]  _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
//      }
//      Fallback "Diffuse"
//      SubShader 1/1 {
//        Tags { "QUEUE"="Transparent" "RenderType"="Opaque" }
//        Pass 2/3 {
//          Name "FORWARD_DELTA"
//          Tags { "LIGHTMODE"="ForwardAdd" "QUEUE"="Transparent" "SHADOWSUPPORT"="true" "RenderType"="Opaque" }
//          Blend One One
//          GpuProgramID 105009
//          Program "fp" {
//            SubProgram "d3d11 " {
//              GpuProgramIndex 231
//            }
//          }
//        }
//      }
//    }
//
// Unity 5.3 headers extracted from SpecGrayscaleAdvReflSkinBurnTimeSF.shader.decompressed:
//   API d3d11
//   Shader model ps_4_0
//   undeciphered1: 101 10 0
//   Keywords { "DIRECTIONAL" "SHADOWS_OFF" "LIGHTMAP_OFF" "DIRLIGHTMAP_OFF" "DYNAMICLIGHTMAP_OFF" }
//   undeciphered2: 1 10 3 10 0
//   undeciphered3: 0 0
//   ConstBuffer "$Globals" 496
//   Vector 96 [_LightColor0]
//   Float 128 [_GlossLow]
//   Vector 144 [_Diffuse_ST]
//   Vector 160 [_LowSpecColor]
//   Vector 176 [_NormalMap_ST]
//   Vector 192 [_CubeColor]
//   Vector 208 [_Shining_ST]
//   Vector 224 [_DiffColor]
//   Vector 240 [_HighSpecColor]
//   Float 256 [_GlossHigh]
//   Float 304 [_HighSpecMultiplayerN]
//   Float 308 [_RoughContrast]
//   Float 312 [_MetCubeMultiplayer]
//   Vector 320 [_MetallnessMap_ST]
//   Float 336 [_MetallnessMultiplayer]
//   Vector 352 [_Translucent]
//   Float 368 [_TranslucentIntens]
//   Vector 384 [_TranslucentText_ST]
//   Float 400 [_TranslucentRange]
//   Vector 416 [_BurnTexture_ST]
//   Float 432 [_BurnRangeMax]
//   Vector 448 [_BurnMask_ST]
//   Vector 464 [_CoalTexture_ST]
//   Float 480 [_CoalMaskRange]
//   Float 484 [_BurnRangeMin]
//   Float 488 [_LifeSpan]
//   Float 492 [_LifespanSpeed]
//   ConstBuffer "UnityPerCamera" 144
//   Vector 64 [_WorldSpaceCameraPos] 3
//   ConstBuffer "UnityLighting" 720
//   Vector 0 [_WorldSpaceLightPos0]
//   SetTexture 0 [_NormalMap] 2D 2
//   SetTexture 1 [_BurnTexture] 2D 7
//   SetTexture 2 [_BurnMask] 2D 8
//   SetTexture 3 [_Shining] 2D 3
//   SetTexture 4 [_Diffuse] 2D 1
//   SetTexture 5 [_MetallnessMap] 2D 5
//   SetTexture 6 [_TranslucentText] 2D 6
//   SetTexture 7 [_CubemapBlured] CUBE 4
//   SetTexture 8 [_Cubemap] CUBE 0
//   SetTexture 9 [_CoalTexture] 2D 9
//   BindCB "$Globals" 0
//   BindCB "UnityPerCamera" 1
//   BindCB "UnityLighting" 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 Thu Aug 18 03:38:02 2016
Texture2D<float4> t9 : register(t9);

TextureCube<float4> t8 : register(t8);

TextureCube<float4> t7 : register(t7);

Texture2D<float4> t6 : register(t6);

Texture2D<float4> t5 : register(t5);

Texture2D<float4> t4 : register(t4);

Texture2D<float4> t3 : register(t3);

Texture2D<float4> t2 : register(t2);

Texture2D<float4> t1 : register(t1);

Texture2D<float4> t0 : register(t0);

SamplerState s9_s : register(s9);

SamplerState s8_s : register(s8);

SamplerState s7_s : register(s7);

SamplerState s6_s : register(s6);

SamplerState s5_s : register(s5);

SamplerState s4_s : register(s4);

SamplerState s3_s : register(s3);

SamplerState s2_s : register(s2);

SamplerState s1_s : register(s1);

SamplerState s0_s : register(s0);

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

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

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




// 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 : SV_POSITION0,
  float2 v1 : TEXCOORD0,
  float2 w1 : TEXCOORD1,
  float4 v2 : TEXCOORD2,
  float4 v3 : TEXCOORD3,
  float4 v4 : TEXCOORD4,
  float4 v5 : TEXCOORD5,
  float3 v6 : TEXCOORD6,
  out float4 o0 : SV_Target0)
{
  float4 r0,r1,r2,r3,r4,r5,r6,r7;
  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 ../.. --fix-unity-reflection --only-autofixed --fxc /home/Ryan/fxc.exe 8ca3049789707080-ps_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.xy = v1.xy * cb0[26].xy + cb0[26].zw;
  r0.xyzw = t1.Sample(s7_s, r0.xy).xyzw;
  r0.x = log2(r0.x);
  r0.yz = v1.xy * cb0[28].xy + cb0[28].zw;
  r1.xyzw = t2.Sample(s8_s, r0.yz).xyzw;
  r0.y = 1 + -r1.x;
  r0.z = 0.100000001 + r1.x;
  r0.x = r0.y * r0.x;
  r0.x = exp2(r0.x);
  r0.x = max(0.00100000005, r0.x);
  r0.x = min(0.899999976, r0.x);
  r0.x = 1 + -r0.x;
  r0.x = log2(r0.x);
  r0.y = cb0[30].y + -cb0[27].x;
  r0.w = saturate(cb0[30].w * cb0[30].z);
  r0.y = r0.w * r0.y + cb0[27].x;
  r0.w = cb0[30].x * r0.w;
  r0.z = saturate(r0.z * r0.w);
  r0.y = -1.44269502 * r0.y;
  r0.y = exp2(r0.y);
  r0.x = r0.y * r0.x;
  r0.x = exp2(r0.x);
  r0.x = -0.5 + r0.x;
  r0.x = cmp(r0.x < 0);
  if (r0.x != 0) discard;
  r0.xy = v1.xy * cb0[24].xy + cb0[24].zw;
  r1.xyzw = t6.Sample(s6_s, r0.xy).xyzw;
  r0.xyw = cb0[22].xyz * r1.xyz;
  r0.xyw = cb0[23].xxx * r0.xyw;
  r1.x = dot(v4.xyz, v4.xyz);
  r1.x = rsqrt(r1.x);
  r1.xyz = v4.xyz * r1.xxx;
  r2.xy = v1.xy * cb0[11].xy + cb0[11].zw;
  r2.xyzw = t0.Sample(s2_s, r2.xy).xyzw;
  r2.xy = r2.wy * float2(2,2) + float2(-1,-1);
  r3.xyz = v6.xyz * r2.yyy;
  r3.xyz = r2.xxx * v5.xyz + r3.xyz;
  r1.w = dot(r2.xy, r2.xy);
  r1.w = min(1, r1.w);
  r1.w = 1 + -r1.w;
  r1.w = sqrt(r1.w);
  r1.xyz = r1.www * r1.xyz + r3.xyz;
  r1.w = dot(r1.xyz, r1.xyz);
  r1.w = rsqrt(r1.w);
  r1.xyz = r1.xyz * r1.www;
  r2.xyz = cb2[0].www * -v3.xyz + cb2[0].xyz;
  r1.w = dot(r2.xyz, r2.xyz);
  r1.w = rsqrt(r1.w);
  r2.xyz = r2.xyz * r1.www;
  r1.w = dot(r1.xyz, r2.xyz);
  r2.w = log2(abs(r1.w));
  r3.x = 1.44269502 * cb0[25].x;
  r3.x = exp2(r3.x);
  r2.w = r3.x * r2.w;
  r2.w = exp2(r2.w);
  r2.w = 1 + -r2.w;
  r0.xyw = r2.www * r0.xyw;
  r3.xyz = float3(0.5,0.5,0.5) * r0.xyw;
  r0.xyw = -r0.xyw * float3(0.5,0.5,0.5) + float3(1,1,1);
  r0.xyw = r1.www * r0.xyw + r3.xyz;
  r0.xyw = max(float3(0,0,0), r0.xyw);
  r0.xyw = cb0[6].xyz * r0.xyw;
  r3.xyz = _WorldSpaceCameraPos.xyz + -v3.xyz;
  r1.w = dot(r3.xyz, r3.xyz);
  r1.w = rsqrt(r1.w);
  r4.xyz = r3.xyz * r1.www;
  r2.xyz = r3.xyz * r1.www + r2.xyz;
  r1.w = dot(-r4.xyz, r1.xyz);
  r1.w = r1.w + r1.w;
  r3.xyz = r1.xyz * -r1.www + -r4.xyz;
  r4.xyzw = t8.Sample(s0_s, r3.xyz).xyzw;
  r3.xyzw = t7.Sample(s4_s, r3.xyz).xyzw;
  r3.xyz = cb0[12].xyz * r3.xyz;
  r4.xyz = cb0[12].xyz * r4.xyz + -r3.xyz;
  r5.xy = v1.xy * cb0[13].xy + cb0[13].zw;
  r5.xyzw = t3.Sample(s3_s, r5.xy).xyzw;
  r6.xyz = log2(r5.xyz);
  r6.xyz = cb0[19].yyy * r6.xyz;
  r6.xyz = exp2(r6.xyz);
  r6.xyz = saturate(cb0[19].yyy * r6.xyz);
  r3.xyz = r6.xyz * r4.xyz + r3.xyz;
  r3.xyz = cb0[19].zzz * r3.xyz;
  r4.xy = v1.xy * cb0[9].xy + cb0[9].zw;
  r4.xyzw = t4.Sample(s1_s, r4.xy).xyzw;
  r6.xyz = cb0[14].xyz * r4.xyz;
  r3.xyz = r3.xyz * r6.xyz + -r6.xyz;
  r7.xy = v1.xy * cb0[20].xy + cb0[20].zw;
  r7.xyzw = t5.Sample(s5_s, r7.xy).xyzw;
  r1.w = cb0[21].x * r7.x;
  r3.xyz = r1.www * r3.xyz + r6.xyz;
  r6.xy = v1.xy * cb0[29].xy + cb0[29].zw;
  r6.xyzw = t9.Sample(s9_s, r6.xy).xyzw;
  r6.xyz = r6.xyz + -r3.xyz;
  r3.xyz = r0.zzz * r6.xyz + r3.xyz;
  r5.yzw = cb0[15].xyz * r5.xyz;
  r0.z = r5.x * cb0[16].x + cb0[8].x;
  r0.z = r0.z * 10 + 1;
  r0.z = exp2(r0.z);
  r5.xyz = r5.yzw * cb0[19].xxx + cb0[10].xyz;
  r4.xyz = r4.xyz * r5.xyz + -r5.xyz;
  r4.xyz = r1.www * r4.xyz + r5.xyz;
  r1.w = dot(r2.xyz, r2.xyz);
  r1.w = rsqrt(r1.w);
  r2.xyz = r2.xyz * r1.www;
  r1.x = dot(r2.xyz, r1.xyz);
  r1.x = max(0, r1.x);
  r1.x = log2(r1.x);
  r0.z = r1.x * r0.z;
  r0.z = exp2(r0.z);
  r1.xyz = cb0[6].xyz * r0.zzz;
  r1.xyz = r1.xyz * r4.xyz;
  o0.xyz = r0.xyw * r3.xyz + r1.xyz;
  o0.w = 0;
  return;
}
