//
// Generated by Microsoft (R) HLSL Shader Compiler 10.0.10011.16384
//
//   using 3Dmigoto v1.3.16 on Sat Jan 29 12:20:23 2022
//
//
// Buffer Definitions:
//
// cbuffer ConstBuf__spriteLensFlareData
// {
//
//   struct SpriteLensFlareData
//   {
//
//       struct SpriteLensFlareInstanceData
//       {
//
//           float sizeX;               // Index:    0
//           float sizeY;               // Index:    0.y
//           float offsetAlongLensFlareDirection;// Index:    0.z
//           float scaleWithOcclusion;  // Index:    0.w
//           float rotationFactor;      // Index:    1
//           float rotationOffset;      // Index:    1.y
//           float offsetFromAxis;      // Index:    1.z
//           float colorR;              // Index:    1.w
//           float colorG;              // Index:    2
//           float colorB;              // Index:    2.y
//
//       } spriteParameters[32];        // Index:    0
//       float4 lightPosPS;             // Index:   96
//       float4 fromLightToCenterPSAndDistance;// Index:   97
//       uint lightIndex;               // Index:   98
//       uint lensFlareTotalPixels;     // Index:   98.y
//       float widthScreenScaling;      // Index:   98.z
//       float heightScreenScaling;     // Index:   98.w
//       float heightToWidthRatio;      // Index:   99
//       bool useOctagonalVertexBuffer; // Index:   99.y
//
//   } resourceTables__spriteLensFlareData;// Index:    0-99.y           Components:   398
                                        // Textures:  t0-t33
//
// }
//
// Resource bind info for resourceTables__spriteLensFlareData.position
// {
//
//   uint2 $Element;                    // Index:    0.xy             Components:     2
//
// }
//
// Resource bind info for resourceTables__spriteLensFlareData.lensFlareVisiblePixels
// {
//
//   uint $Element;                     // Index:    0.x              Components:     1
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// resourceTables__spriteLensFlareData.position    texture  struct         r/o   32        1
// resourceTables__spriteLensFlareData.lensFlareVisiblePixels    texture  struct         r/o   33        1
// ConstBuf__spriteLensFlareData     cbuffer      NA          NA    0        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_VertexID              0   x           0   VERTID    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   x           2     NONE   float   x
// TEXCOORD                 2    y          2     NONE    uint    y
//
vs_5_0
dcl_globalFlags refactoringAllowed
dcl_immediateConstantBuffer { { -1.000000, 0.333333, 0, 0.333333343},
                              { -0.333333, 1.000000, 0.333333343, 0},
                              { 0.333333, 1.000000, 0.666666687, 0},
                              { 1.000000, 0.333333, 1.000000, 0.333333343},
                              { 1.000000, -0.333333, 1.000000, 0.666666687},
                              { 0.333333, -1.000000, 0.666666687, 1.000000},
                              { -0.333333, -1.000000, 0.333333343, 1.000000},
                              { -1.000000, -0.333333, 0, 0.666666687},
                              { 0, 0, 0.500000, 0.500000},
                              { -1.000000, 1.000000, 0, 0},
                              { -1.000000, -1.000000, 0, 1.000000},
                              { 1.000000, -1.000000, 1.000000, 1.000000},
                              { 1.000000, 1.000000, 1.000000, 0} }
dcl_constantbuffer cb0[100], dynamicIndexed
dcl_resource_structured t32, 8
dcl_resource_structured t33, 4
dcl_input_sgv v0.x, vertex_id
dcl_output_siv o0.xyzw, position
dcl_output o1.xy
dcl_output o2.x
dcl_output o2.y
dcl_temps 50
dcl_resource_texture2d (float,float,float,float) t125
dcl_resource_texture1d (float,float,float,float) t120
ld_indexable(texture2d)(float,float,float,float) r40.xyzw, l(0, 0, 0, 0), t125.xyzw
ld_indexable(texture1d)(float,float,float,float) r35.xyzw, l(10, 0, 0, 0), t120.xyzw
utof r0.x, cb0[98].y
ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r0.y, cb0[98].x, l(0), t33.xxxx
utof r0.y, r0.y

