// asmtool.py -I ../.. --fix-unity-reflection --only-autofixed 141e52cfd2954590-ps.txt
// 3DMigoto: 141e52cfd2954590 |    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 113 2 10
//   undeciphered1a: 15
//   Keywords { "FOG_DISTANCE_ON" "FOG_POINT_LIGHT0" }
//   undeciphered2: 1 2 2 2 0 0
//   undeciphered3: 0 0
//   ConstBuffer "$Globals" 416
//   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 320 [_SunDir] 3
//   Vector 336 [_SunColor] 3
//   Vector 368 [_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:52:13 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[24], 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 17
dcl_constantbuffer cb10[4], immediateIndexed

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

ld_indexable(texture2d)(float,float,float,float) r15.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 141e52cfd2954590-ps.txt

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