// ---- Created with 3Dmigoto v1.2.35 on Tue Apr 26 22:31:00 2016

cbuffer cbFog : register(b6)
{
  float4 FC_FogParam : packoffset(c0);
  float4 FC_FogCol : packoffset(c1);
  float4 FC_ExtFogParam : packoffset(c2);
  float4 FC_HeightFogParam : packoffset(c3);
  float4 FC_HeightFogCol : packoffset(c4);
  bool FC_FogType : packoffset(c5);
  float4 FC_LsBeta1PlusBeta2 : packoffset(c6);
  float4 FC_LsTerrainReflectance : packoffset(c7);
  float4 FC_LsOneOverBeta1PlusBeta2 : packoffset(c8);
  float4 FC_LsHGg : packoffset(c9);
  float4 FC_LsBetaDash1 : packoffset(c10);
  float4 FC_LsBetaDash2 : packoffset(c11);
  float4 FC_LsSunColor : packoffset(c12);
  float4 FC_LsLightDir : packoffset(c13);
}

cbuffer PSCommonBuffer : register(b0)
{
  float4 g_color : packoffset(c0);
  float4 g_directionalLightColor : packoffset(c1);
  float4 g_hemiLightColor0 : packoffset(c2);
  float4 g_hemiLightColor1 : packoffset(c3);
  float g_ps_nearFar : packoffset(c4);
  float g_ps_nearFarDistance : packoffset(c4.y);
  float g_ps_far : packoffset(c4.z);
  float g_ps_near : packoffset(c4.w);
  float g_waveTime : packoffset(c5);
  float g_clampDistanceInverse : packoffset(c5.y);
  float g_waveStrength : packoffset(c5.z);
  float g_waveNum : packoffset(c5.w);
  float g_vNormalMapScrollDistance : packoffset(c6);
  float g_hNormalMapScrollDistance : packoffset(c6.y);
  float g_fToneMapReceiprocalExposure : packoffset(c6.z);
  float2 g_screenCenter : packoffset(c7);
  float g_radialDistance : packoffset(c7.z);
  float g_TransrancyPower : packoffset(c7.w);
  float4 g_directionalLightColor2 : packoffset(c8);
  float4 g_vColorScale : packoffset(c9);
  float4 g_vAmbientSH[3] : packoffset(c10);
  float4 g_vLightMask : packoffset(c13);
  float4 g_vTracerParam : packoffset(c14);
  float g_Decay : packoffset(c15);
  float g_DecayWeight : packoffset(c15.y);
  float g_Dencity : packoffset(c15.z);
  float g_Exposure : packoffset(c15.w);
  float g_LightSourceScaleX : packoffset(c16);
  float g_LightSourceScaleY : packoffset(c16.y);
  int g_SampleNum : packoffset(c16.z);
  float g_LightSourceScale : packoffset(c16.w);
  float4 g_LightShaftScreenCenter : packoffset(c17);
  float4x4 g_psViewMatrix : packoffset(c18);
  float4 g_psGlowScale : packoffset(c22);
  int g_ps_TexBlendType : packoffset(c23);
  int g_ps_TexBlendType2 : packoffset(c23.y);
  int g_ps_TexBlendType3 : packoffset(c23.z);
  int g_ps_ColorBlendType : packoffset(c23.w);
  float4 g_ps_TextureColor1 : packoffset(c24);
  float4 g_ps_TextureColor2 : packoffset(c25);
  float4 g_ps_TextureColor3 : packoffset(c26);
  int g_ps_MultiTexBlendOld : packoffset(c27);
  int g_ps_RadiationBlurConjtrastAdjust : packoffset(c27.y);
  int g_ps_BlendingMode : packoffset(c27.z);
  int g_ps_FogMultMode : packoffset(c27.w);
  float4 g_ps_TextureOnlyColor : packoffset(c28);
  float4 g_ps_softSpriteParam : packoffset(c29);
  float g_ps_RadialBlurSamplingLengthMaxX : packoffset(c30);
  float g_ps_RadialBlurSamplingLengthMaxY : packoffset(c30.y);
  float2 g_ps_softSpriteScaleOffset : packoffset(c30.z);
  float4 g_ps_LightShaftDir : packoffset(c31);
  float4 g_ps_LightShaftDustScaleOffset : packoffset(c32);
  float4 g_ps_LightShaftDustThreshold : packoffset(c33);
  int g_ps_bPreAlphaMult : packoffset(c34);
  int3 g_ps_Dummy : packoffset(c34.y);
}

