//P5S some lens flares. Don't use.
// ---- Created with 3Dmigoto v1.3.16 on Thu Mar 03 00:10:11 2022

struct sSpriteInfo
{
    float fCenterScale;            // Offset:    0
    float fSizeRate;               // Offset:    4
    float4 vRefColor;              // Offset:    8
    float fAnamorphicFlare;        // Offset:   24
};

cbuffer cbFlare : register(b2)
{
  float4 g_vLensFlareInfo : packoffset(c0);
  float4 g_vSun2dInfo : packoffset(c1);
  float4 g_vScreenInfo : packoffset(c2);
  float4 g_vLensHaloInfo0 : packoffset(c3);
  float4 g_vLensHaloInfo1 : packoffset(c4);
  float4 g_vAnamorphicCoat : packoffset(c5);
}

StructuredBuffer<sSpriteInfo> g_tSpriteInfo : register(t1);


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


void main(
  uint v0 : SV_VertexID0,
  uint v1 : SV_InstanceID0,
  out float4 o0 : SV_Position0,
  out float2 o1 : TEXCOORD0,
  out float2 p1 : TEXCOORD1,
  out float4 o2 : COLOR0,
  out float o3 : TEXCOORD2)
{
// Needs manual fix for instruction:
// unknown dcl_: dcl_input_sgv v0.x, vertex_id
// Needs manual fix for instruction:
// unknown dcl_: dcl_input_sgv v1.x, instance_id
  float4 r0,r1,r2,r3,r4;
  uint4 bitmask, uiDest;
  float4 fDest;
  
  float4 stereo = StereoParams.Load(0);
  
  r0.x = g_vScreenInfo.y + g_vScreenInfo.y;
  r1.w = g_vSun2dInfo.w / r0.x;
  r0.y = (int)v1.x & 1;
  r0.y = cmp((int)r0.y == 1);
  r0.y = r0.y ? 1 : -1;
  r2.w = g_vSun2dInfo.y;
  r3.x = g_tSpriteInfo[v1.x].vRefColor.x;
  r3.y = g_tSpriteInfo[v1.x].vRefColor.y;
  r3.z = g_tSpriteInfo[v1.x].fCenterScale;
  r3.w = g_tSpriteInfo[v1.x].fSizeRate;
  r2.xyz = g_vSun2dInfo.xyx * r3.zzz;
  r1.xy = r2.zw * r0.yy;
  r0.y = cmp(0 < g_vAnamorphicCoat.w);
  r4.x = g_tSpriteInfo[v1.x].vRefColor.z;
  r4.y = g_tSpriteInfo[v1.x].vRefColor.w;
  r4.z = g_tSpriteInfo[v1.x].fAnamorphicFlare;
  r0.z = cmp(0 < r4.z);
  r0.y = r0.z ? r0.y : 0;
  r0.z = g_vScreenInfo.y;
  r0.w = 1;
  r2.zw = r3.ww * r0.zw;
  r1.z = r3.w * r0.x;
  r1.xyzw = r0.yyyy ? r1.xyzw : r2.xyzw;
  r0.x = (int)v0.x & 1;
  r2.x = (uint)r0.x;
  if (1 == 0) r0.x = 0; else if (1+1 < 32) {   r0.x = (uint)v0.x << (32-(1 + 1)); r0.x = (uint)r0.x >> (32-1);  } else r0.x = (uint)v0.x >> 1;
  r2.y = (uint)r0.x;
  r0.xz = r2.xy * float2(2,-2) + float2(-1,1);
  r0.xz = r1.zw * r0.xz;
  o0.xy = r0.xz * float2(2,2) + r1.xy;
  o0.z = g_vLensHaloInfo1.z;
  o0.w = 1;
  
  //o0.x+=stereo.x;
  
  p1.xy = r2.xy * float2(2,-2) + float2(-1,1);
  o1.xy = r2.xy;
  r0.x = 1 / r3.w;
  r0.x = g_vLensFlareInfo.w * r0.x;
  o3.x = abs(r0.x);
  r3.z = r4.x;
  r0.x = max(9.99999975e-005, r4.y);
  o2.w = 1 / r0.x;
  o2.xyz = r0.yyy ? g_vAnamorphicCoat.xyz : r3.xyz;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//   using 3Dmigoto v1.3.16 on Thu Mar 03 00:10:11 2022
//
//
// Buffer Definitions:
//
// cbuffer cbFlare
// {
//
//   float4 g_vLensFlareInfo;           // Offset:    0 Size:    16
//   float4 g_vSun2dInfo;               // Offset:   16 Size:    16
//   float4 g_vScreenInfo;              // Offset:   32 Size:    16
//   float4 g_vLensHaloInfo0;           // Offset:   48 Size:    16 [unused]
//   float4 g_vLensHaloInfo1;           // Offset:   64 Size:    16
//   float4 g_vAnamorphicCoat;          // Offset:   80 Size:    16
//
// }
//
// Resource bind info for g_tSpriteInfo
// {
//
//   struct sSpriteInfo
//   {
//
//       float fCenterScale;            // Offset:    0
//       float fSizeRate;               // Offset:    4
//       float4 vRefColor;              // Offset:    8
//       float fAnamorphicFlare;        // Offset:   24
//
//   } $Element;                        // Offset:    0 Size:    28
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// g_tSpriteInfo                     texture  struct         r/o    1        1
// cbFlare                           cbuffer      NA          NA    2        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_VertexID              0   x           0   VERTID    uint   x
// SV_InstanceID            0   x           1   INSTID    uint   x
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float   xyzw
// TEXCOORD                 0   xy          1     NONE   float   xy
// TEXCOORD                 1     zw        1     NONE   float     zw
// COLOR                    0   xyzw        2     NONE   float   xyzw
// TEXCOORD                 2   x           3     NONE   float   x
//
vs_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb2[6], immediateIndexed
dcl_resource_structured t1, 28
dcl_input_sgv v0.x, vertex_id
dcl_input_sgv v1.x, instance_id
dcl_output_siv o0.xyzw, position
dcl_output o1.xy
dcl_output o1.zw
dcl_output o2.xyzw
dcl_output o3.x
dcl_temps 5
add r0.x, cb2[2].y, cb2[2].y
div r1.w, cb2[1].w, r0.x
and r0.y, v1.x, l(1)
ieq r0.y, r0.y, l(1)
movc r0.y, r0.y, l(1.000000), l(-1.000000)
mov r2.w, cb2[1].y
ld_structured_indexable(structured_buffer, stride=28)(mixed,mixed,mixed,mixed) r3.xyzw, v1.x, l(0), t1.zwxy
mul r2.xyz, r3.zzzz, cb2[1].xyxx
mul r1.xy, r0.yyyy, r2.zwzz
lt r0.y, l(0.000000), cb2[5].w
ld_structured_indexable(structured_buffer, stride=28)(mixed,mixed,mixed,mixed) r4.xyz, v1.x, l(16), t1.xyzx
lt r0.z, l(0.000000), r4.z
and r0.y, r0.z, r0.y
mov r0.z, cb2[2].y
mov r0.w, l(1.000000)
mul r2.zw, r0.zzzw, r3.wwww
mul r1.z, r0.x, r3.w
movc r1.xyzw, r0.yyyy, r1.xyzw, r2.xyzw
and r0.x, v0.x, l(1)
utof r2.x, r0.x
ubfe r0.x, l(1), l(1), v0.x
utof r2.y, r0.x
mad r0.xz, r2.xxyx, l(2.000000, 0.000000, -2.000000, 0.000000), l(-1.000000, 0.000000, 1.000000, 0.000000)
mul r0.xz, r0.xxzx, r1.zzwz
mad o0.xy, r0.xzxx, l(2.000000, 2.000000, 0.000000, 0.000000), r1.xyxx
mov o0.z, cb2[4].z
mov o0.w, l(1.000000)
mad o1.zw, r2.xxxy, l(0.000000, 0.000000, 2.000000, -2.000000), l(0.000000, 0.000000, -1.000000, 1.000000)
mov o1.xy, r2.xyxx
div r0.x, l(1.000000, 1.000000, 1.000000, 1.000000), r3.w
mul r0.x, r0.x, cb2[0].w
mov o3.x, |r0.x|
mov r3.z, r4.x
max r0.x, r4.y, l(0.000100)
div o2.w, l(1.000000, 1.000000, 1.000000, 1.000000), r0.x
movc o2.xyz, r0.yyyy, cb2[5].xyzx, r3.xyzx
ret
// Approximately 37 instruction slots used

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