// hlsltool.py -I ../.. --fix-unity-reflection --only-autofixed --fxc /home/Ryan/fxc.exe 34039e3ccb196ed3-ps_replace.txt
// 3DMigoto: 34039e3ccb196ed3 |    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 249
//            }
//          }
//        }
//      }
//    }
//
// Unity 5.3 headers extracted from SpecGrayscaleAdvReflSkinBurnTimeSF.shader.decompressed:
//   API d3d11
//   Shader model ps_4_0
//   undeciphered1: 118 12 0
//   Keywords { "SPOT" "SHADOWS_DEPTH" "SHADOWS_SOFT" "SHADOWS_NATIVE" "LIGHTMAP_OFF" "DIRLIGHTMAP_OFF" "DYNAMICLIGHTMAP_OFF" }
//   undeciphered2: 1 13 4 13 0
//   undeciphered3: 0 0
//   ConstBuffer "$Globals" 624
//   Vector 96 [_ShadowOffsets0]
//   Vector 112 [_ShadowOffsets1]
//   Vector 128 [_ShadowOffsets2]
//   Vector 144 [_ShadowOffsets3]
//   Vector 224 [_LightColor0]
//   Float 256 [_GlossLow]
//   Vector 272 [_Diffuse_ST]
//   Vector 288 [_LowSpecColor]
//   Vector 304 [_NormalMap_ST]
//   Vector 320 [_CubeColor]
//   Vector 336 [_Shining_ST]
//   Vector 352 [_DiffColor]
//   Vector 368 [_HighSpecColor]
//   Float 384 [_GlossHigh]
//   Float 432 [_HighSpecMultiplayerN]
//   Float 436 [_RoughContrast]
//   Float 440 [_MetCubeMultiplayer]
//   Vector 448 [_MetallnessMap_ST]
//   Float 464 [_MetallnessMultiplayer]
//   Vector 480 [_Translucent]
//   Float 496 [_TranslucentIntens]
//   Vector 512 [_TranslucentText_ST]
//   Float 528 [_TranslucentRange]
//   Vector 544 [_BurnTexture_ST]
//   Float 560 [_BurnRangeMax]
//   Vector 576 [_BurnMask_ST]
//   Vector 592 [_CoalTexture_ST]
//   Float 608 [_CoalMaskRange]
//   Float 612 [_BurnRangeMin]
//   Float 616 [_LifeSpan]
//   Float 620 [_LifespanSpeed]
//   ConstBuffer "UnityPerCamera" 144
//   Vector 64 [_WorldSpaceCameraPos] 3
//   ConstBuffer "UnityLighting" 720
//   Vector 0 [_WorldSpaceLightPos0]
//   ConstBuffer "UnityShadows" 416
//   Vector 384 [_LightShadowData]
//   SetTexture 0 [_NormalMap] 2D 5
//   SetTexture 1 [_BurnTexture] 2D 10
//   SetTexture 2 [_BurnMask] 2D 11
//   SetTexture 3 [_LightTexture0] 2D 1
//   SetTexture 4 [_LightTextureB0] 2D 2
//   SetTexture 5 [_Shining] 2D 6
//   SetTexture 6 [_Diffuse] 2D 4
//   SetTexture 7 [_MetallnessMap] 2D 8
//   SetTexture 8 [_TranslucentText] 2D 9
//   SetTexture 9 [_CubemapBlured] CUBE 7
//   SetTexture 10 [_Cubemap] CUBE 3
//   SetTexture 11 [_CoalTexture] 2D 12
//   SetTexture 12 [_ShadowMapTexture] 2D 0
//   BindCB "$Globals" 0
//   BindCB "UnityPerCamera" 1
//   BindCB "UnityLighting" 2
//   BindCB "UnityShadows" 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.30 on Thu Aug 18 03:38:03 2016
Texture2D<float4> t12 : register(t12);

Texture2D<float4> t11 : register(t11);

TextureCube<float4> t10 : register(t10);

TextureCube<float4> t9 : register(t9);

Texture2D<float4> t8 : register(t8);

Texture2D<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 s12_s : register(s12);

