// Fog PS - Stain and Tint remove
// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546
//
//   using 3Dmigoto v1.2.57 on Fri Jun 02 13:32:22 2017
//
//
// Buffer Definitions: 
//
// cbuffer $Globals
// {
//
//   float4 SharedFogParameter0;        // Offset:    0 Size:    16 [unused]
//   float4 SharedFogParameter1;        // Offset:   16 Size:    16 [unused]
//   float4 SharedFogParameter2;        // Offset:   32 Size:    16 [unused]
//   float4 SharedFogParameter3;        // Offset:   48 Size:    16 [unused]
//   bool bUseExponentialHeightFog;     // Offset:   64 Size:     4 [unused]
//   float4 FogInScattering[4];         // Offset:   80 Size:    64 [unused]
//   float4 FogMaxHeight;               // Offset:  144 Size:    16 [unused]
//   float4 TextureSize;                // Offset:  160 Size:    16
//   float4 ClampRects;                 // Offset:  176 Size:    16
//
// }
//
// cbuffer PSOffsetConstants
// {
//
//   float4 ScreenPositionScaleBias;    // Offset:    0 Size:    16 [unused]
//   float4 MinZ_MaxZRatio;             // Offset:   16 Size:    16
//   float NvStereoEnabled;             // Offset:   32 Size:     4 [unused]
//   float MetallicOverrideParameter;   // Offset:   36 Size:     4 [unused]
//   float4 DiffuseOverrideParameter;   // Offset:   48 Size:    16 [unused]
//   float4 SpecularOverrideParameter;  // Offset:   64 Size:    16 [unused]
//   float4 CameraPositionPS;           // Offset:   80 Size:    16 [unused]
//   float4 ScreenAndTexelSize;         // Offset:   96 Size:    16 [unused]
//   float4 ViewClampRect;              // Offset:  112 Size:    16 [unused]
//   float2 ProjectionInvScale;         // Offset:  128 Size:     8 [unused]
//   float4x4 ViewProjectionMatrixPS;   // Offset:  144 Size:    64 [unused]
//   float2 SceneColorExponentBias;     // Offset:  208 Size:     8 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// SceneDepthTextureSampler          sampler      NA          NA    2        1
// PointSampler                      sampler      NA          NA    3        1
// BilinearSampler                   sampler      NA          NA    4        1
// SceneDepthTexture                 texture  float4          2d    0        1
// DownsampledDepthTexture           texture  float4          2d    1        1
// FogTextureNear                    texture  float4          2d    2        1
// FogTextureFar                     texture  float4          2d    3        1
// OpticalDepthTexture               texture  float4          2d    4        1
// $Globals                          cbuffer      NA          NA    0        1
// PSOffsetConstants                 cbuffer      NA          NA    2        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// TEXCOORD                 0   xy          0     NONE   float   xy  
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
//
ps_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[12], immediateIndexed
dcl_constantbuffer cb2[2], immediateIndexed
dcl_sampler s2, mode_default
dcl_sampler s3, mode_default
dcl_sampler s4, 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_resource_texture2d (float,float,float,float) t3
dcl_resource_texture2d (float,float,float,float) t4
dcl_input_ps linear v0.xy
dcl_output o0.xyzw
dcl_temps 13


min r0.xy, v0.xyxx, cb0[11].xyxx

sample_l_indexable(texture2d)(float,float,float,float) r0.z, v0.xyxx, t0.yzxw, s2, l(0.000000)

max r0.z, r0.z, l(0.00100000994)
mad r0.z, r0.z, cb2[1].z, -cb2[1].w

div r0.z, l(1.000000, 1.000000, 1.000000, 1.000000), r0.z
min r0.z, r0.z, l(65504.000000)


gather4_indexable(texture2d)(float,float,float,float) r1.xyzw, r0.xyxx, t1.xyzw, s3.x
gather4_indexable(texture2d)(float,float,float,float) r2.xyzw, r0.xyxx, t1.xyzw, s3.y
min r0.w, r1.z, r1.y
min r0.w, r0.w, r1.x
min r0.w, r1.w, r0.w
max r3.x, r2.z, r2.y
max r3.x, r2.x, r3.x
max r3.x, r2.w, r3.x
add r0.w, -r0.w, r3.x
div_sat r0.w, |r0.w|, r0.z
lt r0.w, r0.w, l(0.100000)
if_nz r0.w
  sample_l_indexable(texture2d)(float,float,float,float) r3.xyz, r0.xyxx, t2.xyzw, s4, l(0.000000)
  sample_l_indexable(texture2d)(float,float,float,float) r0.w, r0.xyxx, t4.yzwx, s4, l(0.000000)
  
  //seems to remove the stain/tint
  mov r0.w, l(0.0)
  
  exp o0.w, -r0.w
  mov o0.xyz, r3.xyzx
