// MORE FOG MASK
// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546
//
//   using 3Dmigoto v1.3.16 on Wed Mar 27 20:05:06 2019
//
//
// Buffer Definitions:
//
// cbuffer PSCommonBuffer
// {
//
//   float4 g_color;                    // Offset:    0 Size:    16 [unused]
//   float4 g_resolveRectUV;            // Offset:   16 Size:    16 [unused]
//   float g_ps_nearFar;                // Offset:   64 Size:     4
//   float g_ps_nearFarDistance;        // Offset:   68 Size:     4
//   float g_ps_far;                    // Offset:   72 Size:     4
//   float g_ps_near;                   // Offset:   76 Size:     4 [unused]
//   float g_waveTime;                  // Offset:   80 Size:     4 [unused]
//   float g_clampDistanceInverse;      // Offset:   84 Size:     4 [unused]
//   float g_waveStrength;              // Offset:   88 Size:     4 [unused]
//   float g_waveNum;                   // Offset:   92 Size:     4 [unused]
//   float g_vNormalMapScrollDistance;  // Offset:   96 Size:     4 [unused]
//   float g_hNormalMapScrollDistance;  // Offset:  100 Size:     4 [unused]
//   float g_fToneMapReceiprocalExposure;// Offset:  104 Size:     4 [unused]
//   float2 g_screenCenter;             // Offset:  112 Size:     8 [unused]
//   float g_radialDistance;            // Offset:  120 Size:     4 [unused]
//   float g_TransrancyPower;           // Offset:  124 Size:     4 [unused]
//   float4 g_ps_aboveShadowCascadeSwitchDist;// Offset:  128 Size:    16 [unused]
//   float4 g_vColorScale;              // Offset:  144 Size:    16
//   float g_specularShininessFactor;   // Offset:  176 Size:     4 [unused]
//   uint g_ps_envCbIndex;              // Offset:  180 Size:     4
//   float g_specularScale;             // Offset:  184 Size:     4 [unused]
//   int g_flipbookBlendMode;           // Offset:  188 Size:     4
//   float4 g_vLightMask;               // Offset:  208 Size:    16
//   float4 g_vTracerParam;             // Offset:  224 Size:    16 [unused]
//   float g_Decay;                     // Offset:  240 Size:     4 [unused]
//   float g_DecayWeight;               // Offset:  244 Size:     4 [unused]
//   float g_Dencity;                   // Offset:  248 Size:     4 [unused]
//   float g_Exposure;                  // Offset:  252 Size:     4 [unused]
//   float g_LightSourceScaleX;         // Offset:  256 Size:     4 [unused]
//   float g_LightSourceScaleY;         // Offset:  260 Size:     4 [unused]
//   int g_SampleNum;                   // Offset:  264 Size:     4 [unused]
//   float g_LightSourceScale;          // Offset:  268 Size:     4 [unused]
//   float4 g_LightShaftScreenCenter;   // Offset:  272 Size:    16 [unused]
//   float4x4 g_psViewMatrix;           // Offset:  288 Size:    64 [unused]
//   float4 g_psGlowScale;              // Offset:  352 Size:    16 [unused]
//   int g_ps_TexBlendType;             // Offset:  368 Size:     4 [unused]
//   int g_ps_TexBlendType2;            // Offset:  372 Size:     4 [unused]
//   int g_ps_TexBlendType3;            // Offset:  376 Size:     4 [unused]
//   int g_ps_ColorBlendType;           // Offset:  380 Size:     4
//   float4 g_ps_TextureColor1;         // Offset:  384 Size:    16 [unused]
//   float4 g_ps_TextureColor2;         // Offset:  400 Size:    16 [unused]
//   float4 g_ps_TextureColor3;         // Offset:  416 Size:    16 [unused]
//   float g_ps_invPreExposure;         // Offset:  436 Size:     4
//   int g_ps_BlendingMode;             // Offset:  440 Size:     4
//   int g_ps_FogMultMode;              // Offset:  444 Size:     4
//   float4 g_ps_TextureOnlyColor;      // Offset:  448 Size:    16 [unused]
//   float4 g_ps_softSpriteParam;       // Offset:  464 Size:    16
//   float g_ps_RadialBlurSamplingLengthMaxX;// Offset:  480 Size:     4 [unused]
//   float g_ps_RadialBlurSamplingLengthMaxY;// Offset:  484 Size:     4 [unused]
//   float2 g_ps_softSpriteScaleOffset; // Offset:  488 Size:     8 [unused]
//   float4 g_ps_LightShaftDir;         // Offset:  496 Size:    16 [unused]
//   float4 g_ps_LightShaftDustScaleOffset;// Offset:  512 Size:    16 [unused]
//   float4 g_ps_LightShaftDustThreshold;// Offset:  528 Size:    16 [unused]
//   int g_ps_bPreAlphaMult;            // Offset:  544 Size:     4
//   int g_ps_bEnableLighting;          // Offset:  548 Size:     4
//   int g_ps_bEnableFog;               // Offset:  552 Size:     4 [unused]
//   float g_ps_preExposure;            // Offset:  556 Size:     4
//   float g_ps_BillboardShadowIntensity;// Offset:  560 Size:     4
//   float4 g_ps_ShadowcVolumeParam0;   // Offset:  576 Size:    16
//   float4 g_ps_ShadowcVolumeParam1;   // Offset:  592 Size:    16 [unused]
//   float4x4 g_ps_invProjMatrix;       // Offset:  608 Size:    64 [unused]
//   float4x4 g_ps_shadowMatrixNarrrow; // Offset:  672 Size:    64 [unused]
//   float4 g_ps_envCbColScale;         // Offset:  752 Size:    16
//   float4 g_ps_VolumeFogParam[4];     // Offset:  768 Size:    64
//   float4x4 g_ps_projectionMatrix;    // Offset:  832 Size:    64 [unused]
//   float4x4 g_ps_shadowMatrixBroad;   // Offset:  896 Size:    64 [unused]
//
// }
//
// cbuffer PSEnvLightBuffer
// {
//
//   struct LightSetParam
//   {
//
//       float4 Vec_0;                  // Offset:    0
//       float4 Vec_1;                  // Offset:   16
//       float4 _unused_Vec_2;          // Offset:   32
//       float4 _unused_Vec_3;          // Offset:   48
//       float4 Col_0;                  // Offset:   64
//       float4 Col_1;                  // Offset:   80
//       float4 _unused_Col_2;          // Offset:   96
//       float4 _unused_Col_3;          // Offset:  112
//       float4 Spc_0;                  // Offset:  128
//       float4 Spc_1;                  // Offset:  144
//       float4 _unused_Spc_2;          // Offset:  160
//       float4 _unused_Spc_3;          // Offset:  176
//       float4 _unused_AmbientSH[3];   // Offset:  192
//       float4 _unused_AmbientReflection;// Offset:  240
//       uint4 _unused_bLocalLight;     // Offset:  256
//       float4 _unused_FC_SsaoWeight;  // Offset:  272
//
//   } FC_DirLight[2];                  // Offset:    0 Size:   576
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// g_ClampPointSampler               sampler      NA          NA    7        1
// g_WrapLinearSampler               sampler      NA          NA    8        1
// g_ClampLinearSampler              sampler      NA          NA    9        1
// g_diffuseTexture                  texture  float4          2d    0        1
// g_depthTexture                    texture  float4          2d    3        1
// g_shadowVolumeTexture             texture  float4          3d    5        1
// g_MotionVectorTexture             texture  float4          2d    6        1
// g_volumetricFog                   texture  float4          3d   16        1
// PSCommonBuffer                    cbuffer      NA          NA    0        1
// PSEnvLightBuffer                  cbuffer      NA          NA    7        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// COLOR                    0   xyzw        0     NONE   float   xyzw
// TEXCOORD                 0   xyz         1     NONE   float   xy
// TEXCOORD                 1   xyz         2     NONE   float   xyz
// TEXCOORD                 2   xyzw        3     NONE   float     zw
// TEXCOORD                 3   xyzw        4     NONE   float   xy w
// TEXCOORD                 4   xyzw        5     NONE   float   xyz
// TEXCOORD                 5   xy          6     NONE   float   x
// TEXCOORD                 6   xyz         7     NONE   float   xyz
// SV_POSITION              0   xyzw        8      POS   float      w
//
//
// 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_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[52], immediateIndexed
dcl_constantbuffer cb7[35], dynamicIndexed
dcl_sampler s7, mode_default
dcl_sampler s8, mode_default
dcl_sampler s9, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t3
dcl_resource_texture3d (float,float,float,float) t5
dcl_resource_texture2d (float,float,float,float) t6
dcl_resource_texture3d (float,float,float,float) t16
dcl_input_ps linear v0.xyzw
dcl_input_ps linear v1.xy
dcl_input_ps linear v2.xyz
dcl_input_ps linear v3.zw
dcl_input_ps linear v4.xyw
dcl_input_ps linear v5.xyz
dcl_input_ps linear v6.x
dcl_input_ps linear v7.xyz
dcl_input_ps_siv linear noperspective v8.w, position
dcl_output o0.xyzw
dcl_output o1.xyzw
dcl_temps 9
div r0.xy, v4.xyxx, v4.wwww
mad r0.xy, r0.xyxx, l(0.500000, -0.500000, 0.000000, 0.000000), l(0.500000, 0.500000, 0.000000, 0.000000)
ieq r1.x, l(1), cb0[11].w
if_nz r1.x
  sample_indexable(texture2d)(float,float,float,float) r1.xy, v1.xyxx, t6.xyzw, s8
  mad r1.xy, r1.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
  mul r1.xy, r1.xyxx, v2.zzzz
  mad r1.xy, -r1.xyxx, l(0.003700, 0.003700, 0.000000, 0.000000), v1.xyxx
  sample_indexable(texture2d)(float,float,float,float) r1.xyzw, r1.xyxx, t0.xyzw, s8
  sample_indexable(texture2d)(float,float,float,float) r2.xy, v2.xyxx, t6.xyzw, s8
  mad r2.xy, r2.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
  add r2.z, -v2.z, l(1.000000)
  mul r2.xy, r2.zzzz, r2.xyxx
  mad r2.xy, r2.xyxx, l(0.003700, 0.003700, 0.000000, 0.000000), v2.xyxx
  sample_indexable(texture2d)(float,float,float,float) r2.xyzw, r2.xyxx, t0.xyzw, s8
  add r2.xyzw, -r1.xyzw, r2.xyzw
  mad r1.xyzw, v2.zzzz, r2.xyzw, r1.xyzw
