//709d4065c5f515e0-ps.txt
//
// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.17672
//
//   using 3Dmigoto v1.2.27 on Thu Feb 04 22:04:13 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 [unused]
//   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
//   float3 __CameraPosition;           // Offset:  160 Size:    12
//   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
//   float4 FogParams2;                 // Offset:  400 Size:    16
//   float4 FogParams3;                 // Offset:  416 Size:    16
//   float3 GlobalAmbient;              // Offset:  432 Size:    12 [unused]
//   float __padding8;                  // Offset:  444 Size:     4 [unused]
//   float4 GlobalParams[16];           // Offset:  448 Size:   256
//   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
//   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
// ------------------------------ ---------- ------- ----------- ---- --------
// SamplerGenericTrilinearWrap       sampler      NA          NA   11        1
// SamplerGenericBilinearClamp       sampler      NA          NA   13        1
// p_default_Material_n131_n194_fogCube_texture    texture  float4        cube    0        1
// p_default_Material_n138_n164_Texture_texture    texture  float4        cube    1        1
// p_default_Material_5D538DD03205705_Param_texture    texture  float4          2d    2        1
// p_default_Setup_n1_n74_Texture_texture    texture  float4          2d    3        1
// p_default_Setup_n1_n45_Texture_texture    texture  float4          2d    4        1
// p_default_Setup_n1_n67_Texture_texture    texture  float4          2d    5        1
// p_default_Setup_47AC6AA019884710_Param_texture    texture  float4          2d    6        1
// p_default_Setup_n0_n74_Texture_texture    texture  float4          2d    7        1
// p_default_Setup_n0_n45_Texture_texture    texture  float4          2d    8        1
// p_default_Setup_n0_n67_Texture_texture    texture  float4          2d    9        1
// AttenuationSampler_texture        texture  float4          2d   44        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     zw
// TEXCOORD                 0   xyzw        2     NONE   float   xy  
// TEXCOORD                 2   xyz         3     NONE   float   xyz 
// PSIZE                    0   x           4     NONE    uint   x   
//
//
// 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 cb1[259], dynamicIndexed
dcl_constantbuffer cb2[96], immediateIndexed
dcl_constantbuffer cb3[12], immediateIndexed
dcl_sampler s11, mode_default
dcl_sampler s13, mode_default
dcl_resource_texturecube (float,float,float,float) t0
dcl_resource_texturecube (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) t44
dcl_input_ps_siv linear noperspective v0.xyw, position
dcl_input_ps linear v1.zw
dcl_input_ps linear v2.xy
dcl_input_ps linear v3.xyz
dcl_input_ps constant v4.x
dcl_output o0.xyzw
// dcl_temps 14
dcl_temps 16
dcl_resource_texture2d (float,float,float,float) t125
dp3 r0.x, v3.xyzx, v3.xyzx
rsq r0.x, r0.x
mul r0.xyz, r0.xxxx, v3.xyzx
mad r1.xyzw, v0.xyxy, cb2[45].zwzw, cb2[45].xyxy
mul r2.xyzw, r1.xyzw, v0.wwww
mov r3.xy, r2.xyxx
mov r3.z, v0.w

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


mov r3.w, l(1.000000)
dp4 r4.x, cb2[15].xyzw, r3.xyzw
dp4 r4.y, cb2[16].xyzw, r3.xyzw
dp4 r4.z, cb2[17].xyzw, r3.xyzw
mad r1.xy, r1.zwzz, cb2[18].xyxx, cb2[18].zwzz
mul r1.xy, r1.xyxx, v0.wwww
mov r1.z, v0.w

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


