//b9735f37aaf1a3b9-ps.txt
//
// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.17672
//
//   using 3Dmigoto v1.2.27 on Thu Feb 04 22:07:47 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
//   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
//   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
//   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_n123_n166_fogCube_texture    texture  float4        cube    0        1
// p_default_Setup_98031E0013807502_Param_texture    texture  float4          2d    1        1
// p_default_Material_n127_n150_Texture_texture    texture  float4        cube    2        1
// p_default_Setup_98FB7CC08930578_cp0_Param_texture    texture  float4          2d    3        1
// p_default_Material_n118_n132_DepthBufferTexture_texture    texture  float4          2d    4        1
// p_default_Setup_n3_8FB12BF0761067_cp0_Param_texture    texture  float4          2d    5        1
// p_default_Setup_n3_8FB12BF0685975_cp0_Param_texture    texture  float4          2d    6        1
// p_default_Setup_n3_DECAB8306147855_cp0_Param_texture    texture  float4          2d    7        1
// p_default_Setup_n3_DECA25A07266119_cp0_Param_texture    texture  float4          2d    8        1
// AttenuationSampler_texture        texture  float4          2d   44        1
// VolumetricLightIntensity_texture    texture  float4          3d   59        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   xy  
// 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
//
ps_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb1[259], dynamicIndexed
dcl_constantbuffer cb2[97], immediateIndexed
dcl_constantbuffer cb3[10], immediateIndexed
dcl_sampler s10, mode_default
dcl_sampler s11, mode_default
dcl_sampler s13, mode_default
dcl_resource_texturecube (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t1
dcl_resource_texturecube (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) t44
dcl_resource_texture3d (float,float,float,float) t59
dcl_input_ps_siv linear noperspective v0.xyw, position
dcl_input_ps linear v1.xy
dcl_input_ps linear v2.xyz
dcl_input_ps constant v3.x
dcl_output o0.xyzw
// dcl_temps 12
dcl_temps 14
dcl_resource_texture2d (float,float,float,float) t125
dp3 r0.x, v2.xyzx, v2.xyzx
rsq r0.x, r0.x
mul r0.xyz, r0.xxxx, v2.xyzx
mad r1.xyzw, v0.xyxy, cb2[45].zwzw, cb2[45].xyxy
mul r2.xyzw, r1.zwxy, 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) r13.xyzw, l(0, 0, 0, 0), t125.xyzw
add r13.w, v0.w, -r13.y
mul r13.w, r13.w, r13.x
mul r13.w, r13.w, l(0.5)
add r3.x, r3.x, -r13.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 r2.xy, r1.xyxx, 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) r13.xyzw, l(0, 0, 0, 0), t125.xyzw
add r13.w, v0.w, -r13.y
mul r13.w, r13.w, r13.x
mul r13.w, r13.w, cb2[81].x
add r5.x, r5.x, -r13.w