SamplerState s11_s : register(s11);

SamplerState s10_s : register(s10);

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);

SamplerComparisonState s0_s : register(s0);

cbuffer cb3 : register(b3)
{
  float4 cb3[25];
}

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

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

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




// 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,
  float4 v6 : TEXCOORD6,
  float4 v7 : TEXCOORD7,
  float4 v8 : TEXCOORD8,
  out float4 o0 : SV_Target0)
{
  float4 r0,r1,r2,r3,r4,r5,r6,r7,r8;
  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 34039e3ccb196ed3-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[34].xy + cb0[34].zw;
  r0.xyzw = t1.Sample(s10_s, r0.xy).xyzw;
  r0.x = log2(r0.x);
  r0.yz = v1.xy * cb0[36].xy + cb0[36].zw;
  r1.xyzw = t2.Sample(s11_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[38].y + -cb0[35].x;
  r0.w = saturate(cb0[38].w * cb0[38].z);
  r0.y = r0.w * r0.y + cb0[35].x;
  r0.w = cb0[38].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.x = 1 + -cb3[24].x;
  r1.xyz = v8.xyz / v8.www;
  r2.xyz = cb0[6].xyz + r1.xyz;
  r2.x = t12.SampleCmpLevelZero(s0_s, r2.xy, r2.z).x;
  r3.xyz = cb0[7].xyz + r1.xyz;
  r2.y = t12.SampleCmpLevelZero(s0_s, r3.xy, r3.z).x;
  r3.xyz = cb0[8].xyz + r1.xyz;
  r1.xyz = cb0[9].xyz + r1.xyz;
  r2.w = t12.SampleCmpLevelZero(s0_s, r1.xy, r1.z).x;
  r2.z = t12.SampleCmpLevelZero(s0_s, r3.xy, r3.z).x;
  r1.xyzw = r2.xyzw * r0.xxxx + cb3[24].xxxx;
  r0.x = dot(r1.xyzw, float4(0.25,0.25,0.25,0.25));
  r0.yw = v7.xy / v7.ww;
  r0.yw = float2(0.5,0.5) + r0.yw;
  r1.xyzw = t3.Sample(s1_s, r0.yw).xyzw;
  r0.y = cmp(0 < v7.z);
  r0.y = r0.y ? 1.000000 : 0;
  r0.y = r0.y * r1.w;
  r0.w = dot(v7.xyz, v7.xyz);
  r1.xyzw = t4.Sample(s2_s, r0.ww).xyzw;
  r0.y = r1.x * r0.y;
  r0.x = r0.y * r0.x;
  r0.xyw = cb0[14].xyz * r0.xxx;
  r1.xy = v1.xy * cb0[32].xy + cb0[32].zw;
  r1.xyzw = t8.Sample(s9_s, r1.xy).xyzw;
  r1.xyz = cb0[30].xyz * r1.xyz;
  r1.xyz = cb0[31].xxx * r1.xyz;
  r1.w = dot(v4.xyz, v4.xyz);
  r1.w = rsqrt(r1.w);
  r2.xyz = v4.xyz * r1.www;
  r3.xy = v1.xy * cb0[19].xy + cb0[19].zw;
  r3.xyzw = t0.Sample(s5_s, r3.xy).xyzw;
  r3.xy = r3.wy * float2(2,2) + float2(-1,-1);
  r4.xyz = v6.xyz * r3.yyy;
  r4.xyz = r3.xxx * v5.xyz + r4.xyz;
  r1.w = dot(r3.xy, r3.xy);
  r1.w = min(1, r1.w);
  r1.w = 1 + -r1.w;
  r1.w = sqrt(r1.w);
  r2.xyz = r1.www * r2.xyz + r4.xyz;
  r1.w = dot(r2.xyz, r2.xyz);
  r1.w = rsqrt(r1.w);
  r2.xyz = r2.xyz * r1.www;
  r3.xyz = cb2[0].www * -v3.xyz + cb2[0].xyz;
  r1.w = dot(r3.xyz, r3.xyz);
  r1.w = rsqrt(r1.w);
  r3.xyz = r3.xyz * r1.www;
  r1.w = dot(r2.xyz, r3.xyz);
  r2.w = log2(abs(r1.w));
  r3.w = 1.44269502 * cb0[33].x;
  r3.w = exp2(r3.w);
  r2.w = r3.w * r2.w;
  r2.w = exp2(r2.w);
  r2.w = 1 + -r2.w;
  r1.xyz = r2.www * r1.xyz;
  r4.xyz = float3(0.5,0.5,0.5) * r1.xyz;
  r1.xyz = -r1.xyz * float3(0.5,0.5,0.5) + float3(1,1,1);
  r1.xyz = r1.www * r1.xyz + r4.xyz;
  r1.xyz = max(float3(0,0,0), r1.xyz);
  r1.xyz = r1.xyz * r0.xyw;
  r4.xyz = _WorldSpaceCameraPos.xyz + -v3.xyz;
  r1.w = dot(r4.xyz, r4.xyz);
  r1.w = rsqrt(r1.w);
  r5.xyz = r4.xyz * r1.www;
  r3.xyz = r4.xyz * r1.www + r3.xyz;
  r1.w = dot(-r5.xyz, r2.xyz);
  r1.w = r1.w + r1.w;
  r4.xyz = r2.xyz * -r1.www + -r5.xyz;
  r5.xyzw = t10.Sample(s3_s, r4.xyz).xyzw;
  r4.xyzw = t9.Sample(s7_s, r4.xyz).xyzw;
  r4.xyz = cb0[20].xyz * r4.xyz;
  r5.xyz = cb0[20].xyz * r5.xyz + -r4.xyz;
  r6.xy = v1.xy * cb0[21].xy + cb0[21].zw;
  r6.xyzw = t5.Sample(s6_s, r6.xy).xyzw;
  r7.xyz = log2(r6.xyz);
  r7.xyz = cb0[27].yyy * r7.xyz;
  r7.xyz = exp2(r7.xyz);
  r7.xyz = saturate(cb0[27].yyy * r7.xyz);
  r4.xyz = r7.xyz * r5.xyz + r4.xyz;
  r4.xyz = cb0[27].zzz * r4.xyz;
  r5.xy = v1.xy * cb0[17].xy + cb0[17].zw;
  r5.xyzw = t6.Sample(s4_s, r5.xy).xyzw;
  r7.xyz = cb0[22].xyz * r5.xyz;
  r4.xyz = r4.xyz * r7.xyz + -r7.xyz;
  r8.xy = v1.xy * cb0[28].xy + cb0[28].zw;
  r8.xyzw = t7.Sample(s8_s, r8.xy).xyzw;
  r1.w = cb0[29].x * r8.x;
  r4.xyz = r1.www * r4.xyz + r7.xyz;
  r7.xy = v1.xy * cb0[37].xy + cb0[37].zw;
  r7.xyzw = t11.Sample(s12_s, r7.xy).xyzw;
  r7.xyz = r7.xyz + -r4.xyz;
  r4.xyz = r0.zzz * r7.xyz + r4.xyz;
  r6.yzw = cb0[23].xyz * r6.xyz;
  r0.z = r6.x * cb0[24].x + cb0[16].x;
  r0.z = r0.z * 10 + 1;
  r0.z = exp2(r0.z);
  r6.xyz = r6.yzw * cb0[27].xxx + cb0[18].xyz;
  r5.xyz = r5.xyz * r6.xyz + -r6.xyz;
  r5.xyz = r1.www * r5.xyz + r6.xyz;
  r1.w = dot(r3.xyz, r3.xyz);
  r1.w = rsqrt(r1.w);
  r3.xyz = r3.xyz * r1.www;
  r1.w = dot(r3.xyz, r2.xyz);
  r1.w = max(0, r1.w);
  r1.w = log2(r1.w);
  r0.z = r1.w * r0.z;
  r0.z = exp2(r0.z);
  r0.xyz = r0.xyw * r0.zzz;
  r0.xyz = r0.xyz * r5.xyz;
  o0.xyz = r1.xyz * r4.xyz + r0.xyz;
  o0.w = 0;
  return;
}