mov r10.y, r0.y
div r10.y, r10.y, l(640.0)

div r0.x, r0.y, r0.x
ne r0.w, r0.x, l(0.000000)
if_nz r0.w
  ld_structured_indexable(structured_buffer, stride=8)(mixed,mixed,mixed,mixed) r0.yz, v0.x, l(0), t32.xyxx
  imul null, r0.w, r0.y, l(3)
  movc r1.xyzw, cb0[99].yyyy, icb[r0.z + 0].zwxy, icb[r0.z + 9].zwxy
  add r0.z, cb0[97].z, cb0[97].z
  
  mov r10.z, r0.z
  
  mul r0.z, r0.z, cb0[r0.w + 0].z
  
  
  
  mul r1.zw, r1.zzzw, cb0[r0.w + 0].xxxy
  eq r2.x, l(1.000000), cb0[r0.w + 0].w
  max r2.y, r0.x, l(0.001000)
  mul r2.yz, r1.zzwz, r2.yyyy
  movc r1.zw, r2.xxxx, r2.yyyz, r1.zzzw
  lt r2.x, l(0.000000), cb0[97].z
  div r2.y, cb0[97].x, cb0[99].x
  min r2.z, |r2.y|, |cb0[97].y|
  max r2.w, |r2.y|, |cb0[97].y|
  div r2.w, l(1.000000, 1.000000, 1.000000, 1.000000), r2.w
  mul r2.z, r2.w, r2.z
  mul r2.w, r2.z, r2.z
  mad r3.x, r2.w, l(0.0208350997), l(-0.085133)
  mad r3.x, r2.w, r3.x, l(0.180141)
  mad r3.x, r2.w, r3.x, l(-0.330299497)
  mad r2.w, r2.w, r3.x, l(0.999866)
  mul r3.x, r2.w, r2.z
  
  mov r10.x, r2.w
  mul r10.x, r10.x, l(0.025)
  
  lt r3.y, |r2.y|, |cb0[97].y|
  mad r3.x, r3.x, l(-2.000000), l(1.57079637)
  and r3.x, r3.y, r3.x
  mad r2.z, r2.z, r2.w, r3.x
  
  //mov r10.x, r2.z
  
  lt r2.w, r2.y, -r2.y
  and r2.w, r2.w, l(0xc0490fdb)
  add r2.z, r2.w, r2.z
  min r2.w, r2.y, cb0[97].y
  max r2.y, r2.y, cb0[97].y
  lt r2.w, r2.w, -r2.w
  ge r2.y, r2.y, -r2.y
  and r2.y, r2.y, r2.w
  movc r2.y, r2.y, -r2.z, r2.z
  add r2.y, r2.y, l(1.57079637)
  mad r2.y, r2.y, cb0[r0.w + 1].x, cb0[r0.w + 1].y
  movc r2.x, r2.x, r2.y, cb0[r0.w + 1].y
  
  mov r10.w, r2.x
  
  sincos r2.x, r3.x, r2.x
  mov r4.x, -r2.x
  mov r4.y, r3.x
  dp2 r3.x, r1.wzww, r4.xyxx
  mov r4.z, r2.x
  dp2 r1.z, r1.wzww, r4.yzyy
  mad r3.y, cb0[r0.w + 1].z, cb0[97].z, r1.z
  mad r1.zw, r3.xxxy, cb0[98].zzzw, cb0[96].xxxy
  mad r2.xy, r0.zzzz, cb0[97].xyxx, r1.zwzz
  mov r2.z, l(1.000000)
  
  mul r40.w, r40.y, -r10.x
  add r40.w, r2.z, r40.w
  //mad r2.x, r40.x, r40.w, r2.x
  mad r2.x, r40.x, r2.z, r2.x
  