dp3 r0.w, -r5.xyzx, -r5.xyzx
rsq r0.w, r0.w
mul r5.xyz, r0.wwww, -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
deriv_rty_fine r5.xy, v1.xyxx
deriv_rtx_fine r2.xy, v1.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 r7.z, r0.w
deriv_rtx_fine r7.x, r1.w
deriv_rtx_fine r7.y, r2.z
mul r2.zw, v1.xxxy, cb3[7].zzzw
dp3 r0.w, r7.zxyz, r0.xyzx
mad r7.xyz, -r0.wwww, r0.yzxy, r7.xyzx
dp3 r0.w, r3.xyzx, r0.xyzx
mad r3.xyz, -r0.wwww, r0.xyzx, r3.xyzx
mul r0.w, r5.x, r2.y
mad r0.w, r2.x, r5.y, -r0.w
lt r1.w, r0.w, l(0.000000)
movc r1.w, r1.w, l(-1.000000), l(1.000000)
mov r5.z, -r2.y
mul r2.xy, r1.wwww, r5.yzyy
mul r5.xyz, r2.yyyy, r3.xyzx
mad r5.xyz, r7.zxyz, r2.xxxx, r5.xyzx
lt r0.w, l(0.000000), |r0.w|
dp3 r2.x, r5.xyzx, r5.xyzx
rsq r2.x, r2.x
mul r8.xyz, r2.xxxx, r5.xyzx
movc r5.xyz, r0.wwww, r8.xyzx, r5.xyzx
mul r8.xyz, r0.zxyz, r5.yzxy
mad r8.xyz, r0.yzxy, r5.zxyz, -r8.xyzx
mul r9.xyz, r0.zxyz, r7.xyzx
mad r7.xyz, r0.yzxy, r7.yzxy, -r9.xyzx
dp3 r0.w, r3.xyzx, r7.xyzx
lt r0.w, r0.w, l(0.000000)
movc r0.w, r0.w, l(-1.000000), l(1.000000)
mul r0.w, r0.w, r1.w
mul r3.xyz, r0.wwww, r8.xyzx
sample_indexable(texture2d)(float,float,float,float) r2.xy, r2.zwzz, t1.xyzw, s11
mad r7.xy, r2.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
mul r7.z, r7.y, cb3[9].y
mov r2.x, cb3[9].y
mov r2.y, l(-1.000000)
mul r2.xy, r2.xyxx, r7.xzxx
sample_indexable(texture2d)(float,float,float,float) r0.w, r2.zwzz, t3.yzwx, s11
mul r0.w, r0.w, cb3[3].w
mad r0.w, cb2[24].x, cb3[9].x, r0.w
frc r0.w, r0.w
mad r1.w, r0.w, l(2.000000), l(-1.000000)
add r7.xyz, r0.wwww, l(-0.500000, -1.000000, 0.500000, 0.000000)
lt r2.z, r7.x, l(0.000000)
movc r2.z, r2.z, r0.w, r7.y
mul r7.yw, r2.xxxy, r7.xxxx
mul r2.zw, r2.xxxy, r2.zzzz
lt r3.w, r0.w, l(0.500000)
movc r3.w, r3.w, r7.z, r7.x
mul r7.xz, v1.xxyx, cb3[5].xxyx
mul r8.xy, v1.xyxx, cb3[6].zwzz
mad r8.xy, cb2[24].xxxx, cb3[5].zwzz, r8.xyxx
sample_indexable(texture2d)(float,float,float,float) r4.w, r8.xyxx, t7.yzwx, s11
mul r8.xyz, r4.wwww, cb3[4].xyzx
mad r9.xy, -r2.xyxx, r3.wwww, r7.xzxx
mad r9.zw, v1.xxxy, cb3[6].xxxy, -r7.yyyw
mad r10.xy, v1.xyxx, cb3[6].xyxx, -r2.zwzz
mad r7.yw, v1.xxxy, cb3[7].xxxy, -r7.yyyw
mad r2.xy, -r2.xyxx, r0.wwww, r7.xzxx
mad r2.zw, v1.xxxy, cb3[7].xxxy, -r2.zzzw
sample_indexable(texture2d)(float,float,float,float) r11.xyz, r9.zwzz, t6.xyzw, s11
sample_indexable(texture2d)(float,float,float,float) r10.xyz, r10.xyxx, t6.xyzw, s11
add r10.xyz, -r11.xyzx, r10.xyzx
mad r10.xyz, |r1.wwww|, r10.xyzx, r11.xyzx
sample_indexable(texture2d)(float,float,float,float) r2.xy, r2.xyxx, t8.xyzw, s11
mad r11.xy, r2.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
dp2 r0.w, r11.xyxx, r11.xyxx
add r0.w, -r0.w, l(1.000000)
max r0.w, r0.w, l(0.000000)
sqrt r11.z, r0.w
sample_indexable(texture2d)(float,float,float,float) r2.xy, r9.xyxx, t8.xyzw, s11
mad r9.xy, r2.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
dp2 r0.w, r9.xyxx, r9.xyxx
add r0.w, -r0.w, l(1.000000)
max r0.w, r0.w, l(0.000000)
sqrt r9.z, r0.w
add r9.xyz, -r11.xyzx, r9.xyzx
mad r9.xyz, |r1.wwww|, r9.xyzx, r11.xyzx
sample_indexable(texture2d)(float,float,float,float) r7.xyz, r7.ywyy, t5.xyzw, s11
sample_indexable(texture2d)(float,float,float,float) r2.xyz, r2.zwzz, t5.xyzw, s11
add r2.xyz, -r7.xyzx, r2.xyzx
mad r2.xyz, |r1.wwww|, r2.xyzx, r7.xyzx
mul r7.xyz, r10.xyzx, cb3[0].xyzx
add r0.w, -r9.z, l(1.000000)
mul r9.xy, r9.xyxx, cb3[8].wwww
mad r9.w, -cb3[8].w, r0.w, l(1.000000)
dp3 r0.w, r9.xywx, r9.xywx
rsq r0.w, r0.w
mul r9.xyz, r0.wwww, r9.xywx
mad r2.xyz, r2.xyzx, cb3[2].xyzx, -r7.xyzx
mad r2.xyz, cb3[8].zzzz, r2.xyzx, r7.xyzx
mul r3.xyz, r3.xyzx, r9.yyyy
mad r3.xyz, r9.xxxx, r5.xyzx, r3.xyzx
mad r0.xyz, r9.zzzz, r0.xyzx, r3.xyzx
dp3 r0.w, r0.xyzx, r0.xyzx
rsq r0.w, r0.w
mul r0.xyz, r0.wwww, r0.xyzx
and r3.xyz, r0.xyzx, l(0x7f800000, 0x7f800000, 0x7f800000, 0)
ine r3.xyz, r3.xyzx, l(0x7f800000, 0x7f800000, 0x7f800000, 0)
and r0.xyz, r0.xyzx, r3.xyzx
add r3.xyz, r4.xyzx, -cb2[10].xyzx
dp3 r0.w, r3.xyzx, cb2[11].xyzx
sample_indexable(texture2d)(float,float,float,float) r1.w, r1.xyxx, t4.yzwx, s10
mad r1.w, r1.w, cb2[20].x, cb2[20].y
max r1.w, r1.w, l(0.000001)
div r1.w, l(1.000000, 1.000000, 1.000000, 1.000000), r1.w
add r0.w, -r0.w, r1.w
max r0.w, r0.w, l(0.000000)
mul_sat r0.w, r0.w, cb3[1].y
mov r1.w, v3.x
mul r0.w, r0.w, cb1[r1.w + 3].x
add r0.xyz, r0.xyzx, l(-0.000000, -0.000000, -1.000000, 0.000000)
mad r0.xyz, cb3[8].xxxx, r0.xyzx, l(0.000000, 0.000000, 1.000000, 0.000000)
dp3 r2.w, r6.xyzx, r0.xyzx
mul r0.xyz, r0.xyzx, r2.wwww
mad r0.xyz, r0.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), -r6.xyzx
add_sat r2.w, -r2.w, l(1.000000)
log r2.w, r2.w
mul r2.w, r2.w, cb3[8].y
exp r2.w, r2.w
sample_indexable(texturecube)(float,float,float,float) r0.xyz, r0.xyzx, t2.xyzw, s11
mul r0.xyz, r0.xyzx, cb3[4].wwww
mul r0.xyz, r2.wwww, r0.xyzx
mul r0.xyz, r0.xyzx, cb3[3].xyzx
mad r0.xyz, r0.xyzx, r8.xyzx, r2.xyzx
eq r2.x, cb2[95].w, l(0.000000)
movc r2.xyz, r2.xxxx, cb2[95].xyzx, cb2[35].xyzx
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 r4.x, r4.z, cb2[9].y, cb2[25].y
mov r4.yw, cb2[25].zzzz
sample_l_indexable(texture2d)(float,float,float,float) r2.w, r4.xyxx, t44.xzwy, s13, l(0.000000)
dp3 r3.w, r3.xyzx, r3.xyzx
sqrt r3.w, r3.w
lt r4.x, l(0.000000), cb2[26].w
if_nz r4.x
  mul r4.xy, r3.xyxx, cb2[9].wwww
  mad r5.x, cb2[25].w, r3.y, r4.x
  mad r5.y, -cb2[25].w, r3.x, r4.y
  mov r5.z, r3.z
  sample_indexable(texturecube)(float,float,float,float) r3.xyz, r5.xyzx, t0.xyzw, s11
  add r3.xyz, r3.xyzx, -cb2[95].xyzx
  mad r3.xyz, cb2[26].wwww, r3.xyzx, cb2[95].xyzx
