//98c760f6923db17d-ps.txt
//
// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.17672
//
//   using 3Dmigoto v1.2.27 on Sat Feb 06 00:39:27 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
//
// }
//
// 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
//   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
// SamplerGenericBilinearClamp       sampler      NA          NA   13        1
// p_default_Material_n165_n204_n207_661830C016465534_cp0_Param_texture    texture  float4          2d    0        1
// p_default_Setup_4FE05D605316617_Param_texture    texture  float4          2d    1        1
// p_default_Material_n184_n187_Texture_texture    texture  float4          2d    2        1
// p_default_Material_n162_NormalBufferTexture_texture    texture  float4          2d    3        1
// p_default_Setup_n3_5637D76019617032_cp1_Param_texture    texture  float4          2d    4        1
// p_default_Setup_n3_2FCBF5109468681_Param_texture    texture  float4          2d    5        1
// p_default_Setup_n0_n50_Texture_texture    texture  float4          2d    6        1
// p_default_Setup_n11_n64_Texture_texture    texture  float4          2d    7        1
// p_default_Setup_n0_n64_Texture_texture    texture  float4          2d    8        1
// p_default_Setup_n11_n50_Texture_texture    texture  float4          2d    9        1
// p_default_Setup_n1_n50_Texture_texture    texture  float4          2d   10        1
// p_default_Setup_n1_n64_Texture_texture    texture  float4          2d   11        1
// LightAccumulation_texture         texture  float4          2d   51        1
// SpecularAccumulation_texture      texture  float4          2d   52        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
// TEXCOORD                 0   xyzw        1     NONE   float   xyzw
// TEXCOORD                 2   xyz         2     NONE   float   xyz 
// PSIZE                    0   x           3     NONE    uint   x   
//
//
// 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[259], dynamicIndexed
dcl_constantbuffer cb2[95], immediateIndexed
dcl_constantbuffer cb3[21], immediateIndexed
dcl_sampler s10, mode_default
dcl_sampler s11, mode_default
dcl_sampler s13, 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) t6
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) t51
dcl_resource_texture2d (float,float,float,float) t52
dcl_resource_texture2d (float,float,float,float) t53
dcl_input_ps_siv linear noperspective v0.xyw, position
dcl_input_ps linear v1.xyzw
dcl_input_ps linear v2.xyz
dcl_input_ps constant v3.x
dcl_output o0.xyzw
dcl_output o1.x
// dcl_temps 10
dcl_temps 12
dcl_resource_texture2d (float,float,float,float) t125
mul r0.xy, v0.xyxx, l(0.250000, 0.250000, 0.000000, 0.000000)
sample_indexable(texture2d)(float,float,float,float) r0.x, r0.xyxx, t2.xyzw, s11
mov r0.y, v3.x
mad r0.x, r0.x, cb1[r0.y + 3].y, cb1[r0.y + 3].z
mov r1.z, v0.w
mov r1.w, l(1.000000)
mad r2.xyzw, v0.xyxy, cb2[45].zwzw, cb2[45].xyxy
mul r1.xy, r2.xyxx, v0.wwww

//Screen space correction, therefore need the '0.5'
ld_indexable(texture2d)(float,float,float,float) r11.xyzw, l(0, 0, 0, 0), t125.xyzw
add r11.w, v0.w, -r11.y
mul r11.w, r11.w, r11.x
mul r11.w, r11.w, l(0.5)
add r1.x, r1.x, -r11.w


dp4 r3.x, cb2[15].xyzw, r1.xyzw
dp4 r3.y, cb2[16].xyzw, r1.xyzw
dp4 r3.z, cb2[17].xyzw, r1.xyzw
deriv_rty_fine r0.yzw, r3.zzxy
dp3 r1.x, v2.xyzx, v2.xyzx
rsq r1.x, r1.x
mul r1.xyz, r1.xxxx, v2.xyzx
mul r4.xyz, r0.yzwy, r1.yzxy
mad r0.yzw, r0.wwyz, r1.zzxy, -r4.xxyz
deriv_rtx_fine r4.xyz, r3.xyzx
dp3 r1.w, r4.xyzx, r0.yzwy
mad r2.xy, r2.zwzz, cb2[18].xyxx, cb2[18].zwzz
mul r5.xy, r2.xyxx, v0.wwww
mov r5.z, v0.w

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


