// Targetting circle

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 cPSObject : register(b5)
{

  struct
  {
    float4x4 m_viewWorld;
    float4x4 m_world;
    float4 m_useWeightCount;
    float4 m_localParam[4];
  } g_psObject : 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);
Texture2D<float4> inDepthTexture : register(t13);


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


void main( 
  float4 v0 : COLOR0,
  float4 v1 : COLOR1,
  float4 v2 : SV_Position0,
  float4 v3 : TEXCOORD0,
  float4 v4 : TEXCOORD1,
  float3 v5 : TEXCOORD2,
  out float4 o0 : SV_Target0)
{
  float4 r0,r1,r2,r3;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.xyzw = float4(-0.5,-0.5,-0.00390625,-0.00390625) + v2.xyxy;
  r1.xy = g_psObject.m_localParam[0].zw * r0.zw;
  r1.zw = g_psSystem.m_renderInfo.xy / g_psScene.m_viewportSize.xy;
  r2.xy = g_psScene.m_viewportSize.xy / g_psSystem.m_renderBuffer.xy;
  r0.xy = float2(0.5,0.5) * r0.xy;
  r2.zw = float2(0.5,0.5) / r1.zw;
  r3.xy = r2.zw * r0.xy;
  r3.xy = floor(r3.xy);
  r0.xy = r0.xy * r2.zw + -r3.xy;
  r0.xy = float2(-0.5,-0.5) + r0.xy;
  r0.xy = -abs(r0.xy) * float2(2,2) + float2(1,1);
  r0.x = r0.x * r0.y;
  r1.xy = r2.xy * r1.xy;
  r1.xy = r1.xy * r1.zw;
  r0.y = inDepthTexture.SampleLevel(g_samplerPoint_Clamp_s, r1.xy, 0).x;
  r0.y = -g_psScene.m_projectionParam.w + r0.y;
  r0.y = g_psScene.m_projectionParam.z / r0.y;
  r0.zw = r0.zw * g_psObject.m_localParam[0].zw + -g_psMaterial.m_materials[0].xy;
  
  float4 stereo = StereoParams.Load(0);
  r0.z -= stereo.x * (r0.y - stereo.y) / r0.y / 2;
    
  r0.zw = g_psMaterial.m_materials[1].xy * r0.zw;
  r1.xy = r0.zw + r0.zw;
  r1.z = -g_psMaterial.m_materials[0].z + r0.y;
  r0.y = dot(r1.xyz, r1.xyz);
  r0.y = sqrt(r0.y);
  r0.z = cmp(1.29999995 < r0.y);
  if (r0.z != 0) {
    r0.z = 1.5 + -r0.y;
    r0.z = saturate(5 * r0.z);
    r0.z = r0.x * r0.z;
  } else {
    r0.x = r0.y * r0.x;
    r0.z = 0.769230783 * r0.x;
  }
  r0.x = r0.z * r0.z;
  r0.x = 1.5 * r0.x;
  r0.x = min(1, r0.x);
  r0.x = v0.w * r0.x;
  o0.xyz = v0.xyz * r0.xxx;
  o0.w = r0.x;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Original ASM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//
// 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 cPSObject
// {
//
//   struct PSObject
//   {
//       
//       float4x4 m_viewWorld;          // Offset:    0
//       float4x4 m_world;              // Offset:   64
//       float4 m_useWeightCount;       // Offset:  128
//       float4 m_localParam[4];        // Offset:  144
//
//   } g_psObject;                      // Offset:    0 Size:   208
//
// }
//
// 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
// inDepthTexture                    texture  float4          2d   13        1
// cPSSystem                         cbuffer      NA          NA    0        1
// cPSScene                          cbuffer      NA          NA    2        1
// cPSMaterial                       cbuffer      NA          NA    4        1
// cPSObject                         cbuffer      NA          NA    5        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// COLOR                    0   xyzw        0     NONE   float   xyzw
// COLOR                    1   xyzw        1     NONE   float       
// SV_Position              0   xyzw        2      POS   float   xy  
// TEXCOORD                 0   xy          3     NONE   float       
// TEXCOORD                 1   xyz         4     NONE   float       
// TEXCOORD                 2   xyz         5     NONE   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[23], immediateIndexed
dcl_constantbuffer cb5[10], immediateIndexed
dcl_constantbuffer cb4[2], immediateIndexed
dcl_constantbuffer cb0[3], immediateIndexed
dcl_sampler s9, mode_default
dcl_resource_texture2d (float,float,float,float) t13
dcl_input_ps linear v0.xyzw
dcl_input_ps_siv linear noperspective v2.xy, position
dcl_output o0.xyzw
dcl_temps 4
add r0.xyzw, v2.xyxy, l(-0.500000, -0.500000, -0.003906, -0.003906)
mul r1.xy, r0.zwzz, cb5[9].zwzz
div r1.zw, cb0[1].xxxy, cb2[22].xxxy
div r2.xy, cb2[22].xyxx, cb0[2].xyxx
mul r0.xy, r0.xyxx, l(0.500000, 0.500000, 0.000000, 0.000000)
div r2.zw, l(0.000000, 0.000000, 0.500000, 0.500000), r1.zzzw
mul r3.xy, r0.xyxx, r2.zwzz
round_ni r3.xy, r3.xyxx
mad r0.xy, r0.xyxx, r2.zwzz, -r3.xyxx
add r0.xy, r0.xyxx, l(-0.500000, -0.500000, 0.000000, 0.000000)
mad r0.xy, -|r0.xyxx|, l(2.000000, 2.000000, 0.000000, 0.000000), l(1.000000, 1.000000, 0.000000, 0.000000)
mul r0.x, r0.y, r0.x
mul r1.xy, r1.xyxx, r2.xyxx
mul r1.xy, r1.zwzz, r1.xyxx
sample_l_indexable(texture2d)(float,float,float,float) r0.y, r1.xyxx, t13.yxzw, s9, l(0.000000)
add r0.y, r0.y, -cb2[21].w
div r0.y, cb2[21].z, r0.y
mad r0.zw, r0.zzzw, cb5[9].zzzw, -cb4[0].xxxy
mul r0.zw, r0.zzzw, cb4[1].xxxy
add r1.xy, r0.zwzz, r0.zwzz
add r1.z, r0.y, -cb4[0].z
dp3 r0.y, r1.xyzx, r1.xyzx
sqrt r0.y, r0.y
lt r0.z, l(1.300000), r0.y
if_nz r0.z
  add r0.z, -r0.y, l(1.500000)
  mul_sat r0.z, r0.z, l(5.000000)
  mul r0.z, r0.z, r0.x
else 
  mul r0.x, r0.x, r0.y
  mul r0.z, r0.x, l(0.769231)
endif 
mul r0.x, r0.z, r0.z
mul r0.x, r0.x, l(1.500000)
min r0.x, r0.x, l(1.000000)
mul r0.x, r0.x, v0.w
mul o0.xyz, r0.xxxx, v0.xyzx
mov o0.w, r0.x
ret 
// Approximately 39 instruction slots used

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