// asmtool.py -I ../.. --fix-unity-reflection --only-autofixed f87c274e6dc3b073-ps.txt
// 3DMigoto: f87c274e6dc3b073 |    Unity headers extracted from Double Sided
//    Shader "Double Sided" {
//      CustomEditor "StandardShaderGUI"
//      Fallback "VertexLit"
// 1:   SubShader 1/2 {
// 2:   SubShader 2/2 {
// 2:     LOD 150
// 1:     LOD 300
//        Tags { "PerformanceChecks"="False" "RenderType"="Opaque" }
// 2:     Pass 1/4 {
// 1:     Pass 1/5 {
//          Name "FORWARD"
//          Tags { "LIGHTMODE"="FORWARDBASE" "PerformanceChecks"="False" "RenderType"="Opaque" "SHADOWSUPPORT"="true" }
//          ZWrite [_ZWrite]
//          Program "fp" {
//            SubProgram "d3d11" {
//            }
//          }
//        }
//      }
//    }
//
// Unity 5.3 headers extracted from Double Sided:
//   API d3d11
//   Shader model ps_4_0
//   undeciphered1: 201609010 174 7 8
//   undeciphered1a: 14
//   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" }
//   undeciphered2: 1 6 7 5 0 0
//   undeciphered3: 0 0
//   ConstBuffer "$Globals" 1200
//   Vector 32 [_LightColor0]
//   Vector 48 [_SpecColor]
//   Vector 1088 [_Color]
//   Float 1164 [_Glossiness]
//   Float 1172 [_OcclusionStrength]
//   ConstBuffer "UnityPerCamera" 144
//   Vector 64 [_WorldSpaceCameraPos] 3
//   ConstBuffer "UnityLighting" 752
//   Vector 0 [_WorldSpaceLightPos0]
//   Vector 608 [unity_SHAr]
//   Vector 624 [unity_SHAg]
//   Vector 640 [unity_SHAb]
//   Vector 720 [unity_OcclusionMaskSelector]
//   ConstBuffer "UnityShadows" 416
//   Vector 384 [_LightShadowData]
//   Vector 400 [unity_ShadowFadeCenterAndType]
//   ConstBuffer "UnityPerFrame" 384
//   Matrix 144 [unity_MatrixV]
//   ConstBuffer "UnityReflectionProbes" 128
//   Vector 0 [unity_SpecCube0_BoxMax]
//   Vector 16 [unity_SpecCube0_BoxMin]
//   Vector 32 [unity_SpecCube0_ProbePosition]
//   Vector 48 [unity_SpecCube0_HDR]
//   Vector 64 [unity_SpecCube1_BoxMax]
//   Vector 80 [unity_SpecCube1_BoxMin]
//   Vector 96 [unity_SpecCube1_ProbePosition]
//   Vector 112 [unity_SpecCube1_HDR]
//   ConstBuffer "UnityProbeVolume" 112
//   Vector 0 [unity_ProbeVolumeParams]
//   Vector 80 [unity_ProbeVolumeSizeInv] 3
//   Vector 96 [unity_ProbeVolumeMin] 3
//   Matrix 16 [unity_ProbeVolumeWorldToObject]
//   SetTexture 0 [_MainTex] 2D 2
//   SetTexture 1 [_ShadowMapTexture] 2D 4
//   SetTexture 2 [_OcclusionMap] 2D 3
//   SetTexture 3 [unity_SpecCube0] CUBE 0
//   SetTexture 4 [unity_SpecCube1] CUBE -1
//   SetTexture 5 [unity_ProbeVolumeSH] 3D 1
//   BindCB "$Globals" 0
//   BindCB "UnityPerCamera" 1
//   BindCB "UnityLighting" 2
//   BindCB "UnityShadows" 3
//   BindCB "UnityPerFrame" 4
//   BindCB "UnityReflectionProbes" 5
//   BindCB "UnityProbeVolume" 6
//
// Headers extracted with DarkStarSword's extract_unity55_shaders.py
// https://github.com/DarkStarSword/3d-fixes