else 
  mov r3.xyz, cb2[95].xyzx
endif 
max r3.xyz, r3.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000)
log r3.xyz, r3.xyzx
mul r3.xyz, r3.xyzx, cb2[26].yyyy
exp r3.xyz, r3.xyzx
mad r4.z, r3.w, cb2[9].x, cb2[25].x
sample_l_indexable(texture2d)(float,float,float,float) r3.w, r4.zwzz, t44.yzwx, s13, l(0.000000)
mad r3.xyz, cb2[26].xxxx, r3.xyzx, -r0.xyzx
mad r0.xyz, r3.wwww, r3.xyzx, r0.xyzx
mad r2.xyz, cb2[26].xxxx, r2.xyzx, -r0.xyzx
mad r0.xyz, r2.wwww, r2.xyzx, r0.xyzx
div r2.x, l(1.000000, 1.000000, 1.000000, 1.000000), cb2[20].y
add r2.x, -r2.x, v0.w
rcp r2.y, cb2[96].x
mul r2.x, r2.y, r2.x
rsq r2.x, |r2.x|
div r1.z, l(1.000000, 1.000000, 1.000000, 1.000000), r2.x
mov_sat r1.xyz, r1.xyzx
mad r1.xyz, r1.xyzx, l(1.000000, 1.000000, 0.984375, 0.000000), l(0.000000, 0.000000, -0.0117187500, 0.000000)
sample_l_indexable(texture3d)(float,float,float,float) r1.xyz, r1.xyzx, t59.xyzw, s13, l(0.000000)
add o0.xyz, r0.xyzx, r1.xyzx
mul o0.w, r0.w, cb1[r1.w + 3].x
ret 
// Approximately 198 instruction slots used
