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

cbuffer cbCubeEnvSH1 : register(b11)
{
  float4 FC_CubeEnvSH1[3] : packoffset(c0);
}

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_ClampPointSampler_s : register(s7);
SamplerState g_samLinearWrap_s : register(s8);
Texture2D<float4> g_texAlbedo0 : register(t0);
Texture2D<float4> g_depthMap : register(t3);


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


void main( 
  float4 v0 : SV_Position0,
  float4 v1 : TEXCOORD0,
  float4 v2 : TEXCOORD1,
  float4 v3 : TEXCOORD2,
  nointerpolation uint4 v4 : TEXCORRD3,
  float4 v5 : TEXCOORD4,
  float4 v6 : TEXCOORD5,
  out float4 o0 : SV_TARGET0)
{
  float4 r0,r1,r2,r3,r4,r5;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.x = dot(v5.xyz, v5.xyz);
  r0.x = rsqrt(r0.x);
  r0.xyz = v5.xyz * r0.xxx;
  r0.x = dot(r0.xyz, FC_LsLightDir.xyz);
  r0.y = FC_LsHGg.z * -r0.x + FC_LsHGg.y;
  r0.x = r0.x * r0.x + 1;
  r0.y = max(9.99999997e-007, r0.y);
  r0.z = rsqrt(r0.y);
  r0.y = 1 / r0.y;
  r0.y = r0.z * r0.y;
  r0.y = FC_LsHGg.x * r0.y;
  r0.yzw = FC_LsBetaDash2.xyz * r0.yyy;
  r0.xyz = FC_LsBetaDash1.xyz * r0.xxx + r0.yzw;
  r0.w = dot(v5.xyzw, v5.xyzw);
  r0.w = sqrt(r0.w);
  r1.xyz = -FC_LsBeta1PlusBeta2.xyz * r0.www;
  r1.xyz = FC_LsLightDir.www * r1.xyz;
  r1.xyz = float3(2.08136892,2.08136892,2.08136892) * r1.xyz;
  r1.xyz = exp2(r1.xyz);
  r2.xyz = float3(1,1,1) + -r1.xyz;
  r1.xyz = FC_LsTerrainReflectance.xyz * r1.xyz;
  r0.xyz = r2.xyz * r0.xyz;
  r0.xyz = FC_LsOneOverBeta1PlusBeta2.xyz * r0.xyz;
  r0.xyz = FC_LsTerrainReflectance.www * r0.xyz;
  r0.xyz = FC_LsSunColor.xyz * r0.xyz;
  r0.w = g_depthMap.Sample(g_ClampPointSampler_s, v6.xy).x;
  r2.xy = (uint2)v4.xz >> int2(16,16);
  r2.zw = (int2)v4.zw & int2(0,0);
  r2.xyzw = f16tof32(r2.xyzw);
  r0.w = r0.w * r2.y + -r2.w;
  r0.w = -r2.z / r0.w;
  r0.w = -v6.z + r0.w;
  r0.w = min(v6.w, r0.w);
  r0.w = max(0, r0.w);
  r3.xyzw = g_texAlbedo0.Sample(g_samLinearWrap_s, v2.zw).xyzw;
  r2.yzw = v3.xyz * r3.xyz;
  r3.xyz = r2.yzw * r2.yzw;
  r4.xyzw = g_texAlbedo0.Sample(g_samLinearWrap_s, v2.xy).xyzw;
  r2.yzw = v3.xyz * r4.xyz;
  r4.xyz = r2.yzw * r2.yzw;
  r3.xyzw = -r4.xyzw + r3.xyzw;
  r2.xyzw = r2.xxxx * r3.xyzw + r4.xyzw;
  r0.w = r2.w * r0.w;
  r3.w = v3.w * r0.w;
  r0.w = dot(-v5.xz, -v5.xz);
  r0.w = sqrt(r0.w);
  r0.w = -FC_ExtFogParam.y + r0.w;
  r0.w = FC_ExtFogParam.z * r0.w;
  r0.w = exp2(-r0.w);
  r4.x = saturate(-r0.w * FC_ExtFogParam.x + FC_ExtFogParam.x);
  r0.w = FC_HeightFogParam.w + -v5.y;
  r0.w = -FC_HeightFogParam.y + r0.w;
  r0.w = saturate(FC_HeightFogParam.z * r0.w);
  r4.y = saturate(FC_HeightFogParam.x * r0.w);
  r4.zw = float2(1,1) + -r4.xy;
  r0.w = r4.z * r4.w;
  r5.w = r3.w * r0.w;
  r5.x = FC_CubeEnvSH1[0].w * r2.x;
  r5.y = FC_CubeEnvSH1[1].w * r2.y;
  r5.z = FC_CubeEnvSH1[2].w * r2.z;
  r0.w = dot(r5.xyz, float3(0.298909992,0.586610019,0.114480004));
  r0.w = -1 + r0.w;
  r1.w = FC_FogCol.w * r0.w + 1;
  r0.w = FC_HeightFogCol.w * r0.w + 1;
  r2.xyz = FC_FogCol.xyz * r1.www + -r5.xyz;
  r2.xyz = r4.xxx * r2.xyz + r5.xyz;
  r4.xzw = FC_HeightFogCol.xyz * r0.www + -r2.xyz;
  r3.xyz = r4.yyy * r4.xzw + r2.xyz;
  r0.w = cmp(0 < g_ps_FogMultMode);
  r2.xyzw = r0.wwww ? r5.xyzw : r3.xyzw;
  r0.xyz = r2.xyz * r1.xyz + r0.xyz;
  r0.xyz = r0.xyz + -r2.xyz;
  o0.xyz = saturate(FC_LsSunColor.www * r0.xyz + r2.xyz);
  r0.x = cmp(g_ps_softSpriteParam.y >= r2.w);
  o0.w = saturate(r0.x ? 0 : r2.w);
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Original ASM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546
//
//
// Buffer Definitions: 
//
// cbuffer cbCubeEnvSH1
// {
//
//   float4 FC_CubeEnvSH1[3];           // Offset:    0 Size:    48
//
// }
//
// 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_ClampPointSampler               sampler      NA          NA    7        1
// g_samLinearWrap                   sampler      NA          NA    8        1
// g_texAlbedo0                      texture  float4          2d    0        1
// g_depthMap                        texture  float4          2d    3        1
// PSCommonBuffer                    cbuffer      NA          NA    0        1
// cbFog                             cbuffer      NA          NA    6        1
// cbCubeEnvSH1                      cbuffer      NA          NA   11        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float       
// TEXCOORD                 0   xyz         1     NONE   float       
// TEXCOORD                 1   xyzw        2     NONE   float   xyzw
// TEXCOORD                 2   xyzw        3     NONE   float   xyzw
// TEXCORRD                 3   xyzw        4     NONE    uint   x zw
// TEXCOORD                 4   xyzw        5     NONE   float   xyzw
// TEXCOORD                 5   xyzw        6     NONE   float   xyzw
//
//
// 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 cb11[3], immediateIndexed
dcl_constantbuffer cb6[14], immediateIndexed
dcl_constantbuffer cb0[30], immediateIndexed
dcl_sampler s7, mode_default
dcl_sampler s8, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t3
dcl_input_ps linear v2.xyzw
dcl_input_ps linear v3.xyzw
dcl_input_ps constant v4.xzw
dcl_input_ps linear v5.xyzw
dcl_input_ps linear v6.xyzw
dcl_output o0.xyzw
dcl_temps 6
dp3 r0.x, v5.xyzx, v5.xyzx
rsq r0.x, r0.x
mul r0.xyz, r0.xxxx, v5.xyzx
dp3 r0.x, r0.xyzx, cb6[13].xyzx
mad r0.y, cb6[9].z, -r0.x, cb6[9].y
mad r0.x, r0.x, r0.x, l(1.000000)
max r0.y, r0.y, l(0.000001)
rsq r0.z, r0.y
div r0.y, l(1.000000, 1.000000, 1.000000, 1.000000), r0.y
mul r0.y, r0.y, r0.z
mul r0.y, r0.y, cb6[9].x
mul r0.yzw, r0.yyyy, cb6[11].xxyz
mad r0.xyz, cb6[10].xyzx, r0.xxxx, r0.yzwy
dp4 r0.w, v5.xyzw, v5.xyzw
sqrt r0.w, r0.w
mul r1.xyz, r0.wwww, -cb6[6].xyzx
mul r1.xyz, r1.xyzx, cb6[13].wwww
mul r1.xyz, r1.xyzx, l(2.081369, 2.081369, 2.081369, 0.000000)
exp r1.xyz, r1.xyzx
add r2.xyz, -r1.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
mul r1.xyz, r1.xyzx, cb6[7].xyzx
mul r0.xyz, r0.xyzx, r2.xyzx
mul r0.xyz, r0.xyzx, cb6[8].xyzx
mul r0.xyz, r0.xyzx, cb6[7].wwww
mul r0.xyz, r0.xyzx, cb6[12].xyzx
sample_indexable(texture2d)(float,float,float,float) r0.w, v6.xyxx, t3.yzwx, s7
ushr r2.xy, v4.xzxx, l(16, 16, 0, 0)
and r2.zw, v4.zzzw, l(0, 0, 0x0000ffff, 0x0000ffff)
f16tof32 r2.xyzw, r2.xyzw
mad r0.w, r0.w, r2.y, -r2.w
div r0.w, -r2.z, r0.w
add r0.w, r0.w, -v6.z
min r0.w, r0.w, v6.w
max r0.w, r0.w, l(0.000000)
sample_indexable(texture2d)(float,float,float,float) r3.xyzw, v2.zwzz, t0.xyzw, s8
mul r2.yzw, r3.xxyz, v3.xxyz
mul r3.xyz, r2.yzwy, r2.yzwy
sample_indexable(texture2d)(float,float,float,float) r4.xyzw, v2.xyxx, t0.xyzw, s8
mul r2.yzw, r4.xxyz, v3.xxyz
mul r4.xyz, r2.yzwy, r2.yzwy
add r3.xyzw, r3.xyzw, -r4.xyzw
mad r2.xyzw, r2.xxxx, r3.xyzw, r4.xyzw
mul r0.w, r0.w, r2.w
mul r3.w, r0.w, v3.w
dp2 r0.w, -v5.xzxx, -v5.xzxx
sqrt r0.w, r0.w
add r0.w, r0.w, -cb6[2].y
mul r0.w, r0.w, cb6[2].z
exp r0.w, -r0.w
mad_sat r4.x, -r0.w, cb6[2].x, cb6[2].x
add r0.w, -v5.y, cb6[3].w
add r0.w, r0.w, -cb6[3].y
mul_sat r0.w, r0.w, cb6[3].z
mul_sat r4.y, r0.w, cb6[3].x
add r4.zw, -r4.xxxy, l(0.000000, 0.000000, 1.000000, 1.000000)
mul r0.w, r4.w, r4.z
mul r5.w, r0.w, r3.w
mul r5.x, r2.x, cb11[0].w
mul r5.y, r2.y, cb11[1].w
mul r5.z, r2.z, cb11[2].w
dp3 r0.w, r5.xyzx, l(0.298910, 0.586610, 0.114480, 0.000000)
add r0.w, r0.w, l(-1.000000)
mad r1.w, cb6[1].w, r0.w, l(1.000000)
mad r0.w, cb6[4].w, r0.w, l(1.000000)
mad r2.xyz, cb6[1].xyzx, r1.wwww, -r5.xyzx
mad r2.xyz, r4.xxxx, r2.xyzx, r5.xyzx
mad r4.xzw, cb6[4].xxyz, r0.wwww, -r2.xxyz
mad r3.xyz, r4.yyyy, r4.xzwx, r2.xyzx
ilt r0.w, l(0), cb0[27].w
movc r2.xyzw, r0.wwww, r5.xyzw, r3.xyzw
mad r0.xyz, r2.xyzx, r1.xyzx, r0.xyzx
add r0.xyz, -r2.xyzx, r0.xyzx
mad_sat o0.xyz, cb6[12].wwww, r0.xyzx, r2.xyzx
ge r0.x, cb0[29].y, r2.w
movc_sat o0.w, r0.x, l(0), r2.w
ret 
// Approximately 76 instruction slots used

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