else
  sample_indexable(texture2d)(float,float,float,float) r2.xyzw, v1.xyxx, t0.xyzw, s8
  sample_indexable(texture2d)(float,float,float,float) r3.xyzw, v2.xyxx, t0.xyzw, s8
  add r3.xyzw, -r2.xyzw, r3.xyzw
  mad r1.xyzw, v2.zzzz, r3.xyzw, r2.xyzw
endif
add_sat r2.w, r1.w, v6.x
ilt r3.xy, l(0, 0, 0, 0), cb0[34].xyxx
movc r1.w, r3.x, r2.w, l(1.000000)
mul r2.xyz, r1.wwww, r1.xyzx
dp3 r1.x, v0.xyzx, v0.xyzx
sqrt r1.xyz, r1.xxxx
ge r3.x, l(0.000010), r1.z
div r4.xyz, v0.xyzx, r1.zzzz
mov r5.x, l(0)
mov r5.w, v0.w
mov r4.w, v0.w
movc r4.xyzw, r3.xxxx, r5.xxxw, r4.xyzw
ieq r3.x, l(2), cb0[23].w
mul r5.xyz, r2.wwww, r2.xyzx
lt r6.xyz, r5.xyzx, l(0.500000, 0.500000, 0.500000, 0.000000)
mul r5.xyz, r4.xyzx, r5.xyzx
add r5.xyz, r5.xyzx, r5.xyzx
mad r7.xyz, -r2.xyzx, r2.wwww, l(1.000000, 1.000000, 1.000000, 0.000000)
add r7.xyz, r7.xyzx, r7.xyzx
add r8.xyz, -r4.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
mad r7.xyz, -r7.xyzx, r8.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
movc r5.xyz, r6.xyzx, r5.xyzx, r7.xyzx
mul r6.w, r2.w, r4.w
mul r6.xyz, r5.xyzx, r5.xyzx
mul r5.xyzw, r6.xyzw, cb0[9].xyzw
mov r1.w, l(1.000000)
mul r5.xyzw, r1.xyzw, r5.xyzw
mul r2.xyzw, r2.xyzw, r4.xyzw
mul r2.xyz, r2.xyzx, r2.xyzx
mul r2.xyzw, r2.xyzw, cb0[9].xyzw
mul r1.xyzw, r1.xyzw, r2.xyzw
movc r1.xyzw, r3.xxxx, r5.xyzw, r1.xyzw
sample_indexable(texture2d)(float,float,float,float) r2.x, r0.xyxx, t3.xyzw, s7
add r2.x, -r2.x, l(1.000000)
mad r2.x, r2.x, cb0[4].y, -cb0[4].z
div r2.x, -cb0[4].x, r2.x
add r2.x, r2.x, -v3.z
min r2.x, r2.x, v3.w
div_sat r2.x, r2.x, v3.w
mul r1.w, r1.w, r2.x
mul r2.x, v8.w, cb0[36].y
sqrt r0.z, r2.x
sample_indexable(texture3d)(float,float,float,float) r2.x, r0.xyzx, t5.xyzw, s9
add r2.x, r2.x, l(-1.000000)
mad r2.x, cb0[35].x, r2.x, l(1.000000)
if_nz r3.y
  add r2.y, -v6.x, l(1.000000)
  mad_sat r2.y, cb0[13].x, r2.y, v6.x
  imul null, r2.z, l(18), cb0[11].y
  mul r3.xyz, cb0[47].xyzx, cb7[r2.z + 4].xyzx
  mul r2.yzw, r2.yyyy, r3.xxyz

  // FIX THE MASK HERE
  mad r2.yzw, r2.yyzw, r2.xxxx, v7.xxyz
  //mad r2.yzw, r2.yyzw, r1.xxxx, v7.xxyz  
  mov_sat r1.xyz, r1.xyzx
  mul r2.yzw, r1.xxyz, r2.yyzw