//
// Generated by Microsoft (R) D3D Shader Disassembler
//
//   using 3Dmigoto v1.3.16 on Sun Apr 21 18:04:30 2019
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION              0   xyzw        0      POS   float
// TEXCOORD                 0   xyzw        1     NONE   float   xy
// TEXCOORD                 1   xyz         2     NONE   float   xyz
// TEXCOORD                 2   xyzw        3     NONE   float      w
// TEXCOORD                 3   xyzw        4     NONE   float      w
// TEXCOORD                 4   xyzw        5     NONE   float   xyzw
// TEXCOORD                 5   xyzw        6     NONE   float   xyz
// TEXCOORD                 6   xyzw        7     NONE   float   xy w
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
//
ps_4_0
dcl_constantbuffer cb0[74], immediateIndexed
dcl_constantbuffer cb1[9], immediateIndexed
dcl_constantbuffer cb2[46], immediateIndexed
dcl_constantbuffer cb3[26], immediateIndexed
dcl_constantbuffer cb4[12], immediateIndexed
dcl_constantbuffer cb5[8], immediateIndexed
dcl_constantbuffer cb6[7], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_default
dcl_sampler s2, mode_default
dcl_sampler s3, mode_default
dcl_sampler s4, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t1
dcl_resource_texture2d (float,float,float,float) t2
dcl_resource_texturecube (float,float,float,float) t3
dcl_resource_texturecube (float,float,float,float) t4
dcl_resource_texture3d (float,float,float,float) t5
dcl_input_ps linear v1.xy
dcl_input_ps linear v2.xyz
dcl_input_ps linear v3.w
dcl_input_ps linear v4.w
dcl_input_ps linear v5.xyzw
dcl_input_ps linear v6.xyz
dcl_input_ps linear v7.xyw
dcl_output o0.xyzw
dcl_temps 16
dcl_constantbuffer cb10[4], immediateIndexed

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

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


// Unity reflection/specular fix inserted with DarkStarSword's asmtool.py:
// asmtool.py -I ../.. --fix-unity-reflection --only-autofixed f87c274e6dc3b073-ps.txt

mul r14.w, -r14.x, r14.y
mad r15.xyz, -r14.wwww, cb10[0].xyzw, cb1[4].xyzw

sample r0.xyzw, v1.xyxx, t0.xyzw, s2
mul r0.xyz, r0.xyzx, cb0[68].xyzx
max r0.w, cb0[3].y, cb0[3].x
max r0.w, r0.w, cb0[3].z
add r0.w, -r0.w, l(1.000000)
mul r0.xyz, r0.wwww, r0.xyzx
dp3 r1.x, v5.xyzx, v5.xyzx
rsq r1.x, r1.x
mul r1.xyz, r1.xxxx, v5.xyzx
dp3 r2.x, v2.xyzx, v2.xyzx
rsq r2.x, r2.x
mul r2.yzw, r2.xxxx, v2.xxyz
mov r3.x, v3.w
mov r3.y, v4.w
mov r3.z, v5.w
add r4.xyz, -r3.xyzx, r15.xyzx
mov r5.x, cb4[9].z
mov r5.y, cb4[10].z
mov r5.z, cb4[11].z
dp3 r3.w, r4.xyzx, r5.xyzx
add r4.xyz, r3.xyzx, -cb3[25].xyzx
dp3 r4.x, r4.xyzx, r4.xyzx
sqrt r4.x, r4.x
add r4.x, -r3.w, r4.x
mad r3.w, cb3[25].w, r4.x, r3.w
mad_sat r3.w, r3.w, cb3[24].z, cb3[24].w
eq r4.x, cb6[0].x, l(1.000000)
if_nz r4.x
  eq r4.y, cb6[0].y, l(1.000000)
  mul r5.xyz, v4.wwww, cb6[2].xyzx
  mad r5.xyz, cb6[1].xyzx, v3.wwww, r5.xyzx
  mad r5.xyz, cb6[3].xyzx, v5.wwww, r5.xyzx
  add r5.xyz, r5.xyzx, cb6[4].xyzx
  movc r4.yzw, r4.yyyy, r5.xxyz, r3.xxyz
  add r4.yzw, r4.yyzw, -cb6[6].xxyz
  mul r5.yzw, r4.yyzw, cb6[5].xxyz
  mad r4.y, r5.y, l(0.250000), l(0.750000)
  mad r4.z, cb6[0].z, l(0.500000), l(0.750000)
  max r5.x, r4.z, r4.y
  sample r5.xyzw, r5.xzwx, t5.xyzw, s1
else
  mov r5.xyzw, l(1.000000,1.000000,1.000000,1.000000)
