// asmtool.py -I ../.. --fix-unity-reflection --only-autofixed e4e7e9c4e268a042-ps.txt
// 3DMigoto: e4e7e9c4e268a042 |    Unity headers extracted from VolumetricFogAndMist_VolumetricFog
//    Shader "VolumetricFogAndMist/VolumetricFog" {
//      SubShader 1/1 {
//        Pass 1/5 {
//          ZWrite Off
//          Program "fp" {
//            SubProgram "d3d11" {
//            }
//          }
//        }
//      }
//    }
//
// Unity 5.3 headers extracted from VolumetricFogAndMist_VolumetricFog:
//   API d3d11
//   Shader model ps_4_0
//   undeciphered1: 201609010 109 2 10
//   undeciphered1a: 15
//   Keywords { "FOG_POINT_LIGHT1" }
//   undeciphered2: 1 3 2 3 0 0
//   undeciphered3: 0 0
//   ConstBuffer "$Globals" 368
//   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
//   ConstBuffer "UnityPerCamera" 144
//   Vector 64 [_WorldSpaceCameraPos] 3
//   Vector 96 [_ScreenParams]
//   Vector 112 [_ZBufferParams]
//   SetTexture 0 [_CameraDepthTexture] 2D 2
//   SetTexture 1 [_NoiseTex] 2D 1
//   SetTexture 2 [_MainTex] 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:29 2019
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION              0   xyzw        0      POS   float
// TEXCOORD                 0   xy          1     NONE   float   xy
// 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[21], immediateIndexed
dcl_constantbuffer cb1[9], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_default
dcl_sampler s2, 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_input_ps linear v1.xy
dcl_input_ps linear v1.zw
dcl_input_ps linear v2.xyz
dcl_output o0.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 e4e7e9c4e268a042-ps.txt

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