else
    // FIX THE MASK HERE
  mul r2.yzw, r1.xxyz, r2.xxxx
  //mul r2.yzw, r1.xxyz, r1.xxxx
  //mul r2.yzw, r2.yzw, l(2.0)

endif
min r1.x, v4.w, cb0[48].w
add r1.x, r1.x, cb0[48].x
log r1.x, r1.x
mad r0.w, cb0[48].y, r1.x, cb0[48].z
sample_indexable(texture3d)(float,float,float,float) r3.xyzw, r0.xywx, t16.xyzw, s9
lt r0.w, cb0[49].w, v4.w
if_nz r0.w
  mul r0.w, -v5.y, cb0[48].w
  div r0.w, r0.w, v4.w
  add r0.w, r0.w, cb0[50].w
  add r1.x, -v5.y, cb0[50].w
  dp3 r1.y, -v5.xyzx, -v5.xyzx
  sqrt r1.y, r1.y
  div r1.z, r1.y, -v5.y
  div r2.x, cb0[48].w, v4.w
  add r2.x, -r2.x, l(1.000000)
  mul r1.y, r1.y, r2.x
  add r2.x, -r0.w, r1.x
  mul r2.x, r2.x, cb0[51].x
  lt r2.x, |r2.x|, l(0.000100)
  if_nz r2.x
    lt r2.x, l(0.000000), r0.w
    mul r4.x, r0.w, -cb0[51].x
    mul r4.x, r4.x, l(1.442695)
    exp r4.x, r4.x
    mul r4.y, r0.w, cb0[51].x
    mul r4.y, r4.y, l(1.442695)
    exp r4.y, r4.y
    add r4.y, -r4.y, l(2.000000)
    movc r2.x, r2.x, r4.x, r4.y
    mad r2.x, r2.x, cb0[51].y, cb0[51].z
    mul r2.x, r1.y, r2.x
  else
    div r4.x, l(1.000000, 1.000000, 1.000000, 1.000000), cb0[51].x
    max r4.y, r0.w, r1.x
    min r0.w, r0.w, r1.x
    max r1.x, r4.y, l(0.000000)
    max r4.z, r0.w, l(0.000000)
    mul r1.x, r1.x, -cb0[51].x
    mul r1.x, r1.x, l(1.442695)
    exp r1.x, r1.x
    mul r4.z, r4.z, -cb0[51].x
    mul r4.z, r4.z, l(1.442695)
    exp r4.z, r4.z
    add r1.x, r1.x, -r4.z
    min r4.y, r4.y, l(0.000000)
    min r0.w, r0.w, l(0.000000)
    add r4.z, -r0.w, r4.y
    add r4.z, r4.z, r4.z
    mul r4.y, r4.y, cb0[51].x
    mul r4.y, r4.y, l(1.442695)
    exp r4.y, r4.y
    mul r0.w, r0.w, cb0[51].x
    mul r0.w, r0.w, l(1.442695)
    exp r0.w, r0.w
    add r0.w, -r0.w, r4.y
    mad r0.w, -r4.x, r0.w, r4.z
    mad r0.w, -r4.x, r1.x, r0.w
    mul r0.w, r0.w, cb0[51].y
    mul r1.x, r1.y, cb0[51].z
    mad r2.x, r0.w, |r1.z|, r1.x
  endif
  mov r0.z, l(1.000000)
  sample_l_indexable(texture3d)(float,float,float,float) r0.xyzw, r0.xyzx, t16.xyzw, s9, l(0.000000)
  add r0.w, -r0.w, l(1.000000)
  mul r0.w, r0.w, -r2.x
  mul r0.w, r0.w, l(1.442695)
  exp r1.x, r0.w
  mul r4.xyz, r0.wwww, cb0[49].xyzx
  exp r4.xyz, r4.xyzx
  add r4.xyz, -r4.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
  mul r0.xyz, r0.xyzx, r4.xyzx
  div r0.xyz, r0.xyzx, cb0[49].xyzx
  log r0.w, r3.w
  mul r4.xyz, r0.wwww, cb0[49].xyzx
  exp r4.xyz, r4.xyzx
  mad r3.xyz, r0.xyzx, r4.xyzx, r3.xyzx
  mul r3.w, r1.x, r3.w