else 
  mad r3.xy, r0.yxyy, cb0[10].yxyy, l(0.500000, 0.500000, 0.000000, 0.000000)
  frc r3.xy, r3.xyxx
  gather4_indexable(texture2d)(float,float,float,float) r4.xyzw, r0.xyxx, t2.xyzw, s3.x
  gather4_indexable(texture2d)(float,float,float,float) r5.xyzw, r0.xyxx, t2.xyzw, s3.y
  gather4_indexable(texture2d)(float,float,float,float) r6.xyzw, r0.xyxx, t2.xyzw, s3.z
  gather4_indexable(texture2d)(float,float,float,float) r7.xyzw, r0.xyxx, t4.xyzw, s3.x
  gather4_indexable(texture2d)(float,float,float,float) r8.xyzw, r0.xyxx, t3.xyzw, s3.x
  gather4_indexable(texture2d)(float,float,float,float) r9.xyzw, r0.xyxx, t3.xyzw, s3.y
  gather4_indexable(texture2d)(float,float,float,float) r10.xyzw, r0.xyxx, t3.xyzw, s3.z
  gather4_indexable(texture2d)(float,float,float,float) r11.xyzw, r0.xyxx, t4.xyzw, s3.y
  add r12.xyzw, r0.zzzz, -r1.xyzw
  add r1.xyzw, -r1.xyzw, r2.xyzw
  max r1.xyzw, r1.xyzw, l(0.001000, 0.001000, 0.001000, 0.001000)
  div_sat r1.xyzw, r12.xyzw, r1.xyzw
  mul r12.xyzw, |r12.xyzw|, l(0.010000, 0.010000, 0.010000, 0.010000)
  min r12.xyzw, r12.xyzw, l(1.000000, 1.000000, 1.000000, 1.000000)
  add r12.xyzw, -r12.xyzw, l(1.000000, 1.000000, 1.000000, 1.000000)
  add r0.xyzw, r0.zzzz, -r2.xyzw
  mul r0.xyzw, |r0.xyzw|, l(0.010000, 0.010000, 0.010000, 0.010000)
  min r0.xyzw, r0.xyzw, l(1.000000, 1.000000, 1.000000, 1.000000)
  add r0.xyzw, -r0.xyzw, l(1.000000, 1.000000, 1.000000, 1.000000)
  max r0.xyzw, r0.xyzw, r12.xyzw
  add r2.xy, -r3.yxyy, l(1.000000, 1.000000, 0.000000, 0.000000)
  mul r12.y, r3.x, r3.y
  mul r12.xz, r3.xxyx, r2.xxyx
  mul r12.w, r2.y, r2.x
  mul r2.xyzw, r0.xyzw, r12.xyzw
  add r0.x, r2.y, r2.x
  mad r0.x, r0.z, r12.z, r0.x
  mad r0.x, r0.w, r12.w, r0.x
  lt r0.y, l(0.000000), r0.x
  div r2.xyzw, r2.xyzw, r0.xxxx
  movc r0.xyzw, r0.yyyy, r2.xyzw, l(0.250000,0.250000,0.250000,0.250000)
  add r2.xyzw, -r4.xyzw, r8.xyzw
  mad r2.xyzw, r1.xyzw, r2.xyzw, r4.xyzw
  dp4 o0.x, r2.xyzw, r0.xyzw
  add r2.xyzw, -r5.xyzw, r9.xyzw
  mad r2.xyzw, r1.xyzw, r2.xyzw, r5.xyzw
  dp4 o0.y, r2.xyzw, r0.xyzw
  add r2.xyzw, -r6.xyzw, r10.xyzw
  mad r2.xyzw, r1.xyzw, r2.xyzw, r6.xyzw
  dp4 o0.z, r2.xyzw, r0.xyzw
  add r2.xyzw, -r7.xyzw, r11.xyzw
  mad r1.xyzw, r1.xyzw, r2.xyzw, r7.xyzw
  dp4 r0.x, r1.xyzw, r0.xyzw
  
  //seems to remove the stain/tint
  mov r0.x, l(0.0)
  
  exp o0.w, -r0.x
endif 
ret 
// Approximately 71 instruction slots used
