//920a3be359df87f9-ps.txt
//
// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.17672
//
//   using 3Dmigoto v1.2.27 on Fri Jan 29 08:59:29 2016
//
//
// Buffer Definitions: 
//
// cbuffer DrawableBuffer
// {
//
//   float4 FogColor;                   // Offset:    0 Size:    16
//   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 [unused]
//   float4 FogParams2;                 // Offset:  400 Size:    16
//   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
//
// }
//
// cbuffer InstanceBuffer
// {
//
//   struct InstanceStruct
//   {
//       
//       float4 InstanceParams[8];      // Offset:    0
//
//   } InstanceParameters[256];         // Offset:    0 Size: 32768
//
// }
//
// cbuffer xtendedInstanceBuffer
// {
//
//   struct ExtendedInstanceStruct
//   {
//       
//       float4 ExtendedInstanceParams[16];// Offset:    0
//
//   } ExtendedInstanceParameters[256]; // Offset:    0 Size: 65536
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// SamplerGenericTrilinearWrap       sampler      NA          NA   11        1
// SamplerGenericBilinearClamp       sampler      NA          NA   13        1
// p_default_Setup_44B49D9020766938_cp1_Param_texture    texture  float4          2d    0        1
// p_default_Material_n29_Texture_texture    texture  float4        cube    1        1
// p_default_Setup_n5_Texture_texture    texture  float4          2d    2        1
// p_default_Material_n33_4FA1DE2018946028_cp3_Param_texture    texture  float4          2d    3        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
// InstanceBuffer                    cbuffer      NA          NA    5        1
// xtendedInstanceBuffer             cbuffer      NA          NA    8        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   xyzw
// TEXCOORD                 0   xyzw        2     NONE   float   xy  
// TEXCOORD                 2   xyz         3     NONE   float   xyz 
// TEXCOORD                 3   xyz         4     NONE   float   xyz 
// TEXCOORD                 4   xyz         5     NONE   float       
// PSIZE                    0   x           6     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[46], immediateIndexed
dcl_constantbuffer cb2[82], immediateIndexed
dcl_constantbuffer cb3[2], immediateIndexed
dcl_constantbuffer cb5[2048], dynamicIndexed
dcl_constantbuffer cb8[4096], dynamicIndexed
dcl_sampler s11, mode_default
dcl_sampler s13, mode_default
dcl_resource_texture2d (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) t44
dcl_input_ps_siv linear noperspective v0.xyw, position
dcl_input_ps linear v1.xyzw
dcl_input_ps linear v2.xy
dcl_input_ps linear v3.xyz
dcl_input_ps linear v4.xyz
dcl_input_ps constant v6.x
dcl_output o0.xyzw
// dcl_temps 15
dcl_temps 17
dcl_resource_texture2d (float,float,float,float) t125
mad r0.xyzw, v0.xyxy, cb2[45].zwzw, cb2[45].xyxy
mul r1.xy, r0.xyxx, v0.wwww
mov r1.z, v0.w
mov r1.w, l(1.000000)

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


dp4 r2.x, cb2[15].xyzw, r1.xyzw
dp4 r2.y, cb2[16].xyzw, r1.xyzw
dp4 r2.z, cb2[17].xyzw, r1.xyzw
add r1.xyz, -r2.xyzx, cb2[10].xyzx
dp3 r0.x, r1.xyzx, r1.xyzx
sqrt r0.y, r0.x
mad r3.x, r0.y, cb2[9].x, cb2[25].x
mad r0.yz, r0.zzwz, cb2[18].xxyx, cb2[18].zzwz
mul r4.xy, r0.yzyy, v0.wwww
mov r4.z, v0.w

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


