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

cbuffer cbSceneParam : register(b8)
{
  float4 FC_FarClipInfo : packoffset(c0);
  float4 FC_ScreenSize : packoffset(c1);
  float4 FC_DepthComputeParam : packoffset(c2);
  float4 SC_CameraPos : packoffset(c3);
  float4 VC_ClipPlane : packoffset(c4);
  float4x3 FC_MatrixView : packoffset(c5);
  float4x4 FC_MatrixInvViewProj : packoffset(c8);
  float4x4 FC_MatrixInvProj : packoffset(c12);
  float4x4 FC_MatrixProj : packoffset(c16);
  float4x4 FC_MatrixInvView : packoffset(c20);
  float4x4 VC_MatrixViewProj : packoffset(c24);
  float4 FC_ShadowMapParam : packoffset(c28);
  float4 FC_ShadowColor : packoffset(c29);
  float4 FC_ShadowDir : packoffset(c30);
  float4x4 VC_ShadowMapMatrix : packoffset(c31);
  float FC_ShadowDepthRate : packoffset(c35);
  float FC_ShadowDepthScale : packoffset(c35.y);
  float FC_ShadowKernelScale : packoffset(c35.z);
  float FC_ShadowRandTexInvScale : packoffset(c35.w);
  float FC_ShadowTexInvScaleX : packoffset(c36);
  float FC_ShadowTexInvScaleY : packoffset(c36.y);
  float FC_ShadowDepthOffsetScale : packoffset(c36.z);
  float4 FC_ShadowViewKernelScale : packoffset(c37);
  float4x4 FC_ProjSpaceToShadowMatrix[4] : packoffset(c38);
  float4 FC_CascadeSelectDist : packoffset(c54);
  float FC_FrustumNear : packoffset(c55);
  float FC_FrustumSliceScale : packoffset(c55.y);
  float FC_FrustumSliceBias : packoffset(c55.z);
  uint FC_LightTile_Width : packoffset(c56);
  uint FC_LightTile_NumCellX : packoffset(c56.y);
  float4 FC_CloudShadowParam0 : packoffset(c57);
  float4 FC_CloudShadowParam1 : packoffset(c58);
  float FC_ShadowScale0 : packoffset(c59);
  float FC_ShadowScale1 : packoffset(c59.y);
}

cbuffer cbPerFrame : register(b9)
{
  float4 FC_DebugParam : packoffset(c0);
  float4 FC_DebugOutputMode : packoffset(c1);
  float4 FC_DebugParam2 : packoffset(c2);
  float FC_GlobalSpecularMask : packoffset(c3);
  float FC_GlobalReflectanceScale : packoffset(c3.y);
  float FC_GlobalShininessScale : packoffset(c3.z);
  float FC_GlobalAlbedoOffset : packoffset(c3.w);
  float4 FC_GlobalRefRectanceRGBScale : packoffset(c4);
  float4 FC_GlobalAlbedoOffsetRGB : packoffset(c5);
  float4 FC_SnowDir : packoffset(c6);
  float4 FC_SnowTilingScale : packoffset(c7);
  float4 FC_SnowAlbedo : packoffset(c8);
  float FC_SnowReflectance : packoffset(c9);
  float FC_GroundPlaneHeight : packoffset(c9.y);
  float FC_RcpSnowHeightRange : packoffset(c9.z);
  float FC_SnowNormalScale : packoffset(c9.w);
  float4 FC_SnowSpakleTinlingScale : packoffset(c10);
  float FC_GlobalTime : packoffset(c11);
  float FC_DominantSharpnesMinValue : packoffset(c12);
  float FC_DominantSharpnesOffset : packoffset(c12.y);
  float FC_DominantSharpnesExponent : packoffset(c12.z);
  float FC_DominantColorScale : packoffset(c12.w);
  float4 FC_DominantRgbScale : packoffset(c13);
}

SamplerState SS_ClampPoint_s : register(s7);
SamplerState SS_ClampLinear_s : register(s9);
Texture2D<float4> g_LightPrepassAttrTexture : register(t0);
Texture2D<float4> g_LightPrepassAttrTexture2 : register(t1);
Texture2D<float4> g_DepthTexture : register(t2);