dp3 r2.x, -r5.xyzx, -r5.xyzx
rsq r2.x, r2.x
mul r5.xyz, r2.xxxx, -r5.xyzx
dp3 r6.x, r5.xyzx, cb2[0].xyzx
dp3 r6.y, r5.xyzx, cb2[1].xyzx
dp3 r6.z, r5.xyzx, cb2[2].xyzx
dp3 r2.x, r0.yzwy, r6.xyzx
mul r0.yzw, r1.zzxy, r4.yyzx
mad r0.yzw, r1.yyzx, r4.zzxy, -r0.yyzw
dp3 r2.y, r0.yzwy, r6.xyzx
div r0.yz, r2.xxyx, r1.wwww
mul r2.xy, v1.xyxx, cb3[17].zwzz
deriv_rty_fine r4.xy, r2.xyxx
mul r0.zw, r0.zzzz, r4.xxxy
deriv_rtx_fine r4.xy, r2.xyxx
sample_indexable(texture2d)(float,float,float,float) r1.w, r2.xyxx, t1.yzwx, s11
add r1.w, r1.w, l(-0.500000)
mad r0.yz, r0.yyyy, r4.xxyx, r0.zzwz
mul r0.w, r1.w, cb3[19].z
mul r1.w, r1.w, cb3[12].w
mul r2.xy, r0.wwww, r0.yzyy
mad r4.xy, r0.yzyy, r0.wwww, v1.xyxx
mul r4.xy, r4.xyxx, cb3[13].zwzz
sample_indexable(texture2d)(float,float,float,float) r0.w, r4.xyxx, t8.yzwx, s11
mul r4.xyz, r0.wwww, cb3[4].xyzx
mul r4.xyz, r4.xyzx, cb3[13].yyyy
mad r2.xy, cb3[14].zwzz, v1.xyxx, r2.xyxx
sample_indexable(texture2d)(float,float,float,float) r5.xyzw, r2.xyxx, t6.xyzw, s11
mul r5.xyzw, r5.xyzw, cb3[8].xyzw
max r0.w, r5.w, l(0.000000)
add r2.x, r0.w, -cb1[2].x
mov o0.w, r0.w
min r0.x, r0.x, r2.x
lt r0.x, r0.x, l(0.000000)
discard_nz r0.x
mul r7.xyz, cb3[1].yyyy, cb3[11].xyzx
mul r3.xyz, r3.xyzx, r7.xyzx
sample_indexable(texture2d)(float,float,float,float) r0.xw, r3.yzyy, t5.xywz, s11
sample_indexable(texture2d)(float,float,float,float) r2.xy, r3.xzxx, t5.xzyw, s11
sample_indexable(texture2d)(float,float,float,float) r3.xy, r3.xyxx, t5.xzyw, s11
mul r2.xy, |r1.yyyy|, r2.xyxx
mad r0.xw, r0.xxxw, |r1.xxxx|, r2.xxxy
mad_sat r0.xw, r3.xxxy, |r1.zzzz|, r0.xxxw
add_sat r3.x, r0.x, cb3[10].w
add_sat r7.x, r0.w, cb3[11].w
mul r0.xw, v1.zzzw, cb3[16].zzzw
mul r2.xy, r0.xwxx, cb3[16].xyxx
mul r0.xw, r0.xxxw, cb3[17].xxxy
sample_indexable(texture2d)(float,float,float,float) r7.y, r0.xwxx, t4.xyzw, s11
sample_indexable(texture2d)(float,float,float,float) r3.y, r2.xyxx, t4.xyzw, s11
mov r3.z, l(1.000000)
dp3_sat r0.x, cb3[10].xyzx, r3.xyzx
mov r7.z, l(1.000000)
dp3_sat r0.w, cb3[12].xyzx, r7.xyzx
add r3.xyz, cb3[3].xyzx, -cb3[6].xyzx
mad r3.xyz, r0.wwww, r3.xyzx, cb3[6].xyzx
add r7.xyz, -r3.xyzx, cb3[9].xyzx
mad r3.xyz, r0.xxxx, r7.xyzx, r3.xyzx
sample_indexable(texture2d)(float,float,float,float) r7.xyz, r2.zwzz, t51.xyzw, s13
add r3.xyz, r3.xyzx, r7.xyzx
ftoi r7.xy, v0.xyxx
mov r7.zw, l(0,0,0,0)
ld_indexable(texture2d)(float,float,float,float) r8.xyz, r7.xyzw, t53.xyzw
ld_indexable(texture2d)(float,float,float,float) r2.x, r7.xyww, t0.xyzw
add r3.xyz, r3.xyzx, r8.xyzx
add r2.y, cb3[19].w, cb3[20].x
add_sat r2.y, -r2.y, l(1.000000)
mad r2.y, cb3[19].w, r2.x, r2.y
mul r2.x, r2.x, r2.x
mad_sat r2.x, r2.x, cb3[20].x, r2.y
add r7.xyz, -cb2[94].xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
mad_sat r7.xyz, r2.xxxx, r7.xyzx, cb2[94].xyzx
mul r3.xyz, r3.xyzx, r7.xyzx
sample_indexable(texture2d)(float,float,float,float) r8.xyz, r2.zwzz, t52.xyzw, s13
sample_indexable(texture2d)(float,float,float,float) r2.xyz, r2.zwzz, t3.xyzw, s10
mul r7.yzw, r7.xxyz, r8.xxyz
add r2.w, -cb3[13].x, cb3[18].x
mad r2.w, r0.w, r2.w, cb3[13].x
add r3.w, -r2.w, cb3[14].x
mad r2.w, r0.x, r3.w, r2.w
add r2.w, r2.w, l(2.000000)
mul r2.w, r2.w, l(0.010000)
mad r8.xy, r0.yzyy, r1.wwww, v1.xyxx
mul r0.yz, r0.yyzy, r1.wwww
mad r0.yz, cb3[18].zzwz, v1.xxyx, r0.yyzy
sample_indexable(texture2d)(float,float,float,float) r9.xyz, r0.yzyy, t10.xyzw, s11
mad r9.xyz, r9.xyzx, cb3[0].xyzx, -r5.xyzx
mad r5.xyz, r0.wwww, r9.xyzx, r5.xyzx
mul r0.yz, r8.xxyx, cb3[15].zzwz
sample_indexable(texture2d)(float,float,float,float) r0.y, r0.yzyy, t11.yxzw, s11
mul r8.xyz, r0.yyyy, cb3[2].xyzx
mad r8.xyz, cb3[18].yyyy, r8.xyzx, -r4.xyzx
mad r0.yzw, r0.wwww, r8.xxyz, r4.xxyz
mul r4.xy, v1.xyxx, cb3[19].xyxx
sample_indexable(texture2d)(float,float,float,float) r1.w, r4.xyxx, t7.yzwx, s11
mul r4.xyz, r1.wwww, cb3[5].xyzx
mad r4.xyz, cb3[14].yyyy, r4.xyzx, -r0.yzwy
mad r0.yzw, r0.xxxx, r4.xxyz, r0.yyzw
mul r4.xyz, r2.wwww, r0.yzwy
dp3 r0.y, r0.yzwy, l(0.299000, 0.587000, 0.114000, 0.000000)
mul r4.xyz, r4.xyzx, r7.yzwy
mul r0.zw, v1.xxxy, cb3[15].xxxy
sample_indexable(texture2d)(float,float,float,float) r7.yzw, r0.zwzz, t9.wxyz, s11
mad r7.yzw, r7.yyzw, cb3[7].xxyz, -r5.xxyz
mad r0.xzw, r0.xxxx, r7.yyzw, r5.xxyz
mad r0.xzw, r3.xxyz, r0.xxzw, r4.xxyz
max o0.xyz, r0.xzwx, l(0.000000, 0.000000, 0.000000, 0.000000)
dp3 r0.x, r2.xyzx, r6.xyzx
mul r2.xyz, r2.xyzx, r0.xxxx
max r0.x, r0.x, l(1.000000012E-007)
add r0.x, -r0.x, l(1.000000)
mad r2.xyz, r2.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), -r6.xyzx
dp3 r0.z, r2.xyzx, r1.xyzx
mad_sat r0.z, cb3[20].z, r0.z, l(1.000000)
mul r0.z, r0.z, r0.z
mul r0.w, r0.x, r0.x
mul r0.w, r0.w, r0.w
mul r0.x, r0.x, r0.w
mad r0.x, r0.x, l(0.960000), l(0.040000)
mul r0.x, r0.x, r0.z
mul r0.x, r0.x, cb3[20].y
mul r0.x, r7.x, r0.x
mul r0.x, r0.y, r0.x
mul_sat r0.x, r0.x, l(0.250000)
sqrt o1.x, r0.x
ret 
// Approximately 148 instruction slots used
