// asmtool.py -I ../.. --fix-unity-reflection --only-autofixed e231c64b4ee3fe73-ps.txt
// 3DMigoto: e231c64b4ee3fe73 |    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 112 2 10
//   undeciphered1a: 16
//   Keywords { "FOG_POINT_LIGHT1" }
//   undeciphered2: 1 2 2 2 0 0
//   undeciphered3: 0 0
//   ConstBuffer "$Globals" 448
//   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 272 [_FogPointLightPosition0] 3
//   Vector 288 [_FogPointLightColor0] 3
//   Vector 304 [_FogPointLightPosition1] 3
//   Vector 320 [_FogPointLightColor1] 3
//   Vector 352 [_SunDir] 3
//   Vector 368 [_SunColor] 3
//   Vector 400 [_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:03:20 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[26], 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 18
dcl_constantbuffer cb10[4], immediateIndexed

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

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

mul r16.w, -r16.x, r16.y
mad r17.xyz, -r16.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, r17.y
mov r1.xz, r17.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, r17.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, r17.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
      add r3.xyz, r4.xyzx, -cb0[17].xyzx
      add r5.xyz, r4.xyzx, -cb0[19].xyzx
      mul r6.xz, r1.yywy, cb0[13].wwww
      mul r2.w, cb0[13].z, cb0[13].y
      div r6.y, r1.z, r2.w
      add r4.xz, r4.xxzx, cb0[14].xxzx
      mul r4.xz, r4.xxzx, cb0[13].wwww
      div r2.w, r4.y, r2.w
      ge r0.x, r0.x, r0.z
      mov r7.xyzw, l(0,0,0,0)
      mov r8.xyz, r3.xyzx
      mov r9.xyz, r5.xyzx
      mov r11.xz, r4.xxzx
      mov r0.z, r0.w
      mov r11.y, r2.w
      mov r10.xyzw, l(0,0,0,0)
      loop
        ge r3.w, l(1.000000), r0.z
        breakc_nz r3.w
        sample_l r12.xyzw, r11.xzxx, t1.xyzw, s0, l(0.000000)
        add r3.w, -|r11.y|, r12.w
        lt r4.y, l(0.000000), r3.w
        if_nz r4.y
          add r4.y, -r3.w, l(1.000000)
          mul r13.xyz, r4.yyyy, cb0[11].xyzx
          mul r14.w, r3.w, l(0.400000)
          dp3 r3.w, r8.xyzx, r8.xyzx
          div r3.w, l(1.000000, 1.000000, 1.000000, 1.000000), r3.w
          dp3 r4.y, r9.xyzx, r9.xyzx
          div r4.y, l(1.000000, 1.000000, 1.000000, 1.000000), r4.y
          mul r15.xyz, r3.wwww, cb0[18].xyzx
          mad r15.xyz, cb0[20].xyzx, r4.yyyy, r15.xyzx
          mad r12.xyz, r15.xyzx, r14.wwww, r12.xyzx
          mul r12.xyz, r14.wwww, r12.xyzx
          mul r14.xyz, r12.xyzx, r13.xyzx
          add r3.w, -r10.w, l(1.000000)
          mad r12.xyzw, r14.xyzw, r3.wwww, r10.xyzw
          lt r3.w, l(0.990000), r12.w
          if_nz r3.w
            mov r7.xyzw, r14.xyzw
            mov r10.xyzw, r12.xyzw
            break
          endif
          mov r7.xyzw, r14.xyzw
          mov r10.xyzw, r12.xyzw
        endif
        add r8.xyz, r1.yzwy, r8.xyzx
        add r9.xyz, r1.yzwy, r9.xyzx
        add r0.z, r0.z, l(-1.000000)
        add r11.xyz, r6.xyzx, r11.xyzx
      endloop
      lt r0.w, r10.w, l(0.990000)
      and r0.xw, r0.xxxw, l(0x3f800000, 0, 0, 0x3f800000)
      add r1.y, -r10.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, r7.xyzw, r0.xxxx, r10.xyzw
      div r0.xyz, r2.xyzx, r0.yyyy
      dp3 r0.x, r0.xyzx, cb0[22].xyzx
      mul r0.x, r0.x, cb0[25].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[23].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