SamplerState g_samLinearWrap_s : register(s8);
Texture2D<float4> g_texAlbedo0 : register(t0);


// 3Dmigoto declarations
#define cmp -
Texture1D<float4> IniParams : register(t120);
Texture2D<float4> StereoParams : register(t125);


void main( 
  float4 v0 : SV_Position0,
  float4 v1 : TEXCOORD0,
  nointerpolation uint4 v2 : TEXCOORD1,
  float4 v3 : TEXCOORD2,
  float4 v4 : TEXCOORD3,
  float4 v5 : TEXCOORD4,
  float4 v6 : TEXCOORD5,
  float4 v7 : TEXCOORD6,
  float4 v8 : TEXCOORD7,
  float3 v9 : TEXCOORD8,
  out float4 o0 : SV_Target0)
{
  float4 r0,r1,r2,r3,r4;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.x = (uint)v2.x >> 16;
  r0.x = f16tof32(r0.x);
  r1.xyzw = g_texAlbedo0.Sample(g_samLinearWrap_s, v1.xy).xyzw;
  r2.xyzw = g_texAlbedo0.Sample(g_samLinearWrap_s, v1.zw).xyzw;
  r2.xyzw = r2.xyzw + -r1.xyzw;
  r0.xyzw = r0.xxxx * r2.yzxw + r1.yzxw;
  r1.z = saturate(r0.w);
  r1.w = cmp(0 < r1.z);
  if (r1.w != 0) {
    r1.w = dot(v5.xyz, v5.xyz);
    r1.w = rsqrt(r1.w);
    r2.xyz = v5.xyz * r1.www;
    r1.w = dot(v5.xyzw, v5.xyzw);
    r1.w = sqrt(r1.w);
    r2.w = FC_HeightFogParam.w + -v5.y;
    r2.w = -FC_HeightFogParam.y + r2.w;
    r2.w = saturate(FC_HeightFogParam.z * r2.w);
    r3.x = dot(-v5.xz, -v5.xz);
    r3.x = sqrt(r3.x);
    r3.x = -FC_ExtFogParam.y + r3.x;
    r3.x = FC_ExtFogParam.z * r3.x;
    r3.x = exp2(-r3.x);
    r3.x = saturate(-r3.x * FC_ExtFogParam.x + FC_ExtFogParam.x);
    r3.y = saturate(FC_HeightFogParam.x * r2.w);
    r2.w = dot(r0.zxy, float3(0.298909992,0.586610019,0.114480004));
    r2.w = -1 + r2.w;
    r3.z = FC_FogCol.w * r2.w + 1;
    r2.w = FC_HeightFogCol.w * r2.w + 1;
    r3.w = cmp(0 < g_ps_FogMultMode);
    r4.xy = float2(1,1) + -r3.xy;
    r4.x = r4.x * r4.y;
    r0.z = r4.x * r1.z;
    r4.xy = FC_FogCol.yz * r3.zz + -r0.xy;
    r3.xz = r3.xx * r4.xy + r0.xy;
    r4.xy = FC_HeightFogCol.yz * r2.ww + -r3.xz;
    r1.xy = r3.yy * r4.xy + r3.xz;
    r1.xyz = r3.www ? r0.xyz : r1.xyz;
    r2.x = dot(r2.xyz, FC_LsLightDir.xyz);
    r2.y = r2.x * r2.x + 1;
    r2.zw = -FC_LsBeta1PlusBeta2.yz * r1.ww;
    r2.zw = FC_LsLightDir.ww * r2.zw;
    r2.zw = float2(2.08136892,2.08136892) * r2.zw;
    r2.zw = exp2(r2.zw);
    r3.xy = FC_LsTerrainReflectance.yz * r2.zw;
    r1.w = FC_LsHGg.z * -r2.x + FC_LsHGg.y;
    r1.w = max(9.99999997e-007, r1.w);
    r2.x = rsqrt(r1.w);
    r1.w = 1 / r1.w;
    r1.w = r2.x * r1.w;
    r1.w = FC_LsHGg.x * r1.w;
    r3.zw = FC_LsBetaDash2.yz * r1.ww;
    r2.xy = FC_LsBetaDash1.yz * r2.yy + r3.zw;
    r2.zw = float2(1,1) + -r2.zw;
    r2.xy = r2.xy * r2.zw;
    r2.xy = FC_LsOneOverBeta1PlusBeta2.yz * r2.xy;
    r2.xy = FC_LsTerrainReflectance.ww * r2.xy;
    r2.xy = FC_LsSunColor.yz * r2.xy;
    r2.xy = r1.xy * r3.xy + r2.xy;
    r2.xy = r2.xy + -r1.xy;
    r0.xy = FC_LsSunColor.ww * r2.xy + r1.xy;
    r0.zw = r1.zz * float2(-0.5,1) + float2(0.5,0);
  } else {
    r0.w = 0;
  }
  r0.xyzw = saturate(r0.xyzw);
  r1.x = cmp(g_ps_softSpriteParam.y >= r0.w);
  o0.w = r1.x ? 0 : r0.w;
  o0.xyz = r0.zxy;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Original ASM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546
//
//
// Buffer Definitions: 
//
// cbuffer cbFog
// {
//
//   float4 FC_FogParam;                // Offset:    0 Size:    16 [unused]
//   float4 FC_FogCol;                  // Offset:   16 Size:    16
//   float4 FC_ExtFogParam;             // Offset:   32 Size:    16
//   float4 FC_HeightFogParam;          // Offset:   48 Size:    16
//   float4 FC_HeightFogCol;            // Offset:   64 Size:    16
//   bool FC_FogType;                   // Offset:   80 Size:     4 [unused]
//   float4 FC_LsBeta1PlusBeta2;        // Offset:   96 Size:    16
//   float4 FC_LsTerrainReflectance;    // Offset:  112 Size:    16
//   float4 FC_LsOneOverBeta1PlusBeta2; // Offset:  128 Size:    16
//   float4 FC_LsHGg;                   // Offset:  144 Size:    16
//   float4 FC_LsBetaDash1;             // Offset:  160 Size:    16
//   float4 FC_LsBetaDash2;             // Offset:  176 Size:    16
//   float4 FC_LsSunColor;              // Offset:  192 Size:    16
//   float4 FC_LsLightDir;              // Offset:  208 Size:    16
//
// }
//
// cbuffer PSCommonBuffer
// {
//
//   float4 g_color;                    // Offset:    0 Size:    16 [unused]
//   float4 g_directionalLightColor;    // Offset:   16 Size:    16 [unused]
//   float4 g_hemiLightColor0;          // Offset:   32 Size:    16 [unused]
//   float4 g_hemiLightColor1;          // Offset:   48 Size:    16 [unused]
//   float g_ps_nearFar;                // Offset:   64 Size:     4 [unused]
//   float g_ps_nearFarDistance;        // Offset:   68 Size:     4 [unused]
//   float g_ps_far;                    // Offset:   72 Size:     4 [unused]
//   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_directionalLightColor2;   // Offset:  128 Size:    16 [unused]
//   float4 g_vColorScale;              // Offset:  144 Size:    16 [unused]
//   float4 g_vAmbientSH[3];            // Offset:  160 Size:    48 [unused]
//   float4 g_vLightMask;               // Offset:  208 Size:    16 [unused]
//   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 [unused]
//   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]
//   int g_ps_MultiTexBlendOld;         // Offset:  432 Size:     4 [unused]
//   int g_ps_RadiationBlurConjtrastAdjust;// Offset:  436 Size:     4 [unused]
//   int g_ps_BlendingMode;             // Offset:  440 Size:     4 [unused]
//   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 [unused]
//   int3 g_ps_Dummy;                   // Offset:  548 Size:    12 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// g_samLinearWrap                   sampler      NA          NA    8        1
// g_texAlbedo0                      texture  float4          2d    0        1
// PSCommonBuffer                    cbuffer      NA          NA    0        1
// cbFog                             cbuffer      NA          NA    6        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float       
// TEXCOORD                 0   xyzw        1     NONE   float   xyzw
// TEXCOORD                 1   xyzw        2     NONE    uint   x   
// TEXCOORD                 2   xyzw        3     NONE   float       
// TEXCOORD                 3   xyzw        4     NONE   float       
// TEXCOORD                 4   xyzw        5     NONE   float   xyzw
// TEXCOORD                 5   xyzw        6     NONE   float       
// TEXCOORD                 6   xyz         7     NONE   float       
// TEXCOORD                 7   xyz         8     NONE   float       
// TEXCOORD                 8   xyz         9     NONE   float       
//
//
// 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 cb6[14], immediateIndexed
dcl_constantbuffer cb0[30], immediateIndexed
dcl_sampler s8, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_input_ps linear v1.xyzw
dcl_input_ps constant v2.x
dcl_input_ps linear v5.xyzw
dcl_output o0.xyzw
dcl_temps 5
ushr r0.x, v2.x, l(16)
f16tof32 r0.x, r0.x
sample_indexable(texture2d)(float,float,float,float) r1.xyzw, v1.xyxx, t0.xyzw, s8
sample_indexable(texture2d)(float,float,float,float) r2.xyzw, v1.zwzz, t0.xyzw, s8
add r2.xyzw, -r1.xyzw, r2.xyzw
mad r0.xyzw, r0.xxxx, r2.yzxw, r1.yzxw
mov_sat r1.z, r0.w
lt r1.w, l(0.000000), r1.z
if_nz r1.w
  dp3 r1.w, v5.xyzx, v5.xyzx
  rsq r1.w, r1.w
  mul r2.xyz, r1.wwww, v5.xyzx
  dp4 r1.w, v5.xyzw, v5.xyzw
  sqrt r1.w, r1.w
  add r2.w, -v5.y, cb6[3].w
  add r2.w, r2.w, -cb6[3].y
  mul_sat r2.w, r2.w, cb6[3].z
  dp2 r3.x, -v5.xzxx, -v5.xzxx
  sqrt r3.x, r3.x
  add r3.x, r3.x, -cb6[2].y
  mul r3.x, r3.x, cb6[2].z
  exp r3.x, -r3.x
  mad_sat r3.x, -r3.x, cb6[2].x, cb6[2].x
  mul_sat r3.y, r2.w, cb6[3].x
  dp3 r2.w, r0.zxyz, l(0.298910, 0.586610, 0.114480, 0.000000)
  add r2.w, r2.w, l(-1.000000)
  mad r3.z, cb6[1].w, r2.w, l(1.000000)
  mad r2.w, cb6[4].w, r2.w, l(1.000000)
  ilt r3.w, l(0), cb0[27].w
  add r4.xy, -r3.xyxx, l(1.000000, 1.000000, 0.000000, 0.000000)
  mul r4.x, r4.y, r4.x
  mul r0.z, r1.z, r4.x
  mad r4.xy, cb6[1].yzyy, r3.zzzz, -r0.xyxx
  mad r3.xz, r3.xxxx, r4.xxyx, r0.xxyx
  mad r4.xy, cb6[4].yzyy, r2.wwww, -r3.xzxx
  mad r1.xy, r3.yyyy, r4.xyxx, r3.xzxx
  movc r1.xyz, r3.wwww, r0.xyzx, r1.xyzx
  dp3 r2.x, r2.xyzx, cb6[13].xyzx
  mad r2.y, r2.x, r2.x, l(1.000000)
  mul r2.zw, r1.wwww, -cb6[6].yyyz
  mul r2.zw, r2.zzzw, cb6[13].wwww
  mul r2.zw, r2.zzzw, l(0.000000, 0.000000, 2.081369, 2.081369)
  exp r2.zw, r2.zzzw
  mul r3.xy, r2.zwzz, cb6[7].yzyy
  mad r1.w, cb6[9].z, -r2.x, cb6[9].y
  max r1.w, r1.w, l(0.000001)
  rsq r2.x, r1.w
  div r1.w, l(1.000000, 1.000000, 1.000000, 1.000000), r1.w
  mul r1.w, r1.w, r2.x
  mul r1.w, r1.w, cb6[9].x
  mul r3.zw, r1.wwww, cb6[11].yyyz
  mad r2.xy, cb6[10].yzyy, r2.yyyy, r3.zwzz
  add r2.zw, -r2.zzzw, l(0.000000, 0.000000, 1.000000, 1.000000)
  mul r2.xy, r2.zwzz, r2.xyxx
  mul r2.xy, r2.xyxx, cb6[8].yzyy
  mul r2.xy, r2.xyxx, cb6[7].wwww
  mul r2.xy, r2.xyxx, cb6[12].yzyy
  mad r2.xy, r1.xyxx, r3.xyxx, r2.xyxx
  add r2.xy, -r1.xyxx, r2.xyxx
  mad r0.xy, cb6[12].wwww, r2.xyxx, r1.xyxx
  mad r0.zw, r1.zzzz, l(0.000000, 0.000000, -0.500000, 1.000000), l(0.000000, 0.000000, 0.500000, 0.000000)
else 
  mov r0.w, l(0)
endif 
mov_sat r0.xyzw, r0.xyzw
ge r1.x, cb0[29].y, r0.w
movc o0.w, r1.x, l(0), r0.w
mov o0.xyz, r0.zxyz
ret 
// Approximately 69 instruction slots used

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
