// asmtool.py -I ../.. --fix-unity-reflection --only-autofixed 3d9e56d8474f0d06-ps.txt
// 3DMigoto: 3d9e56d8474f0d06 |    Unity headers extracted from VolumetricFogAndMist_VolumetricFog
//    Shader "VolumetricFogAndMist/VolumetricFog" {
//      SubShader 1/1 {
//        Pass 2/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: 17
//   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 17:54:27 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
// SV_Target                1   xyzw        1   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_output o1.xyzw
dcl_temps 19
dcl_constantbuffer cb10[4], immediateIndexed

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

ld_indexable(texture2d)(float,float,float,float) r17.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 3d9e56d8474f0d06-ps.txt

mul r17.w, -r17.x, r17.y
mad r18.xyz, -r17.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.xyzw, r0.xxxx, r1.xxxx
mad r1.x, cb1[7].x, r0.w, cb1[7].y
div r1.x, l(1.000000, 1.000000, 1.000000, 1.000000), r1.x
mov r1.yz, -cb0[13].xxyx
add r2.y, r1.y, r18.y
mov r2.xz, r18.xxzx
mad r3.xyz, v2.xyzx, r1.xxxx, r2.xyzx
add r1.x, r3.y, l(0.000010)
lt r1.y, cb0[13].y, r2.y
lt r1.w, cb0[13].y, r1.x
and r1.y, r1.w, r1.y
lt r1.w, r2.y, r1.z
lt r2.w, r1.x, r1.z
and r1.w, r1.w, r2.w
or r1.y, r1.w, r1.y
if_z r1.y
  add r3.w, r3.y, l(0.000010)
  add r3.xyz, -r2.xyzx, r3.xwzx
  dp3 r1.y, r3.xyzx, r3.xyzx
  dp2 r1.w, r3.xzxx, r3.xzxx
  sqrt r1.yw, r1.yyyw
  div r4.xy, r3.xzxx, r1.wwww
  div r1.w, r1.w, r3.y
  max r2.w, r1.z, r2.y
  min r5.y, r2.w, cb0[13].y
  add r2.w, r2.y, -r5.y
  mul r2.w, r1.w, r2.w
  mad r5.xz, -r4.xxyx, r2.wwww, r18.xxzx
  min r2.w, r1.y, cb0[12].z
  add r6.xyz, -r2.xyzx, r5.xyzx
  dp3 r2.x, r6.xyzx, r6.xyzx
  sqrt r2.x, r2.x
  lt r2.z, r2.x, r2.w
  if_nz r2.z
    lt r2.z, l(0.000000), r1.w
    lt r3.w, l(-0.500000), r1.x
    and r2.z, r2.z, r3.w
    lt r3.w, r1.w, l(0.000000)
    lt r1.x, r1.x, l(0.500000)
    and r1.x, r1.x, r3.w
    and r1.x, r1.z, r1.x
    movc r6.y, r2.z, cb0[13].y, r1.x
    add r1.x, -r2.y, r6.y
    mul r1.x, r1.x, r1.w
    mad r6.xz, -r4.xxyx, r1.xxxx, r18.xxzx
    add r1.xzw, r5.xxyz, -r6.xxyz
    dp3 r1.x, r1.xzwx, r1.xzwx
    sqrt r1.x, r1.x
    add r1.z, -r2.x, r2.w
    min r1.x, r1.z, r1.x
    lt r1.w, l(0.000000), r1.x
    if_nz r1.w
      log r1.w, r1.x
      mul r1.w, r1.w, l(0.693147182)
      max r1.w, r1.w, l(0.000000)
      mad r1.w, r1.w, cb0[15].x, l(0.100000)
      mul r1.w, r1.w, cb0[13].z
      mul_sat r2.y, r2.w, cb0[15].y
      mul r1.w, r1.w, r2.y
      max r1.w, r1.w, l(0.010000)
      mul r2.yzw, r1.wwww, r3.xxyz
      div r2.yzw, r2.yyzw, r1.yyyy
      div r1.w, r1.x, r1.w
      add r4.xyz, r5.xyzx, -cb0[17].xyzx
      add r6.xyz, r5.xyzx, -cb0[19].xyzx
      mul r7.xz, r2.yywy, cb0[13].wwww
      mul r3.w, cb0[13].z, cb0[13].y
      div r7.y, r2.z, r3.w
      add r5.xz, r5.xxzx, cb0[14].xxzx
      mul r5.xz, r5.xxzx, cb0[13].wwww
      div r3.w, r5.y, r3.w
      ge r1.x, r1.x, r1.z
      mov r8.xyzw, l(0,0,0,0)
      mov r9.xyz, r4.xyzx
      mov r10.xyz, r6.xyzx
      mov r12.xz, r5.xxzx
      mov r1.z, r1.w
      mov r12.y, r3.w
      mov r11.xyzw, l(0,0,0,0)
      loop
        ge r4.w, l(1.000000), r1.z
        breakc_nz r4.w
        sample_l r13.xyzw, r12.xzxx, t1.xyzw, s0, l(0.000000)
        add r4.w, -|r12.y|, r13.w
        lt r5.y, l(0.000000), r4.w
        if_nz r5.y
          add r5.y, -r4.w, l(1.000000)
          mul r14.xyz, r5.yyyy, cb0[11].xyzx
          mul r15.w, r4.w, l(0.400000)
          dp3 r4.w, r9.xyzx, r9.xyzx
          div r4.w, l(1.000000, 1.000000, 1.000000, 1.000000), r4.w
          dp3 r5.y, r10.xyzx, r10.xyzx
          div r5.y, l(1.000000, 1.000000, 1.000000, 1.000000), r5.y
          mul r16.xyz, r4.wwww, cb0[18].xyzx
          mad r16.xyz, cb0[20].xyzx, r5.yyyy, r16.xyzx
          mad r13.xyz, r16.xyzx, r15.wwww, r13.xyzx
          mul r13.xyz, r15.wwww, r13.xyzx
          mul r15.xyz, r13.xyzx, r14.xyzx
          add r4.w, -r11.w, l(1.000000)
          mad r13.xyzw, r15.xyzw, r4.wwww, r11.xyzw
          lt r4.w, l(0.990000), r13.w
          if_nz r4.w
            mov r8.xyzw, r15.xyzw
            mov r11.xyzw, r13.xyzw
            break
          endif
          mov r8.xyzw, r15.xyzw
          mov r11.xyzw, r13.xyzw
        endif
        add r9.xyz, r2.yzwy, r9.xyzx
        add r10.xyz, r2.yzwy, r10.xyzx
        add r1.z, r1.z, l(-1.000000)
        add r12.xyz, r7.xyzx, r12.xyzx
      endloop
      lt r1.w, r11.w, l(0.990000)
      and r1.xw, r1.xxxw, l(0x3f800000, 0, 0, 0x3f800000)
      add r2.y, -r11.w, l(1.000000)
      mul r1.x, r1.z, r1.x
      mul r1.z, r1.w, r2.y
      mul r1.x, r1.x, r1.z
      mad r4.xyzw, r8.xyzw, r1.xxxx, r11.xyzw
      div r1.xyz, r3.xyzx, r1.yyyy
      dp3 r1.x, r1.xyzx, cb0[22].xyzx
      mul r1.x, r1.x, cb0[25].w
      max r1.x, r1.x, l(0.000000)
      mul r1.x, r1.x, r1.x
      mul r1.x, r1.x, r1.x
      mul r1.x, r1.x, r1.x
      mul r1.x, r4.w, r1.x
      add r1.yzw, -r4.xxyz, cb0[23].xxyz
      mad r4.xyz, r1.xxxx, r1.yzwy, r4.xyzx
      mul r1.xyzw, r4.xyzw, cb0[10].wwww
      add r2.x, -r2.x, cb0[12].z
      div_sat r2.x, r2.x, cb0[12].w
      mul r2.x, r2.x, r2.x
      mul o0.xyzw, r1.xyzw, r2.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
mov o1.xyzw, r0.xyzw
ret
// Approximately 0 instruction slots used