else
  mov r2.xyz, l(0,0,0,0)
  mov r1.xy, l(0,0,0,0)
  mov r0.xy, l(0,0,0,0)
endif



mov o0.xyw, r2.xyxz
mov o0.z, l(0)

//mad r0.x, r40.x, l(1.0), r0.x

mov o1.xy, r1.xyxx
mov o2.xy, r0.xyxx
ret
// Approximately 64 instruction slots used

///////////////////////////////// HLSL Code /////////////////////////////////
// // ---- Created with 3Dmigoto v1.3.16 on Sat Jan 29 12:20:23 2022
//
// cbuffer ConstBuf__spriteLensFlareData : register(b0)
// {
//
//   struct
//   {
//
//     struct
//     {
//       float sizeX;
//       float sizeY;
//       float offsetAlongLensFlareDirection;
//       float scaleWithOcclusion;
//       float rotationFactor;
//       float rotationOffset;
//       float offsetFromAxis;
//       float colorR;
//       float colorG;
//       float colorB;
//     } spriteParameters[32];
//
//     float4 lightPosPS;
//     float4 fromLightToCenterPSAndDistance;
//     uint lightIndex;
//     uint lensFlareTotalPixels;
//     float widthScreenScaling;
//     float heightScreenScaling;
//     float heightToWidthRatio;
//     bool useOctagonalVertexBuffer;
//   } resourceTables__spriteLensFlareData : packoffset(c0);
//
//
// StructuredBuffer<uint2> resourceTables__spriteLensFlareData.position : register(t32);
// StructuredBuffer<uint> resourceTables__spriteLensFlareData.lensFlareVisiblePixels : register(t33);
//
//
// // 3Dmigoto declarations
// #define cmp -
// Texture1D<float4> IniParams : register(t120);
// Texture2D<float4> StereoParams : register(t125);
//
//
// void main(
//   uint v0 : SV_VertexID0,
//   out float4 o0 : SV_POSITION0,
//   out float4 o1 : TEXCOORD0,
//   out float o2 : TEXCOORD1,
//   out uint p2 : TEXCOORD2)
// {
//   Textures: = t0-t33;
//   const float4 icb[] = { { -1.000000, 0.333333, 0, 0.333333343},
//                               { -0.333333, 1.000000, 0.333333343, 0},
//                               { 0.333333, 1.000000, 0.666666687, 0},
//                               { 1.000000, 0.333333, 1.000000, 0.333333343},
//                               { 1.000000, -0.333333, 1.000000, 0.666666687},
//                               { 0.333333, -1.000000, 0.666666687, 1.000000},
//                               { -0.333333, -1.000000, 0.333333343, 1.000000},
//                               { -1.000000, -0.333333, 0, 0.666666687},
//                               { 0, 0, 0.500000, 0.500000},
//                               { -1.000000, 1.000000, 0, 0},
//                               { -1.000000, -1.000000, 0, 1.000000},
//                               { 1.000000, -1.000000, 1.000000, 1.000000},
//                               { 1.000000, 1.000000, 1.000000, 0} };
// // Needs manual fix for instruction:
// // unknown dcl_: dcl_input_sgv v0.x, vertex_id
//   float4 r0,r1,r2,r3,r4;
//   uint4 bitmask, uiDest;
//   float4 fDest;
//
//   r0.y = [resourceTables__spriteLensFlareData.lensFlareTotalPixels].val[/4];
//   stride=4)(mixed = (uint)r0.y;
//   r0.y = r0.y / ;
//   r0.x = cmp(r0.y != r0.x);
//   if (r0.w != 0) {
//     r0.y = [].val[/4+1];
//     r0.z = [].val[/4];
//     r0.yz = (int)v0.x * 0;
//     null = r0.w ? r0.y : 3;
// }
//////////////////////////////// HLSL Errors ////////////////////////////////
// error X3506: unrecognized compiler target '                                        // Textures:  t0-t33'
/////////////////////////////////////////////////////////////////////////////
