//light shafts
// ---- Created with 3Dmigoto v1.2.39 on Tue Jun 21 11:56:32 2016

cbuffer _Globals : register(b0)
{
  float4x4 ScreenToWorldMatrix : packoffset(c0);
  bool bDecompressSceneColor : packoffset(c4);
  float4x4 ScreenToWorld : packoffset(c5);
  float4x4 ScreenToViewport : packoffset(c9);
  float2 TextureSpaceBlurOrigin : packoffset(c13);
  float4 WorldSpaceBlurOriginAndRadius : packoffset(c14);
  float3 WorldSpaceSpotDirection : packoffset(c15);
  float2 SpotAngles : packoffset(c16);
  float4 WorldSpaceCameraPositionAndDistance : packoffset(c17);
  float4 UVMinMax : packoffset(c18);
  float4 AspectRatioAndInvAspectRatio : packoffset(c19);
  float4 LightShaftParameters : packoffset(c20);
  float4 BloomTintAndThreshold : packoffset(c21);
  float DistanceFade : packoffset(c22);
  float4 SampleOffsets[2] : packoffset(c23);
  float BlurPassIndex : packoffset(c25);
  float4 SourceTextureScaleBias : packoffset(c26);
  float4 SceneColorScaleBias : packoffset(c27);
  float BloomScreenBlendThreshold : packoffset(c28);
}

SamplerState SceneColorTextureSampler_s : register(s0);
SamplerState SourceTextureSampler_s : register(s1);
Texture2D<float4> SceneColorTexture : register(t0);
Texture2D<float4> SourceTexture : register(t1);


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


void main( 
  float2 v0 : TEXCOORD0,
  float2 w0 : TEXCOORD1,
  out float4 o0 : SV_Target0)
{
  float4 r0,r1,r16;
  uint4 bitmask, uiDest;
  float4 fDest;

float4 stereo = StereoParams.Load(0);
r16.xy = TextureSpaceBlurOrigin.xy;
r16.x += stereo.x * 0.5;

 r0.xy = -v0.xy * AspectRatioAndInvAspectRatio.zw + r16.xy;
  r0.x = dot(r0.xy, r0.xy);
  r0.x = sqrt(r0.x);
  r0.x = 0.5 * r0.x;
  r0.x = min(1, r0.x);
  r0.y = -LightShaftParameters.w * 0.5 + 1.5;
  r0.y = -LightShaftParameters.w + r0.y;
  r1.xyzw = SourceTexture.Sample(SourceTextureSampler_s, v0.xy).xyzw;
  r0.z = r1.w * r1.w;
  r1.xyz = BloomTintAndThreshold.xyz * r1.xyz;
  r0.y = r0.z * r0.y + LightShaftParameters.w;
  r0.z = 1 + -r0.y;
  r0.x = r0.x * r0.z + r0.y;
  r0.y = 1 + -r0.x;
  r0.z = DistanceFade * DistanceFade;
  r0.z = DistanceFade * r0.z;
  o0.w = r0.z * r0.y + r0.x;
  r0.xyz = SceneColorTexture.Sample(SceneColorTextureSampler_s, w0.xy).xyz;
  r0.x = dot(r0.xyz, float3(0.300000012,0.589999974,0.109999999));
  r0.x = -3 * r0.x;
  r0.x = exp2(r0.x);
  r0.x = saturate(BloomScreenBlendThreshold * r0.x);
  r0.xyz = r1.xyz * r0.xxx;
  o0.xyz = float3(4,4,4) * r0.xyz;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//   using 3Dmigoto v1.2.39 on Tue Jun 21 11:56:32 2016
//
//
// Buffer Definitions: 
//
// cbuffer $Globals
// {
//
//   float4x4 ScreenToWorldMatrix;      // Offset:    0 Size:    64 [unused]
//   bool bDecompressSceneColor;        // Offset:   64 Size:     4 [unused]
//   float4x4 ScreenToWorld;            // Offset:   80 Size:    64 [unused]
//   float4x4 ScreenToViewport;         // Offset:  144 Size:    64 [unused]
//   float2 TextureSpaceBlurOrigin;     // Offset:  208 Size:     8
//   float4 WorldSpaceBlurOriginAndRadius;// Offset:  224 Size:    16 [unused]
//   float3 WorldSpaceSpotDirection;    // Offset:  240 Size:    12 [unused]
//   float2 SpotAngles;                 // Offset:  256 Size:     8 [unused]
//   float4 WorldSpaceCameraPositionAndDistance;// Offset:  272 Size:    16 [unused]
//   float4 UVMinMax;                   // Offset:  288 Size:    16 [unused]
//   float4 AspectRatioAndInvAspectRatio;// Offset:  304 Size:    16
//   float4 LightShaftParameters;       // Offset:  320 Size:    16
//   float4 BloomTintAndThreshold;      // Offset:  336 Size:    16
//   float DistanceFade;                // Offset:  352 Size:     4
//   float4 SampleOffsets[2];           // Offset:  368 Size:    32 [unused]
//   float BlurPassIndex;               // Offset:  400 Size:     4 [unused]
//   float4 SourceTextureScaleBias;     // Offset:  416 Size:    16 [unused]
//   float4 SceneColorScaleBias;        // Offset:  432 Size:    16 [unused]
//   float BloomScreenBlendThreshold;   // Offset:  448 Size:     4
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// SceneColorTextureSampler          sampler      NA          NA    0        1
// SourceTextureSampler              sampler      NA          NA    1        1
// SceneColorTexture                 texture  float4          2d    0        1
// SourceTexture                     texture  float4          2d    1        1
// $Globals                          cbuffer      NA          NA    0        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// TEXCOORD                 0   xy          0     NONE   float   xy  
// TEXCOORD                 1     zw        0     NONE   float     zw
//
//
// 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 cb0[29], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t1
dcl_input_ps linear v0.xy
dcl_input_ps linear v0.zw
dcl_output o0.xyzw
dcl_temps 2
mad r0.xy, -v0.xyxx, cb0[19].zwzz, cb0[13].xyxx
dp2 r0.x, r0.xyxx, r0.xyxx
sqrt r0.x, r0.x
mul r0.x, r0.x, l(0.500000)
min r0.x, r0.x, l(1.000000)
mad r0.y, -cb0[20].w, l(0.500000), l(1.500000)
add r0.y, r0.y, -cb0[20].w
sample_indexable(texture2d)(float,float,float,float) r1.xyzw, v0.xyxx, t1.xyzw, s1
mul r0.z, r1.w, r1.w
mul r1.xyz, r1.xyzx, cb0[21].xyzx
mad r0.y, r0.z, r0.y, cb0[20].w
add r0.z, -r0.y, l(1.000000)
mad r0.x, r0.x, r0.z, r0.y
add r0.y, -r0.x, l(1.000000)
mul r0.z, cb0[22].x, cb0[22].x
mul r0.z, r0.z, cb0[22].x
mad o0.w, r0.z, r0.y, r0.x
sample_indexable(texture2d)(float,float,float,float) r0.xyz, v0.zwzz, t0.xyzw, s0
dp3 r0.x, r0.xyzx, l(0.300000, 0.590000, 0.110000, 0.000000)
mul r0.x, r0.x, l(-3.000000)
exp r0.x, r0.x
mul_sat r0.x, r0.x, cb0[28].x
mul r0.xyz, r0.xxxx, r1.xyzx
mul o0.xyz, r0.xyzx, l(4.000000, 4.000000, 4.000000, 0.000000)
ret 
// Approximately 25 instruction slots used

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