//16ff704b435a13be-ps.txt
//
// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.17672
//
//   using 3Dmigoto v1.2.27 on Thu Feb 04 21:52:39 2016
//
//
// Buffer Definitions: 
//
// cbuffer DrawableBuffer
// {
//
//   float4 FogColor;                   // Offset:    0 Size:    16 [unused]
//   float4 DebugColor;                 // Offset:   16 Size:    16 [unused]
//   float AlphaThreshold;              // Offset:   32 Size:     4
//   float4 __InstancedMaterialOpacity[256];// Offset:   48 Size:  4096 [unused]
//
// }
//
// cbuffer SceneBuffer
// {
//
//   row_major float4x4 View;           // Offset:    0 Size:    64
//   row_major float4x4 ScreenMatrix;   // Offset:   64 Size:    64 [unused]
//   float2 DepthExportScale;           // Offset:  128 Size:     8 [unused]
//   float2 __padding0;                 // Offset:  136 Size:     8 [unused]
//   float4 FogParams;                  // Offset:  144 Size:    16 [unused]
//   float3 __CameraPosition;           // Offset:  160 Size:    12 [unused]
//   float __padding12;                 // Offset:  172 Size:     4 [unused]
//   float3 CameraDirection;            // Offset:  176 Size:    12 [unused]
//   float __padding9;                  // Offset:  188 Size:     4 [unused]
//   float3 DepthFactors;               // Offset:  192 Size:    12 [unused]
//   float __padding10;                 // Offset:  204 Size:     4 [unused]
//   float3 ShadowDepthBiasAndLightType;// Offset:  208 Size:    12 [unused]
//   float __padding11;                 // Offset:  220 Size:     4 [unused]
//   float4 SubframeViewport;           // Offset:  224 Size:    16 [unused]
//   row_major float3x4 DepthToWorld;   // Offset:  240 Size:    48
//   float4 DepthToView;                // Offset:  288 Size:    16
//   float4 OneOverDepthToView;         // Offset:  304 Size:    16 [unused]
//   float4 DepthToW;                   // Offset:  320 Size:    16 [unused]
//   float4 ClipPlane;                  // Offset:  336 Size:    16 [unused]
//   float2 ViewportDepthScaleOffset;   // Offset:  352 Size:     8 [unused]
//   float2 __padding1;                 // Offset:  360 Size:     8 [unused]
//   float2 ColorDOFDepthScaleOffset;   // Offset:  368 Size:     8 [unused]
//   float2 __padding2;                 // Offset:  376 Size:     8 [unused]
//   float4 TimeVector;                 // Offset:  384 Size:    16 [unused]
//   float4 FogParams2;                 // Offset:  400 Size:    16 [unused]
//   float4 FogParams3;                 // Offset:  416 Size:    16 [unused]
//   float3 GlobalAmbient;              // Offset:  432 Size:    12 [unused]
//   float __padding8;                  // Offset:  444 Size:     4 [unused]
//   float4 GlobalParams[16];           // Offset:  448 Size:   256 [unused]
//   float4 ViewToFogH;                 // Offset:  704 Size:    16 [unused]
//   float4 ScreenExtents;              // Offset:  720 Size:    16
//   float2 ScreenResolution;           // Offset:  736 Size:     8 [unused]
//   float2 __padding3;                 // Offset:  744 Size:     8 [unused]
//   float4 PSSMToMap1Lin;              // Offset:  752 Size:    16 [unused]
//   float4 PSSMToMap1Const;            // Offset:  768 Size:    16 [unused]
//   float4 PSSMToMap2Lin;              // Offset:  784 Size:    16 [unused]
//   float4 PSSMToMap2Const;            // Offset:  800 Size:    16 [unused]
//   float4 PSSMToMap3Lin;              // Offset:  816 Size:    16 [unused]
//   float4 PSSMToMap3Const;            // Offset:  832 Size:    16 [unused]
//   float4 PSSMDistances;              // Offset:  848 Size:    16 [unused]
//   row_major float4x4 WorldToPSSM0;   // Offset:  864 Size:    64 [unused]
//   row_major float4x4 PrevViewProject;// Offset:  928 Size:    64 [unused]
//   row_major float4x4 PrevWorld;      // Offset:  992 Size:    64 [unused]
//   row_major float4x4 ViewT;          // Offset: 1056 Size:    64 [unused]
//   float4 PSSMExtents;                // Offset: 1120 Size:    16 [unused]
//   float4 ShadowAtlasResolution;      // Offset: 1136 Size:    16 [unused]
//   float4 UnitRimData[3];             // Offset: 1152 Size:    48 [unused]
//   float3 __CameraPositionForCorrection;// Offset: 1200 Size:    12 [unused]
//   float __padding7;                  // Offset: 1212 Size:     4 [unused]
//   row_major float4x4 CameraViewProject;// Offset: 1216 Size:    64 [unused]
//   float4 BackBufferResolution;       // Offset: 1280 Size:    16 [unused]
//   row_major float4x4 InverseProjection;// Offset: 1296 Size:    64 [unused]
//   float4 StereoOffset;               // Offset: 1360 Size:    16 [unused]
//   row_major float4x4 Projection;     // Offset: 1376 Size:    64 [unused]
//   row_major float4x4 ViewInv;        // Offset: 1440 Size:    64 [unused]
//   float4 ColorSSAO;                  // Offset: 1504 Size:    16 [unused]
//   float4 GlobalFogColor;             // Offset: 1520 Size:    16 [unused]
//   float4 VolumetricLightGlobalParams;// Offset: 1536 Size:    16 [unused]
//   float4 SnowParams01;               // Offset: 1552 Size:    16 [unused]
//   float4 SnowParams02;               // Offset: 1568 Size:    16 [unused]
//   float4 SnowParams03;               // Offset: 1584 Size:    16 [unused]
//   int SSREnabled;                    // Offset: 1600 Size:     4 [unused]
//   int __padding4;                    // Offset: 1604 Size:     4 [unused]
//   int __padding5;                    // Offset: 1608 Size:     4 [unused]
//   int __padding6;                    // Offset: 1612 Size:     4 [unused]
//
// }
//
// cbuffer MaterialBuffer
// {
//
//   float4 MaterialParams[512];        // Offset:    0 Size:  8192
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// SamplerGenericPointClamp          sampler      NA          NA   10        1
// SamplerGenericTrilinearWrap       sampler      NA          NA   11        1
// p_default_Material_n159_19B9FD0C15847118_Param_texture    texture  float4          2d    0        1
// p_default_Setup_n35_Texture_texture    texture  float4          2d    1        1
// p_default_Setup_n40_Texture_texture    texture  float4          2d    2        1
// p_default_Material_n161_n179_n186_661830C016465534_cp0_Param_texture    texture  float4          2d    3        1
// p_default_Setup_n11_n111_Texture_texture    texture  float4          2d    4        1
// p_default_Material_n159_49EF29C0204713_cp0_Param_texture    texture  float4          2d    5        1
// p_default_Setup_n38_BD8AA44026454365_cp7_Param_texture    texture  float4          2d    7        1
// p_default_Setup_n1_n69_Texture_texture    texture  float4          2d    8        1
// p_default_Setup_n39_Texture_texture    texture  float4          2d    9        1
// p_default_Setup_n1_n56_Texture_texture    texture  float4          2d   10        1
// p_default_Setup_n11_n91_Texture_texture    texture  float4          2d   11        1
// p_default_Setup_n1_n58_Texture_texture    texture  float4          2d   12        1
// p_default_Setup_n11_n79_Texture_texture    texture  float4          2d   13        1
// p_default_Setup_n15_Texture_texture    texture  float4          2d   14        1
// p_default_Setup_n19_Texture_texture    texture  float4          2d   15        1
// p_default_Setup_n11_471057409100914_cp8_Param_texture    texture  float4          2d   16        1
// AmbientAccumulation_texture       texture  float4          2d   53        1
// DrawableBuffer                    cbuffer      NA          NA    1        1
// SceneBuffer                       cbuffer      NA          NA    2        1
// MaterialBuffer                    cbuffer      NA          NA    3        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION              0   xyzw        0      POS   float   xy w
// COLOR                    0   xyzw        1     NONE   float   xy  
// COLOR                    1   xyzw        2     NONE   float   x   
// TEXCOORD                 0   xyzw        3     NONE   float   xy  
// TEXCOORD                 2   xyz         4     NONE   float   xyz 
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_TARGET                0   xyzw        0   TARGET   float   xyzw
// SV_TARGET                1   x           1   TARGET   float   x   
//
ps_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb1[3], immediateIndexed
// dcl_constantbuffer cb2[46], immediateIndexed
dcl_constantbuffer cb2[82], immediateIndexed
dcl_constantbuffer cb3[12], immediateIndexed
dcl_sampler s10, mode_default
dcl_sampler s11, 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_resource_texture2d (float,float,float,float) t5
dcl_resource_texture2d (float,float,float,float) t7
dcl_resource_texture2d (float,float,float,float) t8
dcl_resource_texture2d (float,float,float,float) t9
dcl_resource_texture2d (float,float,float,float) t10
dcl_resource_texture2d (float,float,float,float) t11
dcl_resource_texture2d (float,float,float,float) t12
dcl_resource_texture2d (float,float,float,float) t13
dcl_resource_texture2d (float,float,float,float) t14
dcl_resource_texture2d (float,float,float,float) t15
dcl_resource_texture2d (float,float,float,float) t16
dcl_resource_texture2d (float,float,float,float) t53
dcl_input_ps_siv linear noperspective v0.xyw, position
dcl_input_ps linear v1.xy
dcl_input_ps linear v2.x
dcl_input_ps linear v3.xy
dcl_input_ps linear v4.xyz
dcl_output o0.xyzw
dcl_output o1.x
// dcl_temps 8
dcl_temps 10
dcl_resource_texture2d (float,float,float,float) t125
mul r0.xyzw, v3.xyxy, cb3[6].xyzw
sample_indexable(texture2d)(float,float,float,float) r1.xyzw, r0.xyxx, t10.xyzw, s11
sample_indexable(texture2d)(float,float,float,float) r0.xy, r0.zwzz, t13.xyzw, s11
mad r0.xy, r0.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
mul r1.xyzw, r1.xyzw, cb3[0].xyzw
max r0.z, r1.w, l(0.000000)
add r0.w, r0.z, -cb1[2].x
mov o0.w, r0.z
min r0.z, r0.w, l(0.000000)
lt r0.z, r0.z, l(0.000000)
discard_nz r0.z
sample_indexable(texture2d)(float,float,float,float) r2.xyz, v3.xyxx, t9.xyzw, s11
add r2.xyz, r2.xyzx, l(-1.000000, -1.000000, -1.000000, 0.000000)
mov_sat r0.zw, v1.xxxy
add r1.w, r0.w, r0.z
div r3.xy, r0.zwzz, r1.wwww
lt r2.w, l(1.000000), r1.w
add r1.w, -r1.w, l(1.000000)
movc r3.xy, r2.wwww, r3.xyxx, r0.zwzz
mad r2.xyz, r3.xxxx, r2.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
sample_indexable(texture2d)(float,float,float,float) r3.xzw, v3.xyxx, t2.xwyz, s11
add r3.xzw, r3.xxzw, l(-1.000000, 0.000000, -1.000000, -1.000000)
mad r3.xyz, r3.yyyy, r3.xzwx, l(1.000000, 1.000000, 1.000000, 0.000000)
min r2.xyz, r2.xyzx, r3.xyzx
mul r1.xyz, r1.xyzx, r2.xyzx
mul r2.xyzw, v3.xyxy, cb3[7].xyzw
sample_indexable(texture2d)(float,float,float,float) r3.xyz, r2.zwzz, t4.xyzw, s11
sample_indexable(texture2d)(float,float,float,float) r2.xy, r2.xyxx, t12.xyzw, s11
mad r3.xyz, cb3[3].xyzx, r3.xyzx, -r1.xyzx
sample_indexable(texture2d)(float,float,float,float) r2.z, v3.xyxx, t1.yzxw, s11
mad r2.z, r2.z, cb3[2].w, cb3[4].w
mov_sat r2.w, v2.x
mul_sat r4.x, r2.z, r2.w
mul r2.zw, v3.xxxy, cb3[8].xxxy
sample_indexable(texture2d)(float,float,float,float) r4.y, r2.zwzz, t16.yxzw, s11
mov r4.z, l(1.000000)
dp3_sat r2.z, cb3[2].xyzx, r4.xyzx
mad r1.xyz, r2.zzzz, r3.xyzx, r1.xyzx
add r2.w, -cb3[10].z, cb3[10].y
mad r2.y, r2.y, r2.w, cb3[10].z
mul r2.x, r2.x, cb3[10].x
mul r3.xyz, r2.xxxx, cb3[1].xyzx
add r2.x, -cb3[3].w, cb3[8].w
mul r4.xyzw, v3.xyxy, cb3[5].xyzw
sample_indexable(texture2d)(float,float,float,float) r4.zw, r4.zwzz, t11.zwxy, s11
sample_indexable(texture2d)(float,float,float,float) r4.xy, r4.xyxx, t8.xyzw, s11
mad r4.xy, r4.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
mad r2.x, r4.w, r2.x, cb3[3].w
mad r5.xyz, cb3[11].yyyy, r4.zzzz, -r3.xyzx
mad r3.xyz, r2.zzzz, r5.xyzx, r3.xyzx
add r2.x, -r2.y, r2.x
mad r2.x, r2.z, r2.x, r2.y
add r2.x, r2.x, l(2.000000)
mul r2.x, r2.x, l(0.010000)
mul r2.xyw, r2.xxxx, r3.xyxz
dp3 r3.x, r3.xyzx, l(0.299000, 0.587000, 0.114000, 0.000000)
add r3.yzw, -cb3[4].xxyz, l(0.000000, 1.000000, 1.000000, 1.000000)
add r4.z, cb3[10].w, cb3[11].x
add_sat r4.z, -r4.z, l(1.000000)
mad r5.xy, v0.xyxx, cb2[45].zwzz, cb2[45].xyxx
sample_indexable(texture2d)(float,float,float,float) r4.w, r5.xyxx, t3.yzwx, s10
mad r4.z, cb3[10].w, r4.w, r4.z
mul r4.w, r4.w, r4.w
mad_sat r4.z, r4.w, cb3[11].x, r4.z
mad_sat r3.yzw, r4.zzzz, r3.yyzw, cb3[4].xxyz
sample_indexable(texture2d)(float,float,float,float) r6.xyz, r5.xyxx, t5.xyzw, s11
mul r6.xyz, r3.yzwy, r6.xyzx
mul r2.xyw, r2.xyxw, r6.xyxz
ftoi r6.xy, v0.xyxx
mov r6.zw, l(0,0,0,0)
ld_indexable(texture2d)(float,float,float,float) r6.xyz, r6.xyzw, t53.xyzw
sample_indexable(texture2d)(float,float,float,float) r4.z, v3.xyxx, t7.yzxw, s11
add_sat r4.w, -cb3[1].w, l(1.000000)
mad_sat r4.z, cb3[1].w, r4.z, r4.w
sample_indexable(texture2d)(float,float,float,float) r7.xyz, r5.xyxx, t0.xyzw, s11
mad r6.xyz, r4.zzzz, r6.xyzx, r7.xyzx
mul r4.z, r3.y, r4.z
mul r3.yzw, r3.yyzw, r6.xxyz
mad r1.xyz, r3.yzwy, r1.xyzx, r2.xywx
max o0.xyz, r1.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000)
mad r1.x, -r0.x, r0.x, l(1.000000)
mad r1.x, -r0.y, r0.y, r1.x
mul r1.yz, r0.xxyx, r0.xxyx
max r1.y, r1.z, r1.y
mul r1.y, r1.y, l(0.0000610351563)
max r1.x, r1.y, r1.x
rsq r1.x, r1.x
mul r0.xy, r0.xyxx, -r1.xxxx
mul r0.xy, r0.xyxx, cb3[8].zzzz
mad r1.x, -r4.x, r4.x, l(1.000000)
mad r1.x, -r4.y, r4.y, r1.x
mul r1.yz, r4.xxyx, r4.xxyx
max r1.y, r1.z, r1.y
mul r1.y, r1.y, l(0.0000610351563)
max r1.x, r1.y, r1.x
rsq r1.x, r1.x
mul r1.xy, r4.xyxx, -r1.xxxx
mul r1.xy, r1.xyxx, cb3[9].wwww
sample_indexable(texture2d)(float,float,float,float) r2.xy, v3.xyxx, t14.xyzw, s11
mad r2.xy, r2.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
mad r1.z, -r2.x, r2.x, l(1.000000)
mad r1.z, -r2.y, r2.y, r1.z
mul r3.yz, r2.xxyx, r2.xxyx
max r2.w, r3.z, r3.y
mul r2.w, r2.w, l(0.0000610351563)
max r1.z, r1.z, r2.w
rsq r1.z, r1.z
mul r2.xy, r2.xyxx, -r1.zzzz
mul r2.xy, r0.wwww, r2.xyxx
sample_indexable(texture2d)(float,float,float,float) r3.yz, v3.xyxx, t15.zxyw, s11
mad r3.yz, r3.yyzy, l(0.000000, 2.000000, 2.000000, 0.000000), l(0.000000, -1.000000, -1.000000, 0.000000)
mad r0.w, -r3.y, r3.y, l(1.000000)
mad r0.w, -r3.z, r3.z, r0.w
mul r4.xy, r3.yzyy, r3.yzyy
max r1.z, r4.y, r4.x
mul r1.z, r1.z, l(0.0000610351563)
max r0.w, r0.w, r1.z
rsq r0.w, r0.w
mul r3.yz, r3.yyzy, -r0.wwww
mad r0.zw, r3.yyyz, r0.zzzz, r2.xxxy
mad r0.zw, r1.xxxy, r1.wwww, r0.zzzw
mad r0.xy, r2.zzzz, r0.xyxx, r0.zwzz
deriv_rty_fine r1.xy, v3.xyxx
deriv_rtx_fine r0.zw, v3.xxxy
mul r1.x, r1.x, r0.w
mad r0.z, r0.z, r1.y, -r1.x
mov r1.z, -r0.w
lt r0.w, r0.z, l(0.000000)
lt r0.z, l(0.000000), |r0.z|
movc r0.w, r0.w, l(-1.000000), l(1.000000)
mul r1.xy, r1.yzyy, r0.wwww
mul r2.xy, r5.xyxx, v0.wwww
mad r1.zw, r5.xxxy, cb2[18].xxxy, cb2[18].zzzw
mul r5.xy, r1.zwzz, v0.wwww
mov r2.z, v0.w