endif
log r0.x, r3.w
mul r0.xyz, r0.xxxx, cb0[49].xyzx
exp r0.xyz, r0.xyzx
mul r0.xyz, r0.xyzx, r2.yzwy
mad r1.xyz, r3.xyzx, cb0[27].yyyy, r0.xyzx
movc r0.xyz, cb0[27].wwww, r0.xyzx, r1.xyzx
max r0.xyz, r0.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000)
ge r0.w, cb0[29].y, r1.w
movc r1.w, r0.w, l(0), r1.w
ine r0.w, l(4), cb0[27].z
mul r2.xyz, r0.xyzx, cb0[34].wwww
movc r1.xyz, r0.wwww, r2.xyzx, r0.xyzx
lt r0.x, l(1.000000), r1.w
if_nz r0.x
  ieq r0.xy, l(1, 2, 0, 0), cb0[27].zzzz
  or r0.x, r0.y, r0.x
  mul r0.yzw, r1.wwww, r1.xxyz
  movc r1.xyz, r0.xxxx, r0.yzwy, r1.xyzx
  mov_sat r1.w, r1.w
else
  max r1.w, r1.w, l(0.000000)
endif
mov o0.xyzw, r1.xyzw
mov o1.xyz, l(0,0,0,0)
mov o1.w, r1.w
ret
// Approximately 185 instruction slots used
