// Point lights/shadows - flashlight
Texture2D<float4> t4 : register(t4);

Texture2D<float4> t3 : register(t3);

Texture2D<float4> t2 : register(t2);

Texture2D<float4> t1 : register(t1);

Texture2D<float4> t0 : register(t0);

SamplerState s4_s : register(s4);

SamplerComparisonState s3_s : register(s3);

SamplerState s2_s : register(s2);

SamplerState s1_s : register(s1);

SamplerState s0_s : register(s0);

cbuffer cb3 : register(b3)
{
  float4 cb3[4];
}

cbuffer cb2 : register(b2)
{
  float4 cb2[26];
}

cbuffer cb1 : register(b1)
{
  float4 cb1[8];
}

cbuffer cb0 : register(b0)
{
  float4 cb0[19];
}




// 3Dmigoto declarations
#define cmp -
Texture1D<float4> IniParams : register(t120);
Texture2D<float4> StereoParams : register(t125);


void main( 
  float4 v0 : SV_POSITION0,
  float4 v1 : TEXCOORD0,
  float3 v2 : TEXCOORD1,
  out float4 o0 : SV_Target0,
  float fov : TEXCOORD2)
{
  float4 r0,r1,r2,r3,r4,r5,r6;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.x = 1 + -cb2[24].x;
  r0.yz = v1.xy / v1.ww;
  r1.xyzw = t0.Sample(s0_s, r0.yz).xyzw;
  r2.xyzw = t3.Sample(s4_s, r0.yz).xyzw;
  r0.y = cb1[7].x * r1.x + cb1[7].y;
  r0.y = 1 / r0.y;
  r0.z = cb1[5].z / v2.z;
  r1.xyz = v2.xyz * r0.zzz;
  r1.xyw = r1.xyz * r0.yyy;
float4 stereo = StereoParams.Load(0);
float4 params = IniParams.Load(0);
r1.x -= stereo.x * (r1.w - stereo.y)*fov;
  r3.xyz = cb3[1].xyz * r1.yyy;
  r3.xyz = cb3[0].xyz * r1.xxx + r3.xyz;
  r3.xyz = cb3[2].xyz * r1.www + r3.xyz;
  r3.xyz = cb3[3].xyz + r3.xyz;
  r4.xyzw = cb2[9].xyzw * r3.yyyy;
  r4.xyzw = cb2[8].xyzw * r3.xxxx + r4.xyzw;
  r4.xyzw = cb2[10].xyzw * r3.zzzz + r4.xyzw;
  r4.xyzw = cb2[11].xyzw + r4.xyzw;
  r4.xyz = r4.xyz / r4.www;
  r5.xyz = cb0[15].xyz + r4.xyz;
  r5.x = t4.SampleCmpLevelZero(s3_s, r5.xy, r5.z).x;
  r6.xyz = cb0[16].xyz + r4.xyz;
  r5.y = t4.SampleCmpLevelZero(s3_s, r6.xy, r6.z).x;
  r6.xyz = cb0[17].xyz + r4.xyz;
  r4.xyz = cb0[18].xyz + r4.xyz;
  r5.w = t4.SampleCmpLevelZero(s3_s, r4.xy, r4.z).x;
  r5.z = t4.SampleCmpLevelZero(s3_s, r6.xy, r6.z).x;
  r4.xyzw = r5.xyzw * r0.xxxx + cb2[24].xxxx;
  r0.x = dot(r4.xyzw, float4(0.25,0.25,0.25,0.25));
  r4.xyz = -cb2[25].xyz + r3.xyz;
  r0.z = dot(r4.xyz, r4.xyz);
  r0.z = sqrt(r0.z);
  r0.y = -r1.z * r0.y + r0.z;
  r0.y = cb2[25].w * r0.y + r1.w;
  r0.z = saturate(r0.y * cb2[24].z + cb2[24].w);
  r0.y = r0.y * cb0[10].z + cb0[10].w;
  r0.y = saturate(1 + -r0.y);
  r0.x = saturate(r0.x + r0.z);
  r1.xyz = cb0[12].xyw * r3.yyy;
  r1.xyz = cb0[11].xyw * r3.xxx + r1.xyz;
  r1.xyz = cb0[13].xyw * r3.zzz + r1.xyz;
  r1.xyz = cb0[14].xyw + r1.xyz;
  r0.zw = r1.xy / r1.zz;
  r1.x = cmp(r1.z < 0);
  r1.x = r1.x ? 1.000000 : 0;
  r4.xyzw = t1.SampleBias(s2_s, r0.zw, -8).xyzw;
  r0.z = r4.w * r1.x;
  r1.xyz = cb0[8].xyz + -r3.xyz;
  r3.xyz = -cb1[4].xyz + r3.xyz;
  r0.w = dot(r1.xyz, r1.xyz);
  r1.w = cb0[8].w * r0.w;
  r0.w = rsqrt(r0.w);
  r1.xyz = r1.xyz * r0.www;
  r4.xyzw = t2.Sample(s1_s, r1.ww).xyzw;
  r0.z = r4.x * r0.z;
  r0.x = r0.z * r0.x;
  r0.z = saturate(r0.x);
  r0.w = dot(r3.xyz, r3.xyz);
  r0.w = rsqrt(r0.w);
  r3.xyz = -r3.xyz * r0.www + r1.xyz;
  r0.w = dot(r3.xyz, r3.xyz);
  r0.w = rsqrt(r0.w);
  r3.xyz = r3.xyz * r0.www;
  r2.xyz = r2.xyz * float3(2,2,2) + float3(-1,-1,-1);
  r0.w = 128 * r2.w;
  r1.w = dot(r2.xyz, r2.xyz);
  r1.w = rsqrt(r1.w);
  r2.xyz = r2.xyz * r1.www;
  r1.w = dot(r3.xyz, r2.xyz);
  r1.x = dot(r1.xyz, r2.xyz);
  r1.x = max(0, r1.x);
  r0.x = r1.x * r0.x;
  r2.xyz = cb0[9].xyz * r0.xxx;
  r0.x = max(0, r1.w);
  r0.x = log2(r0.x);
  r0.x = r0.w * r0.x;
  r0.x = exp2(r0.x);
  r0.x = r0.x * r0.z;
  r1.xyz = cb0[9].xyz * cb0[3].xyz;
  r0.zw = r1.xx + r1.yz;
  r0.w = r1.y * r0.w;
  r0.z = cb0[9].z * cb0[3].z + r0.z;
  r0.w = sqrt(r0.w);
  r0.w = dot(cb0[3].ww, r0.ww);
  r0.z = r0.z + r0.w;
  r2.w = r0.x * r0.z;
  r0.xyzw = r2.xyzw * r0.yyyy;
  o0.xyzw = exp2(-r0.xyzw);
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Original ASM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) D3D Shader Disassembler
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION              0   xyzw        0      POS   float       
// TEXCOORD                 0   xyzw        1     NONE   float   xy w
// TEXCOORD                 1   xyz         2     NONE   float   xyz 
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
//
ps_4_0
dcl_constantbuffer cb0[19], immediateIndexed
dcl_constantbuffer cb1[8], immediateIndexed
dcl_constantbuffer cb2[26], immediateIndexed
dcl_constantbuffer cb3[4], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_default
dcl_sampler s2, mode_default
dcl_sampler s3, mode_comparison
dcl_sampler s4, 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_input_ps linear v1.xyw
dcl_input_ps linear v2.xyz
dcl_output o0.xyzw
dcl_temps 7
add r0.x, -cb2[24].x, l(1.000000)
div r0.yz, v1.xxyx, v1.wwww
sample r1.xyzw, r0.yzyy, t0.xyzw, s0
sample r2.xyzw, r0.yzyy, t3.xyzw, s4
mad r0.y, cb1[7].x, r1.x, cb1[7].y
div r0.y, l(1.000000, 1.000000, 1.000000, 1.000000), r0.y
div r0.z, cb1[5].z, v2.z
mul r1.xyz, r0.zzzz, v2.xyzx
mul r1.xyw, r0.yyyy, r1.xyxz
mul r3.xyz, r1.yyyy, cb3[1].xyzx
mad r3.xyz, cb3[0].xyzx, r1.xxxx, r3.xyzx
mad r3.xyz, cb3[2].xyzx, r1.wwww, r3.xyzx
add r3.xyz, r3.xyzx, cb3[3].xyzx
mul r4.xyzw, r3.yyyy, cb2[9].xyzw
mad r4.xyzw, cb2[8].xyzw, r3.xxxx, r4.xyzw
mad r4.xyzw, cb2[10].xyzw, r3.zzzz, r4.xyzw
add r4.xyzw, r4.xyzw, cb2[11].xyzw
div r4.xyz, r4.xyzx, r4.wwww
add r5.xyz, r4.xyzx, cb0[15].xyzx
sample_c_lz r5.x, r5.xyxx, t4.xxxx, s3, r5.z
add r6.xyz, r4.xyzx, cb0[16].xyzx
sample_c_lz r5.y, r6.xyxx, t4.xxxx, s3, r6.z
add r6.xyz, r4.xyzx, cb0[17].xyzx
add r4.xyz, r4.xyzx, cb0[18].xyzx
sample_c_lz r5.w, r4.xyxx, t4.xxxx, s3, r4.z
sample_c_lz r5.z, r6.xyxx, t4.xxxx, s3, r6.z
mad r4.xyzw, r5.xyzw, r0.xxxx, cb2[24].xxxx
dp4 r0.x, r4.xyzw, l(0.250000, 0.250000, 0.250000, 0.250000)
add r4.xyz, r3.xyzx, -cb2[25].xyzx
dp3 r0.z, r4.xyzx, r4.xyzx
sqrt r0.z, r0.z
mad r0.y, -r1.z, r0.y, r0.z
mad r0.y, cb2[25].w, r0.y, r1.w
mad_sat r0.z, r0.y, cb2[24].z, cb2[24].w
mad r0.y, r0.y, cb0[10].z, cb0[10].w
add_sat r0.y, -r0.y, l(1.000000)
add_sat r0.x, r0.z, r0.x
mul r1.xyz, r3.yyyy, cb0[12].xywx
mad r1.xyz, cb0[11].xywx, r3.xxxx, r1.xyzx
mad r1.xyz, cb0[13].xywx, r3.zzzz, r1.xyzx
add r1.xyz, r1.xyzx, cb0[14].xywx
div r0.zw, r1.xxxy, r1.zzzz
lt r1.x, r1.z, l(0.000000)
and r1.x, r1.x, l(0x3f800000)
sample_b r4.xyzw, r0.zwzz, t1.xyzw, s2, l(-8.000000)
mul r0.z, r1.x, r4.w
add r1.xyz, -r3.xyzx, cb0[8].xyzx
add r3.xyz, r3.xyzx, -cb1[4].xyzx
dp3 r0.w, r1.xyzx, r1.xyzx
mul r1.w, r0.w, cb0[8].w
rsq r0.w, r0.w
mul r1.xyz, r0.wwww, r1.xyzx
sample r4.xyzw, r1.wwww, t2.xyzw, s1
mul r0.z, r0.z, r4.x
mul r0.x, r0.x, r0.z
mov_sat r0.z, r0.x
dp3 r0.w, r3.xyzx, r3.xyzx
rsq r0.w, r0.w
mad r3.xyz, -r3.xyzx, r0.wwww, r1.xyzx
dp3 r0.w, r3.xyzx, r3.xyzx
rsq r0.w, r0.w
mul r3.xyz, r0.wwww, r3.xyzx
mad r2.xyz, r2.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000)
mul r0.w, r2.w, l(128.000000)
dp3 r1.w, r2.xyzx, r2.xyzx
rsq r1.w, r1.w
mul r2.xyz, r1.wwww, r2.xyzx
dp3 r1.w, r3.xyzx, r2.xyzx
dp3 r1.x, r1.xyzx, r2.xyzx
max r1.x, r1.x, l(0.000000)
mul r0.x, r0.x, r1.x
mul r2.xyz, r0.xxxx, cb0[9].xyzx
max r0.x, r1.w, l(0.000000)
log r0.x, r0.x
mul r0.x, r0.x, r0.w
exp r0.x, r0.x
mul r0.x, r0.z, r0.x
mul r1.xyz, cb0[3].xyzx, cb0[9].xyzx
add r0.zw, r1.yyyz, r1.xxxx
mul r0.w, r0.w, r1.y
mad r0.z, cb0[9].z, cb0[3].z, r0.z
sqrt r0.w, r0.w
dp2 r0.w, cb0[3].wwww, r0.wwww
add r0.z, r0.w, r0.z
mul r2.w, r0.z, r0.x
mul r0.xyzw, r0.yyyy, r2.xyzw
exp o0.xyzw, -r0.xyzw
ret 
// Approximately 0 instruction slots used

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