//View space correction, therefore need the InvProj._m00
ld_indexable(texture2d)(float,float,float,float) r9.xyzw, l(0, 0, 0, 0), t125.xyzw
add r9.w, v0.w, -r9.y
mul r9.w, r9.w, r9.x
mul r9.w, r9.w, cb2[81].x
add r2.x, r2.x, -r9.w


mov r2.w, l(1.000000)
dp4 r1.z, cb2[15].xyzw, r2.xyzw
deriv_rty_fine r6.x, r1.z
deriv_rtx_fine r7.z, r1.z
dp4 r1.z, cb2[16].xyzw, r2.xyzw
dp4 r1.w, cb2[17].xyzw, r2.xyzw
deriv_rty_fine r6.yz, r1.zzwz
deriv_rtx_fine r7.xy, r1.zwzz
dp3 r1.z, v4.xyzx, v4.xyzx
rsq r1.z, r1.z
mul r2.xyz, r1.zzzz, v4.xyzx
dp3 r1.w, r6.xyzx, r2.xyzx
mad r3.yzw, -r1.wwww, r2.xxyz, r6.xxyz
mul r4.xyw, r1.yyyy, r3.yzyw
dp3 r1.y, r7.zxyz, r2.xyzx
mad r6.xyz, -r1.yyyy, r2.yzxy, r7.xyzx
mad r1.xyw, r6.zxzy, r1.xxxx, r4.xyxw
dp3 r2.w, r1.xywx, r1.xywx
rsq r2.w, r2.w
mul r4.xyw, r1.xyxw, r2.wwww
movc r1.xyw, r0.zzzz, r4.xyxw, r1.xyxw
mul r4.xyw, r1.ywyx, r2.zxzy
mad r4.xyw, r2.yzyx, r1.wxwy, -r4.xyxw
mul r7.xyz, r2.zxyz, r6.xyzx
mad r6.xyz, r2.yzxy, r6.yzxy, -r7.xyzx
dp3 r0.z, r3.yzwy, r6.xyzx
lt r0.z, r0.z, l(0.000000)
movc r0.z, r0.z, l(-1.000000), l(1.000000)
mul r0.z, r0.z, r0.w
mul r3.yzw, r0.zzzz, r4.xxyw
mul r0.yzw, r0.yyyy, r3.yyzw
mad r0.xyz, r0.xxxx, r1.xywx, r0.yzwy
mad r0.xyz, v4.xyzx, r1.zzzz, -r0.xyzx
dp3 r0.w, r0.xyzx, r0.xyzx
rsq r0.w, r0.w
mul r0.xyz, r0.wwww, r0.xyzx
mov r5.z, v0.w
dp3 r0.w, -r5.xyzx, -r5.xyzx
rsq r0.w, r0.w
mul r1.xyz, r0.wwww, -r5.xyzx
dp3 r5.x, r1.xyzx, cb2[0].xyzx
dp3 r5.y, r1.xyzx, cb2[1].xyzx
dp3 r5.z, r1.xyzx, cb2[2].xyzx
dp3 r0.w, r0.xyzx, r5.xyzx
mul r0.xyz, r0.xyzx, r0.wwww
max r0.w, r0.w, l(1.000000012E-007)
add r0.w, -r0.w, l(1.000000)
mad r0.xyz, r0.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), -r5.xyzx
dp3 r0.x, r0.xyzx, r2.xyzx
mad_sat r0.x, cb3[11].w, r0.x, l(1.000000)
mul r0.x, r0.x, r0.x
mul r0.y, r0.w, r0.w
mul r0.y, r0.y, r0.y
mul r0.y, r0.w, r0.y
mad r0.y, r0.y, l(0.960000), l(0.040000)
mul r0.x, r0.y, r0.x
mul r0.x, r0.x, cb3[11].z
mul r0.x, r4.z, r0.x
mul r0.x, r3.x, r0.x
mul_sat r0.x, r0.x, l(0.250000)
sqrt o1.x, r0.x
ret 
// Approximately 197 instruction slots used