endif
dp4_sat r4.y, r5.xyzw, cb2[45].xyzw
div r4.zw, v7.xxxy, v7.wwww
sample r5.xyzw, r4.zwzz, t1.xyzw, s4
add r4.y, r4.y, -r5.x
mad r3.w, r3.w, r4.y, r5.x
sample r5.xyzw, v1.xyxx, t2.xyzw, s3
add r4.y, -cb0[73].y, l(1.000000)
mad r4.y, r5.y, cb0[73].y, r4.y
add r4.z, -cb0[72].w, l(1.000000)
dp3 r4.w, r2.yzwy, r1.xyzx
add r4.w, r4.w, r4.w
mad r5.xyz, r1.xyzx, -r4.wwww, r2.yzwy
mul r6.xyz, r3.wwww, cb0[2].xyzx
if_nz r4.x
  eq r3.w, cb6[0].y, l(1.000000)
  mul r7.xyz, v4.wwww, cb6[2].xyzx
  mad r7.xyz, cb6[1].xyzx, v3.wwww, r7.xyzx
  mad r7.xyz, cb6[3].xyzx, v5.wwww, r7.xyzx
  add r7.xyz, r7.xyzx, cb6[4].xyzx
  movc r7.xyz, r3.wwww, r7.xyzx, r3.xyzx
  add r7.xyz, r7.xyzx, -cb6[6].xyzx
  mul r7.yzw, r7.xxyz, cb6[5].xxyz
  mul r3.w, r7.y, l(0.250000)
  mul r4.x, cb6[0].z, l(0.500000)
  mad r4.w, -cb6[0].z, l(0.500000), l(0.250000)
  max r3.w, r3.w, r4.x
  min r7.x, r4.w, r3.w
  sample r8.xyzw, r7.xzwx, t5.xyzw, s1
  add r9.xyz, r7.xzwx, l(0.250000, 0.000000, 0.000000, 0.000000)
  sample r9.xyzw, r9.xyzx, t5.xyzw, s1
  add r7.xyz, r7.xzwx, l(0.500000, 0.000000, 0.000000, 0.000000)
  sample r7.xyzw, r7.xyzx, t5.xyzw, s1
  mov r1.w, l(1.000000)
  dp4 r8.x, r8.xyzw, r1.xyzw
  dp4 r8.y, r9.xyzw, r1.xyzw
  dp4 r8.z, r7.xyzw, r1.xyzw
else
  mov r1.w, l(1.000000)
  dp4 r8.x, cb2[38].xyzw, r1.xyzw
  dp4 r8.y, cb2[39].xyzw, r1.xyzw
  dp4 r8.z, cb2[40].xyzw, r1.xyzw
endif
add r7.xyz, r8.xyzx, v6.xyzx
max r7.xyz, r7.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000)
lt r1.w, l(0.000000), cb5[2].w
if_nz r1.w
  dp3 r1.w, r5.xyzx, r5.xyzx
  rsq r1.w, r1.w
  mul r8.xyz, r1.wwww, r5.xyzx
  add r9.xyz, -r3.xyzx, cb5[0].xyzx
  div r9.xyz, r9.xyzx, r8.xyzx
  add r10.xyz, -r3.xyzx, cb5[1].xyzx
  div r10.xyz, r10.xyzx, r8.xyzx
  lt r11.xyz, l(0.000000, 0.000000, 0.000000, 0.000000), r8.xyzx
  movc r9.xyz, r11.xyzx, r9.xyzx, r10.xyzx
  min r1.w, r9.y, r9.x
  min r1.w, r9.z, r1.w
  add r9.xyz, r3.xyzx, -cb5[2].xyzx
  mad r8.xyz, r8.xyzx, r1.wwww, r9.xyzx
else
  mov r8.xyz, r5.xyzx
endif
mad r1.w, -r4.z, l(0.700000), l(1.700000)
mul r1.w, r1.w, r4.z
mul r1.w, r1.w, l(6.000000)
sample_l r8.xyzw, r8.xyzx, t3.xyzw, s0, r1.w
add r3.w, r8.w, l(-1.000000)
mad r3.w, cb5[3].w, r3.w, l(1.000000)
log r3.w, r3.w
mul r3.w, r3.w, cb5[3].y
exp r3.w, r3.w
mul r3.w, r3.w, cb5[3].x
mul r9.xyz, r8.xyzx, r3.wwww
lt r4.x, cb5[1].w, l(0.999990)
if_nz r4.x
  lt r4.x, l(0.000000), cb5[6].w
  if_nz r4.x
    dp3 r4.x, r5.xyzx, r5.xyzx
    rsq r4.x, r4.x
    mul r10.xyz, r4.xxxx, r5.xyzx
    add r11.xyz, -r3.xyzx, cb5[4].xyzx
    div r11.xyz, r11.xyzx, r10.xyzx
    add r12.xyz, -r3.xyzx, cb5[5].xyzx
    div r12.xyz, r12.xyzx, r10.xyzx
    lt r13.xyz, l(0.000000, 0.000000, 0.000000, 0.000000), r10.xyzx
    movc r11.xyz, r13.xyzx, r11.xyzx, r12.xyzx
    min r4.x, r11.y, r11.x
    min r4.x, r11.z, r4.x
    add r3.xyz, r3.xyzx, -cb5[6].xyzx
    mad r5.xyz, r10.xyzx, r4.xxxx, r3.xyzx
  endif
  sample_l r5.xyzw, r5.xyzx, t4.xyzw, s0, r1.w
  add r1.w, r5.w, l(-1.000000)
  mad r1.w, cb5[7].w, r1.w, l(1.000000)
  log r1.w, r1.w
  mul r1.w, r1.w, cb5[7].y
  exp r1.w, r1.w
  mul r1.w, r1.w, cb5[7].x
  mul r3.xyz, r5.xyzx, r1.wwww
  mad r5.xyz, r3.wwww, r8.xyzx, -r3.xyzx
  mad r9.xyz, cb5[1].wwww, r5.xyzx, r3.xyzx