/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Recompiled ASM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20789
//
//   using 3Dmigoto v1.2.43 on Thu Aug 18 00:38:11 2016
//
//
// Buffer Definitions: 
//
// cbuffer cb3
// {
//
//   float4 cb3[4];                     // Offset:    0 Size:    64
//
// }
//
// cbuffer cb2
// {
//
//   float4 cb2[26];                    // Offset:    0 Size:   416
//
// }
//
// cbuffer cb1
// {
//
//   float4 cb1[8];                     // Offset:    0 Size:   128
//
// }
//
// cbuffer cb0
// {
//
//   float4 cb0[19];                    // Offset:    0 Size:   304
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// s0_s                              sampler      NA          NA    0        1
// s1_s                              sampler      NA          NA    1        1
// s2_s                              sampler      NA          NA    2        1
// s3_s                            sampler_c      NA          NA    3        1
// s4_s                              sampler      NA          NA    4        1
// t0                                texture  float4          2d    0        1
// t1                                texture  float4          2d    1        1
// t2                                texture  float4          2d    2        1
// t3                                texture  float4          2d    3        1
// t4                                texture  float4          2d    4        1
// cb0                               cbuffer      NA          NA    0        1
// cb1                               cbuffer      NA          NA    1        1
// cb2                               cbuffer      NA          NA    2        1
// cb3                               cbuffer      NA          NA    3        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION              0   xyzw        0      POS   float       
// TEXCOORD                 0   xyzw        1     NONE   float   xy w
// TEXCOORD                 1   xyz         2     NONE   float   xyz 
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
//
ps_4_0
dcl_constantbuffer cb3[4], immediateIndexed
dcl_constantbuffer cb2[26], immediateIndexed
dcl_constantbuffer cb1[8], immediateIndexed
dcl_constantbuffer cb0[19], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_default
dcl_sampler s2, mode_default
dcl_sampler s3, mode_comparison
dcl_sampler s4, 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_input_ps linear v1.xyw
dcl_input_ps linear v2.xyz
dcl_output o0.xyzw
dcl_temps 7
add r0.x, -cb2[24].x, l(1.000000)
div r0.yz, v1.xxyx, v1.wwww
sample r1.xyzw, r0.yzyy, t0.xyzw, s0
sample r2.xyzw, r0.yzyy, t3.xyzw, s4
mad r0.y, cb1[7].x, r1.x, cb1[7].y
div r0.y, l(1.000000, 1.000000, 1.000000, 1.000000), r0.y
div r0.z, cb1[5].z, v2.z
mul r1.xyz, r0.zzzz, v2.xyzx
mul r1.xyw, r0.yyyy, r1.xyxz
mul r3.xyz, r1.yyyy, cb3[1].xyzx
mad r3.xyz, cb3[0].xyzx, r1.xxxx, r3.xyzx
mad r3.xyz, cb3[2].xyzx, r1.wwww, r3.xyzx
add r3.xyz, r3.xyzx, cb3[3].xyzx
mul r4.xyzw, r3.yyyy, cb2[9].xyzw
mad r4.xyzw, cb2[8].xyzw, r3.xxxx, r4.xyzw
mad r4.xyzw, cb2[10].xyzw, r3.zzzz, r4.xyzw
add r4.xyzw, r4.xyzw, cb2[11].xyzw
div r4.xyz, r4.xyzx, r4.wwww
add r5.xyz, r4.xyzx, cb0[15].xyzx
sample_c_lz r5.x, r5.xyxx, t4.xxxx, s3, r5.z
add r6.xyz, r4.xyzx, cb0[16].xyzx
sample_c_lz r5.y, r6.xyxx, t4.xxxx, s3, r6.z
add r6.xyz, r4.xyzx, cb0[18].xyzx
add r4.xyz, r4.xyzx, cb0[17].xyzx
sample_c_lz r5.z, r4.xyxx, t4.xxxx, s3, r4.z
sample_c_lz r5.w, r6.xyxx, t4.xxxx, s3, r6.z
mad r4.xyzw, r5.xyzw, r0.xxxx, cb2[24].xxxx
dp4 r0.x, r4.xyzw, l(0.250000, 0.250000, 0.250000, 0.250000)
add r4.xyz, r3.xyzx, -cb2[25].xyzx
dp3 r0.z, r4.xyzx, r4.xyzx
sqrt r0.z, r0.z
mad r0.y, -r1.z, r0.y, r0.z
mad r0.y, cb2[25].w, r0.y, r1.w
mad_sat r0.z, r0.y, cb2[24].z, cb2[24].w
mad r0.y, r0.y, cb0[10].z, cb0[10].w
add_sat r0.y, -r0.y, l(1.000000)
add_sat r0.x, r0.z, r0.x
mul r1.xyz, r3.yyyy, cb0[12].xywx
mad r1.xyz, cb0[11].xywx, r3.xxxx, r1.xyzx
mad r1.xyz, cb0[13].xywx, r3.zzzz, r1.xyzx
add r1.xyz, r1.xyzx, cb0[14].xywx
lt r0.z, r1.z, l(0.000000)
div r1.xy, r1.xyxx, r1.zzzz
sample_b r1.xyzw, r1.xyxx, t1.xyzw, s2, l(-8.000000)
and r0.z, r0.z, l(0x3f800000)
mul r0.z, r0.z, r1.w
add r1.xyz, -r3.xyzx, cb0[8].xyzx
add r3.xyz, r3.xyzx, -cb1[4].xyzx
dp3 r0.w, r1.xyzx, r1.xyzx
mul r1.w, r0.w, cb0[8].w
rsq r0.w, r0.w
mul r1.xyz, r0.wwww, r1.xyzx
sample r4.xyzw, r1.wwww, t2.xyzw, s1
mul r0.z, r0.z, r4.x
mul r0.x, r0.x, r0.z
mov_sat r0.z, r0.x
dp3 r0.w, r3.xyzx, r3.xyzx
rsq r0.w, r0.w
mad r3.xyz, -r3.xyzx, r0.wwww, r1.xyzx
dp3 r0.w, r3.xyzx, r3.xyzx
rsq r0.w, r0.w
mul r3.xyz, r0.wwww, r3.xyzx
mad r2.xyz, r2.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000)
mul r0.w, r2.w, l(128.000000)
dp3 r1.w, r2.xyzx, r2.xyzx
rsq r1.w, r1.w
mul r2.xyz, r1.wwww, r2.xyzx
dp3 r1.w, r3.xyzx, r2.xyzx
dp3 r1.x, r1.xyzx, r2.xyzx
max r1.x, r1.x, l(0.000000)
mul r0.x, r0.x, r1.x
mul r2.xyz, r0.xxxx, cb0[9].xyzx
max r0.x, r1.w, l(0.000000)
log r0.x, r0.x
mul r0.x, r0.x, r0.w
exp r0.x, r0.x
mul r0.x, r0.z, r0.x
mul r1.xyz, cb0[3].xyzx, cb0[9].xyzx
add r0.zw, r1.yyyz, r1.xxxx
mul r0.w, r0.w, r1.y
mad r0.z, cb0[9].z, cb0[3].z, r0.z
sqrt r0.w, r0.w
dp2 r0.w, cb0[3].wwww, r0.wwww
add r0.z, r0.w, r0.z
mul r2.w, r0.z, r0.x
mul r0.xyzw, r0.yyyy, r2.xyzw
exp o0.xyzw, -r0.xyzw
ret 
// Approximately 88 instruction slots used

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