// asmtool.py -I ../.. --fix-unity-reflection --only-autofixed bee1cbc0f5125e72-ps.txt
// 3DMigoto: bee1cbc0f5125e72 |    Unity headers extracted from VolumetricFogAndMist_VolumetricFog
//    Shader "VolumetricFogAndMist/VolumetricFog" {
//      SubShader 1/1 {
//        Pass 4/5 {
//          ZWrite Off
//          Program "fp" {
//            SubProgram "d3d11" {
//            }
//          }
//        }
//      }
//    }
//
// Unity 5.3 headers extracted from VolumetricFogAndMist_VolumetricFog:
//   API d3d11
//   Shader model ps_4_0
//   undeciphered1: 201609010 107 2 10
//   undeciphered1a: 11
//   Keywords { "FOG_DISTANCE_ON" }
//   undeciphered2: 1 2 2 2 0 0
//   undeciphered3: 0 0
//   ConstBuffer "$Globals" 384
//   Vector 64 [_CameraDepthTexture_TexelSize]
//   Float 172 [_FogAlpha]
//   Vector 176 [_Color] 3
//   Vector 192 [_FogDistance]
//   Vector 208 [_FogData]
//   Vector 224 [_FogWindDir] 3
//   Vector 240 [_FogStepping]
//   Vector 288 [_SunDir] 3
//   Vector 304 [_SunColor] 3
//   Vector 336 [_FogScatteringData2]
//   ConstBuffer "UnityPerCamera" 144
//   Vector 64 [_WorldSpaceCameraPos] 3
//   Vector 112 [_ZBufferParams]
//   SetTexture 0 [_CameraDepthTexture] 2D 1
//   SetTexture 1 [_NoiseTex] 2D 0
//   BindCB "$Globals" 0
//   BindCB "UnityPerCamera" 1
//
// 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:01:21 2019
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION              0   xyzw        0      POS   float
// TEXCOORD                 0   xy          1     NONE   float
// TEXCOORD                 1     zw        1     NONE   float     zw
// TEXCOORD                 2   xyz         2     NONE   float   xyz
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
//
ps_4_0
dcl_constantbuffer cb0[22], immediateIndexed
dcl_constantbuffer cb1[9], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t1
dcl_input_ps linear v1.zw
dcl_input_ps linear v2.xyz
dcl_output o0.xyzw
dcl_temps 13
dcl_constantbuffer cb10[4], immediateIndexed

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

ld_indexable(texture2d)(float,float,float,float) r11.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 bee1cbc0f5125e72-ps.txt

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

