//Shadows PS 2
cbuffer PER_BATCH : register(b0)
{
  float4 g_LightPos : packoffset(c0);
  float4 g_LightDiffuse : packoffset(c1);
  float4 g_ScreenScale : packoffset(c2);
  float4 vWBasisX : packoffset(c3);
  float4 vWBasisY : packoffset(c4);
  float4 vWBasisZ : packoffset(c5);
}
SamplerState _tex0_s : register(s0);
SamplerState _tex1_s : register(s1);
SamplerState _cubetex2_s : register(s2);
SamplerState _cubetex3_s : register(s3);
Texture2D<float4> _tex0 : register(t0);
Texture2D<float4> _tex1 : register(t1);
TextureCube<float4> _cubetex2 : register(t2);
TextureCube<float4> _cubetex3 : register(t3);

Texture2D<float4> StereoParams : register(t125);
Texture1D<float4> IniParams : register(t120);

void main( 
  float4 v0 : SV_POSITION0,
  out float4 o0 : SV_Target0,
  out float4 o1 : SV_Target1,
  
  float4 g_VS_NearFarClipDist : TEXCOORD2,
  float4 g_VS_ScreenSize : TEXCOORD3)
  
{
  float4 r0,r1,r2;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.xy = v0.xy * g_ScreenScale.xy + g_ScreenScale.zw;
  r1.xyzw = _tex1.Sample(_tex1_s, r0.xy).xyzw;
  r0.x = _tex0.Sample(_tex0_s, r0.xy).x;
  r0.yzw = r1.xyz * float3(2,2,2) + float3(-1,-1,-1);
  r1.x = 255 * r1.w;
  r1.x = sqrt(r1.x);
  r1.x = -r1.x * 0.497417986 + 6.16231012;
  r1.y = dot(r0.yzw, r0.yzw);
  r1.y = rsqrt(r1.y);
  r0.yzw = r1.yyy * r0.yzw;
  r2.xyzw = _cubetex2.Sample(_cubetex2_s, r0.yzw).xyzw;
  r1.y = 16 * r2.w;
  r1.yzw = r2.xyz * r1.yyy;
  
  float4 stereo = StereoParams.Load(0);
  float depth = r0.x * g_VS_NearFarClipDist.y;
  v0.x -= stereo.x * (depth - stereo.y) / depth * g_VS_ScreenSize.x / 2;
  
  o0.xyz = g_LightDiffuse.xyz * r1.yzw;
  r1.yzw = vWBasisX.xyz * v0.xxx + vWBasisZ.xyz;
  r1.yzw = vWBasisY.xyz * v0.yyy + r1.yzw;
  r2.xyz = -r1.yzw * r0.xxx + g_LightPos.xyz;
  r2.xyz = g_LightPos.www * r2.xyz;
  r0.x = dot(r2.xyz, r2.xyz);
  r0.x = 1 + -r0.x;
  r0.x = max(0, r0.x);
  o0.w = r0.x;
  o1.w = r0.x;
  r0.x = dot(r1.yzw, r1.yzw);
  r0.x = rsqrt(r0.x);
  r1.yzw = r1.yzw * r0.xxx;
  r0.x = dot(r1.yzw, r0.yzw);
  r0.x = r0.x + r0.x;
  r0.xyz = r0.yzw * -r0.xxx + r1.yzw;
  r0.xyzw = _cubetex3.SampleLevel(_cubetex3_s, r0.xyz, r1.x).xyzw;
  r0.w = 16 * r0.w;
  r0.xyz = r0.xyz * r0.www;
  r1.xyz = g_LightDiffuse.xyz * g_LightDiffuse.www;
  o1.xyz = r1.xyz * r0.xyz;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.27.952.3022
//
//   using 3Dmigoto v1.2.1 on Sun Aug 30 07:55:39 2015
//
//
// Buffer Definitions: 
//
// cbuffer PER_BATCH
// {
//
//   float4 g_LightPos;                 // Offset:    0 Size:    16
//   float4 g_LightDiffuse;             // Offset:   16 Size:    16
//   float4 g_ScreenScale;              // Offset:   32 Size:    16
//   float4 vWBasisX;                   // Offset:   48 Size:    16
//   float4 vWBasisY;                   // Offset:   64 Size:    16
//   float4 vWBasisZ;                   // Offset:   80 Size:    16
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// _tex0                             sampler      NA          NA    0        1
// _tex1                             sampler      NA          NA    1        1
// _cubetex2                         sampler      NA          NA    2        1
// _cubetex3                         sampler      NA          NA    3        1
// _tex0                             texture  float4          2d    0        1
// _tex1                             texture  float4          2d    1        1
// _cubetex2                         texture  float4        cube    2        1
// _cubetex3                         texture  float4        cube    3        1
// PER_BATCH                         cbuffer      NA          NA    0        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION              0   xyzw        0      POS   float   xy  
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
// SV_Target                1   xyzw        1   TARGET   float   xyzw
//
ps_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[6], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_default
dcl_sampler s2, mode_default
dcl_sampler s3, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t1
dcl_resource_texturecube (float,float,float,float) t2
dcl_resource_texturecube (float,float,float,float) t3
dcl_input_ps_siv linear noperspective v0.xy, position
dcl_output o0.xyzw
dcl_output o1.xyzw
dcl_temps 3
mad r0.xy, v0.xyxx, cb0[2].xyxx, cb0[2].zwzz
sample_indexable(texture2d)(float,float,float,float) r1.xyzw, r0.xyxx, t1.xyzw, s1
sample_indexable(texture2d)(float,float,float,float) r0.x, r0.xyxx, t0.xyzw, s0
mad r0.yzw, r1.xxyz, l(0.000000, 2.000000, 2.000000, 2.000000), l(0.000000, -1.000000, -1.000000, -1.000000)
mul r1.x, r1.w, l(255.000000)
sqrt r1.x, r1.x
mad r1.x, -r1.x, l(0.497418), l(6.162310)
dp3 r1.y, r0.yzwy, r0.yzwy
rsq r1.y, r1.y
mul r0.yzw, r0.yyzw, r1.yyyy
sample_indexable(texturecube)(float,float,float,float) r2.xyzw, r0.yzwy, t2.xyzw, s2
mul r1.y, r2.w, l(16.000000)
mul r1.yzw, r1.yyyy, r2.xxyz
mul o0.xyz, r1.yzwy, cb0[1].xyzx
mad r1.yzw, cb0[3].xxyz, v0.xxxx, cb0[5].xxyz
mad r1.yzw, cb0[4].xxyz, v0.yyyy, r1.yyzw
mad r2.xyz, -r1.yzwy, r0.xxxx, cb0[0].xyzx
mul r2.xyz, r2.xyzx, cb0[0].wwww
dp3 r0.x, r2.xyzx, r2.xyzx
add r0.x, -r0.x, l(1.000000)
max r0.x, r0.x, l(0.000000)
mov o0.w, r0.x
mov o1.w, r0.x
dp3 r0.x, r1.yzwy, r1.yzwy
rsq r0.x, r0.x
mul r1.yzw, r0.xxxx, r1.yyzw
dp3 r0.x, r1.yzwy, r0.yzwy
add r0.x, r0.x, r0.x
mad r0.xyz, r0.yzwy, -r0.xxxx, r1.yzwy
sample_l_indexable(texturecube)(float,float,float,float) r0.xyzw, r0.xyzx, t3.xyzw, s3, r1.x
mul r0.w, r0.w, l(16.000000)
mul r0.xyz, r0.wwww, r0.xyzx
mul r1.xyz, cb0[1].wwww, cb0[1].xyzx
mul o1.xyz, r0.xyzx, r1.xyzx
ret 
// Approximately 35 instruction slots used

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
