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

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);
}

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);
}

SamplerState g_ClampLinearSampler_s : register(s9);
Texture2D<float4> g_diffuseTexture : register(t0);
Texture2D<float4> g_depthTexture : register(t3);


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


void main( 
  float4 v0 : COLOR0,
  float3 v1 : TEXCOORD0,
  float w1 : TEXCOORD4,
  float4 v2 : TEXCOORD2,
  float4 v3 : TEXCOORD3,
  out float4 o0 : SV_Target0)
{
  float4 r0,r1,r2,r3,r4,r5;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.x = g_vAmbientSH[0].w + -v0.x;
  r0.y = g_vAmbientSH[1].w + -v0.y;
  r0.z = g_vAmbientSH[2].w + -v0.z;
  r0.xyz = g_ps_softSpriteParam.www * r0.xyz + v0.xyz;
  r0.w = dot(r0.xyz, r0.xyz);
  r1.xyz = sqrt(r0.www);
  r0.xyz = r0.xyz / r1.xyz;
  r2.x = 0;
  r2.w = v0.w;
  r0.w = v0.w;
  r2.y = cmp(9.99999975e-006 >= r1.z);
  r0.xyzw = r2.yyyy ? r2.xxxw : r0.xyzw;
  r2.xyz = float3(1,1,1) + -r0.xyz;
  r3.xyzw = g_diffuseTexture.Sample(g_ClampLinearSampler_s, v1.xy).xyzw;
  r2.w = cmp(0 < g_ps_bPreAlphaMult);
  r4.w = saturate(w1.x + r3.w);
  r2.w = r2.w ? r4.w : 1;
  r4.xyz = r3.xyz * r2.www;
  r3.xyz = -r4.xyz * r4.www + float3(1,1,1);
  r3.xyz = r3.xyz + r3.xyz;
  r2.xyz = -r3.xyz * r2.xyz + float3(1,1,1);
  r3.xyz = r4.xyz * r4.www;
  r5.xyzw = r4.xyzw * r0.xyzw;
  r4.w = r4.w * r0.w;
  r0.xyz = r3.xyz * r0.xyz;
  r3.xyz = cmp(r3.xyz < float3(0.5,0.5,0.5));
  r0.xyz = r0.xyz + r0.xyz;
  r0.xyz = r3.xyz ? r0.xyz : r2.xyz;
  r4.xyz = r0.xyz * r0.xyz;
  r0.xyzw = g_vColorScale.xyzw * r4.xyzw;
  r1.w = 1;
  r0.xyzw = r1.xyzw * r0.xyzw;
  r5.xyz = r5.xyz * r5.xyz;
  r2.xyzw = g_vColorScale.xyzw * r5.xyzw;
  r1.xyzw = r2.xyzw * r1.xyzw;
  r2.x = cmp(2 == g_ps_ColorBlendType);
  r0.xyzw = r2.xxxx ? r0.xyzw : r1.xyzw;
  r1.x = dot(r0.xyz, float3(0.298909992,0.586610019,0.114480004));
  r1.x = -1 + r1.x;
  r1.y = FC_FogCol.w * r1.x + 1;
  r1.x = FC_HeightFogCol.w * r1.x + 1;
  r1.yzw = FC_FogCol.xyz * r1.yyy + -r0.xyz;
  r2.x = dot(-v2.xz, -v2.xz);
  r2.x = sqrt(r2.x);
  r2.x = -FC_ExtFogParam.y + r2.x;
  r2.x = FC_ExtFogParam.z * r2.x;
  r2.x = exp2(-r2.x);
  r2.x = saturate(-r2.x * FC_ExtFogParam.x + FC_ExtFogParam.x);
  r1.yzw = r2.xxx * r1.yzw + r0.xyz;
  r3.xyz = FC_HeightFogCol.xyz * r1.xxx + -r1.yzw;
  r1.x = FC_HeightFogParam.w + -v2.y;
  r1.x = -FC_HeightFogParam.y + r1.x;
  r1.x = saturate(FC_HeightFogParam.z * r1.x);
  r2.y = saturate(FC_HeightFogParam.x * r1.x);
  r1.xyz = r2.yyy * r3.xyz + r1.yzw;
  r2.xy = float2(1,1) + -r2.xy;
  r2.x = r2.x * r2.y;
  r2.y = g_depthTexture.Sample(g_ClampLinearSampler_s, v3.xy).x;
  r2.y = r2.y * g_ps_nearFarDistance + -g_ps_far;
  r2.y = -g_ps_nearFar / r2.y;
  r2.y = -v3.z + r2.y;
  r2.y = min(v3.w, r2.y);
  r2.y = saturate(r2.y / v3.w);
  r2.z = cmp(v3.w < 9.99999975e-005);
  r2.y = r2.z ? 1 : r2.y;
  r1.w = r2.y * r0.w;
  r0.w = r1.w * r2.x;
  r2.x = cmp(0 < g_ps_FogMultMode);
  r0.xyzw = r2.xxxx ? r0.xyzw : r1.xyzw;
  r1.x = cmp(0 < g_vTracerParam.w);
  r0.xyzw = r1.xxxx ? r0.wwww : r0.xyzw;
  r0.xyzw = max(float4(0,0,0,0), r0.xyzw);
  r1.x = cmp(g_ps_softSpriteParam.y >= r0.w);
  o0.w = r1.x ? 0 : r0.w;
  o0.xyz = r0.xyz;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Original ASM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546
//
//
// Buffer Definitions: 
//
// 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
//   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_directionalLightColor2;   // Offset:  128 Size:    16 [unused]
//   float4 g_vColorScale;              // Offset:  144 Size:    16
//   float4 g_vAmbientSH[3];            // Offset:  160 Size:    48
//   float4 g_vLightMask;               // Offset:  208 Size:    16 [unused]
//   float4 g_vTracerParam;             // Offset:  224 Size:    16
//   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]
//   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
//   int3 g_ps_Dummy;                   // Offset:  548 Size:    12 [unused]
//
// }
//
// 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 [unused]
//   float4 FC_LsTerrainReflectance;    // Offset:  112 Size:    16 [unused]
//   float4 FC_LsOneOverBeta1PlusBeta2; // Offset:  128 Size:    16 [unused]
//   float4 FC_LsHGg;                   // Offset:  144 Size:    16 [unused]
//   float4 FC_LsBetaDash1;             // Offset:  160 Size:    16 [unused]
//   float4 FC_LsBetaDash2;             // Offset:  176 Size:    16 [unused]
//   float4 FC_LsSunColor;              // Offset:  192 Size:    16 [unused]
//   float4 FC_LsLightDir;              // Offset:  208 Size:    16 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// g_ClampLinearSampler              sampler      NA          NA    9        1
// g_diffuseTexture                  texture  float4          2d    0        1
// g_depthTexture                    texture  float4          2d    3        1
// PSCommonBuffer                    cbuffer      NA          NA    0        1
// cbFog                             cbuffer      NA          NA    6        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                 4      w        1     NONE   float      w
// TEXCOORD                 2   xyzw        2     NONE   float   xyz 
// TEXCOORD                 3   xyzw        3     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 cb0[35], immediateIndexed
dcl_constantbuffer cb6[5], immediateIndexed
dcl_sampler s9, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t3
dcl_input_ps linear v0.xyzw
dcl_input_ps linear v1.xy
dcl_input_ps linear v1.w
dcl_input_ps linear v2.xyz
dcl_input_ps linear v3.xyzw
dcl_output o0.xyzw
dcl_temps 6
add r0.x, -v0.x, cb0[10].w
add r0.y, -v0.y, cb0[11].w
add r0.z, -v0.z, cb0[12].w
mad r0.xyz, cb0[29].wwww, r0.xyzx, v0.xyzx
dp3 r0.w, r0.xyzx, r0.xyzx
sqrt r1.xyz, r0.wwww
div r0.xyz, r0.xyzx, r1.xyzx
mov r2.x, l(0)
mov r2.w, v0.w
mov r0.w, v0.w
ge r2.y, l(0.000010), r1.z
movc r0.xyzw, r2.yyyy, r2.xxxw, r0.xyzw
add r2.xyz, -r0.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
sample_indexable(texture2d)(float,float,float,float) r3.xyzw, v1.xyxx, t0.xyzw, s9
ilt r2.w, l(0), cb0[34].x
add_sat r4.w, r3.w, v1.w
movc r2.w, r2.w, r4.w, l(1.000000)
mul r4.xyz, r2.wwww, r3.xyzx
mad r3.xyz, -r4.xyzx, r4.wwww, l(1.000000, 1.000000, 1.000000, 0.000000)
add r3.xyz, r3.xyzx, r3.xyzx
mad r2.xyz, -r3.xyzx, r2.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
mul r3.xyz, r4.wwww, r4.xyzx
mul r5.xyzw, r0.xyzw, r4.xyzw
mul r4.w, r0.w, r4.w
mul r0.xyz, r0.xyzx, r3.xyzx
lt r3.xyz, r3.xyzx, l(0.500000, 0.500000, 0.500000, 0.000000)
add r0.xyz, r0.xyzx, r0.xyzx
movc r0.xyz, r3.xyzx, r0.xyzx, r2.xyzx
mul r4.xyz, r0.xyzx, r0.xyzx
mul r0.xyzw, r4.xyzw, cb0[9].xyzw
mov r1.w, l(1.000000)
mul r0.xyzw, r0.xyzw, r1.xyzw
mul r5.xyz, r5.xyzx, r5.xyzx
mul r2.xyzw, r5.xyzw, cb0[9].xyzw
mul r1.xyzw, r1.xyzw, r2.xyzw
ieq r2.x, l(2), cb0[23].w
movc r0.xyzw, r2.xxxx, r0.xyzw, r1.xyzw
dp3 r1.x, r0.xyzx, l(0.298910, 0.586610, 0.114480, 0.000000)
add r1.x, r1.x, l(-1.000000)
mad r1.y, cb6[1].w, r1.x, l(1.000000)
mad r1.x, cb6[4].w, r1.x, l(1.000000)
mad r1.yzw, cb6[1].xxyz, r1.yyyy, -r0.xxyz
dp2 r2.x, -v2.xzxx, -v2.xzxx
sqrt r2.x, r2.x
add r2.x, r2.x, -cb6[2].y
mul r2.x, r2.x, cb6[2].z
exp r2.x, -r2.x
mad_sat r2.x, -r2.x, cb6[2].x, cb6[2].x
mad r1.yzw, r2.xxxx, r1.yyzw, r0.xxyz
mad r3.xyz, cb6[4].xyzx, r1.xxxx, -r1.yzwy
add r1.x, -v2.y, cb6[3].w
add r1.x, r1.x, -cb6[3].y
mul_sat r1.x, r1.x, cb6[3].z
mul_sat r2.y, r1.x, cb6[3].x
mad r1.xyz, r2.yyyy, r3.xyzx, r1.yzwy
add r2.xy, -r2.xyxx, l(1.000000, 1.000000, 0.000000, 0.000000)
mul r2.x, r2.y, r2.x
sample_indexable(texture2d)(float,float,float,float) r2.y, v3.xyxx, t3.yxzw, s9
mad r2.y, r2.y, cb0[4].y, -cb0[4].z
div r2.y, -cb0[4].x, r2.y
add r2.y, r2.y, -v3.z
min r2.y, r2.y, v3.w
div_sat r2.y, r2.y, v3.w
lt r2.z, v3.w, l(0.000100)
movc r2.y, r2.z, l(1.000000), r2.y
mul r1.w, r0.w, r2.y
mul r0.w, r2.x, r1.w
ilt r2.x, l(0), cb0[27].w
movc r0.xyzw, r2.xxxx, r0.xyzw, r1.xyzw
lt r1.x, l(0.000000), cb0[14].w
movc r0.xyzw, r1.xxxx, r0.wwww, r0.xyzw
max r0.xyzw, r0.xyzw, l(0.000000, 0.000000, 0.000000, 0.000000)
ge r1.x, cb0[29].y, r0.w
movc o0.w, r1.x, l(0), r0.w
mov o0.xyz, r0.xyzx
ret 
// Approximately 76 instruction slots used

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