//Sun Shafts

cbuffer _Globals : register(b4)
{
  float2 gm_vTextureSizeInv : packoffset(c0);
  float3 g_vCameraPosition : packoffset(c1);
  float3 g_vEyeUpperLeft : packoffset(c2);
  float3 g_vEyeUpperRight : packoffset(c3);
  float3 g_vEyeLowerLeft : packoffset(c4);
  float3 g_vEyeLowerRight : packoffset(c5);
  float3 g_vScaledEyeUpperLeft : packoffset(c6);
  float3 g_vScaledEyeDelta : packoffset(c7);
  float3 g_vViewRemap : packoffset(c8);
  float4 g_avSampleOffsets[16] : packoffset(c9);
  float4 g_avSampleWeights[16] : packoffset(c25);
  float g_fBrightPassThreshold : packoffset(c41);
  float g_fElapsedTime : packoffset(c41.y);
  float g_fTonemapScale : packoffset(c41.z);
  float g_fGlareSaturation : packoffset(c41.w);
  float g_fBloomScale : packoffset(c42);
  float g_fStarScale : packoffset(c42.y);
  float2 g_vAdaptationRange : packoffset(c42.z);
  float2 g_vAdaptationSpeed : packoffset(c43);
  float2 g_vBlueShiftRange : packoffset(c43.z);
  float3 g_vBlueShiftWeight : packoffset(c44);
  float4 g_vLensFlareColorA : packoffset(c45);
  float4 g_vLensFlareColorB : packoffset(c46);
  float4 g_vLensFlareColorC : packoffset(c47);
  float4 g_vLensFlareColorD : packoffset(c48);
  float4 g_vLensFlareThresholds : packoffset(c49);
  float g_fLensFlareAttenuation : packoffset(c50);
  float3 g_vRegionCenter : packoffset(c50.y);
  float g_fFocalRange : packoffset(c51);
  float g_fFocalFade : packoffset(c51.y);
  float g_fBlurriness : packoffset(c51.z);
  float g_FgDofStrength : packoffset(c51.w);
  float g_fFogDensity : packoffset(c52);
  float4 g_vFogColor : packoffset(c53);
  float3 g_vFogNearDistance : packoffset(c54);
  float3 g_vTurbulenceScale : packoffset(c55);
  float g_fTurbulenceOpacity : packoffset(c55.w);
  float4 g_vTurbulenceSampleWeights : packoffset(c56);
  float4 g_vTurbulenceOctaveOffset[4] : packoffset(c57);
  float2 g_vFogTargetSize : packoffset(c61);
  float2 g_vFogPixelSize : packoffset(c61.z);
  float4 g_vFogPixelOffsets : packoffset(c62);
  float4 g_vFogRasterScaleOffset : packoffset(c63);
  float4 g_vFogFadeParams[27] : packoffset(c64);
  float4 g_vFogFadeParams2[4] : packoffset(c91);
  float2 g_vVideoScale : packoffset(c95);
  float2 g_vVideoOffset : packoffset(c95.z);
  float g_fVideoHorizSkew : packoffset(c96);
  float g_fVideoHorizBend : packoffset(c96.y);
  float g_fVideoFineShaking : packoffset(c96.z);
  float g_fVideoColorNoise : packoffset(c96.w);
  float4 g_vRadialParams : packoffset(c97);
  float2 g_vRadialCenter : packoffset(c98);
  float g_fScreenAspectXByY : packoffset(c98.z);
  float g_fNoiseIntensity : packoffset(c98.w);
  float g_fDistortionScale : packoffset(c99);
  float2 g_vDistortWobbleWaveLength : packoffset(c99.y);
  float2 g_vDistortWobbleTime : packoffset(c100);
  float2 g_vVolumeLightParams : packoffset(c100.z);
  float2 g_vDepthRemapRange : packoffset(c101);
  float g_fSaturation : packoffset(c101.z);
  float g_fMotionBlurriness : packoffset(c101.w);
  float g_fGammaWhiteCutoff : packoffset(c102);
  float2 g_vGammaPostchain : packoffset(c102.y);
  float g_fGammaCorrectionParams : packoffset(c102.w);
  float3 g_vParticlesDiffuseColor : packoffset(c103);
  float3 g_vParticlesLightDirVS : packoffset(c104);
  float3 g_vParticlesLightColor : packoffset(c105);
  float4 g_vParticlesFactors : packoffset(c106);
  float4 g_vVignetteParams : packoffset(c107);
  float4 g_vFastFogParams : packoffset(c108);
  row_major float4x4 g_mViewProj : packoffset(c109);
  float4 g_vParams0 : packoffset(c113);
  float4 g_vParams1 : packoffset(c114);
  float4 g_vParams2 : packoffset(c115);
  float4 g_vParams3 : packoffset(c116);
  float4 g_vParams4 : packoffset(c117);
  float4 g_vParams5 : packoffset(c118);
  float4 g_vParams6 : packoffset(c119);
  float4 g_vParams7 : packoffset(c120);
  float4 g_vParams8 : packoffset(c121);
  float4 g_vParams9 : packoffset(c122);
  float4 g_vParams10 : packoffset(c123);
  float4 g_vParams11 : packoffset(c124);
  float4 g_vParams12 : packoffset(c125);
  float4 g_vParams13 : packoffset(c126);
  float4 g_vParams14 : packoffset(c127);
  float4 g_vParams15 : packoffset(c128);
  row_major float4x4 g_mMatrix0 : packoffset(c129);
  row_major float4x4 g_mMatrix1 : packoffset(c133);
  row_major float4x4 g_mMatrix2 : packoffset(c137);
  float2 g_vBarrel : packoffset(c141);
  float2 g_vPixelSize : packoffset(c141.z);
  float4 g_SSAO_Color : packoffset(c142);
  float4 g_vSSAO_Params : packoffset(c143);
  float g_vSSAO_FarDistance : packoffset(c144);
  float3 g_vLeftTopScreen : packoffset(c144.y);
  float3 g_vRightBottomScreen : packoffset(c145);
  float2 g_vSSAO_SampleRadii : packoffset(c146);
  float2 g_vSSAO_RandScale : packoffset(c146.z);
  float4 g_HBAO1 : packoffset(c147);
  float4 g_HBAO2 : packoffset(c148);
  float4 g_HBAO3 : packoffset(c149);
  float4 g_vDoubleVision1 : packoffset(c150);
  float4 g_vDoubleVision2 : packoffset(c151);
  float4 g_vDoubleVisionBlend : packoffset(c152);
}

