//Lens flares VS (like sun position VS).
// ---- Created with 3Dmigoto v1.3.16 on Sun May 30 10:51:57 2021
Texture2D<float4> t0 : register(t0);

SamplerState s0_s : register(s0);

cbuffer cb2 : register(b2)
{
  float4 cb2[18];
}

cbuffer cb1 : register(b1)
{
  float4 cb1[53];
}

cbuffer cb0 : register(b0)
{
  float4 cb0[3];
}




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


void main(
  float2 v0 : ATTRIBUTE0,
  float2 v1 : ATTRIBUTE1,
  uint v2 : SV_InstanceID0,
  out float4 o0 : SV_POSITION0,
  out float4 o1 : TEXCOORD0,
  out float4 o2 : TEXCOORD1,
  out float2 o3 : TEXCOORD2)
{
// Needs manual fix for instruction:
// unknown dcl_: dcl_input_sgv v2.x, instance_id
  float4 r0,r1,r2,r3,r4,r10;
  uint4 bitmask, uiDest;
  float4 fDest;
  
  float4 stereo = StereoParams.Load(0);
  
  r0.xyz = cb1[1].xyw * cb0[0].yyy;
  r0.xyz = cb0[0].xxx * cb1[0].xyw + r0.xyz;
  r0.xyz = cb0[0].zzz * cb1[2].xyw + r0.xyz;
  r0.xyz = cb1[3].xyw + r0.xyz;
  
  r10.x=r0.z;
  
  r0.x+=stereo.x*(r0.z-stereo.y);
  
  r0.xy = r0.xy / r0.zz;
  r0.xy = r0.xy * cb1[52].xy + cb1[52].wz;
  r0.xy = float2(-0.5,-0.5) + r0.xy;
  r0.x = dot(abs(r0.xy), abs(r0.xy));
  r0.x = cb2[17].y * r0.x;
  r0.x = max(1, r0.x);
  r0.xy = cb2[15].xy * r0.xx;
  r0.z = dot(cb0[0].xyz, cb0[0].xyz);
  r0.z = sqrt(r0.z);
  r0.z = 1 + r0.z;
  r0.z = 100 / r0.z;
  r0.z = sqrt(r0.z);
  r0.xy = r0.xy * r0.zz;
  r0.xy = v1.xy * r0.xy;
  r0.z = cb0[1].x + cb0[1].y;
  r0.z = cb2[16].y * r0.z;
  r1.xy = float2(-1,0.5) + cb0[2].xy;
  r0.w = max(1, r1.x);
  r1.z = (uint)v2.x;
  r0.w = r1.z / r0.w;
  r0.w = -0.5 + r0.w;
  r1.xw = r1.yz / cb0[2].zx;
  o3.x = r1.z;
  r0.z = r0.w * r0.z + r1.w;
  r0.z = frac(r0.z);
  r0.z = 6.28318548 * r0.z;
  sincos(r0.z, r2.x, r3.x);
  r4.z = r2.x;
  r4.y = r3.x;
  r4.x = -r2.x;
  r2.x = dot(r0.yx, r4.xy);
  r0.x = dot(r0.yx, r4.yz);
  r2.y = cb0[2].w * r0.x;
  r0.xy = cb0[1].xy * cb2[12].xy + r2.xy;
  r1.y = 0.5;
  r0.z = t0.SampleLevel(s0_s, r1.xy, 3).w;
  r0.z = cmp(0 < r0.z);
  r0.z = r0.z ? 1.000000 : 0;
  o0.xy = r0.xy * r0.zz;
  o0.zw = float2(0,1);
  o1.xy = v1.xy;
  o2.xy = cb0[1].xy;
  o3.y = cb0[2].x;
  o0.x+=stereo.x*(1-stereo.y/r10.x);
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) D3D Shader Disassembler
//
//   using 3Dmigoto v1.3.16 on Sun May 30 10:51:57 2021
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// ATTRIBUTE                0   xy          0     NONE   float
// ATTRIBUTE                1   xy          1     NONE   float   xy
// SV_InstanceID            0   x           2   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   xy          2     NONE   float   xy
// TEXCOORD                 2   xy          3     NONE   float   xy
//
vs_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[3], immediateIndexed
dcl_constantbuffer cb1[53], immediateIndexed
dcl_constantbuffer cb2[18], immediateIndexed
dcl_sampler s0, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_input v1.xy
dcl_input_sgv v2.x, instance_id
dcl_output_siv o0.xyzw, position
dcl_output o1.xy
dcl_output o2.xy
dcl_output o3.xy
dcl_temps 5
mul r0.xyz, cb0[0].yyyy, cb1[1].xywx
mad r0.xyz, cb0[0].xxxx, cb1[0].xywx, r0.xyzx
mad r0.xyz, cb0[0].zzzz, cb1[2].xywx, r0.xyzx
add r0.xyz, r0.xyzx, cb1[3].xywx
div r0.xy, r0.xyxx, r0.zzzz
mad r0.xy, r0.xyxx, cb1[52].xyxx, cb1[52].wzww
add r0.xy, r0.xyxx, l(-0.500000, -0.500000, 0.000000, 0.000000)
dp2 r0.x, |r0.xyxx|, |r0.xyxx|
mul r0.x, r0.x, cb2[17].y
max r0.x, r0.x, l(1.000000)
mul r0.xy, r0.xxxx, cb2[15].xyxx
dp3 r0.z, cb0[0].xyzx, cb0[0].xyzx
sqrt r0.z, r0.z
add r0.z, r0.z, l(1.000000)
div r0.z, l(100.000000), r0.z
sqrt r0.z, r0.z
mul r0.xy, r0.zzzz, r0.xyxx
mul r0.xy, r0.xyxx, v1.xyxx
add r0.z, cb0[1].y, cb0[1].x
mul r0.z, r0.z, cb2[16].y
add r1.xy, cb0[2].xyxx, l(-1.000000, 0.500000, 0.000000, 0.000000)
max r0.w, r1.x, l(1.000000)
utof r1.z, v2.x
div r0.w, r1.z, r0.w
add r0.w, r0.w, l(-0.500000)
div r1.xw, r1.yyyz, cb0[2].zzzx
mov o3.x, r1.z
mad r0.z, r0.w, r0.z, r1.w
frc r0.z, r0.z
mul r0.z, r0.z, l(6.28318548)
sincos r2.x, r3.x, r0.z
mov r4.z, r2.x
mov r4.y, r3.x
mov r4.x, -r2.x
dp2 r2.x, r0.yxyy, r4.xyxx
dp2 r0.x, r0.yxyy, r4.yzyy
mul r2.y, r0.x, cb0[2].w
mad r0.xy, cb0[1].xyxx, cb2[12].xyxx, r2.xyxx
mov r1.y, l(0.500000)
sample_l_indexable(texture2d)(float,float,float,float) r0.z, r1.xyxx, t0.xywz, s0, l(3.000000)
lt r0.z, l(0.000000), r0.z
and r0.z, r0.z, l(0x3f800000)
mul o0.xy, r0.zzzz, r0.xyxx
mov o0.zw, l(0,0,0,1.000000)
mov o1.xy, v1.xyxx
mov o2.xy, cb0[1].xyxx
mov o3.y, cb0[2].x
ret
// Approximately 0 instruction slots used

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