dp3 r0.y, -r4.xyzx, -r4.xyzx
rsq r0.y, r0.y
mul r0.yzw, r0.yyyy, -r4.xxyz
dp3 r4.x, r0.yzwy, cb2[0].xyzx
dp3 r4.y, r0.yzwy, cb2[1].xyzx
dp3 r4.z, r0.yzwy, cb2[2].xyzx
dp3 r0.y, v4.xyzx, v4.xyzx
rsq r0.y, r0.y
mul r0.yzw, r0.yyyy, v4.xxyz
mul r5.xyz, r0.wyzw, v3.yzxy
mad r5.xyz, r0.zwyz, v3.zxyz, -r5.xyzx
mul r3.zw, v2.xxxy, cb3[0].xxxy
sample_indexable(texture2d)(float,float,float,float) r3.zw, r3.zwzz, t2.zwxy, s11
mad r3.zw, r3.zzzw, l(0.000000, 0.000000, 2.000000, 2.000000), l(0.000000, 0.000000, -1.000000, -1.000000)
dp2 r1.w, r3.zwzz, r3.zwzz
add r1.w, -r1.w, l(1.000000)
max r1.w, r1.w, l(0.000000)
sqrt r6.z, r1.w
sample_indexable(texture2d)(float,float,float,float) r1.w, v2.xyxx, t0.xyzw, s11
mul r6.xy, r3.zwzz, cb3[1].yyyy
dp3 r2.w, r6.xyzx, r6.xyzx
rsq r2.w, r2.w
mul r6.xyz, r2.wwww, r6.xyzx
mul r5.xyz, r5.xyzx, r6.yyyy
mad r0.yzw, r6.xxxx, r0.yyzw, r5.xxyz
mad r0.yzw, r6.zzzz, v3.xxyz, r0.yyzw
dp3 r2.w, r0.yzwy, r0.yzwy
rsq r2.w, r2.w
mul r0.yzw, r0.yyzw, r2.wwww
dp3 r2.w, r4.xyzx, r0.yzwy
mul r5.xyz, r0.yzwy, r2.wwww
mad r4.xyz, r5.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), -r4.xyzx
sample_b_indexable(texturecube)(float,float,float,float) r4.xyz, r4.xyzx, t1.xyzw, s11, cb3[0].z
ishl r3.zw, v6.xxxx, l(0, 0, 3, 4)
max r2.w, l(0.010000), cb5[r3.z + 3].z
sample_indexable(texture2d)(float,float,float,float) r4.w, v2.xyxx, t3.yzwx, s11
add r4.w, -r4.w, l(1.000000)
add r2.w, -r2.w, r4.w
add r4.w, -r2.w, r4.w
add r2.w, -r2.w, v1.w
div r4.w, l(1.000000, 1.000000, 1.000000, 1.000000), r4.w
mul_sat r2.w, r2.w, r4.w
mad r4.w, r2.w, l(-2.000000), l(3.000000)
mul r2.w, r2.w, r2.w
mul r2.w, r2.w, r4.w
mul r1.w, r1.w, r2.w
mul r1.w, r1.w, v1.w
mul_sat r1.w, r1.w, cb5[r3.z + 3].w
ne r2.w, cb3[0].w, l(0.000000)
rsq r0.x, r0.x
mov_sat r4.w, cb3[1].w
add r5.x, -r4.w, l(1.000000)
div r5.x, l(1.000000, 1.000000, 1.000000, 1.000000), r5.x
mov r6.y, l(0)
mov r7.xyzw, l(0,0,0,0)
mov r5.yzw, l(0,0,0,0)
mov r8.xyz, l(0,0,0,0)
mov r9.xyz, l(0,0,0,0)
mov r10.xyz, l(0,0,0,0)
mov r6.w, l(0)
loop 
  ige r8.w, r6.w, l(3)
  breakc_nz r8.w
  if_z r6.w
    mov r7.xyzw, cb5[r3.z + 4].xyzw
    mov r8.xyz, cb5[r3.z + 5].xyzx
    mov r5.yzw, cb5[r3.z + 6].xxyz
    mov r9.xyz, cb5[r3.z + 7].xyzx
  else 
    ilt r8.w, r6.w, l(3)
    if_nz r8.w
      ishl r8.w, r6.w, l(2)
      iadd r8.w, r8.w, l(-4)
      iadd r9.w, r3.w, r8.w
      iadd r11.xyz, r8.wwww, l(1, 2, 3, 0)
      iadd r11.xyz, r3.wwww, r11.xyzx
      mov r7.xyzw, cb8[r9.w + 0].xyzw
      mov r8.xyz, cb8[r11.x + 0].xyzx
      mov r5.yzw, cb8[r11.y + 0].xxyz
      mov r9.xyz, cb8[r11.z + 0].xyzx
    endif 
  endif 
  add r11.xyz, -r2.xyzx, r5.yzwy
  dp3 r8.w, r11.xyzx, r11.xyzx
  sqrt r6.x, r8.w
  eq r9.w, r7.x, l(1.000000)
  if_nz r9.w
    lt r9.w, r6.x, r7.y
    ne r10.w, r7.y, l(0.000000)
    and r9.w, r9.w, r10.w
    div r10.w, r6.x, r7.y
    add r10.w, -r10.w, l(1.000000)
    and r12.y, r9.w, r10.w
    mov r12.x, r6.x
  else 
    mul r9.w, r7.z, l(0.500000)
    dp3 r10.w, r9.xyzx, r11.xyzx
    lt r11.w, l(0.000000), -r10.w
    lt r12.z, -r10.w, r7.y
    and r11.w, r11.w, r12.z
    ne r12.z, r7.y, l(0.000000)
    and r11.w, r11.w, r12.z
    sincos r13.x, r14.x, r9.w
    div r9.w, r13.x, r14.x
    mul r9.w, r9.w, -r10.w
    mad r8.w, -r10.w, r10.w, r8.w
    ge r12.z, r8.w, l(0.000000)
    sqrt r8.w, r8.w
    lt r12.w, r8.w, r7.w
    add r8.w, -r7.w, r8.w
    lt r13.x, r8.w, r9.w
    div r8.w, r8.w, r9.w
    add r8.w, -r8.w, l(1.000000)
    and r8.w, r8.w, r13.x
    movc r8.w, r12.w, l(1.000000), r8.w
    div r9.w, -r10.w, r7.y
    add r9.w, -r9.w, l(1.000000)
    mul r8.w, r8.w, r9.w
    and r8.w, r8.w, r12.z
    and r6.z, r8.w, r11.w
    eq r12.zw, r7.xxxx, l(0.000000, 0.000000, 2.000000, 3.000000)
    movc r13.xyz, r12.wwww, -r9.xyzx, r11.xyzx
    movc r14.xy, r12.wwww, l(1.000000,1.000000,0,0), r6.xyxx
    movc r11.xyz, r12.zzzz, r11.xyzx, r13.xyzx
    movc r12.xy, r12.zzzz, r6.xzxx, r14.xyxx
  endif 
  ne r6.x, r12.y, l(0.000000)
  ne r12.zw, r12.xxxx, l(0.000000, 0.000000, 0.000000, 1.000000)
  and r6.z, r12.w, r12.z
  div r12.xzw, r11.xxyz, r12.xxxx
  movc r11.xyz, r6.zzzz, r12.xzwx, r11.xyzx
  mad r11.xyz, r1.xyzx, r0.xxxx, r11.xyzx
  dp3 r6.z, r11.xyzx, r11.xyzx
  rsq r6.z, r6.z
  mul r11.xyz, r6.zzzz, r11.xyzx
  dp3 r6.z, r11.xyzx, r0.yzwy
  max r6.z, r6.z, l(0.000000)
  log r6.z, r6.z
  mul r6.z, r6.z, cb3[1].x
  exp r6.z, r6.z
  mad r6.z, -r4.w, l(0.500000), r6.z
  mul_sat r6.z, r5.x, r6.z
  mad r8.w, r6.z, l(-2.000000), l(3.000000)
  mul r6.z, r6.z, r6.z
  mul r6.z, r6.z, r8.w
  mul r6.z, r6.z, cb3[0].w
  and r6.z, r2.w, r6.z
  and r6.x, r6.z, r6.x
  mul r11.xyz, r8.xyzx, r12.yyyy
  mad r10.xyz, r11.xyzx, r6.xxxx, r10.xyzx
  iadd r6.w, r6.w, l(1)
endloop 
mad r0.xyz, cb3[1].zzzz, r4.xyzx, r10.xyzx
mul r1.xyz, r0.xyzx, v1.xyzx
mov r3.y, cb2[25].z
sample_l_indexable(texture2d)(float,float,float,float) r0.w, r3.xyxx, t44.yzwx, s13, l(0.000000)
mad r0.xyz, -v1.xyzx, r0.xyzx, cb1[0].xyzx
mad o0.xyz, r0.wwww, r0.xyzx, r1.xyzx
mov r0.x, v6.x
mul o0.w, r1.w, cb1[r0.x + 3].x
ret 
// Approximately 175 instruction slots used