// 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,
  out float4 o0 : SV_Target0,
  out float4 o1 : SV_Target1)
{
  float4 r0,r1,r2,r3,r4,r5;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.z = g_DepthTexture.Sample(SS_ClampPoint_s, v1.xy).x;
  r0.xy = v2.xy;
  r0.w = 1;
  r1.x = dot(r0.xyzw, FC_MatrixInvProj._m00_m10_m20_m30);
  r1.y = dot(r0.xyzw, FC_MatrixInvProj._m01_m11_m21_m31);
  r1.z = dot(r0.xyzw, FC_MatrixInvProj._m02_m12_m22_m32);
  r1.w = dot(r0.xyzw, FC_MatrixInvProj._m03_m13_m23_m33);
  r0.y = dot(r1.xyzw, FC_MatrixInvView._m00_m10_m20_m30);
  r0.z = dot(r1.xyzw, FC_MatrixInvView._m01_m11_m21_m31);
  r0.x = dot(r1.xyzw, FC_MatrixInvView._m02_m12_m22_m32);
  r0.w = dot(r1.xyzw, FC_MatrixInvView._m03_m13_m23_m33);
  r0.xyz = r0.xyz / r0.www;
  r1.xyz = ddx_coarse(r0.yzx);
  r0.xyz = ddy_coarse(r0.xyz);
  r2.xyz = g_LightPrepassAttrTexture.Sample(SS_ClampPoint_s, v1.xy).xyz;
  r2.xyz = r2.xyz * float3(2,2,2) + float3(-1,-1,-1);
  r0.w = dot(r2.xyz, r2.xyz);
  r0.w = rsqrt(r0.w);
  r2.xyz = r2.xyz * r0.www;
  r3.xyz = r2.zxy * r1.yzx;
  r3.xyz = r2.yzx * r1.zxy + -r3.xyz;
  r0.w = saturate(dot(FC_SnowDir.xyz, r2.xyz));
  r0.w = FC_SnowNormalScale * r0.w;
  r4.xy = ddx_coarse(v1.xy);
  r4.xy = v1.xy + r4.xy;
  r1.w = g_LightPrepassAttrTexture2.Sample(SS_ClampLinear_s, r4.xy).w;
  r4.xyzw = g_LightPrepassAttrTexture2.Sample(SS_ClampLinear_s, v1.xy).xyzw;
  r5.x = -r4.w + r1.w;
  r5.zw = ddy_coarse(v1.xy);
  r5.zw = v1.xy + r5.zw;
  r1.w = g_LightPrepassAttrTexture2.Sample(SS_ClampLinear_s, r5.zw).w;
  r5.y = r1.w + -r4.w;
  r5.xy = r5.xy * r0.ww;
  r3.xyz = r5.yyy * r3.xyz;
  r5.yzw = r2.yzx * r0.xyz;
  r0.xyz = r0.zxy * r2.zxy + -r5.yzw;
  r3.xyz = r5.xxx * r0.xyz + r3.xyz;
  r0.x = dot(r1.xyz, r0.xyz);
  r0.y = cmp(0 < r0.x);
  r0.z = cmp(r0.x < 0);
  r0.y = (int)-r0.y + (int)r0.z;
  r0.y = (int)r0.y;
  r0.yzw = r0.yyy * r3.xyz;
  r0.xyz = abs(r0.xxx) * r2.xyz + -r0.yzw;
  r0.w = dot(r0.xyz, r0.xyz);
  r0.w = rsqrt(r0.w);
  r0.xyz = r0.xyz * r0.www + -r2.xyz;
  r0.xyz = r4.www * r0.xyz + r2.xyz;
  o0.xyz = r0.xyz * float3(0.5,0.5,0.5) + float3(0.5,0.5,0.5);
  o0.w = 1;
  r0.x = -FC_GroundPlaneHeight + r4.w;
  r0.x = saturate(FC_RcpSnowHeightRange * r0.x);
  r0.y = 0.300000012 + -r4.x;
  o1.x = r0.x * r0.y + r4.x;
  o1.yzw = r4.yzw;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Original ASM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546
//
//
// Buffer Definitions: 
//
// cbuffer cbSceneParam
// {
//
//   float4 FC_FarClipInfo;             // Offset:    0 Size:    16 [unused]
//   float4 FC_ScreenSize;              // Offset:   16 Size:    16 [unused]
//   float4 FC_DepthComputeParam;       // Offset:   32 Size:    16 [unused]
//   float4 SC_CameraPos;               // Offset:   48 Size:    16 [unused]
//   float4 VC_ClipPlane;               // Offset:   64 Size:    16 [unused]
//   float4x3 FC_MatrixView;            // Offset:   80 Size:    48 [unused]
//   float4x4 FC_MatrixInvViewProj;     // Offset:  128 Size:    64 [unused]
//   float4x4 FC_MatrixInvProj;         // Offset:  192 Size:    64
//   float4x4 FC_MatrixProj;            // Offset:  256 Size:    64 [unused]
//   float4x4 FC_MatrixInvView;         // Offset:  320 Size:    64
//   float4x4 VC_MatrixViewProj;        // Offset:  384 Size:    64 [unused]
//   float4 FC_ShadowMapParam;          // Offset:  448 Size:    16 [unused]
//   float4 FC_ShadowColor;             // Offset:  464 Size:    16 [unused]
//   float4 FC_ShadowDir;               // Offset:  480 Size:    16 [unused]
//   float4x4 VC_ShadowMapMatrix;       // Offset:  496 Size:    64 [unused]
//   float FC_ShadowDepthRate;          // Offset:  560 Size:     4 [unused]
//   float FC_ShadowDepthScale;         // Offset:  564 Size:     4 [unused]
//   float FC_ShadowKernelScale;        // Offset:  568 Size:     4 [unused]
//   float FC_ShadowRandTexInvScale;    // Offset:  572 Size:     4 [unused]
//   float FC_ShadowTexInvScaleX;       // Offset:  576 Size:     4 [unused]
//   float FC_ShadowTexInvScaleY;       // Offset:  580 Size:     4 [unused]
//   float FC_ShadowDepthOffsetScale;   // Offset:  584 Size:     4 [unused]
//   float4 FC_ShadowViewKernelScale;   // Offset:  592 Size:    16 [unused]
//   float4x4 FC_ProjSpaceToShadowMatrix[4];// Offset:  608 Size:   256 [unused]
//   float4 FC_CascadeSelectDist;       // Offset:  864 Size:    16 [unused]
//   float FC_FrustumNear;              // Offset:  880 Size:     4 [unused]
//   float FC_FrustumSliceScale;        // Offset:  884 Size:     4 [unused]
//   float FC_FrustumSliceBias;         // Offset:  888 Size:     4 [unused]
//   uint FC_LightTile_Width;           // Offset:  896 Size:     4 [unused]
//   uint FC_LightTile_NumCellX;        // Offset:  900 Size:     4 [unused]
//   float4 FC_CloudShadowParam0;       // Offset:  912 Size:    16 [unused]
//   float4 FC_CloudShadowParam1;       // Offset:  928 Size:    16 [unused]
//   float FC_ShadowScale0;             // Offset:  944 Size:     4 [unused]
//   float FC_ShadowScale1;             // Offset:  948 Size:     4 [unused]
//
// }
//
// cbuffer cbPerFrame
// {
//
//   float4 FC_DebugParam;              // Offset:    0 Size:    16 [unused]
//   float4 FC_DebugOutputMode;         // Offset:   16 Size:    16 [unused]
//   float4 FC_DebugParam2;             // Offset:   32 Size:    16 [unused]
//   float FC_GlobalSpecularMask;       // Offset:   48 Size:     4 [unused]
//   float FC_GlobalReflectanceScale;   // Offset:   52 Size:     4 [unused]
//   float FC_GlobalShininessScale;     // Offset:   56 Size:     4 [unused]
//   float FC_GlobalAlbedoOffset;       // Offset:   60 Size:     4 [unused]
//   float4 FC_GlobalRefRectanceRGBScale;// Offset:   64 Size:    16 [unused]
//   float4 FC_GlobalAlbedoOffsetRGB;   // Offset:   80 Size:    16 [unused]
//   float4 FC_SnowDir;                 // Offset:   96 Size:    16
//   float4 FC_SnowTilingScale;         // Offset:  112 Size:    16 [unused]
//   float4 FC_SnowAlbedo;              // Offset:  128 Size:    16 [unused]
//   float FC_SnowReflectance;          // Offset:  144 Size:     4 [unused]
//   float FC_GroundPlaneHeight;        // Offset:  148 Size:     4
//   float FC_RcpSnowHeightRange;       // Offset:  152 Size:     4
//   float FC_SnowNormalScale;          // Offset:  156 Size:     4
//   float4 FC_SnowSpakleTinlingScale;  // Offset:  160 Size:    16 [unused]
//   float FC_GlobalTime;               // Offset:  176 Size:     4 [unused]
//   float FC_DominantSharpnesMinValue; // Offset:  192 Size:     4 [unused]
//   float FC_DominantSharpnesOffset;   // Offset:  196 Size:     4 [unused]
//   float FC_DominantSharpnesExponent; // Offset:  200 Size:     4 [unused]
//   float FC_DominantColorScale;       // Offset:  204 Size:     4 [unused]
//   float4 FC_DominantRgbScale;        // Offset:  208 Size:    16 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// SS_ClampPoint                     sampler      NA          NA    7        1
// SS_ClampLinear                    sampler      NA          NA    9        1
// g_LightPrepassAttrTexture         texture  float4          2d    0        1
// g_LightPrepassAttrTexture2        texture  float4          2d    1        1
// g_DepthTexture                    texture  float4          2d    2        1
// cbSceneParam                      cbuffer      NA          NA    8        1
// cbPerFrame                        cbuffer      NA          NA    9        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION              0   xyzw        0      POS   float       
// TEXCOORD                 0   xy          1     NONE   float   xy  
// TEXCOORD                 1   xyzw        2     NONE   float   xy  
//
//
// 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 cb8[24], immediateIndexed
dcl_constantbuffer cb9[10], immediateIndexed
dcl_sampler s7, mode_default
dcl_sampler s9, 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_input_ps linear v1.xy
dcl_input_ps linear v2.xy
dcl_output o0.xyzw
dcl_output o1.xyzw
dcl_temps 6
sample_indexable(texture2d)(float,float,float,float) r0.z, v1.xyxx, t2.yzxw, s7
mov r0.xy, v2.xyxx
mov r0.w, l(1.000000)
dp4 r1.x, r0.xyzw, cb8[12].xyzw
dp4 r1.y, r0.xyzw, cb8[13].xyzw
dp4 r1.z, r0.xyzw, cb8[14].xyzw
dp4 r1.w, r0.xyzw, cb8[15].xyzw
dp4 r0.y, r1.xyzw, cb8[20].xyzw
dp4 r0.z, r1.xyzw, cb8[21].xyzw
dp4 r0.x, r1.xyzw, cb8[22].xyzw
dp4 r0.w, r1.xyzw, cb8[23].xyzw
div r0.xyz, r0.xyzx, r0.wwww
deriv_rtx_coarse r1.xyz, r0.yzxy
deriv_rty_coarse r0.xyz, r0.xyzx
sample_indexable(texture2d)(float,float,float,float) r2.xyz, v1.xyxx, t0.xyzw, s7
mad r2.xyz, r2.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000)
dp3 r0.w, r2.xyzx, r2.xyzx
rsq r0.w, r0.w
mul r2.xyz, r0.wwww, r2.xyzx
mul r3.xyz, r1.yzxy, r2.zxyz
mad r3.xyz, r2.yzxy, r1.zxyz, -r3.xyzx
dp3_sat r0.w, cb9[6].xyzx, r2.xyzx
mul r0.w, r0.w, cb9[9].w
deriv_rtx_coarse r4.xy, v1.xyxx
add r4.xy, r4.xyxx, v1.xyxx
sample_indexable(texture2d)(float,float,float,float) r1.w, r4.xyxx, t1.xyzw, s9
sample_indexable(texture2d)(float,float,float,float) r4.xyzw, v1.xyxx, t1.xyzw, s9
add r5.x, r1.w, -r4.w
deriv_rty_coarse r5.zw, v1.xxxy
add r5.zw, r5.zzzw, v1.xxxy
sample_indexable(texture2d)(float,float,float,float) r1.w, r5.zwzz, t1.xyzw, s9
add r5.y, -r4.w, r1.w
mul r5.xy, r0.wwww, r5.xyxx
mul r3.xyz, r3.xyzx, r5.yyyy
mul r5.yzw, r0.xxyz, r2.yyzx
mad r0.xyz, r0.zxyz, r2.zxyz, -r5.yzwy
mad r3.xyz, r5.xxxx, r0.xyzx, r3.xyzx
dp3 r0.x, r1.xyzx, r0.xyzx
lt r0.y, l(0.000000), r0.x
lt r0.z, r0.x, l(0.000000)
iadd r0.y, -r0.y, r0.z
itof r0.y, r0.y
mul r0.yzw, r3.xxyz, r0.yyyy
mad r0.xyz, |r0.xxxx|, r2.xyzx, -r0.yzwy
dp3 r0.w, r0.xyzx, r0.xyzx
rsq r0.w, r0.w
mad r0.xyz, r0.xyzx, r0.wwww, -r2.xyzx
mad r0.xyz, r4.wwww, r0.xyzx, r2.xyzx
mad o0.xyz, r0.xyzx, l(0.500000, 0.500000, 0.500000, 0.000000), l(0.500000, 0.500000, 0.500000, 0.000000)
mov o0.w, l(1.000000)
add r0.x, r4.w, -cb9[9].y
mul_sat r0.x, r0.x, cb9[9].z
add r0.y, -r4.x, l(0.300000)
mad o1.x, r0.x, r0.y, r4.x
mov o1.yzw, r4.yyzw
ret 
// Approximately 56 instruction slots used

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