// Lensflares PS

cbuffer cPSScene : register(b2)
{

  struct
  {
    float4x4 m_projectionView;
    float4x4 m_projection;
    float4x4 m_view;
    float4x4 m_shadowProjection;
    float4x4 m_shadowProjection2;
    float4 m_eyepos;
    float4 m_projectionParam;
    float4 m_viewportSize;
    float4 m_exposure;
    float4 m_fogParam[3];
    float4 m_fogColor;
    float4 m_cameraCenterOffset;
    float4 m_shadowMapResolutions;
  } g_psScene : packoffset(c0);

}

cbuffer cPSMaterial : register(b4)
{

  struct
  {
    float4 m_materials[8];
  } g_psMaterial : packoffset(c0);

}

cbuffer cPSSystem : register(b0)
{

  struct
  {
    float4 m_param;
    float4 m_renderInfo;
    float4 m_renderBuffer;
    float4 m_dominantLightDir;
  } g_psSystem : packoffset(c0);

}

SamplerState g_samplerPoint_Clamp_s : register(s9);
SamplerState g_samplerLinear_Wrap_s : register(s10);
Texture2D<float4> inColorTexture : register(t0);
Texture2D<float4> inDepthTexture : register(t1);


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


void main( 
  float4 v0 : COLOR1,
  float2 v1 : TEXCOORD0,
  float w1 : TEXCOORD2,
  float4 v2 : TEXCOORD1,
  float3 v3 : TEXCOORD3,
  float4 v4 : SV_Position0,
  out float4 o0 : SV_Target0)
  