SamplerState samplerTLC0_s_s : register(s0);
Texture2D<float4> mapTLC0 : register(t0);


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


void main( 
  float4 v0 : SV_POSITION0,
  float4 v1 : COLOR0,
  float2 v2 : TEXCOORD0,
  out float4 o0 : SV_TARGET0)
{
  float4 r0,r1,r2,r3,r4;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.xy = -g_vRadialCenter.xy + v2.xy;
  r0.zw = g_vVolumeLightParams.xx * r0.xy;
  r1.xyzw = mapTLC0.Sample(samplerTLC0_s_s, v2.xy).xyzw;
  r2.xyz = r1.xyz;
  r3.xy = v2.xy;
  r1.w = 0;
  while (true) {
    r2.w = (int)r1.w;
    r3.z = cmp((int)r2.w >= 16);
    if (r3.z != 0) {
      break;
    }
    r3.xy = r0.zw * float2(-0.0625,-0.0625) + r3.xy;
    r4.xyzw = mapTLC0.Sample(samplerTLC0_s_s, r3.xy).xyzw;
    r3.z = (uint)r1.w;
    r2.xyz = r4.xyz * g_avSampleWeights[r3.z].xyz + r2.xyz;
    r2.w = (int)r2.w + 1;
    r1.w = (int)r2.w;
  }
  r0.x = dot(abs(r0.xy), abs(r0.xy));
  r0.x = sqrt(r0.x);
  r0.x = saturate(g_vVolumeLightParams.x * r0.x);
  r0.xyz = r0.xxx * -r2.xyz + r2.xyz;
  o0.xyz = g_vParams4.xyz * r0.xyz;
  o0.w = 0;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20789
//
//   using 3Dmigoto v1.2.19 on Mon Dec 21 11:17:30 2015
//
//
// Buffer Definitions: 
//
// cbuffer _Globals
// {
//
//   float2 gm_vTextureSizeInv;         // Offset:    0 Size:     8 [unused]
//   float3 g_vCameraPosition;          // Offset:   16 Size:    12 [unused]
//   float3 g_vEyeUpperLeft;            // Offset:   32 Size:    12 [unused]
//   float3 g_vEyeUpperRight;           // Offset:   48 Size:    12 [unused]
//   float3 g_vEyeLowerLeft;            // Offset:   64 Size:    12 [unused]
//   float3 g_vEyeLowerRight;           // Offset:   80 Size:    12 [unused]
//   float3 g_vScaledEyeUpperLeft;      // Offset:   96 Size:    12 [unused]
//   float3 g_vScaledEyeDelta;          // Offset:  112 Size:    12 [unused]
//   float3 g_vViewRemap;               // Offset:  128 Size:    12 [unused]
//   float4 g_avSampleOffsets[16];      // Offset:  144 Size:   256 [unused]
//   float4 g_avSampleWeights[16];      // Offset:  400 Size:   256
//   float g_fBrightPassThreshold;      // Offset:  656 Size:     4 [unused]
//   float g_fElapsedTime;              // Offset:  660 Size:     4 [unused]
//   float g_fTonemapScale;             // Offset:  664 Size:     4 [unused]
//   float g_fGlareSaturation;          // Offset:  668 Size:     4 [unused]
//   float g_fBloomScale;               // Offset:  672 Size:     4 [unused]
//   float g_fStarScale;                // Offset:  676 Size:     4 [unused]
//   float2 g_vAdaptationRange;         // Offset:  680 Size:     8 [unused]
//   float2 g_vAdaptationSpeed;         // Offset:  688 Size:     8 [unused]
//   float2 g_vBlueShiftRange;          // Offset:  696 Size:     8 [unused]
//   float3 g_vBlueShiftWeight;         // Offset:  704 Size:    12 [unused]
//   float4 g_vLensFlareColorA;         // Offset:  720 Size:    16 [unused]
//   float4 g_vLensFlareColorB;         // Offset:  736 Size:    16 [unused]
//   float4 g_vLensFlareColorC;         // Offset:  752 Size:    16 [unused]
//   float4 g_vLensFlareColorD;         // Offset:  768 Size:    16 [unused]
//   float4 g_vLensFlareThresholds;     // Offset:  784 Size:    16 [unused]
//   float g_fLensFlareAttenuation;     // Offset:  800 Size:     4 [unused]
//   float3 g_vRegionCenter;            // Offset:  804 Size:    12 [unused]
//   float g_fFocalRange;               // Offset:  816 Size:     4 [unused]
//   float g_fFocalFade;                // Offset:  820 Size:     4 [unused]
//   float g_fBlurriness;               // Offset:  824 Size:     4 [unused]
//   float g_FgDofStrength;             // Offset:  828 Size:     4 [unused]
//   float g_fFogDensity;               // Offset:  832 Size:     4 [unused]
//   float4 g_vFogColor;                // Offset:  848 Size:    16 [unused]
//   float3 g_vFogNearDistance;         // Offset:  864 Size:    12 [unused]
//   float3 g_vTurbulenceScale;         // Offset:  880 Size:    12 [unused]
//   float g_fTurbulenceOpacity;        // Offset:  892 Size:     4 [unused]
//   float4 g_vTurbulenceSampleWeights; // Offset:  896 Size:    16 [unused]
//   float4 g_vTurbulenceOctaveOffset[4];// Offset:  912 Size:    64 [unused]
//   float2 g_vFogTargetSize;           // Offset:  976 Size:     8 [unused]
//   float2 g_vFogPixelSize;            // Offset:  984 Size:     8 [unused]
//   float4 g_vFogPixelOffsets;         // Offset:  992 Size:    16 [unused]
//   float4 g_vFogRasterScaleOffset;    // Offset: 1008 Size:    16 [unused]
//   float4 g_vFogFadeParams[27];       // Offset: 1024 Size:   432 [unused]
//   float4 g_vFogFadeParams2[4];       // Offset: 1456 Size:    64 [unused]
//   float2 g_vVideoScale;              // Offset: 1520 Size:     8 [unused]
//   float2 g_vVideoOffset;             // Offset: 1528 Size:     8 [unused]
//   float g_fVideoHorizSkew;           // Offset: 1536 Size:     4 [unused]
//   float g_fVideoHorizBend;           // Offset: 1540 Size:     4 [unused]
//   float g_fVideoFineShaking;         // Offset: 1544 Size:     4 [unused]
//   float g_fVideoColorNoise;          // Offset: 1548 Size:     4 [unused]
//   float4 g_vRadialParams;            // Offset: 1552 Size:    16 [unused]
//   float2 g_vRadialCenter;            // Offset: 1568 Size:     8
//   float g_fScreenAspectXByY;         // Offset: 1576 Size:     4 [unused]
//   float g_fNoiseIntensity;           // Offset: 1580 Size:     4 [unused]
//   float g_fDistortionScale;          // Offset: 1584 Size:     4 [unused]
//   float2 g_vDistortWobbleWaveLength; // Offset: 1588 Size:     8 [unused]
//   float2 g_vDistortWobbleTime;       // Offset: 1600 Size:     8 [unused]
//   float2 g_vVolumeLightParams;       // Offset: 1608 Size:     8
//   float2 g_vDepthRemapRange;         // Offset: 1616 Size:     8 [unused]
//   float g_fSaturation;               // Offset: 1624 Size:     4 [unused]
//   float g_fMotionBlurriness;         // Offset: 1628 Size:     4 [unused]
//   float g_fGammaWhiteCutoff;         // Offset: 1632 Size:     4 [unused]
//   float2 g_vGammaPostchain;          // Offset: 1636 Size:     8 [unused]
//   float g_fGammaCorrectionParams;    // Offset: 1644 Size:     4 [unused]
//   float3 g_vParticlesDiffuseColor;   // Offset: 1648 Size:    12 [unused]
//   float3 g_vParticlesLightDirVS;     // Offset: 1664 Size:    12 [unused]
//   float3 g_vParticlesLightColor;     // Offset: 1680 Size:    12 [unused]
//   float4 g_vParticlesFactors;        // Offset: 1696 Size:    16 [unused]
//   float4 g_vVignetteParams;          // Offset: 1712 Size:    16 [unused]
//   float4 g_vFastFogParams;           // Offset: 1728 Size:    16 [unused]
//   row_major float4x4 g_mViewProj;    // Offset: 1744 Size:    64 [unused]
//   float4 g_vParams0;                 // Offset: 1808 Size:    16 [unused]
//   float4 g_vParams1;                 // Offset: 1824 Size:    16 [unused]
//   float4 g_vParams2;                 // Offset: 1840 Size:    16 [unused]
//   float4 g_vParams3;                 // Offset: 1856 Size:    16 [unused]
//   float4 g_vParams4;                 // Offset: 1872 Size:    16
//   float4 g_vParams5;                 // Offset: 1888 Size:    16 [unused]
//   float4 g_vParams6;                 // Offset: 1904 Size:    16 [unused]
//   float4 g_vParams7;                 // Offset: 1920 Size:    16 [unused]
//   float4 g_vParams8;                 // Offset: 1936 Size:    16 [unused]
//   float4 g_vParams9;                 // Offset: 1952 Size:    16 [unused]
//   float4 g_vParams10;                // Offset: 1968 Size:    16 [unused]
//   float4 g_vParams11;                // Offset: 1984 Size:    16 [unused]
//   float4 g_vParams12;                // Offset: 2000 Size:    16 [unused]
//   float4 g_vParams13;                // Offset: 2016 Size:    16 [unused]
//   float4 g_vParams14;                // Offset: 2032 Size:    16 [unused]
//   float4 g_vParams15;                // Offset: 2048 Size:    16 [unused]
//   row_major float4x4 g_mMatrix0;     // Offset: 2064 Size:    64 [unused]
//   row_major float4x4 g_mMatrix1;     // Offset: 2128 Size:    64 [unused]
//   row_major float4x4 g_mMatrix2;     // Offset: 2192 Size:    64 [unused]
//   float2 g_vBarrel;                  // Offset: 2256 Size:     8 [unused]
//   float2 g_vPixelSize;               // Offset: 2264 Size:     8 [unused]
//   float4 g_SSAO_Color;               // Offset: 2272 Size:    16 [unused]
//   float4 g_vSSAO_Params;             // Offset: 2288 Size:    16 [unused]
//   float g_vSSAO_FarDistance;         // Offset: 2304 Size:     4 [unused]
//   float3 g_vLeftTopScreen;           // Offset: 2308 Size:    12 [unused]
//   float3 g_vRightBottomScreen;       // Offset: 2320 Size:    12 [unused]
//   float2 g_vSSAO_SampleRadii;        // Offset: 2336 Size:     8 [unused]
//   float2 g_vSSAO_RandScale;          // Offset: 2344 Size:     8 [unused]
//   float4 g_HBAO1;                    // Offset: 2352 Size:    16 [unused]
//   float4 g_HBAO2;                    // Offset: 2368 Size:    16 [unused]
//   float4 g_HBAO3;                    // Offset: 2384 Size:    16 [unused]
//   float4 g_vDoubleVision1;           // Offset: 2400 Size:    16 [unused]
//   float4 g_vDoubleVision2;           // Offset: 2416 Size:    16 [unused]
//   float4 g_vDoubleVisionBlend;       // Offset: 2432 Size:    16 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// samplerTLC0_s                     sampler      NA          NA    0        1
// mapTLC0                           texture  float4          2d    0        1
// _Globals                          cbuffer      NA          NA    4        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION              0   xyzw        0      POS   float       
// COLOR                    0   xyzw        1     NONE   float       
// TEXCOORD                 0   xy          2     NONE   float   xy  
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_TARGET                0   xyzw        0   TARGET   float   xyzw
//
ps_4_0
dcl_constantbuffer cb4[118], dynamicIndexed
dcl_sampler s0, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_input_ps linear v2.xy
dcl_output o0.xyzw
dcl_temps 5
add r0.xy, v2.xyxx, -cb4[98].xyxx
mul r0.zw, r0.xxxy, cb4[100].zzzz
sample r1.xyzw, v2.xyxx, t0.xyzw, s0
mov r2.xyz, r1.xyzx
mov r3.xy, v2.xyxx
mov r1.w, l(0)
loop 
  ftoi r2.w, r1.w
  ige r3.z, r2.w, l(16)
  if_nz r3.z
    break 
  endif 
  mad r3.xy, r0.zwzz, l(-0.062500, -0.062500, 0.000000, 0.000000), r3.xyxx
  sample r4.xyzw, r3.xyxx, t0.xyzw, s0
  ftou r3.z, r1.w
  mad r2.xyz, r4.xyzx, cb4[r3.z + 25].xyzx, r2.xyzx
  iadd r2.w, r2.w, l(1)
  itof r1.w, r2.w
endloop 
dp2 r0.x, |r0.xyxx|, |r0.xyxx|
sqrt r0.x, r0.x
mul_sat r0.x, r0.x, cb4[100].z
mad r0.xyz, r0.xxxx, -r2.xyzx, r2.xyzx
mul o0.xyz, r0.xyzx, cb4[117].xyzx
mov o0.w, l(0)
ret 
// Approximately 26 instruction slots used

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