endif
mul r3.xyz, r4.yyyy, r9.xyzx
mad r5.xyz, -v2.xyzx, r2.xxxx, cb2[0].xyzx
dp3 r1.w, r5.xyzx, r5.xyzx
max r1.w, r1.w, l(0.001000)
rsq r1.w, r1.w
mul r5.xyz, r1.wwww, r5.xyzx
dp3 r1.w, r1.xyzx, -r2.yzwy
dp3_sat r2.x, r1.xyzx, cb2[0].xyzx
dp3_sat r1.x, r1.xyzx, r5.xyzx
dp3_sat r1.y, cb2[0].xyzx, r5.xyzx
mul r1.z, r1.y, r1.y
dp2 r1.z, r1.zzzz, r4.zzzz
add r1.z, r1.z, l(-0.500000)
add r2.y, -r2.x, l(1.000000)
mul r2.z, r2.y, r2.y
mul r2.z, r2.z, r2.z
mul r2.y, r2.y, r2.z
mad r2.y, r1.z, r2.y, l(1.000000)
add r2.z, -|r1.w|, l(1.000000)
mul r2.w, r2.z, r2.z
mul r2.w, r2.w, r2.w
mul r2.z, r2.z, r2.w
mad r1.z, r1.z, r2.z, l(1.000000)
mul r1.z, r1.z, r2.y
mul r2.y, r4.z, r4.z
mad r2.w, -r4.z, r4.z, l(1.000000)
mad r3.w, |r1.w|, r2.w, r2.y
mad r2.w, r2.x, r2.w, r2.y
mul r1.w, |r1.w|, r2.w
mad r1.w, r2.x, r3.w, r1.w
add r1.w, r1.w, l(0.000010)
div r1.w, l(0.500000), r1.w
mul r2.w, r2.y, r2.y
mad r3.w, r1.x, r2.w, -r1.x
mad r1.x, r3.w, r1.x, l(1.000000)
mul r2.w, r2.w, l(0.318309873)
mad r1.x, r1.x, r1.x, l(1.000000012E-007)
div r1.x, r2.w, r1.x
mul r1.x, r1.x, r1.w
mul r1.x, r1.x, l(3.14159274)
mul r1.xz, r2.xxxx, r1.xxzx
max r1.x, r1.x, l(0.000000)
mad r1.w, r2.y, r2.y, l(1.000000)
div r1.w, l(1.000000, 1.000000, 1.000000, 1.000000), r1.w
dp3 r2.x, cb0[3].xyzx, cb0[3].xyzx
ne r2.x, r2.x, l(0.000000)
and r2.x, r2.x, l(0x3f800000)
mul r1.x, r1.x, r2.x
add r0.w, -r0.w, l(1.000000)
add_sat r0.w, r0.w, cb0[72].w
mul r2.xyw, r1.zzzz, r6.xyxz
mad r2.xyw, r7.xyxz, r4.yyyy, r2.xyxw
mul r4.xyz, r6.xyzx, r1.xxxx
add r1.x, -r1.y, l(1.000000)
mul r1.y, r1.x, r1.x
mul r1.y, r1.y, r1.y
mul r1.x, r1.x, r1.y
add r5.xyz, -cb0[3].xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
mad r1.xyz, r5.xyzx, r1.xxxx, cb0[3].xyzx
mul r1.xyz, r1.xyzx, r4.xyzx
mad r0.xyz, r0.xyzx, r2.xywx, r1.xyzx
mul r1.xyz, r3.xyzx, r1.wwww
add r2.xyw, r0.wwww, -cb0[3].xyxz
mad r2.xyz, r2.zzzz, r2.xywx, cb0[3].xyzx
mad o0.xyz, r1.xyzx, r2.xyzx, r0.xyzx
mov o0.w, l(1.000000)
ret
// Approximately 0 instruction slots used