{
  float4 r0,r1;
  uint4 bitmask, uiDest;
  float4 fDest;

  float4 x0[3];
  x0[0].xy = float2(0.689999998,-3.94000006);
  x0[1].xy = float2(-3.75999999,1.37);
  x0[2].xy = float2(3.05999994,2.56999993);
  r0.xy = float2(0,0);
  while (true) {
    r0.z = cmp((int)r0.y >= 3);
    if (r0.z != 0) break;
    r0.zw = x0[r0.y+0].xy;
    r0.zw = v3.xy * g_psSystem.m_renderInfo.xy + r0.zw;
    r0.zw = g_psSystem.m_renderBuffer.zw * r0.zw;
    r0.z = inDepthTexture.SampleLevel(g_samplerPoint_Clamp_s, r0.zw, 0).x;
    r0.z = -g_psScene.m_projectionParam.w + r0.z;
    r0.z = g_psScene.m_projectionParam.z / r0.z;
    r0.z = g_psMaterial.m_materials[1].x + r0.z;
    r0.z = -w1.x + r0.z;
    r0.z = saturate(r0.z / g_psMaterial.m_materials[1].x);
    r0.x = r0.x + r0.z;
    r0.y = (int)r0.y + 1;
  }
  r0.x = -r0.x * 0.333333343 + 1;
  r0.w = -r0.x * r0.x + 1;
  r1.xyzw = inColorTexture.Sample(g_samplerLinear_Wrap_s, v1.xy).xyzw;
  r1.xyzw = v2.xyzw * r1.xyzw;
  
   
  r0.xyz = float3(1,1,1);
  o0.xyzw = r1.xyzw * r0.xyzw;
  
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//   using 3Dmigoto v1.2.25 on Wed Jan 20 11:59:49 2016
//
//
// Buffer Definitions: 
//
// cbuffer cPSScene
// {
//
//   struct PSScene
//   {
//       
//       float4x4 m_projectionView;     // Offset:    0
//       float4x4 m_projection;         // Offset:   64
//       float4x4 m_view;               // Offset:  128
//       float4x4 m_shadowProjection;   // Offset:  192
//       float4x4 m_shadowProjection2;  // Offset:  256
//       float4 m_eyepos;               // Offset:  320
//       float4 m_projectionParam;      // Offset:  336
//       float4 m_viewportSize;         // Offset:  352
//       float4 m_exposure;             // Offset:  368
//       float4 m_fogParam[3];          // Offset:  384
//       float4 m_fogColor;             // Offset:  432
//       float4 m_cameraCenterOffset;   // Offset:  448
//       float4 m_shadowMapResolutions; // Offset:  464
//
//   } g_psScene;                       // Offset:    0 Size:   480
//
// }
//
// cbuffer cPSMaterial
// {
//
//   struct PSMaterial
//   {
//       
//       float4 m_materials[8];         // Offset:    0
//
//   } g_psMaterial;                    // Offset:    0 Size:   128
//
// }
//
// cbuffer cPSSystem
// {
//
//   struct PSSystem
//   {
//       
//       float4 m_param;                // Offset:    0
//       float4 m_renderInfo;           // Offset:   16
//       float4 m_renderBuffer;         // Offset:   32
//       float4 m_dominantLightDir;     // Offset:   48
//
//   } g_psSystem;                      // Offset:    0 Size:    64
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// g_samplerPoint_Clamp              sampler      NA          NA    9        1
// g_samplerLinear_Wrap              sampler      NA          NA   10        1
// inColorTexture                    texture  float4          2d    0        1
// inDepthTexture                    texture  float4          2d    1        1
// cPSSystem                         cbuffer      NA          NA    0        1
// cPSScene                          cbuffer      NA          NA    2        1
// cPSMaterial                       cbuffer      NA          NA    4        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// COLOR                    1   xyzw        0     NONE   float       
// TEXCOORD                 0   xy          1     NONE   float   xy  
// TEXCOORD                 2     z         1     NONE   float     z 
// TEXCOORD                 1   xyzw        2     NONE   float   xyzw
// TEXCOORD                 3   xyz         3     NONE   float   xy  
// SV_Position              0   xyzw        4      POS   float       
//
//
// 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 cb2[22], immediateIndexed
dcl_constantbuffer cb4[2], immediateIndexed
dcl_constantbuffer cb0[3], immediateIndexed
dcl_sampler s9, mode_default
dcl_sampler s10, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t1
dcl_input_ps linear v1.xy
dcl_input_ps linear v1.z
dcl_input_ps linear v2.xyzw
dcl_input_ps linear v3.xy
dcl_output o0.xyzw
dcl_temps 2
dcl_indexableTemp x0[3], 4
mov x0[0].xy, l(0.690000,-3.940000,0,0)
mov x0[1].xy, l(-3.760000,1.370000,0,0)
mov x0[2].xy, l(3.060000,2.570000,0,0)
mov r0.xy, l(0,0,0,0)
loop 
  ige r0.z, r0.y, l(3)
  breakc_nz r0.z
  mov r0.zw, x0[r0.y + 0].xxxy
  mad r0.zw, v3.xxxy, cb0[1].xxxy, r0.zzzw
  mul r0.zw, r0.zzzw, cb0[2].zzzw
  sample_l_indexable(texture2d)(float,float,float,float) r0.z, r0.zwzz, t1.yzxw, s9, l(0.000000)
  add r0.z, r0.z, -cb2[21].w
  div r0.z, cb2[21].z, r0.z
  add r0.z, r0.z, cb4[1].x
  add r0.z, r0.z, -v1.z
  div_sat r0.z, r0.z, cb4[1].x
  add r0.x, r0.z, r0.x
  iadd r0.y, r0.y, l(1)
endloop 
mad r0.x, -r0.x, l(0.333333343), l(1.000000)
mad r0.w, -r0.x, r0.x, l(1.000000)
sample_indexable(texture2d)(float,float,float,float) r1.xyzw, v1.xyxx, t0.xyzw, s10
mul r1.xyzw, r1.xyzw, v2.xyzw
mov r0.xyz, l(1.000000,1.000000,1.000000,0)
mul o0.xyzw, r0.xyzw, r1.xyzw
ret 
// Approximately 26 instruction slots used

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