dp3 r0.w, -r1.xyzx, -r1.xyzx
rsq r0.w, r0.w
mul r1.xyz, r0.wwww, -r1.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
deriv_rty_fine r1.xy, v2.xyxx
deriv_rtx_fine r2.xy, v2.xyxx
mov r3.xy, r2.zwzz
dp4 r0.w, cb2[15].xyzw, r3.xyzw
dp4 r1.w, cb2[16].xyzw, r3.xyzw
dp4 r2.z, cb2[17].xyzw, r3.xyzw
deriv_rty_fine r3.x, r0.w
deriv_rty_fine r3.y, r1.w
deriv_rty_fine r3.z, r2.z
deriv_rtx_fine r6.z, r0.w
deriv_rtx_fine r6.x, r1.w
deriv_rtx_fine r6.y, r2.z
mad r2.zw, cb2[24].xxxx, cb3[9].zzzw, v2.xxxy
mad r7.xyzw, cb2[24].xxxx, cb3[7].xyxy, v2.xyxy
mad r8.xy, cb2[24].xxxx, cb3[8].xyxx, v2.xyxx
mul r8.zw, r7.zzzw, cb3[6].zzzw
mul r7.xyzw, r7.xyzw, cb3[5].zwxy
sample_indexable(texture2d)(float,float,float,float) r0.w, r7.zwzz, t9.yzwx, s11
sample_indexable(texture2d)(float,float,float,float) r7.xyzw, r7.xyxx, t8.xyzw, s11
sample_indexable(texture2d)(float,float,float,float) r8.zw, r8.zwzz, t7.zwxy, s11
mad r9.xy, r8.zwzz, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
dp2 r1.w, r9.xyxx, r9.xyxx
add r1.w, -r1.w, l(1.000000)
max r1.w, r1.w, l(0.000000)
sqrt r9.z, r1.w
mul r10.xyz, r0.wwww, cb3[3].xyzx
mul r7.xyzw, r7.xyzw, cb3[0].xyzw
mov r11.x, cb3[11].w
mov r11.z, l(1.000000)
mul r8.xy, r8.xyxx, cb3[10].xyxx
mul r8.zw, r2.zzzw, cb3[8].zzzw
mul r11.yw, r2.zzzw, cb3[6].xxxy
mul r2.zw, r2.zzzw, cb3[7].zzzw
sample_indexable(texture2d)(float,float,float,float) r0.w, r2.zwzz, t5.yzwx, s11
sample_indexable(texture2d)(float,float,float,float) r12.xyz, r11.ywyy, t4.xyzw, s11
sample_indexable(texture2d)(float,float,float,float) r2.zw, r8.zwzz, t3.zwxy, s11
mad r2.zw, r2.zzzw, l(0.000000, 0.000000, 2.000000, 2.000000), l(0.000000, 0.000000, -1.000000, -1.000000)
mul r2.zw, r2.zzzw, cb3[11].zzzz
add_sat r1.w, v1.z, cb3[11].y
sample_indexable(texture2d)(float,float,float,float) r3.w, r8.xyxx, t6.xyzw, s11
dp3 r4.w, r6.zxyz, r0.xyzx
mad r6.xyz, -r4.wwww, r0.yzxy, r6.xyzx
dp3 r4.w, r3.xyzx, r0.xyzx
mad r3.xyz, -r4.wwww, r0.xyzx, r3.xyzx
mul r1.x, r1.x, r2.y
mad r1.x, r2.x, r1.y, -r1.x
lt r2.x, r1.x, l(0.000000)
movc r2.x, r2.x, l(-1.000000), l(1.000000)
mov r1.z, -r2.y
mul r1.yz, r1.yyzy, r2.xxxx
mul r8.xyz, r1.zzzz, r3.xyzx
mad r8.xyz, r6.zxyz, r1.yyyy, r8.xyzx
lt r1.x, l(0.000000), |r1.x|
dp3 r1.y, r8.xyzx, r8.xyzx
rsq r1.y, r1.y
mul r13.xyz, r1.yyyy, r8.xyzx
movc r1.xyz, r1.xxxx, r13.xyzx, r8.xyzx
mul r8.xyz, r0.zxyz, r1.yzxy
mad r8.xyz, r0.yzxy, r1.zxyz, -r8.xyzx
mul r13.xyz, r0.zxyz, r6.xyzx
mad r6.xyz, r0.yzxy, r6.yzxy, -r13.xyzx
dp3 r2.y, r3.xyzx, r6.xyzx
lt r2.y, r2.y, l(0.000000)
movc r2.y, r2.y, l(-1.000000), l(1.000000)
mul r2.x, r2.y, r2.x
mul r3.xyz, r2.xxxx, r8.xyzx
mul r2.x, r1.w, r7.w
mul r2.x, r3.w, r2.x
mul r2.x, r2.x, v1.w
mad r6.xyz, cb3[1].xyzx, r0.wwww, -r10.xyzx
mad r6.xyz, r1.wwww, r6.xyzx, r10.xyzx
mul r8.xy, r2.zwzz, r1.wwww
mov r8.z, l(0)
mad r2.yzw, r9.xxyz, r11.xxxz, r8.xxyz
dp3 r0.w, r2.yzwy, r2.yzwy
rsq r0.w, r0.w
mul r2.yzw, r0.wwww, r2.yyzw
mad r8.xyz, r12.xyzx, cb3[2].xyzx, -r7.xyzx
mad r7.xyz, r1.wwww, r8.xyzx, r7.xyzx
mul r3.xyz, r3.xyzx, r2.zzzz
mad r1.xyz, r2.yyyy, r1.xyzx, r3.xyzx
mad r0.xyz, r2.wwww, r0.xyzx, r1.xyzx
dp3 r0.w, r0.xyzx, r0.xyzx
rsq r0.w, r0.w
mul r0.xyz, r0.wwww, r0.xyzx
max r0.w, r2.x, l(0.000000)
mov r1.x, v4.x
mul o0.w, r0.w, cb1[r1.x + 3].x
mul r1.xyz, r6.xyzx, l(0.020000, 0.020000, 0.020000, 0.000000)
dp3 r0.w, r5.xyzx, r0.xyzx
mul r0.xyz, r0.xyzx, r0.wwww
mad r0.xyz, r0.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), -r5.xyzx
mov_sat r0.w, r0.w
mul r0.w, r0.w, r0.w
max r0.w, r0.w, l(0.010000)
div r0.w, l(1.000000, 1.000000, 1.000000, 1.000000), r0.w
sample_indexable(texturecube)(float,float,float,float) r0.xyz, r0.xyzx, t1.xyzw, s11
mul r0.xyz, r0.xyzx, cb3[10].zzzz
min r0.w, r0.w, cb3[11].x
mul r0.xyz, r0.wwww, r0.xyzx
add_sat r0.w, cb3[10].w, l(1.000000)
mul r0.xyz, r0.wwww, r0.xyzx
mad r0.xyz, r0.xyzx, r1.xyzx, r7.xyzx
mul r1.xy, v2.xyxx, cb3[9].xyxx
sample_indexable(texture2d)(float,float,float,float) r1.xyzw, r1.xyxx, t2.xyzw, s11
mul r1.xyzw, r1.xyzw, cb3[4].xyzw
max r1.xyz, r0.xyzx, r1.xyzx
add r1.xyz, -r0.xyzx, r1.xyzx
mad r0.xyz, r1.wwww, r1.xyzx, r0.xyzx
eq r0.w, cb2[95].w, l(0.000000)
movc r1.xyz, r0.wwww, cb2[95].xyzx, cb2[35].xyzx
max r1.xyz, r1.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000)
log r1.xyz, r1.xyzx
mul r1.xyz, r1.xyzx, cb2[26].yyyy
exp r1.xyz, r1.xyzx
add r2.xyz, r4.xyzx, -cb2[10].xyzx
mad r3.x, r4.z, cb2[9].y, cb2[25].y
mov r3.yw, cb2[25].zzzz
sample_l_indexable(texture2d)(float,float,float,float) r0.w, r3.xyxx, t44.xzwy, s13, l(0.000000)
dp3 r1.w, r2.xyzx, r2.xyzx
sqrt r1.w, r1.w
lt r2.w, l(0.000000), cb2[26].w
if_nz r2.w
  mul r3.xy, r2.xyxx, cb2[9].wwww
  mad r4.x, cb2[25].w, r2.y, r3.x
  mad r4.y, -cb2[25].w, r2.x, r3.y
  mov r4.z, r2.z
  sample_indexable(texturecube)(float,float,float,float) r2.xyz, r4.xyzx, t0.xyzw, s11
  add r2.xyz, r2.xyzx, -cb2[95].xyzx
  mad r2.xyz, cb2[26].wwww, r2.xyzx, cb2[95].xyzx
else 
  mov r2.xyz, cb2[95].xyzx
endif 
max r2.xyz, r2.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000)
log r2.xyz, r2.xyzx
mul r2.xyz, r2.xyzx, cb2[26].yyyy
exp r2.xyz, r2.xyzx
mad r3.z, r1.w, cb2[9].x, cb2[25].x
sample_l_indexable(texture2d)(float,float,float,float) r1.w, r3.zwzz, t44.yzwx, s13, l(0.000000)
mad r2.xyz, cb2[26].xxxx, r2.xyzx, -r0.xyzx
mad r0.xyz, r1.wwww, r2.xyzx, r0.xyzx
mad r1.xyz, cb2[26].xxxx, r1.xyzx, -r0.xyzx
mad r0.xyz, r0.wwww, r1.xyzx, r0.xyzx
max o0.xyz, r0.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000)
ret 
// Approximately 165 instruction slots used