mad r0.xyzw, cb0[4].xyxy, l(0.000000, -0.750000, 0.000000, 0.750000), v1.zwzw
sample r1.xyzw, r0.xyxx, t0.xyzw, s1
sample r0.xyzw, r0.zwzz, t0.xyzw, s1
max r0.x, r0.x, r1.x
mad r0.x, cb1[7].x, r0.x, cb1[7].y
div r0.x, l(1.000000, 1.000000, 1.000000, 1.000000), r0.x
mov r0.yz, -cb0[13].xxyx
add r1.y, r0.y, r12.y
mov r1.xz, r12.xxzx
mad r2.xyz, v2.xyzx, r0.xxxx, r1.xyzx
add r0.x, r2.y, l(0.000010)
lt r0.y, cb0[13].y, r1.y
lt r0.w, cb0[13].y, r0.x
and r0.y, r0.w, r0.y
lt r0.w, r1.y, r0.z
lt r1.w, r0.x, r0.z
and r0.w, r0.w, r1.w
or r0.y, r0.w, r0.y
if_z r0.y
  add r2.w, r2.y, l(0.000010)
  add r2.xyz, -r1.xyzx, r2.xwzx
  dp3 r0.y, r2.xyzx, r2.xyzx
  dp2 r0.w, r2.xzxx, r2.xzxx
  sqrt r0.yw, r0.yyyw
  div r3.xy, r2.xzxx, r0.wwww
  div r0.w, r0.w, r2.y
  max r1.w, r0.z, r1.y
  min r4.y, r1.w, cb0[13].y
  add r1.w, r1.y, -r4.y
  mul r1.w, r0.w, r1.w
  mad r4.xz, -r3.xxyx, r1.wwww, r12.xxzx
  min r1.w, r0.y, cb0[12].z
  add r5.xyz, -r1.xyzx, r4.xyzx
  dp3 r1.x, r5.xyzx, r5.xyzx
  sqrt r1.x, r1.x
  lt r1.z, r1.x, r1.w
  if_nz r1.z
    lt r1.z, l(0.000000), r0.w
    lt r2.w, l(-0.500000), r0.x
    and r1.z, r1.z, r2.w
    lt r2.w, r0.w, l(0.000000)
    lt r0.x, r0.x, l(0.500000)
    and r0.x, r0.x, r2.w
    and r0.x, r0.z, r0.x
    movc r5.y, r1.z, cb0[13].y, r0.x
    add r0.x, -r1.y, r5.y
    mul r0.x, r0.x, r0.w
    mad r5.xz, -r3.xxyx, r0.xxxx, r12.xxzx
    add r0.xzw, r4.xxyz, -r5.xxyz
    dp3 r0.x, r0.xzwx, r0.xzwx
    sqrt r0.x, r0.x
    add r0.z, -r1.x, r1.w
    min r0.x, r0.z, r0.x
    lt r0.w, l(0.000000), r0.x
    if_nz r0.w
      log r0.w, r0.x
      mul r0.w, r0.w, l(0.693147182)
      max r0.w, r0.w, l(0.000000)
      mad r0.w, r0.w, cb0[15].x, l(0.100000)
      mul r0.w, r0.w, cb0[13].z
      mul_sat r1.y, r1.w, cb0[15].y
      mul r0.w, r0.w, r1.y
      max r0.w, r0.w, l(0.010000)
      mul r1.yzw, r0.wwww, r2.xxyz
      div r1.yzw, r1.yyzw, r0.yyyy
      div r0.w, r0.x, r0.w
      mul r3.xz, r1.yywy, cb0[13].wwww
      mul r1.y, cb0[13].z, cb0[13].y
      div r3.y, r1.z, r1.y
      add r1.zw, r4.xxxz, cb0[14].xxxz
      mul r1.zw, r1.zzzw, cb0[13].wwww
      div r1.y, r4.y, r1.y
      add r4.xy, cb0[14].xzxx, r12.xzxx
      ge r0.x, r0.x, r0.z
      mov r5.xyzw, l(0,0,0,0)
      mov r0.z, r0.w
      mov r7.xyz, r1.zywz
      mov r6.xyzw, l(0,0,0,0)
      loop
        ge r2.w, l(1.000000), r0.z
        breakc_nz r2.w
        sample_l r8.xyzw, r7.xzxx, t1.xyzw, s0, l(0.000000)
        add r2.w, -|r7.y|, r8.w
        mad r4.zw, r4.xxxy, cb0[13].wwww, -r7.xxxz
        dp2 r3.w, r4.zwzz, r4.zwzz
        add r3.w, -r3.w, cb0[12].x
        max r3.w, r3.w, l(0.000000)
        mad r2.w, -r3.w, cb0[12].y, r2.w
        lt r3.w, l(0.000000), r2.w
        if_nz r3.w
          add r3.w, -r2.w, l(1.000000)
          mul r9.xyz, r3.wwww, cb0[11].xyzx
          mul r10.w, r2.w, l(0.400000)
          mul r8.xyz, r8.xyzx, r10.wwww
          mul r10.xyz, r8.xyzx, r9.xyzx
          add r2.w, -r6.w, l(1.000000)
          mad r8.xyzw, r10.xyzw, r2.wwww, r6.xyzw
          lt r2.w, l(0.990000), r8.w
          if_nz r2.w
            mov r5.xyzw, r10.xyzw
            mov r6.xyzw, r8.xyzw
            break
          endif
          mov r5.xyzw, r10.xyzw
          mov r6.xyzw, r8.xyzw
        endif
        add r0.z, r0.z, l(-1.000000)
        add r7.xyz, r3.xyzx, r7.xyzx
      endloop
      lt r0.w, r6.w, l(0.990000)
      and r0.xw, r0.xxxw, l(0x3f800000, 0, 0, 0x3f800000)
      add r1.y, -r6.w, l(1.000000)
      mul r0.x, r0.z, r0.x
      mul r0.z, r0.w, r1.y
      mul r0.x, r0.x, r0.z
      mad r3.xyzw, r5.xyzw, r0.xxxx, r6.xyzw
      div r0.xyz, r2.xyzx, r0.yyyy
      dp3 r0.x, r0.xyzx, cb0[18].xyzx
      mul r0.x, r0.x, cb0[21].w
      max r0.x, r0.x, l(0.000000)
      mul r0.x, r0.x, r0.x
      mul r0.x, r0.x, r0.x
      mul r0.x, r0.x, r0.x
      mul r0.x, r3.w, r0.x
      add r0.yzw, -r3.xxyz, cb0[19].xxyz
      mad r3.xyz, r0.xxxx, r0.yzwy, r3.xyzx
      mul r0.xyzw, r3.xyzw, cb0[10].wwww
      add r1.x, -r1.x, cb0[12].z
      div_sat r1.x, r1.x, cb0[12].w
      mul r1.x, r1.x, r1.x
      mul o0.xyzw, r0.xyzw, r1.xxxx
    else
      mov o0.xyzw, l(0,0,0,0)
    endif
  else
    mov o0.xyzw, l(0,0,0,0)
  endif
else
  mov o0.xyzw, l(0,0,0,0)
endif
ret
// Approximately 0 instruction slots used