sample r0.xyzw, v1.zwzz, t0.xyzw, s2
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, r16.y
mov r1.xz, r16.xxzx
mad r2.xyz, v2.xyzx, r0.xxxx, r1.xyzx
add r0.x, r2.y, l(0.000010)
mul r0.yw, v1.xxxy, cb1[6].xxxy
dp2 r0.y, l(2.40845060, 3.25352120, 0.000000, 0.000000), r0.ywyy
frc r0.y, r0.y
add r0.y, r0.y, l(-0.500000)
lt r0.w, cb0[13].y, r1.y
lt r1.w, cb0[13].y, r0.x
and r0.w, r0.w, r1.w
lt r1.w, r1.y, r0.z
lt r3.x, r0.x, r0.z
and r1.w, r1.w, r3.x
or r0.w, r0.w, r1.w
if_z r0.w
  add r2.w, r2.y, l(0.000010)
  add r2.xyz, -r1.xyzx, r2.xwzx
  dp3 r0.w, r2.xyzx, r2.xyzx
  sqrt r0.w, r0.w
  dp2 r1.w, r2.xzxx, r2.xzxx
  sqrt r1.w, r1.w
  div r3.xy, r2.xzxx, r1.wwww
  div r1.w, r1.w, r2.y
  max r2.w, r0.z, r1.y
  min r4.y, r2.w, cb0[13].y
  add r2.w, r1.y, -r4.y
  mul r2.w, r1.w, r2.w
  mad r4.xz, -r3.xxyx, r2.wwww, r16.xxzx
  min r2.w, r0.w, 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, r2.w
  if_nz r1.z
    lt r1.z, l(0.000000), r1.w
    lt r3.z, l(-0.500000), r0.x
    and r1.z, r1.z, r3.z
    lt r3.z, r1.w, l(0.000000)
    lt r0.x, r0.x, l(0.500000)
    and r0.x, r0.x, r3.z
    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, r1.w
    mad r5.xz, -r3.xxyx, r0.xxxx, r16.xxzx
    add r1.yzw, r4.xxyz, -r5.xxyz
    dp3 r0.x, r1.yzwy, r1.yzwy
    sqrt r0.x, r0.x
    add r0.z, -r1.x, r2.w
    min r0.x, r0.z, r0.x
    lt r1.y, l(0.000000), r0.x
    if_nz r1.y
      log r1.y, r0.x
      mul r1.y, r1.y, l(0.693147182)
      max r1.y, r1.y, l(0.000000)
      mad r1.y, r1.y, cb0[15].x, l(0.100000)
      mul r1.y, r1.y, cb0[13].z
      mul_sat r1.z, r2.w, cb0[15].y
      mul r1.y, r1.z, r1.y
      max r1.y, r1.y, l(0.010000)
      mul r2.xyz, r1.yyyy, r2.xyzx
      div r2.xyz, r2.xyzx, r0.wwww
      div r0.w, r0.x, r1.y
      add r1.yzw, r4.xxyz, -cb0[17].xxyz
      add r3.xyz, r4.xyzx, -cb0[19].xyzx
      mul r5.xz, r2.xxzx, cb0[13].wwww
      mul r2.w, cb0[13].z, cb0[13].y
      div r5.y, r2.y, 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 r6.xyzw, l(0,0,0,0)
      mov r7.xyz, r1.yzwy
      mov r8.xyz, r3.xyzx
      mov r10.xz, r4.xxzx
      mov r0.z, r0.w
      mov r10.y, r2.w
      mov r9.xyzw, l(0,0,0,0)
      loop
        ge r3.w, l(1.000000), r0.z
        breakc_nz r3.w
        sample_l r11.xyzw, r10.xzxx, t1.xyzw, s1, l(0.000000)
        add r3.w, -|r10.y|, r11.w
        lt r4.y, l(0.000000), r3.w
        if_nz r4.y
          add r4.y, -r3.w, l(1.000000)
          mul r12.xyz, r4.yyyy, cb0[11].xyzx
          mul r13.w, r3.w, l(0.400000)
          dp3 r3.w, r7.xyzx, r7.xyzx
          div r3.w, l(1.000000, 1.000000, 1.000000, 1.000000), r3.w
          dp3 r4.y, r8.xyzx, r8.xyzx
          div r4.y, l(1.000000, 1.000000, 1.000000, 1.000000), r4.y
          mul r14.xyz, r3.wwww, cb0[18].xyzx
          mad r14.xyz, cb0[20].xyzx, r4.yyyy, r14.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 r3.w, -r9.w, l(1.000000)
          mad r11.xyzw, r13.xyzw, r3.wwww, r9.xyzw
          lt r3.w, l(0.990000), r11.w
          if_nz r3.w
            mov r6.xyzw, r13.xyzw
            mov r9.xyzw, r11.xyzw
            break
          endif
          mov r6.xyzw, r13.xyzw
          mov r9.xyzw, r11.xyzw
        endif
        add r7.xyz, r2.xyzx, r7.xyzx
        add r8.xyz, r2.xyzx, r8.xyzx
        add r0.z, r0.z, l(-1.000000)
        add r10.xyz, r5.xyzx, r10.xyzx
      endloop
      lt r0.w, r9.w, l(0.990000)
      and r0.xw, r0.xxxw, l(0x3f800000, 0, 0, 0x3f800000)
      add r1.y, -r9.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 r2.xyzw, r6.xyzw, r0.xxxx, r9.xyzw
      mul r2.xyzw, r2.xyzw, cb0[10].wwww
      add r0.x, -r1.x, cb0[12].z
      div_sat r0.x, r0.x, cb0[12].w
      mul r0.x, r0.x, r0.x
      mul r1.xyzw, r0.xxxx, r2.xyzw
    else
      mov r1.xyzw, l(0,0,0,0)
    endif
  else
    mov r1.xyzw, l(0,0,0,0)
  endif
else
  mov r1.xyzw, l(0,0,0,0)
endif
mad r0.x, r0.y, cb0[15].w, l(1.000000)
mul r2.xyzw, r0.xxxx, r1.xyzw
sample r3.xyzw, v1.xyxx, t2.xyzw, s0
mad_sat r0.x, -r1.w, r0.x, l(1.000000)
mad o0.xyzw, r3.xyzw, r0.xxxx, r2.xyzw
ret
// Approximately 0 instruction slots used