//Lens flares VS 1.
// ---- Created with 3Dmigoto v1.3.14 on Thu Feb 07 20:04:37 2019

cbuffer SceneInfo : register(b0)
{
  row_major float4x4 viewProjMat : packoffset(c0);
  row_major float3x4 transposeViewMat : packoffset(c4);
  row_major float3x4 transposeViewInvMat : packoffset(c7);
  float4 projElement[2] : packoffset(c10);
  float4 projInvElements[2] : packoffset(c12);
  row_major float4x4 viewProjInvMat : packoffset(c14);
  row_major float4x4 prevViewProjMat : packoffset(c18);
  float3 ZToLinear : packoffset(c22);
  float subdivisionLevel : packoffset(c22.w);
  float2 screenSize : packoffset(c23);
  float2 screenInverseSize : packoffset(c23.z);
  float2 cullingHelper : packoffset(c24);
  float cameraNearPlane : packoffset(c24.z);
  float cameraFarPlane : packoffset(c24.w);
  float4 viewFrustum[6] : packoffset(c25);
  float4 clipplane : packoffset(c31);
}

cbuffer RenderTargetConstant : register(b1)
{
  float2 cbRtexSize : packoffset(c0);
  float cbIsRtex : packoffset(c0.z);
  float cbIsAlphaGamma : packoffset(c0.w);
}

cbuffer LensflareConstnat : register(b2)
{
  float cbLensflareDistance : packoffset(c0);
  float cbLensflareIntensityOffset : packoffset(c0.y);
  float cbLensflareScaleOffset : packoffset(c0.z);
  float cbLensflareBorderWidth : packoffset(c0.w);
  float2 cbLensflareOffset : packoffset(c1);
  float cbLensflareBorderOffset : packoffset(c1.z);
  float cbLensflareAspectRatio : packoffset(c1.w);
  uint cbLensflareOccludeSampleCount : packoffset(c2);
  float cbLensflareOccludeSampleRadius : packoffset(c2.y);
  float cbLensflareFadeStart : packoffset(c2.z);
  float cbLensflareFadeEnd : packoffset(c2.w);
  float2 cbLensflareRotationOffset : packoffset(c3);
  float cbLensflareTranslationVertical : packoffset(c3.z);
  float cbLensflareTranslationHorizontal : packoffset(c3.w);
  float4 cbLensflareGlobalColor : packoffset(c4);
  float3 cbLensflareFadeConeDir : packoffset(c5);
  float cbLensflareGlobalIntensity : packoffset(c5.w);
  float cbLensflareFadeConeAngle : packoffset(c6);
  float cbLensflareFadeSpreadAngle : packoffset(c6.y);
  float cbLensflareFadeNearStart : packoffset(c6.z);
  float cbLensflareFadeNearEnd : packoffset(c6.w);
  float cbLensflareFadeFarStart : packoffset(c7);
  float cbLensflareFadeFarEnd : packoffset(c7.y);
  float cbLensflareFadeByAlphaRate : packoffset(c7.z);
  float cbLensflareResolutionScale : packoffset(c7.w);
  uint cbLensflareFlags : packoffset(c8);
  float cbLensflareInterleaveScale : packoffset(c8.y);
  float cbLensflareReserve0 : packoffset(c8.z);
  float cbLensflareReserve1 : packoffset(c8.w);
}

SamplerComparisonState LinearCompare_s : register(s0);
Texture2D<float4> LensflareDepthTexture : register(t0);


// 3Dmigoto declarations
#define cmp -
Texture1D<float4> IniParams : register(t120);
Texture2D<float4> StereoParams : register(t125);
// Depth buffer copied to this input with 3Dmigoto:
// Texture2D<float> DepthBuffer : register(t110);
Texture2D<float> DepthBuffer : register(t110);



static const float near = 0.0001;
static const float far = 1;

float world_z_from_depth_buffer(float x, float y)
{
    uint width, height;
    float z;

    DepthBuffer.GetDimensions(width, height);

    x = min(max((x / 2 + 0.5) * width, 0), width - 1);
    y = min(max((-y / 2 + 0.5) * height, 0), height - 1);
    z = DepthBuffer.Load(int3(x, y, 0)).x;
    if (z == 1)
        return 0;

  return (far*near/((z)*near) + (far*z));
}

float adjust_from_depth_buffer(float x, float y)
{
    float4 stereo = StereoParams.Load(0);
	if (stereo.x==0) {return 0;}
    float separation = stereo.x; float convergence = stereo.y;
    float old_offset, offset, w, sampled_w, distance;
    uint i;

    // Stereo cursor: To improve the accuracy of the stereo cursor, we
    // sample a number of points on the depth buffer, starting at the near
    // clipping plane and working towards original x + separation.
    //
    // You can think of this as a line in three dimensional space that
    // starts at each eye and stretches out towards infinity. We sample 255
    // points along this line (evenly spaced in the X axis) and compare
    // with the depth buffer to find where the line is first intersected.
    //
    // Note: The reason for sampling 255 points came from a restriction in
    // DX9/SM3 where loops had to run a constant number of iterations and
    // there was no way to set that number from within the shader itself.
    // I'm not sure if the same restriction applies in DX11 with SM4/5 - if
    // it doesn't, we could change this to check each pixel instead for
    // better accuracy.
    //
    // Based on DarkStarSword's stereo crosshair code originally developed
    // for Miasmata, adapted to Unity, then translated to HLSL.

    offset = (near - convergence) * separation; // Z = X offset from center
    distance = separation - offset;         // Total distance to cover (separation - starting X offset)

    old_offset = offset;
    for (i = 0; i < 500; i++) {
        offset += distance / 500.0;

        // Calculate depth for this point on the line:
        w = (separation * convergence*25) / (separation - offset);

        sampled_w = world_z_from_depth_buffer(x + offset, y);
        if (sampled_w == 0)
            return separation;

        // If the sampled depth is closer than the calculated depth,
        // we have found something that intersects the line, so exit
        // the loop and return the last point that was not intersected:
        if (w > sampled_w)
            break;

        old_offset = offset;
    }

    return old_offset;
}

void main(
  float4 v0 : POSITION0,
  float4 v1 : COLOR0,
  float2 v2 : TEXCOORD0,
  float4 v3 : GENERIC0,
  float4 v4 : GENERIC1,
  out float4 o0 : SV_Position0,
  out float4 o1 : Color0,
  out float2 o2 : Texcoord0)
{
  float4 r0,r1,r2,r3,r4,r5,r6,r7,r10,r11,r20,r21,r22;
  uint4 bitmask, uiDest;
  float4 fDest;

  float4 stereo = StereoParams.Load(0);
  float4 iniparams = IniParams.Load(0);
  float4 iniparams1 = IniParams.Load(int2(1,0));
  float4 iniparams3 = IniParams.Load(int2(3,0));
  
  r11=v0;
  
  //r10.xyzw = viewProjMat._m10_m11_m12_m13 * v0.yyyy;
  //r10.xyzw = v0.xxxx * viewProjMat._m00_m01_m02_m03 + r10.xyzw;
  //r10.xyzw = v0.zzzz * viewProjMat._m20_m21_m22_m23 + r10.xyzw;
  //r10.xyzw = viewProjMat._m30_m31_m32_m33 + r10.xyzw;
  
  //r11.x+=stereo.x*(r10.w-stereo.y)/viewProjMat._m00;
  //r10.x=stereo.x*(r10.w-stereo.y);
  
  r0.xyzw = viewProjMat._m10_m11_m12_m13 * v0.yyyy;
  r0.xyzw = r11.xxxx * viewProjMat._m00_m01_m02_m03 + r0.xyzw;
  r0.xyzw = v0.zzzz * viewProjMat._m20_m21_m22_m23 + r0.xyzw;
  r0.xyzw = viewProjMat._m30_m31_m32_m33 + r0.xyzw;
  r0.x+=stereo.x*(r0.w-stereo.y);
  
  r21.x=r0.w;
  
  r1.xyzw = asint(cbLensflareFlags) & int4(4,8,16,32);
  r2.xyzw = r1.xyzw ? float4(1,1,1,1) : float4(0,0,0,0);
  r2.xy = (int2)r2.yw | (int2)r2.xz;
  if (r2.x != 0) {
    r2.x = cmp(r0.w < 0);
    if (r2.x != 0) {
      r2.z = 0;
    }
    if (r2.x == 0) {
      r3.xyz = r0.zxy / r0.www;
      r0.z = max(0, r3.x);
      r2.x = min(16, asuint(cbLensflareOccludeSampleCount));
      r2.w = (uint)r2.x;
      r4.x = 6.28318548 / r2.w;
      r4.zw = projElement[0].xy / r0.ww;
      r2.w = cbRtexSize.x / cbLensflareInterleaveScale;
      r2.w = r2.w / cbRtexSize.y;
      if (r2.x != 0) {
        r5.x = cbLensflareOccludeSampleRadius * r4.z + r3.y;
        if (r1.y != 0) {
          r3.x = rcp(r2.w);
          r5.y = r3.z * r3.x;
          r5.y = dot(r5.xy, r5.xy);
          r5.z = r2.w * r2.w + 1;
          r5.yz = sqrt(r5.yz);
          r3.x = r5.z * r3.x;
          r5.z = cbLensflareFadeStart * r3.x;
          r5.w = cmp(r5.z < r5.y);
          if (r5.w != 0) {
            r5.z = r3.x * cbLensflareFadeEnd + -r5.z;
            r5.w = cmp(0 < r5.z);
            r3.x = -r3.x * cbLensflareFadeStart + r5.y;
            r3.x = r3.x / r5.z;
            r3.x = min(1, r3.x);
            r3.x = r5.w ? r3.x : 1;
          } else {
            r3.x = 0;
          }
          r5.y = cmp(1 < abs(r5.x));
          r5.z = cmp(1 < abs(r3.z));
          r5.y = (int)r5.z | (int)r5.y;
          if (r5.y != 0) {
            r4.y = r3.x;
          }
        } else {
          if (r1.x != 0) {
            r5.z = cmp(1 < abs(r5.x));
            r5.w = cmp(1 < abs(r3.z));
            r5.y = (int)r5.w | (int)r5.z;
            if (r5.y != 0) {
              r4.y = 1;
            }
          } else {
            r5.y = 0;
          }
          r3.x = 0;
        }
        if (r5.y == 0) {
          if (r1.x != 0) {
            r5.x = 1 + r5.x;
            r5.z = -1 + r3.z;
            r5.xy = float2(0.5,-0.5) * r5.xz;
            r5.x = LensflareDepthTexture.SampleCmpLevelZero(LinearCompare_s, r5.xy, r0.z).x;
          } else {
            r5.x = 0;
          }
          r3.x = r5.x + r3.x;
          r4.y = min(1, r3.x);
        }
        r5.xy = r4.xy;
        r3.x = 1;
      } else {
        r5.xy = float2(0,0);
        r3.x = 0;
      }
      r4.y = cmp((uint)r3.x < (uint)r2.x);
      if (r4.y != 0) {
        sincos(r5.x, r6.x, r7.x);
        r5.z = cbLensflareOccludeSampleRadius * r7.x;
        r5.w = cbLensflareOccludeSampleRadius * r6.x;
        r6.x = r5.z * r4.z + r3.y;
        r5.z = r5.w * r4.w + r3.z;
        if (r1.y != 0) {
          r5.w = rcp(r2.w);
          r6.y = r5.z * r5.w;
          r6.y = dot(r6.xy, r6.xy);
          r6.z = r2.w * r2.w + 1;
          r6.yz = sqrt(r6.yz);
          r5.w = r6.z * r5.w;
          r6.z = cbLensflareFadeStart * r5.w;
          r6.w = cmp(r6.z < r6.y);
          if (r6.w != 0) {
            r6.z = r5.w * cbLensflareFadeEnd + -r6.z;
            r6.w = cmp(0 < r6.z);
            r5.w = -r5.w * cbLensflareFadeStart + r6.y;
            r5.w = r5.w / r6.z;
            r5.w = min(1, r5.w);
            r5.w = r6.w ? r5.w : 1;
          } else {
            r5.w = 0;
          }
          r6.y = cmp(1 < abs(r6.x));
          r6.z = cmp(1 < abs(r5.z));
          r6.y = (int)r6.z | (int)r6.y;
          if (r6.y != 0) {
            r6.z = r5.w;
          }
        } else {
          if (r1.x != 0) {
            r6.w = cmp(1 < abs(r6.x));
            r7.x = cmp(1 < abs(r5.z));
            r6.y = (int)r6.w | (int)r7.x;
            if (r6.y != 0) {
              r6.z = 1;
            }
          } else {
            r6.y = 0;
          }
          r5.w = 0;
        }
        if (r6.y == 0) {
          if (r1.x != 0) {
            r6.x = 1 + r6.x;
            r6.x = 0.5 * r6.x;
            r5.z = -1 + r5.z;
            r6.y = -0.5 * r5.z;
            r5.z = LensflareDepthTexture.SampleCmpLevelZero(LinearCompare_s, r6.xy, r0.z).x;
          } else {
            r5.z = 0;
          }
          r5.z = r5.z + r5.w;
          r6.z = min(1, r5.z);
        }
        r5.y = r6.z + r5.y;
        r5.x = r5.x + r4.x;
        r3.x = 2;
      }
      r5.z = cmp((uint)r3.x < (uint)r2.x);
      r4.y = r4.y ? r5.z : 0;
      if (r4.y != 0) {
        sincos(r5.x, r6.x, r7.x);
        r5.z = cbLensflareOccludeSampleRadius * r7.x;
        r5.w = cbLensflareOccludeSampleRadius * r6.x;
        r6.x = r5.z * r4.z + r3.y;
        r5.z = r5.w * r4.w + r3.z;
        if (r1.y != 0) {
          r5.w = rcp(r2.w);
          r6.y = r5.z * r5.w;
          r6.y = dot(r6.xy, r6.xy);
          r6.z = r2.w * r2.w + 1;
          r6.yz = sqrt(r6.yz);
          r5.w = r6.z * r5.w;
          r6.z = cbLensflareFadeStart * r5.w;
          r6.w = cmp(r6.z < r6.y);
          if (r6.w != 0) {
            r6.z = r5.w * cbLensflareFadeEnd + -r6.z;
            r6.w = cmp(0 < r6.z);
            r5.w = -r5.w * cbLensflareFadeStart + r6.y;
            r5.w = r5.w / r6.z;
            r5.w = min(1, r5.w);
            r5.w = r6.w ? r5.w : 1;
          } else {
            r5.w = 0;
          }
          r6.y = cmp(1 < abs(r6.x));
          r6.z = cmp(1 < abs(r5.z));
          r6.y = (int)r6.z | (int)r6.y;
          if (r6.y != 0) {
            r6.z = r5.w;
          }
        } else {
          if (r1.x != 0) {
            r6.w = cmp(1 < abs(r6.x));
            r7.x = cmp(1 < abs(r5.z));
            r6.y = (int)r6.w | (int)r7.x;
            if (r6.y != 0) {
              r6.z = 1;
            }
          } else {
            r6.y = 0;
          }
          r5.w = 0;
        }
        if (r6.y == 0) {
          if (r1.x != 0) {
            r6.x = 1 + r6.x;
            r6.x = 0.5 * r6.x;
            r5.z = -1 + r5.z;
            r6.y = -0.5 * r5.z;
            r5.z = LensflareDepthTexture.SampleCmpLevelZero(LinearCompare_s, r6.xy, r0.z).x;
          } else {
            r5.z = 0;
          }
          r5.z = r5.z + r5.w;
          r6.z = min(1, r5.z);
        }
        r5.y = r6.z + r5.y;
        r5.x = r5.x + r4.x;
        r3.x = 3;
      }
      r5.z = cmp((uint)r3.x < (uint)r2.x);
      r4.y = r4.y ? r5.z : 0;
      if (r4.y != 0) {
        sincos(r5.x, r6.x, r7.x);
        r5.z = cbLensflareOccludeSampleRadius * r7.x;
        r5.w = cbLensflareOccludeSampleRadius * r6.x;
        r6.x = r5.z * r4.z + r3.y;
        r5.z = r5.w * r4.w + r3.z;
        if (r1.y != 0) {
          r5.w = rcp(r2.w);
          r6.y = r5.z * r5.w;
          r6.y = dot(r6.xy, r6.xy);
          r6.z = r2.w * r2.w + 1;
          r6.yz = sqrt(r6.yz);
          r5.w = r6.z * r5.w;
          r6.z = cbLensflareFadeStart * r5.w;
          r6.w = cmp(r6.z < r6.y);
          if (r6.w != 0) {
            r6.z = r5.w * cbLensflareFadeEnd + -r6.z;
            r6.w = cmp(0 < r6.z);
            r5.w = -r5.w * cbLensflareFadeStart + r6.y;
            r5.w = r5.w / r6.z;
            r5.w = min(1, r5.w);
            r5.w = r6.w ? r5.w : 1;
          } else {
            r5.w = 0;
          }
          r6.y = cmp(1 < abs(r6.x));
          r6.z = cmp(1 < abs(r5.z));
          r6.y = (int)r6.z | (int)r6.y;
          if (r6.y != 0) {
            r6.z = r5.w;
          }
        } else {
          if (r1.x != 0) {
            r6.w = cmp(1 < abs(r6.x));
            r7.x = cmp(1 < abs(r5.z));
            r6.y = (int)r6.w | (int)r7.x;
            if (r6.y != 0) {
              r6.z = 1;
            }
          } else {
            r6.y = 0;
          }
          r5.w = 0;
        }
        if (r6.y == 0) {
          if (r1.x != 0) {
            r6.x = 1 + r6.x;
            r6.x = 0.5 * r6.x;
            r5.z = -1 + r5.z;
            r6.y = -0.5 * r5.z;
            r5.z = LensflareDepthTexture.SampleCmpLevelZero(LinearCompare_s, r6.xy, r0.z).x;
          } else {
            r5.z = 0;
          }
          r5.z = r5.z + r5.w;
          r6.z = min(1, r5.z);
        }
        r5.y = r6.z + r5.y;
        r5.x = r5.x + r4.x;
        r3.x = 4;
      }
      r5.z = cmp((uint)r3.x < (uint)r2.x);
      r4.y = r4.y ? r5.z : 0;
      if (r4.y != 0) {
        sincos(r5.x, r6.x, r7.x);
        r5.z = cbLensflareOccludeSampleRadius * r7.x;
        r5.w = cbLensflareOccludeSampleRadius * r6.x;
        r6.x = r5.z * r4.z + r3.y;
        r5.z = r5.w * r4.w + r3.z;
        if (r1.y != 0) {
          r5.w = rcp(r2.w);
          r6.y = r5.z * r5.w;
          r6.y = dot(r6.xy, r6.xy);
          r6.z = r2.w * r2.w + 1;
          r6.yz = sqrt(r6.yz);
          r5.w = r6.z * r5.w;
          r6.z = cbLensflareFadeStart * r5.w;
          r6.w = cmp(r6.z < r6.y);
          if (r6.w != 0) {
            r6.z = r5.w * cbLensflareFadeEnd + -r6.z;
            r6.w = cmp(0 < r6.z);
            r5.w = -r5.w * cbLensflareFadeStart + r6.y;
            r5.w = r5.w / r6.z;
            r5.w = min(1, r5.w);
            r5.w = r6.w ? r5.w : 1;
          } else {
            r5.w = 0;
          }
          r6.y = cmp(1 < abs(r6.x));
          r6.z = cmp(1 < abs(r5.z));
          r6.y = (int)r6.z | (int)r6.y;
          if (r6.y != 0) {
            r6.z = r5.w;
          }
        } else {
          if (r1.x != 0) {
            r6.w = cmp(1 < abs(r6.x));
            r7.x = cmp(1 < abs(r5.z));
            r6.y = (int)r6.w | (int)r7.x;
            if (r6.y != 0) {
              r6.z = 1;
            }
          } else {
            r6.y = 0;
          }
          r5.w = 0;
        }
        if (r6.y == 0) {
          if (r1.x != 0) {
            r6.x = 1 + r6.x;
            r6.x = 0.5 * r6.x;
            r5.z = -1 + r5.z;
            r6.y = -0.5 * r5.z;
            r5.z = LensflareDepthTexture.SampleCmpLevelZero(LinearCompare_s, r6.xy, r0.z).x;
          } else {
            r5.z = 0;
          }
          r5.z = r5.z + r5.w;
          r6.z = min(1, r5.z);
        }
        r5.y = r6.z + r5.y;
        r5.x = r5.x + r4.x;
        r3.x = 5;
      }
      r5.z = cmp((uint)r3.x < (uint)r2.x);
      r4.y = r4.y ? r5.z : 0;
      if (r4.y != 0) {
        sincos(r5.x, r6.x, r7.x);
        r5.z = cbLensflareOccludeSampleRadius * r7.x;
        r5.w = cbLensflareOccludeSampleRadius * r6.x;
        r6.x = r5.z * r4.z + r3.y;
        r5.z = r5.w * r4.w + r3.z;
        if (r1.y != 0) {
          r5.w = rcp(r2.w);
          r6.y = r5.z * r5.w;
          r6.y = dot(r6.xy, r6.xy);
          r6.z = r2.w * r2.w + 1;
          r6.yz = sqrt(r6.yz);
          r5.w = r6.z * r5.w;
          r6.z = cbLensflareFadeStart * r5.w;
          r6.w = cmp(r6.z < r6.y);
          if (r6.w != 0) {
            r6.z = r5.w * cbLensflareFadeEnd + -r6.z;
            r6.w = cmp(0 < r6.z);
            r5.w = -r5.w * cbLensflareFadeStart + r6.y;
            r5.w = r5.w / r6.z;
            r5.w = min(1, r5.w);
            r5.w = r6.w ? r5.w : 1;
          } else {
            r5.w = 0;
          }
          r6.y = cmp(1 < abs(r6.x));
          r6.z = cmp(1 < abs(r5.z));
          r6.y = (int)r6.z | (int)r6.y;
          if (r6.y != 0) {
            r6.z = r5.w;
          }
        } else {
          if (r1.x != 0) {
            r6.w = cmp(1 < abs(r6.x));
            r7.x = cmp(1 < abs(r5.z));
            r6.y = (int)r6.w | (int)r7.x;
            if (r6.y != 0) {
              r6.z = 1;
            }
          } else {
            r6.y = 0;
          }
          r5.w = 0;
        }
        if (r6.y == 0) {
          if (r1.x != 0) {
            r6.x = 1 + r6.x;
            r6.x = 0.5 * r6.x;
            r5.z = -1 + r5.z;
            r6.y = -0.5 * r5.z;
            r5.z = LensflareDepthTexture.SampleCmpLevelZero(LinearCompare_s, r6.xy, r0.z).x;
          } else {
            r5.z = 0;
          }
          r5.z = r5.z + r5.w;
          r6.z = min(1, r5.z);
        }
        r5.y = r6.z + r5.y;
        r5.x = r5.x + r4.x;
        r3.x = 6;
      }
      r5.z = cmp((uint)r3.x < (uint)r2.x);
      r4.y = r4.y ? r5.z : 0;
      if (r4.y != 0) {
        sincos(r5.x, r6.x, r7.x);
        r5.z = cbLensflareOccludeSampleRadius * r7.x;
        r5.w = cbLensflareOccludeSampleRadius * r6.x;
        r6.x = r5.z * r4.z + r3.y;
        r5.z = r5.w * r4.w + r3.z;
        if (r1.y != 0) {
          r5.w = rcp(r2.w);
          r6.y = r5.z * r5.w;
          r6.y = dot(r6.xy, r6.xy);
          r6.z = r2.w * r2.w + 1;
          r6.yz = sqrt(r6.yz);
          r5.w = r6.z * r5.w;
          r6.z = cbLensflareFadeStart * r5.w;
          r6.w = cmp(r6.z < r6.y);
          if (r6.w != 0) {
            r6.z = r5.w * cbLensflareFadeEnd + -r6.z;
            r6.w = cmp(0 < r6.z);
            r5.w = -r5.w * cbLensflareFadeStart + r6.y;
            r5.w = r5.w / r6.z;
            r5.w = min(1, r5.w);
            r5.w = r6.w ? r5.w : 1;
          } else {
            r5.w = 0;
          }
          r6.y = cmp(1 < abs(r6.x));
          r6.z = cmp(1 < abs(r5.z));
          r6.y = (int)r6.z | (int)r6.y;
          if (r6.y != 0) {
            r6.z = r5.w;
          }
        } else {
          if (r1.x != 0) {
            r6.w = cmp(1 < abs(r6.x));
            r7.x = cmp(1 < abs(r5.z));
            r6.y = (int)r6.w | (int)r7.x;
            if (r6.y != 0) {
              r6.z = 1;
            }
          } else {
            r6.y = 0;
          }
          r5.w = 0;
        }
        if (r6.y == 0) {
          if (r1.x != 0) {
            r6.x = 1 + r6.x;
            r6.x = 0.5 * r6.x;
            r5.z = -1 + r5.z;
            r6.y = -0.5 * r5.z;
            r5.z = LensflareDepthTexture.SampleCmpLevelZero(LinearCompare_s, r6.xy, r0.z).x;
          } else {
            r5.z = 0;
          }
          r5.z = r5.z + r5.w;
          r6.z = min(1, r5.z);
        }
        r5.y = r6.z + r5.y;
        r5.x = r5.x + r4.x;
        r3.x = 7;
      }
      r5.z = cmp((uint)r3.x < (uint)r2.x);
      r4.y = r4.y ? r5.z : 0;
      if (r4.y != 0) {
        sincos(r5.x, r6.x, r7.x);
        r5.z = cbLensflareOccludeSampleRadius * r7.x;
        r5.w = cbLensflareOccludeSampleRadius * r6.x;
        r6.x = r5.z * r4.z + r3.y;
        r5.z = r5.w * r4.w + r3.z;
        if (r1.y != 0) {
          r5.w = rcp(r2.w);
          r6.y = r5.z * r5.w;
          r6.y = dot(r6.xy, r6.xy);
          r6.z = r2.w * r2.w + 1;
          r6.yz = sqrt(r6.yz);
          r5.w = r6.z * r5.w;
          r6.z = cbLensflareFadeStart * r5.w;
          r6.w = cmp(r6.z < r6.y);
          if (r6.w != 0) {
            r6.z = r5.w * cbLensflareFadeEnd + -r6.z;
            r6.w = cmp(0 < r6.z);
            r5.w = -r5.w * cbLensflareFadeStart + r6.y;
            r5.w = r5.w / r6.z;
            r5.w = min(1, r5.w);
            r5.w = r6.w ? r5.w : 1;
          } else {
            r5.w = 0;
          }
          r6.y = cmp(1 < abs(r6.x));
          r6.z = cmp(1 < abs(r5.z));
          r6.y = (int)r6.z | (int)r6.y;
          if (r6.y != 0) {
            r6.z = r5.w;
          }
        } else {
          if (r1.x != 0) {
            r6.w = cmp(1 < abs(r6.x));
            r7.x = cmp(1 < abs(r5.z));
            r6.y = (int)r6.w | (int)r7.x;
            if (r6.y != 0) {
              r6.z = 1;
            }
          } else {
            r6.y = 0;
          }
          r5.w = 0;
        }
        if (r6.y == 0) {
          if (r1.x != 0) {
            r6.x = 1 + r6.x;
            r6.x = 0.5 * r6.x;
            r5.z = -1 + r5.z;
            r6.y = -0.5 * r5.z;
            r5.z = LensflareDepthTexture.SampleCmpLevelZero(LinearCompare_s, r6.xy, r0.z).x;
          } else {
            r5.z = 0;
          }
          r5.z = r5.z + r5.w;
          r6.z = min(1, r5.z);
        }
        r5.y = r6.z + r5.y;
        r5.x = r5.x + r4.x;
        r3.x = 8;
      }
      r5.z = cmp((uint)r3.x < (uint)r2.x);
      r4.y = r4.y ? r5.z : 0;
      if (r4.y != 0) {
        sincos(r5.x, r6.x, r7.x);
        r5.z = cbLensflareOccludeSampleRadius * r7.x;
        r5.w = cbLensflareOccludeSampleRadius * r6.x;
        r6.x = r5.z * r4.z + r3.y;
        r5.z = r5.w * r4.w + r3.z;
        if (r1.y != 0) {
          r5.w = rcp(r2.w);
          r6.y = r5.z * r5.w;
          r6.y = dot(r6.xy, r6.xy);
          r6.z = r2.w * r2.w + 1;
          r6.yz = sqrt(r6.yz);
          r5.w = r6.z * r5.w;
          r6.z = cbLensflareFadeStart * r5.w;
          r6.w = cmp(r6.z < r6.y);
          if (r6.w != 0) {
            r6.z = r5.w * cbLensflareFadeEnd + -r6.z;
            r6.w = cmp(0 < r6.z);
            r5.w = -r5.w * cbLensflareFadeStart + r6.y;
            r5.w = r5.w / r6.z;
            r5.w = min(1, r5.w);
            r5.w = r6.w ? r5.w : 1;
          } else {
            r5.w = 0;
          }
          r6.y = cmp(1 < abs(r6.x));
          r6.z = cmp(1 < abs(r5.z));
          r6.y = (int)r6.z | (int)r6.y;
          if (r6.y != 0) {
            r6.z = r5.w;
          }
        } else {
          if (r1.x != 0) {
            r6.w = cmp(1 < abs(r6.x));
            r7.x = cmp(1 < abs(r5.z));
            r6.y = (int)r6.w | (int)r7.x;
            if (r6.y != 0) {
              r6.z = 1;
            }
          } else {
            r6.y = 0;
          }
          r5.w = 0;
        }
        if (r6.y == 0) {
          if (r1.x != 0) {
            r6.x = 1 + r6.x;
            r6.x = 0.5 * r6.x;
            r5.z = -1 + r5.z;
            r6.y = -0.5 * r5.z;
            r5.z = LensflareDepthTexture.SampleCmpLevelZero(LinearCompare_s, r6.xy, r0.z).x;
          } else {
            r5.z = 0;
          }
          r5.z = r5.z + r5.w;
          r6.z = min(1, r5.z);
        }
        r5.y = r6.z + r5.y;
        r5.x = r5.x + r4.x;
        r3.x = 9;
      }
      r5.z = cmp((uint)r3.x < (uint)r2.x);
      r4.y = r4.y ? r5.z : 0;
      if (r4.y != 0) {
        sincos(r5.x, r6.x, r7.x);
        r5.z = cbLensflareOccludeSampleRadius * r7.x;
        r5.w = cbLensflareOccludeSampleRadius * r6.x;
        r6.x = r5.z * r4.z + r3.y;
        r5.z = r5.w * r4.w + r3.z;
        if (r1.y != 0) {
          r5.w = rcp(r2.w);
          r6.y = r5.z * r5.w;
          r6.y = dot(r6.xy, r6.xy);
          r6.z = r2.w * r2.w + 1;
          r6.yz = sqrt(r6.yz);
          r5.w = r6.z * r5.w;
          r6.z = cbLensflareFadeStart * r5.w;
          r6.w = cmp(r6.z < r6.y);
          if (r6.w != 0) {
            r6.z = r5.w * cbLensflareFadeEnd + -r6.z;
            r6.w = cmp(0 < r6.z);
            r5.w = -r5.w * cbLensflareFadeStart + r6.y;
            r5.w = r5.w / r6.z;
            r5.w = min(1, r5.w);
            r5.w = r6.w ? r5.w : 1;
          } else {
            r5.w = 0;
          }
          r6.y = cmp(1 < abs(r6.x));
          r6.z = cmp(1 < abs(r5.z));
          r6.y = (int)r6.z | (int)r6.y;
          if (r6.y != 0) {
            r6.z = r5.w;
          }
        } else {
          if (r1.x != 0) {
            r6.w = cmp(1 < abs(r6.x));
            r7.x = cmp(1 < abs(r5.z));
            r6.y = (int)r6.w | (int)r7.x;
            if (r6.y != 0) {
              r6.z = 1;
            }
          } else {
            r6.y = 0;
          }
          r5.w = 0;
        }
        if (r6.y == 0) {
          if (r1.x != 0) {
            r6.x = 1 + r6.x;
            r6.x = 0.5 * r6.x;
            r5.z = -1 + r5.z;
            r6.y = -0.5 * r5.z;
            r5.z = LensflareDepthTexture.SampleCmpLevelZero(LinearCompare_s, r6.xy, r0.z).x;
          } else {
            r5.z = 0;
          }
          r5.z = r5.z + r5.w;
          r6.z = min(1, r5.z);
        }
        r5.y = r6.z + r5.y;
        r5.x = r5.x + r4.x;
        r3.x = 10;
      }
      r5.z = cmp((uint)r3.x < (uint)r2.x);
      r4.y = r4.y ? r5.z : 0;
      if (r4.y != 0) {
        sincos(r5.x, r6.x, r7.x);
        r5.z = cbLensflareOccludeSampleRadius * r7.x;
        r5.w = cbLensflareOccludeSampleRadius * r6.x;
        r6.x = r5.z * r4.z + r3.y;
        r5.z = r5.w * r4.w + r3.z;
        if (r1.y != 0) {
          r5.w = rcp(r2.w);
          r6.y = r5.z * r5.w;
          r6.y = dot(r6.xy, r6.xy);
          r6.z = r2.w * r2.w + 1;
          r6.yz = sqrt(r6.yz);
          r5.w = r6.z * r5.w;
          r6.z = cbLensflareFadeStart * r5.w;
          r6.w = cmp(r6.z < r6.y);
          if (r6.w != 0) {
            r6.z = r5.w * cbLensflareFadeEnd + -r6.z;
            r6.w = cmp(0 < r6.z);
            r5.w = -r5.w * cbLensflareFadeStart + r6.y;
            r5.w = r5.w / r6.z;
            r5.w = min(1, r5.w);
            r5.w = r6.w ? r5.w : 1;
          } else {
            r5.w = 0;
          }
          r6.y = cmp(1 < abs(r6.x));
          r6.z = cmp(1 < abs(r5.z));
          r6.y = (int)r6.z | (int)r6.y;
          if (r6.y != 0) {
            r6.z = r5.w;
          }
        } else {
          if (r1.x != 0) {
            r6.w = cmp(1 < abs(r6.x));
            r7.x = cmp(1 < abs(r5.z));
            r6.y = (int)r6.w | (int)r7.x;
            if (r6.y != 0) {
              r6.z = 1;
            }
          } else {
            r6.y = 0;
          }
          r5.w = 0;
        }
        if (r6.y == 0) {
          if (r1.x != 0) {
            r6.x = 1 + r6.x;
            r6.x = 0.5 * r6.x;
            r5.z = -1 + r5.z;
            r6.y = -0.5 * r5.z;
            r5.z = LensflareDepthTexture.SampleCmpLevelZero(LinearCompare_s, r6.xy, r0.z).x;
          } else {
            r5.z = 0;
          }
          r5.z = r5.z + r5.w;
          r6.z = min(1, r5.z);
        }
        r5.y = r6.z + r5.y;
        r5.x = r5.x + r4.x;
        r3.x = 11;
      }
      r5.z = cmp((uint)r3.x < (uint)r2.x);
      r4.y = r4.y ? r5.z : 0;
      if (r4.y != 0) {
        sincos(r5.x, r6.x, r7.x);
        r5.z = cbLensflareOccludeSampleRadius * r7.x;
        r5.w = cbLensflareOccludeSampleRadius * r6.x;
        r6.x = r5.z * r4.z + r3.y;
        r5.z = r5.w * r4.w + r3.z;
        if (r1.y != 0) {
          r5.w = rcp(r2.w);
          r6.y = r5.z * r5.w;
          r6.y = dot(r6.xy, r6.xy);
          r6.z = r2.w * r2.w + 1;
          r6.yz = sqrt(r6.yz);
          r5.w = r6.z * r5.w;
          r6.z = cbLensflareFadeStart * r5.w;
          r6.w = cmp(r6.z < r6.y);
          if (r6.w != 0) {
            r6.z = r5.w * cbLensflareFadeEnd + -r6.z;
            r6.w = cmp(0 < r6.z);
            r5.w = -r5.w * cbLensflareFadeStart + r6.y;
            r5.w = r5.w / r6.z;
            r5.w = min(1, r5.w);
            r5.w = r6.w ? r5.w : 1;
          } else {
            r5.w = 0;
          }
          r6.y = cmp(1 < abs(r6.x));
          r6.z = cmp(1 < abs(r5.z));
          r6.y = (int)r6.z | (int)r6.y;
          if (r6.y != 0) {
            r6.z = r5.w;
          }
        } else {
          if (r1.x != 0) {
            r6.w = cmp(1 < abs(r6.x));
            r7.x = cmp(1 < abs(r5.z));
            r6.y = (int)r6.w | (int)r7.x;
            if (r6.y != 0) {
              r6.z = 1;
            }
          } else {
            r6.y = 0;
          }
          r5.w = 0;
        }
        if (r6.y == 0) {
          if (r1.x != 0) {
            r6.x = 1 + r6.x;
            r6.x = 0.5 * r6.x;
            r5.z = -1 + r5.z;
            r6.y = -0.5 * r5.z;
            r5.z = LensflareDepthTexture.SampleCmpLevelZero(LinearCompare_s, r6.xy, r0.z).x;
          } else {
            r5.z = 0;
          }
          r5.z = r5.z + r5.w;
          r6.z = min(1, r5.z);
        }
        r5.y = r6.z + r5.y;
        r5.x = r5.x + r4.x;
        r3.x = 12;
      }
      r5.z = cmp((uint)r3.x < (uint)r2.x);
      r4.y = r4.y ? r5.z : 0;
      if (r4.y != 0) {
        sincos(r5.x, r6.x, r7.x);
        r5.z = cbLensflareOccludeSampleRadius * r7.x;
        r5.w = cbLensflareOccludeSampleRadius * r6.x;
        r6.x = r5.z * r4.z + r3.y;
        r5.z = r5.w * r4.w + r3.z;
        if (r1.y != 0) {
          r5.w = rcp(r2.w);
          r6.y = r5.z * r5.w;
          r6.y = dot(r6.xy, r6.xy);
          r6.z = r2.w * r2.w + 1;
          r6.yz = sqrt(r6.yz);
          r5.w = r6.z * r5.w;
          r6.z = cbLensflareFadeStart * r5.w;
          r6.w = cmp(r6.z < r6.y);
          if (r6.w != 0) {
            r6.z = r5.w * cbLensflareFadeEnd + -r6.z;
            r6.w = cmp(0 < r6.z);
            r5.w = -r5.w * cbLensflareFadeStart + r6.y;
            r5.w = r5.w / r6.z;
            r5.w = min(1, r5.w);
            r5.w = r6.w ? r5.w : 1;
          } else {
            r5.w = 0;
          }
          r6.y = cmp(1 < abs(r6.x));
          r6.z = cmp(1 < abs(r5.z));
          r6.y = (int)r6.z | (int)r6.y;
          if (r6.y != 0) {
            r6.z = r5.w;
          }
        } else {
          if (r1.x != 0) {
            r6.w = cmp(1 < abs(r6.x));
            r7.x = cmp(1 < abs(r5.z));
            r6.y = (int)r6.w | (int)r7.x;
            if (r6.y != 0) {
              r6.z = 1;
            }
          } else {
            r6.y = 0;
          }
          r5.w = 0;
        }
        if (r6.y == 0) {
          if (r1.x != 0) {
            r6.x = 1 + r6.x;
            r6.x = 0.5 * r6.x;
            r5.z = -1 + r5.z;
            r6.y = -0.5 * r5.z;
            r5.z = LensflareDepthTexture.SampleCmpLevelZero(LinearCompare_s, r6.xy, r0.z).x;
          } else {
            r5.z = 0;
          }
          r5.z = r5.z + r5.w;
          r6.z = min(1, r5.z);
        }
        r5.y = r6.z + r5.y;
        r5.x = r5.x + r4.x;
        r3.x = 13;
      }
      r5.z = cmp((uint)r3.x < (uint)r2.x);
      r4.y = r4.y ? r5.z : 0;
      if (r4.y != 0) {
        sincos(r5.x, r6.x, r7.x);
        r5.z = cbLensflareOccludeSampleRadius * r7.x;
        r5.w = cbLensflareOccludeSampleRadius * r6.x;
        r6.x = r5.z * r4.z + r3.y;
        r5.z = r5.w * r4.w + r3.z;
        if (r1.y != 0) {
          r5.w = rcp(r2.w);
          r6.y = r5.z * r5.w;
          r6.y = dot(r6.xy, r6.xy);
          r6.z = r2.w * r2.w + 1;
          r6.yz = sqrt(r6.yz);
          r5.w = r6.z * r5.w;
          r6.z = cbLensflareFadeStart * r5.w;
          r6.w = cmp(r6.z < r6.y);
          if (r6.w != 0) {
            r6.z = r5.w * cbLensflareFadeEnd + -r6.z;
            r6.w = cmp(0 < r6.z);
            r5.w = -r5.w * cbLensflareFadeStart + r6.y;
            r5.w = r5.w / r6.z;
            r5.w = min(1, r5.w);
            r5.w = r6.w ? r5.w : 1;
          } else {
            r5.w = 0;
          }
          r6.y = cmp(1 < abs(r6.x));
          r6.z = cmp(1 < abs(r5.z));
          r6.y = (int)r6.z | (int)r6.y;
          if (r6.y != 0) {
            r6.z = r5.w;
          }
        } else {
          if (r1.x != 0) {
            r6.w = cmp(1 < abs(r6.x));
            r7.x = cmp(1 < abs(r5.z));
            r6.y = (int)r6.w | (int)r7.x;
            if (r6.y != 0) {
              r6.z = 1;
            }
          } else {
            r6.y = 0;
          }
          r5.w = 0;
        }
        if (r6.y == 0) {
          if (r1.x != 0) {
            r6.x = 1 + r6.x;
            r6.x = 0.5 * r6.x;
            r5.z = -1 + r5.z;
            r6.y = -0.5 * r5.z;
            r5.z = LensflareDepthTexture.SampleCmpLevelZero(LinearCompare_s, r6.xy, r0.z).x;
          } else {
            r5.z = 0;
          }
          r5.z = r5.z + r5.w;
          r6.z = min(1, r5.z);
        }
        r5.y = r6.z + r5.y;
        r5.x = r5.x + r4.x;
        r3.x = 14;
      }
      r5.z = cmp((uint)r3.x < (uint)r2.x);
      r4.y = r4.y ? r5.z : 0;
      if (r4.y != 0) {
        sincos(r5.x, r6.x, r7.x);
        r5.z = cbLensflareOccludeSampleRadius * r7.x;
        r5.w = cbLensflareOccludeSampleRadius * r6.x;
        r6.x = r5.z * r4.z + r3.y;
        r5.z = r5.w * r4.w + r3.z;
        if (r1.y != 0) {
          r5.w = rcp(r2.w);
          r6.y = r5.z * r5.w;
          r6.y = dot(r6.xy, r6.xy);
          r6.z = r2.w * r2.w + 1;
          r6.yz = sqrt(r6.yz);
          r5.w = r6.z * r5.w;
          r6.z = cbLensflareFadeStart * r5.w;
          r6.w = cmp(r6.z < r6.y);
          if (r6.w != 0) {
            r6.z = r5.w * cbLensflareFadeEnd + -r6.z;
            r6.w = cmp(0 < r6.z);
            r5.w = -r5.w * cbLensflareFadeStart + r6.y;
            r5.w = r5.w / r6.z;
            r5.w = min(1, r5.w);
            r5.w = r6.w ? r5.w : 1;
          } else {
            r5.w = 0;
          }
          r6.y = cmp(1 < abs(r6.x));
          r6.z = cmp(1 < abs(r5.z));
          r6.y = (int)r6.z | (int)r6.y;
          if (r6.y != 0) {
            r6.z = r5.w;
          }
        } else {
          if (r1.x != 0) {
            r6.w = cmp(1 < abs(r6.x));
            r7.x = cmp(1 < abs(r5.z));
            r6.y = (int)r6.w | (int)r7.x;
            if (r6.y != 0) {
              r6.z = 1;
            }
          } else {
            r6.y = 0;
          }
          r5.w = 0;
        }
        if (r6.y == 0) {
          if (r1.x != 0) {
            r6.x = 1 + r6.x;
            r6.x = 0.5 * r6.x;
            r5.z = -1 + r5.z;
            r6.y = -0.5 * r5.z;
            r5.z = LensflareDepthTexture.SampleCmpLevelZero(LinearCompare_s, r6.xy, r0.z).x;
          } else {
            r5.z = 0;
          }
          r5.z = r5.z + r5.w;
          r6.z = min(1, r5.z);
        }
        r5.y = r6.z + r5.y;
        r5.x = r5.x + r4.x;
        r3.x = 15;
      }
      r3.x = cmp((uint)r3.x < (uint)r2.x);
      r3.x = r3.x ? r4.y : 0;
      if (r3.x != 0) {
        sincos(r5.x, r3.x, r4.x);
        r4.x = cbLensflareOccludeSampleRadius * r4.x;
        r3.x = cbLensflareOccludeSampleRadius * r3.x;
        r4.x = r4.x * r4.z + r3.y;
        r3.x = r3.x * r4.w + r3.z;
        if (r1.y != 0) {
          r4.z = rcp(r2.w);
          r4.y = r4.z * r3.x;
          r4.y = dot(r4.xy, r4.xy);
          r4.w = r2.w * r2.w + 1;
          r4.yw = sqrt(r4.yw);
          r4.z = r4.w * r4.z;
          r4.w = cbLensflareFadeStart * r4.z;
          r5.x = cmp(r4.w < r4.y);
          if (r5.x != 0) {
            r4.w = r4.z * cbLensflareFadeEnd + -r4.w;
            r5.x = cmp(0 < r4.w);
            r4.y = -r4.z * cbLensflareFadeStart + r4.y;
            r4.y = r4.y / r4.w;
            r4.y = min(1, r4.y);
            r4.y = r5.x ? r4.y : 1;
          } else {
            r4.y = 0;
          }
          r4.z = cmp(1 < abs(r4.x));
          r4.w = cmp(1 < abs(r3.x));
          r4.z = (int)r4.w | (int)r4.z;
          if (r4.z != 0) {
            r4.w = r4.y;
          }
        } else {
          if (r1.x != 0) {
            r5.x = cmp(1 < abs(r4.x));
            r5.z = cmp(1 < abs(r3.x));
            r4.z = (int)r5.z | (int)r5.x;
            if (r4.z != 0) {
              r4.w = 1;
            }
          } else {
            r4.z = 0;
          }
          r4.y = 0;
        }
        if (r4.z == 0) {
          if (r1.x != 0) {
            r4.x = 1 + r4.x;
            r6.x = 0.5 * r4.x;
            r3.x = -1 + r3.x;
            r6.y = -0.5 * r3.x;
            r3.x = LensflareDepthTexture.SampleCmpLevelZero(LinearCompare_s, r6.xy, r0.z).x;
          } else {
            r3.x = 0;
          }
          r3.x = r3.x + r4.y;
          r4.w = min(1, r3.x);
        }
        r5.y = r5.y + r4.w;
      }
      if (r1.y != 0) {
        r1.y = rcp(r2.w);
        r3.w = r3.z * r1.y;
        r3.x = dot(r3.yw, r3.yw);
        r3.x = sqrt(r3.x);
        r2.w = r2.w * r2.w + 1;
        r2.w = sqrt(r2.w);
        r1.y = r2.w * r1.y;
        r2.w = cbLensflareFadeStart * r1.y;
        r3.w = cmp(r2.w < r3.x);
        if (r3.w != 0) {
          r2.w = r1.y * cbLensflareFadeEnd + -r2.w;
          r3.w = cmp(0 < r2.w);
          r1.y = -r1.y * cbLensflareFadeStart + r3.x;
          r1.y = r1.y / r2.w;
          r1.y = min(1, r1.y);
          r1.y = r3.w ? r1.y : 1;
        } else {
          r1.y = 0;
        }
        r3.xw = cmp(float2(1,1) < abs(r3.yz));
        r2.w = (int)r3.w | (int)r3.x;
        if (r2.w != 0) {
          r3.x = r1.y;
        }
      } else {
        if (r1.x != 0) {
          r4.xy = cmp(float2(1,1) < abs(r3.yz));
          r2.w = (int)r4.y | (int)r4.x;
          if (r2.w != 0) {
            r3.x = 1;
          }
        } else {
          r2.w = 0;
        }
        r1.y = 0;
      }
      if (r2.w == 0) {
        if (r1.x != 0) {
          r3.yz = float2(1,-1) + r3.yz;
          r3.yz = float2(0.5,-0.5) * r3.yz;
          r0.z = LensflareDepthTexture.SampleCmpLevelZero(LinearCompare_s, r3.yz, r0.z).x;
        } else {
          r0.z = 0;
        }
        r0.z = r0.z + r1.y;
        r3.x = min(1, r0.z);
      }
      r0.z = r5.y + r3.x;
      r1.x = (int)r2.x + 1;
      r1.x = (uint)r1.x;
      r0.z = r0.z / r1.x;
      r2.z = saturate(1 + -r0.z);
    }
  } else {
    r0.z = cmp(0 < r0.w);
    r2.z = r0.z ? 1.000000 : 0;
  }
  if (r1.z != 0) {
    r1.x = transposeViewInvMat._m03;
    r1.y = transposeViewInvMat._m13;
    r1.z = transposeViewInvMat._m23;
    r1.xyz = -v0.xyz + r1.xyz;
    r0.z = dot(r1.xyz, r1.xyz);
    r0.z = rsqrt(r0.z);
    r1.xyz = r1.xyz * r0.zzz;
    r0.z = dot(cbLensflareFadeConeDir.xyz, r1.xyz);
    r1.x = cmp(r0.z >= cbLensflareFadeConeAngle);
    if (r1.x != 0) {
      r1.x = 1;
    } else {
      r1.y = cmp(r0.z >= cbLensflareFadeSpreadAngle);
      if (r1.y != 0) {
        r0.z = -cbLensflareFadeSpreadAngle + r0.z;
        r1.y = cbLensflareFadeConeAngle + -cbLensflareFadeSpreadAngle;
        r1.x = r0.z / r1.y;
      } else {
        r1.x = 0;
      }
    }
  } else {
    r1.x = 1;
  }
  if (r1.w != 0) {
    r3.x = transposeViewInvMat._m03;
    r3.y = transposeViewInvMat._m13;
    r3.z = transposeViewInvMat._m23;
    r1.yzw = v0.xyz + -r3.xyz;
    r0.z = dot(r1.yzw, r1.yzw);
    r0.z = sqrt(r0.z);
    r1.y = cmp(r0.z < cbLensflareFadeNearStart);
    r1.z = cmp(cbLensflareFadeFarEnd < r0.z);
    r1.y = (int)r1.z | (int)r1.y;
    if (r1.y != 0) {
      r1.z = 0;
    }
    if (r1.y == 0) {
      r1.y = cmp(r0.z < cbLensflareFadeNearEnd);
      if (r1.y != 0) {
        r1.y = cbLensflareFadeNearEnd + -cbLensflareFadeNearStart;
        r1.w = cmp(0 < r1.y);
        r1.y = 1 / r1.y;
        r1.y = r1.w ? r1.y : 0;
        r1.w = -cbLensflareFadeNearStart + r0.z;
        r1.z = r1.w * r1.y;
      } else {
        r1.y = cmp(cbLensflareFadeFarStart < r0.z);
        if (r1.y != 0) {
          r1.y = cbLensflareFadeFarEnd + -cbLensflareFadeFarStart;
          r1.w = cmp(0 < r1.y);
          r1.y = 1 / r1.y;
          r1.y = r1.w ? r1.y : 0;
          r0.z = -cbLensflareFadeFarStart + r0.z;
          r0.z = r0.z * r1.y;
          r0.z = max(0, r0.z);
          r1.z = 1 + -r0.z;
        } else {
          r1.z = 1;
        }
      }
    }
    r1.x = r1.x * r1.z;
  }
  if (r2.y != 0) {
    r1.x = max(cbLensflareFadeByAlphaRate, r1.x);
  }
  r3.xyzw = float4(0.5,0.5,0.25,0.25) * cbRtexSize.xyxy;
  
  r20.xyzw=r0.xyzw;
  r20.x-=stereo.x*(r20.w-stereo.y);
  r0.x-=stereo.x*(r20.w-stereo.y);
  r20.x = r20.x / r20.w;
  r22.x = r20.x * r3.x;
  r20.x = -r20.y / r20.w;
  r22.y = r20.x * r3.y;
  
  r0.x = r0.x / r0.w;
  r2.x = r0.x * r3.x;
  r0.x = -r0.y / r0.w;
  r2.y = r0.x * r3.y;
  r0.xy = -r22.xy * cbLensflareDistance + r2.xy;
  r4.x = 1 / cbLensflareInterleaveScale;
  r4.yw = float2(1,1);
  r0.zw = r4.xy * r0.xy;
  r20.zw = r4.xy * r20.xy;
  r1.y = asint(cbLensflareFlags) & 3;
  r1.z = cmp((int)r1.y == 1);
  if (r1.z != 0) {
    r1.z = r2.x * r4.x + -r0.z;
    r1.w = r2.y * r4.y + r0.w;
    r2.x = min(abs(r1.z), abs(r1.w));
    r2.y = max(abs(r1.z), abs(r1.w));
    r2.y = 1 / r2.y;
    r2.x = r2.x * r2.y;
    r2.y = r2.x * r2.x;
    r2.w = r2.y * 0.0208350997 + -0.0851330012;
    r2.w = r2.y * r2.w + 0.180141002;
    r2.w = r2.y * r2.w + -0.330299497;
    r2.y = r2.y * r2.w + 0.999866009;
    r2.w = r2.x * r2.y;
    r4.x = cmp(abs(r1.w) < abs(r1.z));
    r2.w = r2.w * -2 + 1.57079637;
    r2.w = r4.x ? r2.w : 0;
    r2.x = r2.x * r2.y + r2.w;
    r2.y = cmp(r1.w < -r1.w);
    r2.y = r2.y ? -3.141593 : 0;
    r2.x = r2.x + r2.y;
    r2.y = min(r1.z, r1.w);
    r1.z = max(r1.z, r1.w);
    r1.w = cmp(r2.y < -r2.y);
    r1.z = cmp(r1.z >= -r1.z);
    r1.z = r1.z ? r1.w : 0;
    r1.z = r1.z ? -r2.x : r2.x;
    r1.z = v3.z + r1.z;
  } else {
    r1.y = cmp((int)r1.y == 2);
    if (r1.y != 0) {
      r1.y = min(abs(r0.z), abs(r0.w));
      r1.w = max(abs(r0.z), abs(r0.w));
      r1.w = 1 / r1.w;
      r1.y = r1.y * r1.w;
      r1.w = r1.y * r1.y;
      r2.x = r1.w * 0.0208350997 + -0.0851330012;
      r2.x = r1.w * r2.x + 0.180141002;
      r2.x = r1.w * r2.x + -0.330299497;
      r1.w = r1.w * r2.x + 0.999866009;
      r2.x = r1.y * r1.w;
      r2.y = cmp(abs(r0.w) < abs(r0.z));
      r2.x = r2.x * -2 + 1.57079637;
      r2.x = r2.y ? r2.x : 0;
      r1.y = r1.y * r1.w + r2.x;
      r1.w = cmp(r0.w < -r0.w);
      r1.w = r1.w ? -3.141593 : 0;
      r1.y = r1.y + r1.w;
      r1.w = min(r0.z, r0.w);
      r0.z = max(r0.z, r0.w);
      r0.w = cmp(r1.w < -r1.w);
      r0.z = cmp(r0.z >= -r0.z);
      r0.z = r0.z ? r0.w : 0;
      r0.z = r0.z ? -r1.y : r1.y;
      r1.z = v3.z + -r0.z;
    } else {
      r1.z = v3.z;
    }
  }
  r0.zw = cbRtexSize.xy * cbLensflareBorderWidth + r3.zw;
  r1.yw = cbRtexSize.xy * cbLensflareBorderOffset + r3.xy;
  r1.yw = -r1.yw + abs(r0.xy);
  r1.yw = r1.yw + r0.zw;
  r1.yw = max(float2(0,0), r1.yw);
  r0.zw = r1.yw / r0.zw;
  r0.z = max(r0.z, r0.w);
  r0.w = cmp(1 < r0.z);
  r1.y = 2 + -r0.z;
  r0.z = r0.w ? r1.y : r0.z;
  r0.z = max(0, r0.z);
  r2.xyw = cbLensflareScaleOffset * v3.xyw;
  r2.xyw = r2.xyw * r0.zzz + v3.xyw;
  r0.z = max(0, r2.w);
  r1.yw = cbLensflareResolutionScale * r2.xy;
  sincos(r1.z, r2.x, r3.x);
  r2.yw = r3.xx * r1.yw;
  r4.x = -r2.x * r1.w + r2.y;
  r4.y = r2.x * r1.y + r2.w;
  r2.yw = cbLensflareRotationOffset.xy * r3.xx;
  r2.yw = r2.yw * abs(r1.yw);
  r0.w = cbLensflareRotationOffset.y * -r2.x;
  r5.x = r0.w * abs(r1.w) + r2.y;
  r0.w = cbLensflareRotationOffset.x * r2.x;
  r5.y = r0.w * abs(r1.y) + r2.w;
  r2.yw = r5.xy + r4.xy;
  r2.yw = cbLensflareOffset.xy * cbLensflareResolutionScale + r2.yw;
  r4.z = cbLensflareInterleaveScale;
  r0.xy = r2.yw * r4.zw + r0.xy;
  r0.xy = r0.xy / cbRtexSize.xy;
  r0.y = -2 * r0.y;
  r0.w = -1 + cbLensflareAspectRatio;
  r1.z = -r2.x * abs(r1.w);
  r1.y = r3.x * abs(r1.y) + r1.z;
  r1.y = r4.x + r1.y;
  r0.w = r1.y * r0.w;
  r0.w = r0.w / cbRtexSize.x;
  r0.w = dot(r0.ww, cbLensflareInterleaveScale);
  o0.x = r0.x * 2 + r0.w;
  r0.x = r2.z * r1.x;
  o1.xyzw = v1.xyzw * r0.zzzx;
  o0.y = r0.y;
  o0.zw = float2(0,1);
  o2.xy = v2.xy;
  if (o0.z==0)
  {
	//o0.x+=adjust_from_depth_buffer(o0.x,o0.y);
  }
  //o0.x+=stereo.x*(1-stereo.y*r10.z*r10.w*5);
  o0.x+=stereo.x*(1-stereo.y/r21.x);
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 10.1
//
//   using 3Dmigoto v1.3.14 on Thu Feb 07 20:04:37 2019
//
//
// Buffer Definitions:
//
// cbuffer SceneInfo
// {
//
//   row_major float4x4 viewProjMat;    // Offset:    0 Size:    64
//   row_major float3x4 transposeViewMat;// Offset:   64 Size:    48 [unused]
//   row_major float3x4 transposeViewInvMat;// Offset:  112 Size:    48
//   float4 projElement[2];             // Offset:  160 Size:    32
//   float4 projInvElements[2];         // Offset:  192 Size:    32 [unused]
//   row_major float4x4 viewProjInvMat; // Offset:  224 Size:    64 [unused]
//   row_major float4x4 prevViewProjMat;// Offset:  288 Size:    64 [unused]
//   float3 ZToLinear;                  // Offset:  352 Size:    12 [unused]
//   float subdivisionLevel;            // Offset:  364 Size:     4 [unused]
//   float2 screenSize;                 // Offset:  368 Size:     8 [unused]
//   float2 screenInverseSize;          // Offset:  376 Size:     8 [unused]
//   float2 cullingHelper;              // Offset:  384 Size:     8 [unused]
//   float cameraNearPlane;             // Offset:  392 Size:     4 [unused]
//   float cameraFarPlane;              // Offset:  396 Size:     4 [unused]
//   float4 viewFrustum[6];             // Offset:  400 Size:    96 [unused]
//   float4 clipplane;                  // Offset:  496 Size:    16 [unused]
//
// }
//
// cbuffer RenderTargetConstant
// {
//
//   float2 cbRtexSize;                 // Offset:    0 Size:     8
//   float cbIsRtex;                    // Offset:    8 Size:     4 [unused]
//   float cbIsAlphaGamma;              // Offset:   12 Size:     4 [unused]
//
// }
//
// cbuffer LensflareConstnat
// {
//
//   float cbLensflareDistance;         // Offset:    0 Size:     4
//   float cbLensflareIntensityOffset;  // Offset:    4 Size:     4
//   float cbLensflareScaleOffset;      // Offset:    8 Size:     4
//   float cbLensflareBorderWidth;      // Offset:   12 Size:     4
//   float2 cbLensflareOffset;          // Offset:   16 Size:     8
//   float cbLensflareBorderOffset;     // Offset:   24 Size:     4
//   float cbLensflareAspectRatio;      // Offset:   28 Size:     4
//   uint cbLensflareOccludeSampleCount;// Offset:   32 Size:     4
//   float cbLensflareOccludeSampleRadius;// Offset:   36 Size:     4
//   float cbLensflareFadeStart;        // Offset:   40 Size:     4
//   float cbLensflareFadeEnd;          // Offset:   44 Size:     4
//   float2 cbLensflareRotationOffset;  // Offset:   48 Size:     8
//   float cbLensflareTranslationVertical;// Offset:   56 Size:     4 [unused]
//   float cbLensflareTranslationHorizontal;// Offset:   60 Size:     4 [unused]
//   float4 cbLensflareGlobalColor;     // Offset:   64 Size:    16 [unused]
//   float3 cbLensflareFadeConeDir;     // Offset:   80 Size:    12
//   float cbLensflareGlobalIntensity;  // Offset:   92 Size:     4 [unused]
//   float cbLensflareFadeConeAngle;    // Offset:   96 Size:     4
//   float cbLensflareFadeSpreadAngle;  // Offset:  100 Size:     4
//   float cbLensflareFadeNearStart;    // Offset:  104 Size:     4
//   float cbLensflareFadeNearEnd;      // Offset:  108 Size:     4
//   float cbLensflareFadeFarStart;     // Offset:  112 Size:     4
//   float cbLensflareFadeFarEnd;       // Offset:  116 Size:     4
//   float cbLensflareFadeByAlphaRate;  // Offset:  120 Size:     4
//   float cbLensflareResolutionScale;  // Offset:  124 Size:     4
//   uint cbLensflareFlags;             // Offset:  128 Size:     4
//   float cbLensflareInterleaveScale;  // Offset:  132 Size:     4
//   float cbLensflareReserve0;         // Offset:  136 Size:     4 [unused]
//   float cbLensflareReserve1;         // Offset:  140 Size:     4 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// LinearCompare                   sampler_c      NA          NA    0        1
// LensflareDepthTexture             texture  float4          2d    0        1
// SceneInfo                         cbuffer      NA          NA    0        1
// RenderTargetConstant              cbuffer      NA          NA    1        1
// LensflareConstnat                 cbuffer      NA          NA    2        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// POSITION                 0   xyzw        0     NONE   float   xyz
// COLOR                    0   xyzw        1     NONE   float   xyzw
// TEXCOORD                 0   xy          2     NONE   float   xy
// GENERIC                  0   xyzw        3     NONE   float   xyzw
// GENERIC                  1   xyzw        4     NONE   float
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float   xyzw
// Color                    0   xyzw        1     NONE   float   xyzw
// Texcoord                 0   xy          2     NONE   float   xy
//
vs_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[11], immediateIndexed
dcl_constantbuffer cb1[1], immediateIndexed
dcl_constantbuffer cb2[9], immediateIndexed
dcl_sampler s0, mode_comparison
dcl_resource_texture2d (float,float,float,float) t0
dcl_input v0.xyz
dcl_input v1.xyzw
dcl_input v2.xy
dcl_input v3.xyzw
dcl_output_siv o0.xyzw, position
dcl_output o1.xyzw
dcl_output o2.xy
dcl_temps 8
mul r0.xyzw, v0.yyyy, cb0[1].xyzw
mad r0.xyzw, v0.xxxx, cb0[0].xyzw, r0.xyzw
mad r0.xyzw, v0.zzzz, cb0[2].xyzw, r0.xyzw
add r0.xyzw, r0.xyzw, cb0[3].xyzw
and r1.xyzw, cb2[8].xxxx, l(4, 8, 16, 32)
movc r2.xyzw, r1.xyzw, l(1,1,1,1), l(0,0,0,0)
or r2.xy, r2.ywyy, r2.xzxx
if_nz r2.x
  lt r2.x, r0.w, l(0.000000)
  if_nz r2.x
    mov r2.z, l(0)
  endif
  if_z r2.x
    div r3.xyz, r0.zxyz, r0.wwww
    max r0.z, r3.x, l(0.000000)
    umin r2.x, cb2[2].x, l(16)
    utof r2.w, r2.x
    div r4.x, l(6.28318548), r2.w
    div r4.zw, cb0[10].xxxy, r0.wwww
    div r2.w, cb1[0].x, cb2[8].y
    div r2.w, r2.w, cb1[0].y
    if_nz r2.x
      mad r5.x, cb2[2].y, r4.z, r3.y
      if_nz r1.y
        rcp r3.x, r2.w
        mul r5.y, r3.x, r3.z
        dp2 r5.y, r5.xyxx, r5.xyxx
        mad r5.z, r2.w, r2.w, l(1.000000)
        sqrt r5.yz, r5.yyzy
        mul r3.x, r3.x, r5.z
        mul r5.z, r3.x, cb2[2].z
        lt r5.w, r5.z, r5.y
        if_nz r5.w
          mad r5.z, r3.x, cb2[2].w, -r5.z
          lt r5.w, l(0.000000), r5.z
          mad r3.x, -r3.x, cb2[2].z, r5.y
          div r3.x, r3.x, r5.z
          min r3.x, r3.x, l(1.000000)
          movc r3.x, r5.w, r3.x, l(1.000000)
        else
          mov r3.x, l(0)
        endif
        lt r5.y, l(1.000000), |r5.x|
        lt r5.z, l(1.000000), |r3.z|
        or r5.y, r5.z, r5.y
        if_nz r5.y
          mov r4.y, r3.x
        endif
      else
        if_nz r1.x
          lt r5.z, l(1.000000), |r5.x|
          lt r5.w, l(1.000000), |r3.z|
          or r5.y, r5.w, r5.z
          if_nz r5.y
            mov r4.y, l(1.000000)
          endif
        else
          mov r5.y, l(0)
        endif
        mov r3.x, l(0)
      endif
      if_z r5.y
        if_nz r1.x
          add r5.x, r5.x, l(1.000000)
          add r5.z, r3.z, l(-1.000000)
          mul r5.xy, r5.xzxx, l(0.500000, -0.500000, 0.000000, 0.000000)
          sample_c_lz_indexable(texture2d)(float,float,float,float) r5.x, r5.xyxx, t0.xxxx, s0, r0.z
        else
          mov r5.x, l(0)
        endif
        add r3.x, r3.x, r5.x
        min r4.y, r3.x, l(1.000000)
      endif
      mov r5.xy, r4.xyxx
      mov r3.x, l(1)
    else
      mov r5.xy, l(0,0,0,0)
      mov r3.x, l(0)
    endif
    ult r4.y, r3.x, r2.x
    if_nz r4.y
      sincos r6.x, r7.x, r5.x
      mul r5.z, r7.x, cb2[2].y
      mul r5.w, r6.x, cb2[2].y
      mad r6.x, r5.z, r4.z, r3.y
      mad r5.z, r5.w, r4.w, r3.z
      if_nz r1.y
        rcp r5.w, r2.w
        mul r6.y, r5.w, r5.z
        dp2 r6.y, r6.xyxx, r6.xyxx
        mad r6.z, r2.w, r2.w, l(1.000000)
        sqrt r6.yz, r6.yyzy
        mul r5.w, r5.w, r6.z
        mul r6.z, r5.w, cb2[2].z
        lt r6.w, r6.z, r6.y
        if_nz r6.w
          mad r6.z, r5.w, cb2[2].w, -r6.z
          lt r6.w, l(0.000000), r6.z
          mad r5.w, -r5.w, cb2[2].z, r6.y
          div r5.w, r5.w, r6.z
          min r5.w, r5.w, l(1.000000)
          movc r5.w, r6.w, r5.w, l(1.000000)
        else
          mov r5.w, l(0)
        endif
        lt r6.y, l(1.000000), |r6.x|
        lt r6.z, l(1.000000), |r5.z|
        or r6.y, r6.z, r6.y
        if_nz r6.y
          mov r6.z, r5.w
        endif
      else
        if_nz r1.x
          lt r6.w, l(1.000000), |r6.x|
          lt r7.x, l(1.000000), |r5.z|
          or r6.y, r6.w, r7.x
          if_nz r6.y
            mov r6.z, l(1.000000)
          endif
        else
          mov r6.y, l(0)
        endif
        mov r5.w, l(0)
      endif
      if_z r6.y
        if_nz r1.x
          add r6.x, r6.x, l(1.000000)
          mul r6.x, r6.x, l(0.500000)
          add r5.z, r5.z, l(-1.000000)
          mul r6.y, r5.z, l(-0.500000)
          sample_c_lz_indexable(texture2d)(float,float,float,float) r5.z, r6.xyxx, t0.xxxx, s0, r0.z
        else
          mov r5.z, l(0)
        endif
        add r5.z, r5.w, r5.z
        min r6.z, r5.z, l(1.000000)
      endif
      add r5.y, r5.y, r6.z
      add r5.x, r4.x, r5.x
      mov r3.x, l(2)
    endif
    ult r5.z, r3.x, r2.x
    and r4.y, r4.y, r5.z
    if_nz r4.y
      sincos r6.x, r7.x, r5.x
      mul r5.z, r7.x, cb2[2].y
      mul r5.w, r6.x, cb2[2].y
      mad r6.x, r5.z, r4.z, r3.y
      mad r5.z, r5.w, r4.w, r3.z
      if_nz r1.y
        rcp r5.w, r2.w
        mul r6.y, r5.w, r5.z
        dp2 r6.y, r6.xyxx, r6.xyxx
        mad r6.z, r2.w, r2.w, l(1.000000)
        sqrt r6.yz, r6.yyzy
        mul r5.w, r5.w, r6.z
        mul r6.z, r5.w, cb2[2].z
        lt r6.w, r6.z, r6.y
        if_nz r6.w
          mad r6.z, r5.w, cb2[2].w, -r6.z
          lt r6.w, l(0.000000), r6.z
          mad r5.w, -r5.w, cb2[2].z, r6.y
          div r5.w, r5.w, r6.z
          min r5.w, r5.w, l(1.000000)
          movc r5.w, r6.w, r5.w, l(1.000000)
        else
          mov r5.w, l(0)
        endif
        lt r6.y, l(1.000000), |r6.x|
        lt r6.z, l(1.000000), |r5.z|
        or r6.y, r6.z, r6.y
        if_nz r6.y
          mov r6.z, r5.w
        endif
      else
        if_nz r1.x
          lt r6.w, l(1.000000), |r6.x|
          lt r7.x, l(1.000000), |r5.z|
          or r6.y, r6.w, r7.x
          if_nz r6.y
            mov r6.z, l(1.000000)
          endif
        else
          mov r6.y, l(0)
        endif
        mov r5.w, l(0)
      endif
      if_z r6.y
        if_nz r1.x
          add r6.x, r6.x, l(1.000000)
          mul r6.x, r6.x, l(0.500000)
          add r5.z, r5.z, l(-1.000000)
          mul r6.y, r5.z, l(-0.500000)
          sample_c_lz_indexable(texture2d)(float,float,float,float) r5.z, r6.xyxx, t0.xxxx, s0, r0.z
        else
          mov r5.z, l(0)
        endif
        add r5.z, r5.w, r5.z
        min r6.z, r5.z, l(1.000000)
      endif
      add r5.y, r5.y, r6.z
      add r5.x, r4.x, r5.x
      mov r3.x, l(3)
    endif
    ult r5.z, r3.x, r2.x
    and r4.y, r4.y, r5.z
    if_nz r4.y
      sincos r6.x, r7.x, r5.x
      mul r5.z, r7.x, cb2[2].y
      mul r5.w, r6.x, cb2[2].y
      mad r6.x, r5.z, r4.z, r3.y
      mad r5.z, r5.w, r4.w, r3.z
      if_nz r1.y
        rcp r5.w, r2.w
        mul r6.y, r5.w, r5.z
        dp2 r6.y, r6.xyxx, r6.xyxx
        mad r6.z, r2.w, r2.w, l(1.000000)
        sqrt r6.yz, r6.yyzy
        mul r5.w, r5.w, r6.z
        mul r6.z, r5.w, cb2[2].z
        lt r6.w, r6.z, r6.y
        if_nz r6.w
          mad r6.z, r5.w, cb2[2].w, -r6.z
          lt r6.w, l(0.000000), r6.z
          mad r5.w, -r5.w, cb2[2].z, r6.y
          div r5.w, r5.w, r6.z
          min r5.w, r5.w, l(1.000000)
          movc r5.w, r6.w, r5.w, l(1.000000)
        else
          mov r5.w, l(0)
        endif
        lt r6.y, l(1.000000), |r6.x|
        lt r6.z, l(1.000000), |r5.z|
        or r6.y, r6.z, r6.y
        if_nz r6.y
          mov r6.z, r5.w
        endif
      else
        if_nz r1.x
          lt r6.w, l(1.000000), |r6.x|
          lt r7.x, l(1.000000), |r5.z|
          or r6.y, r6.w, r7.x
          if_nz r6.y
            mov r6.z, l(1.000000)
          endif
        else
          mov r6.y, l(0)
        endif
        mov r5.w, l(0)
      endif
      if_z r6.y
        if_nz r1.x
          add r6.x, r6.x, l(1.000000)
          mul r6.x, r6.x, l(0.500000)
          add r5.z, r5.z, l(-1.000000)
          mul r6.y, r5.z, l(-0.500000)
          sample_c_lz_indexable(texture2d)(float,float,float,float) r5.z, r6.xyxx, t0.xxxx, s0, r0.z
        else
          mov r5.z, l(0)
        endif
        add r5.z, r5.w, r5.z
        min r6.z, r5.z, l(1.000000)
      endif
      add r5.y, r5.y, r6.z
      add r5.x, r4.x, r5.x
      mov r3.x, l(4)
    endif
    ult r5.z, r3.x, r2.x
    and r4.y, r4.y, r5.z
    if_nz r4.y
      sincos r6.x, r7.x, r5.x
      mul r5.z, r7.x, cb2[2].y
      mul r5.w, r6.x, cb2[2].y
      mad r6.x, r5.z, r4.z, r3.y
      mad r5.z, r5.w, r4.w, r3.z
      if_nz r1.y
        rcp r5.w, r2.w
        mul r6.y, r5.w, r5.z
        dp2 r6.y, r6.xyxx, r6.xyxx
        mad r6.z, r2.w, r2.w, l(1.000000)
        sqrt r6.yz, r6.yyzy
        mul r5.w, r5.w, r6.z
        mul r6.z, r5.w, cb2[2].z
        lt r6.w, r6.z, r6.y
        if_nz r6.w
          mad r6.z, r5.w, cb2[2].w, -r6.z
          lt r6.w, l(0.000000), r6.z
          mad r5.w, -r5.w, cb2[2].z, r6.y
          div r5.w, r5.w, r6.z
          min r5.w, r5.w, l(1.000000)
          movc r5.w, r6.w, r5.w, l(1.000000)
        else
          mov r5.w, l(0)
        endif
        lt r6.y, l(1.000000), |r6.x|
        lt r6.z, l(1.000000), |r5.z|
        or r6.y, r6.z, r6.y
        if_nz r6.y
          mov r6.z, r5.w
        endif
      else
        if_nz r1.x
          lt r6.w, l(1.000000), |r6.x|
          lt r7.x, l(1.000000), |r5.z|
          or r6.y, r6.w, r7.x
          if_nz r6.y
            mov r6.z, l(1.000000)
          endif
        else
          mov r6.y, l(0)
        endif
        mov r5.w, l(0)
      endif
      if_z r6.y
        if_nz r1.x
          add r6.x, r6.x, l(1.000000)
          mul r6.x, r6.x, l(0.500000)
          add r5.z, r5.z, l(-1.000000)
          mul r6.y, r5.z, l(-0.500000)
          sample_c_lz_indexable(texture2d)(float,float,float,float) r5.z, r6.xyxx, t0.xxxx, s0, r0.z
        else
          mov r5.z, l(0)
        endif
        add r5.z, r5.w, r5.z
        min r6.z, r5.z, l(1.000000)
      endif
      add r5.y, r5.y, r6.z
      add r5.x, r4.x, r5.x
      mov r3.x, l(5)
    endif
    ult r5.z, r3.x, r2.x
    and r4.y, r4.y, r5.z
    if_nz r4.y
      sincos r6.x, r7.x, r5.x
      mul r5.z, r7.x, cb2[2].y
      mul r5.w, r6.x, cb2[2].y
      mad r6.x, r5.z, r4.z, r3.y
      mad r5.z, r5.w, r4.w, r3.z
      if_nz r1.y
        rcp r5.w, r2.w
        mul r6.y, r5.w, r5.z
        dp2 r6.y, r6.xyxx, r6.xyxx
        mad r6.z, r2.w, r2.w, l(1.000000)
        sqrt r6.yz, r6.yyzy
        mul r5.w, r5.w, r6.z
        mul r6.z, r5.w, cb2[2].z
        lt r6.w, r6.z, r6.y
        if_nz r6.w
          mad r6.z, r5.w, cb2[2].w, -r6.z
          lt r6.w, l(0.000000), r6.z
          mad r5.w, -r5.w, cb2[2].z, r6.y
          div r5.w, r5.w, r6.z
          min r5.w, r5.w, l(1.000000)
          movc r5.w, r6.w, r5.w, l(1.000000)
        else
          mov r5.w, l(0)
        endif
        lt r6.y, l(1.000000), |r6.x|
        lt r6.z, l(1.000000), |r5.z|
        or r6.y, r6.z, r6.y
        if_nz r6.y
          mov r6.z, r5.w
        endif
      else
        if_nz r1.x
          lt r6.w, l(1.000000), |r6.x|
          lt r7.x, l(1.000000), |r5.z|
          or r6.y, r6.w, r7.x
          if_nz r6.y
            mov r6.z, l(1.000000)
          endif
        else
          mov r6.y, l(0)
        endif
        mov r5.w, l(0)
      endif
      if_z r6.y
        if_nz r1.x
          add r6.x, r6.x, l(1.000000)
          mul r6.x, r6.x, l(0.500000)
          add r5.z, r5.z, l(-1.000000)
          mul r6.y, r5.z, l(-0.500000)
          sample_c_lz_indexable(texture2d)(float,float,float,float) r5.z, r6.xyxx, t0.xxxx, s0, r0.z
        else
          mov r5.z, l(0)
        endif
        add r5.z, r5.w, r5.z
        min r6.z, r5.z, l(1.000000)
      endif
      add r5.y, r5.y, r6.z
      add r5.x, r4.x, r5.x
      mov r3.x, l(6)
    endif
    ult r5.z, r3.x, r2.x
    and r4.y, r4.y, r5.z
    if_nz r4.y
      sincos r6.x, r7.x, r5.x
      mul r5.z, r7.x, cb2[2].y
      mul r5.w, r6.x, cb2[2].y
      mad r6.x, r5.z, r4.z, r3.y
      mad r5.z, r5.w, r4.w, r3.z
      if_nz r1.y
        rcp r5.w, r2.w
        mul r6.y, r5.w, r5.z
        dp2 r6.y, r6.xyxx, r6.xyxx
        mad r6.z, r2.w, r2.w, l(1.000000)
        sqrt r6.yz, r6.yyzy
        mul r5.w, r5.w, r6.z
        mul r6.z, r5.w, cb2[2].z
        lt r6.w, r6.z, r6.y
        if_nz r6.w
          mad r6.z, r5.w, cb2[2].w, -r6.z
          lt r6.w, l(0.000000), r6.z
          mad r5.w, -r5.w, cb2[2].z, r6.y
          div r5.w, r5.w, r6.z
          min r5.w, r5.w, l(1.000000)
          movc r5.w, r6.w, r5.w, l(1.000000)
        else
          mov r5.w, l(0)
        endif
        lt r6.y, l(1.000000), |r6.x|
        lt r6.z, l(1.000000), |r5.z|
        or r6.y, r6.z, r6.y
        if_nz r6.y
          mov r6.z, r5.w
        endif
      else
        if_nz r1.x
          lt r6.w, l(1.000000), |r6.x|
          lt r7.x, l(1.000000), |r5.z|
          or r6.y, r6.w, r7.x
          if_nz r6.y
            mov r6.z, l(1.000000)
          endif
        else
          mov r6.y, l(0)
        endif
        mov r5.w, l(0)
      endif
      if_z r6.y
        if_nz r1.x
          add r6.x, r6.x, l(1.000000)
          mul r6.x, r6.x, l(0.500000)
          add r5.z, r5.z, l(-1.000000)
          mul r6.y, r5.z, l(-0.500000)
          sample_c_lz_indexable(texture2d)(float,float,float,float) r5.z, r6.xyxx, t0.xxxx, s0, r0.z
        else
          mov r5.z, l(0)
        endif
        add r5.z, r5.w, r5.z
        min r6.z, r5.z, l(1.000000)
      endif
      add r5.y, r5.y, r6.z
      add r5.x, r4.x, r5.x
      mov r3.x, l(7)
    endif
    ult r5.z, r3.x, r2.x
    and r4.y, r4.y, r5.z
    if_nz r4.y
      sincos r6.x, r7.x, r5.x
      mul r5.z, r7.x, cb2[2].y
      mul r5.w, r6.x, cb2[2].y
      mad r6.x, r5.z, r4.z, r3.y
      mad r5.z, r5.w, r4.w, r3.z
      if_nz r1.y
        rcp r5.w, r2.w
        mul r6.y, r5.w, r5.z
        dp2 r6.y, r6.xyxx, r6.xyxx
        mad r6.z, r2.w, r2.w, l(1.000000)
        sqrt r6.yz, r6.yyzy
        mul r5.w, r5.w, r6.z
        mul r6.z, r5.w, cb2[2].z
        lt r6.w, r6.z, r6.y
        if_nz r6.w
          mad r6.z, r5.w, cb2[2].w, -r6.z
          lt r6.w, l(0.000000), r6.z
          mad r5.w, -r5.w, cb2[2].z, r6.y
          div r5.w, r5.w, r6.z
          min r5.w, r5.w, l(1.000000)
          movc r5.w, r6.w, r5.w, l(1.000000)
        else
          mov r5.w, l(0)
        endif
        lt r6.y, l(1.000000), |r6.x|
        lt r6.z, l(1.000000), |r5.z|
        or r6.y, r6.z, r6.y
        if_nz r6.y
          mov r6.z, r5.w
        endif
      else
        if_nz r1.x
          lt r6.w, l(1.000000), |r6.x|
          lt r7.x, l(1.000000), |r5.z|
          or r6.y, r6.w, r7.x
          if_nz r6.y
            mov r6.z, l(1.000000)
          endif
        else
          mov r6.y, l(0)
        endif
        mov r5.w, l(0)
      endif
      if_z r6.y
        if_nz r1.x
          add r6.x, r6.x, l(1.000000)
          mul r6.x, r6.x, l(0.500000)
          add r5.z, r5.z, l(-1.000000)
          mul r6.y, r5.z, l(-0.500000)
          sample_c_lz_indexable(texture2d)(float,float,float,float) r5.z, r6.xyxx, t0.xxxx, s0, r0.z
        else
          mov r5.z, l(0)
        endif
        add r5.z, r5.w, r5.z
        min r6.z, r5.z, l(1.000000)
      endif
      add r5.y, r5.y, r6.z
      add r5.x, r4.x, r5.x
      mov r3.x, l(8)
    endif
    ult r5.z, r3.x, r2.x
    and r4.y, r4.y, r5.z
    if_nz r4.y
      sincos r6.x, r7.x, r5.x
      mul r5.z, r7.x, cb2[2].y
      mul r5.w, r6.x, cb2[2].y
      mad r6.x, r5.z, r4.z, r3.y
      mad r5.z, r5.w, r4.w, r3.z
      if_nz r1.y
        rcp r5.w, r2.w
        mul r6.y, r5.w, r5.z
        dp2 r6.y, r6.xyxx, r6.xyxx
        mad r6.z, r2.w, r2.w, l(1.000000)
        sqrt r6.yz, r6.yyzy
        mul r5.w, r5.w, r6.z
        mul r6.z, r5.w, cb2[2].z
        lt r6.w, r6.z, r6.y
        if_nz r6.w
          mad r6.z, r5.w, cb2[2].w, -r6.z
          lt r6.w, l(0.000000), r6.z
          mad r5.w, -r5.w, cb2[2].z, r6.y
          div r5.w, r5.w, r6.z
          min r5.w, r5.w, l(1.000000)
          movc r5.w, r6.w, r5.w, l(1.000000)
        else
          mov r5.w, l(0)
        endif
        lt r6.y, l(1.000000), |r6.x|
        lt r6.z, l(1.000000), |r5.z|
        or r6.y, r6.z, r6.y
        if_nz r6.y
          mov r6.z, r5.w
        endif
      else
        if_nz r1.x
          lt r6.w, l(1.000000), |r6.x|
          lt r7.x, l(1.000000), |r5.z|
          or r6.y, r6.w, r7.x
          if_nz r6.y
            mov r6.z, l(1.000000)
          endif
        else
          mov r6.y, l(0)
        endif
        mov r5.w, l(0)
      endif
      if_z r6.y
        if_nz r1.x
          add r6.x, r6.x, l(1.000000)
          mul r6.x, r6.x, l(0.500000)
          add r5.z, r5.z, l(-1.000000)
          mul r6.y, r5.z, l(-0.500000)
          sample_c_lz_indexable(texture2d)(float,float,float,float) r5.z, r6.xyxx, t0.xxxx, s0, r0.z
        else
          mov r5.z, l(0)
        endif
        add r5.z, r5.w, r5.z
        min r6.z, r5.z, l(1.000000)
      endif
      add r5.y, r5.y, r6.z
      add r5.x, r4.x, r5.x
      mov r3.x, l(9)
    endif
    ult r5.z, r3.x, r2.x
    and r4.y, r4.y, r5.z
    if_nz r4.y
      sincos r6.x, r7.x, r5.x
      mul r5.z, r7.x, cb2[2].y
      mul r5.w, r6.x, cb2[2].y
      mad r6.x, r5.z, r4.z, r3.y
      mad r5.z, r5.w, r4.w, r3.z
      if_nz r1.y
        rcp r5.w, r2.w
        mul r6.y, r5.w, r5.z
        dp2 r6.y, r6.xyxx, r6.xyxx
        mad r6.z, r2.w, r2.w, l(1.000000)
        sqrt r6.yz, r6.yyzy
        mul r5.w, r5.w, r6.z
        mul r6.z, r5.w, cb2[2].z
        lt r6.w, r6.z, r6.y
        if_nz r6.w
          mad r6.z, r5.w, cb2[2].w, -r6.z
          lt r6.w, l(0.000000), r6.z
          mad r5.w, -r5.w, cb2[2].z, r6.y
          div r5.w, r5.w, r6.z
          min r5.w, r5.w, l(1.000000)
          movc r5.w, r6.w, r5.w, l(1.000000)
        else
          mov r5.w, l(0)
        endif
        lt r6.y, l(1.000000), |r6.x|
        lt r6.z, l(1.000000), |r5.z|
        or r6.y, r6.z, r6.y
        if_nz r6.y
          mov r6.z, r5.w
        endif
      else
        if_nz r1.x
          lt r6.w, l(1.000000), |r6.x|
          lt r7.x, l(1.000000), |r5.z|
          or r6.y, r6.w, r7.x
          if_nz r6.y
            mov r6.z, l(1.000000)
          endif
        else
          mov r6.y, l(0)
        endif
        mov r5.w, l(0)
      endif
      if_z r6.y
        if_nz r1.x
          add r6.x, r6.x, l(1.000000)
          mul r6.x, r6.x, l(0.500000)
          add r5.z, r5.z, l(-1.000000)
          mul r6.y, r5.z, l(-0.500000)
          sample_c_lz_indexable(texture2d)(float,float,float,float) r5.z, r6.xyxx, t0.xxxx, s0, r0.z
        else
          mov r5.z, l(0)
        endif
        add r5.z, r5.w, r5.z
        min r6.z, r5.z, l(1.000000)
      endif
      add r5.y, r5.y, r6.z
      add r5.x, r4.x, r5.x
      mov r3.x, l(10)
    endif
    ult r5.z, r3.x, r2.x
    and r4.y, r4.y, r5.z
    if_nz r4.y
      sincos r6.x, r7.x, r5.x
      mul r5.z, r7.x, cb2[2].y
      mul r5.w, r6.x, cb2[2].y
      mad r6.x, r5.z, r4.z, r3.y
      mad r5.z, r5.w, r4.w, r3.z
      if_nz r1.y
        rcp r5.w, r2.w
        mul r6.y, r5.w, r5.z
        dp2 r6.y, r6.xyxx, r6.xyxx
        mad r6.z, r2.w, r2.w, l(1.000000)
        sqrt r6.yz, r6.yyzy
        mul r5.w, r5.w, r6.z
        mul r6.z, r5.w, cb2[2].z
        lt r6.w, r6.z, r6.y
        if_nz r6.w
          mad r6.z, r5.w, cb2[2].w, -r6.z
          lt r6.w, l(0.000000), r6.z
          mad r5.w, -r5.w, cb2[2].z, r6.y
          div r5.w, r5.w, r6.z
          min r5.w, r5.w, l(1.000000)
          movc r5.w, r6.w, r5.w, l(1.000000)
        else
          mov r5.w, l(0)
        endif
        lt r6.y, l(1.000000), |r6.x|
        lt r6.z, l(1.000000), |r5.z|
        or r6.y, r6.z, r6.y
        if_nz r6.y
          mov r6.z, r5.w
        endif
      else
        if_nz r1.x
          lt r6.w, l(1.000000), |r6.x|
          lt r7.x, l(1.000000), |r5.z|
          or r6.y, r6.w, r7.x
          if_nz r6.y
            mov r6.z, l(1.000000)
          endif
        else
          mov r6.y, l(0)
        endif
        mov r5.w, l(0)
      endif
      if_z r6.y
        if_nz r1.x
          add r6.x, r6.x, l(1.000000)
          mul r6.x, r6.x, l(0.500000)
          add r5.z, r5.z, l(-1.000000)
          mul r6.y, r5.z, l(-0.500000)
          sample_c_lz_indexable(texture2d)(float,float,float,float) r5.z, r6.xyxx, t0.xxxx, s0, r0.z
        else
          mov r5.z, l(0)
        endif
        add r5.z, r5.w, r5.z
        min r6.z, r5.z, l(1.000000)
      endif
      add r5.y, r5.y, r6.z
      add r5.x, r4.x, r5.x
      mov r3.x, l(11)
    endif
    ult r5.z, r3.x, r2.x
    and r4.y, r4.y, r5.z
    if_nz r4.y
      sincos r6.x, r7.x, r5.x
      mul r5.z, r7.x, cb2[2].y
      mul r5.w, r6.x, cb2[2].y
      mad r6.x, r5.z, r4.z, r3.y
      mad r5.z, r5.w, r4.w, r3.z
      if_nz r1.y
        rcp r5.w, r2.w
        mul r6.y, r5.w, r5.z
        dp2 r6.y, r6.xyxx, r6.xyxx
        mad r6.z, r2.w, r2.w, l(1.000000)
        sqrt r6.yz, r6.yyzy
        mul r5.w, r5.w, r6.z
        mul r6.z, r5.w, cb2[2].z
        lt r6.w, r6.z, r6.y
        if_nz r6.w
          mad r6.z, r5.w, cb2[2].w, -r6.z
          lt r6.w, l(0.000000), r6.z
          mad r5.w, -r5.w, cb2[2].z, r6.y
          div r5.w, r5.w, r6.z
          min r5.w, r5.w, l(1.000000)
          movc r5.w, r6.w, r5.w, l(1.000000)
        else
          mov r5.w, l(0)
        endif
        lt r6.y, l(1.000000), |r6.x|
        lt r6.z, l(1.000000), |r5.z|
        or r6.y, r6.z, r6.y
        if_nz r6.y
          mov r6.z, r5.w
        endif
      else
        if_nz r1.x
          lt r6.w, l(1.000000), |r6.x|
          lt r7.x, l(1.000000), |r5.z|
          or r6.y, r6.w, r7.x
          if_nz r6.y
            mov r6.z, l(1.000000)
          endif
        else
          mov r6.y, l(0)
        endif
        mov r5.w, l(0)
      endif
      if_z r6.y
        if_nz r1.x
          add r6.x, r6.x, l(1.000000)
          mul r6.x, r6.x, l(0.500000)
          add r5.z, r5.z, l(-1.000000)
          mul r6.y, r5.z, l(-0.500000)
          sample_c_lz_indexable(texture2d)(float,float,float,float) r5.z, r6.xyxx, t0.xxxx, s0, r0.z
        else
          mov r5.z, l(0)
        endif
        add r5.z, r5.w, r5.z
        min r6.z, r5.z, l(1.000000)
      endif
      add r5.y, r5.y, r6.z
      add r5.x, r4.x, r5.x
      mov r3.x, l(12)
    endif
    ult r5.z, r3.x, r2.x
    and r4.y, r4.y, r5.z
    if_nz r4.y
      sincos r6.x, r7.x, r5.x
      mul r5.z, r7.x, cb2[2].y
      mul r5.w, r6.x, cb2[2].y
      mad r6.x, r5.z, r4.z, r3.y
      mad r5.z, r5.w, r4.w, r3.z
      if_nz r1.y
        rcp r5.w, r2.w
        mul r6.y, r5.w, r5.z
        dp2 r6.y, r6.xyxx, r6.xyxx
        mad r6.z, r2.w, r2.w, l(1.000000)
        sqrt r6.yz, r6.yyzy
        mul r5.w, r5.w, r6.z
        mul r6.z, r5.w, cb2[2].z
        lt r6.w, r6.z, r6.y
        if_nz r6.w
          mad r6.z, r5.w, cb2[2].w, -r6.z
          lt r6.w, l(0.000000), r6.z
          mad r5.w, -r5.w, cb2[2].z, r6.y
          div r5.w, r5.w, r6.z
          min r5.w, r5.w, l(1.000000)
          movc r5.w, r6.w, r5.w, l(1.000000)
        else
          mov r5.w, l(0)
        endif
        lt r6.y, l(1.000000), |r6.x|
        lt r6.z, l(1.000000), |r5.z|
        or r6.y, r6.z, r6.y
        if_nz r6.y
          mov r6.z, r5.w
        endif
      else
        if_nz r1.x
          lt r6.w, l(1.000000), |r6.x|
          lt r7.x, l(1.000000), |r5.z|
          or r6.y, r6.w, r7.x
          if_nz r6.y
            mov r6.z, l(1.000000)
          endif
        else
          mov r6.y, l(0)
        endif
        mov r5.w, l(0)
      endif
      if_z r6.y
        if_nz r1.x
          add r6.x, r6.x, l(1.000000)
          mul r6.x, r6.x, l(0.500000)
          add r5.z, r5.z, l(-1.000000)
          mul r6.y, r5.z, l(-0.500000)
          sample_c_lz_indexable(texture2d)(float,float,float,float) r5.z, r6.xyxx, t0.xxxx, s0, r0.z
        else
          mov r5.z, l(0)
        endif
        add r5.z, r5.w, r5.z
        min r6.z, r5.z, l(1.000000)
      endif
      add r5.y, r5.y, r6.z
      add r5.x, r4.x, r5.x
      mov r3.x, l(13)
    endif
    ult r5.z, r3.x, r2.x
    and r4.y, r4.y, r5.z
    if_nz r4.y
      sincos r6.x, r7.x, r5.x
      mul r5.z, r7.x, cb2[2].y
      mul r5.w, r6.x, cb2[2].y
      mad r6.x, r5.z, r4.z, r3.y
      mad r5.z, r5.w, r4.w, r3.z
      if_nz r1.y
        rcp r5.w, r2.w
        mul r6.y, r5.w, r5.z
        dp2 r6.y, r6.xyxx, r6.xyxx
        mad r6.z, r2.w, r2.w, l(1.000000)
        sqrt r6.yz, r6.yyzy
        mul r5.w, r5.w, r6.z
        mul r6.z, r5.w, cb2[2].z
        lt r6.w, r6.z, r6.y
        if_nz r6.w
          mad r6.z, r5.w, cb2[2].w, -r6.z
          lt r6.w, l(0.000000), r6.z
          mad r5.w, -r5.w, cb2[2].z, r6.y
          div r5.w, r5.w, r6.z
          min r5.w, r5.w, l(1.000000)
          movc r5.w, r6.w, r5.w, l(1.000000)
        else
          mov r5.w, l(0)
        endif
        lt r6.y, l(1.000000), |r6.x|
        lt r6.z, l(1.000000), |r5.z|
        or r6.y, r6.z, r6.y
        if_nz r6.y
          mov r6.z, r5.w
        endif
      else
        if_nz r1.x
          lt r6.w, l(1.000000), |r6.x|
          lt r7.x, l(1.000000), |r5.z|
          or r6.y, r6.w, r7.x
          if_nz r6.y
            mov r6.z, l(1.000000)
          endif
        else
          mov r6.y, l(0)
        endif
        mov r5.w, l(0)
      endif
      if_z r6.y
        if_nz r1.x
          add r6.x, r6.x, l(1.000000)
          mul r6.x, r6.x, l(0.500000)
          add r5.z, r5.z, l(-1.000000)
          mul r6.y, r5.z, l(-0.500000)
          sample_c_lz_indexable(texture2d)(float,float,float,float) r5.z, r6.xyxx, t0.xxxx, s0, r0.z
        else
          mov r5.z, l(0)
        endif
        add r5.z, r5.w, r5.z
        min r6.z, r5.z, l(1.000000)
      endif
      add r5.y, r5.y, r6.z
      add r5.x, r4.x, r5.x
      mov r3.x, l(14)
    endif
    ult r5.z, r3.x, r2.x
    and r4.y, r4.y, r5.z
    if_nz r4.y
      sincos r6.x, r7.x, r5.x
      mul r5.z, r7.x, cb2[2].y
      mul r5.w, r6.x, cb2[2].y
      mad r6.x, r5.z, r4.z, r3.y
      mad r5.z, r5.w, r4.w, r3.z
      if_nz r1.y
        rcp r5.w, r2.w
        mul r6.y, r5.w, r5.z
        dp2 r6.y, r6.xyxx, r6.xyxx
        mad r6.z, r2.w, r2.w, l(1.000000)
        sqrt r6.yz, r6.yyzy
        mul r5.w, r5.w, r6.z
        mul r6.z, r5.w, cb2[2].z
        lt r6.w, r6.z, r6.y
        if_nz r6.w
          mad r6.z, r5.w, cb2[2].w, -r6.z
          lt r6.w, l(0.000000), r6.z
          mad r5.w, -r5.w, cb2[2].z, r6.y
          div r5.w, r5.w, r6.z
          min r5.w, r5.w, l(1.000000)
          movc r5.w, r6.w, r5.w, l(1.000000)
        else
          mov r5.w, l(0)
        endif
        lt r6.y, l(1.000000), |r6.x|
        lt r6.z, l(1.000000), |r5.z|
        or r6.y, r6.z, r6.y
        if_nz r6.y
          mov r6.z, r5.w
        endif
      else
        if_nz r1.x
          lt r6.w, l(1.000000), |r6.x|
          lt r7.x, l(1.000000), |r5.z|
          or r6.y, r6.w, r7.x
          if_nz r6.y
            mov r6.z, l(1.000000)
          endif
        else
          mov r6.y, l(0)
        endif
        mov r5.w, l(0)
      endif
      if_z r6.y
        if_nz r1.x
          add r6.x, r6.x, l(1.000000)
          mul r6.x, r6.x, l(0.500000)
          add r5.z, r5.z, l(-1.000000)
          mul r6.y, r5.z, l(-0.500000)
          sample_c_lz_indexable(texture2d)(float,float,float,float) r5.z, r6.xyxx, t0.xxxx, s0, r0.z
        else
          mov r5.z, l(0)
        endif
        add r5.z, r5.w, r5.z
        min r6.z, r5.z, l(1.000000)
      endif
      add r5.y, r5.y, r6.z
      add r5.x, r4.x, r5.x
      mov r3.x, l(15)
    endif
    ult r3.x, r3.x, r2.x
    and r3.x, r3.x, r4.y
    if_nz r3.x
      sincos r3.x, r4.x, r5.x
      mul r4.x, r4.x, cb2[2].y
      mul r3.x, r3.x, cb2[2].y
      mad r4.x, r4.x, r4.z, r3.y
      mad r3.x, r3.x, r4.w, r3.z
      if_nz r1.y
        rcp r4.z, r2.w
        mul r4.y, r3.x, r4.z
        dp2 r4.y, r4.xyxx, r4.xyxx
        mad r4.w, r2.w, r2.w, l(1.000000)
        sqrt r4.yw, r4.yyyw
        mul r4.z, r4.z, r4.w
        mul r4.w, r4.z, cb2[2].z
        lt r5.x, r4.w, r4.y
        if_nz r5.x
          mad r4.w, r4.z, cb2[2].w, -r4.w
          lt r5.x, l(0.000000), r4.w
          mad r4.y, -r4.z, cb2[2].z, r4.y
          div r4.y, r4.y, r4.w
          min r4.y, r4.y, l(1.000000)
          movc r4.y, r5.x, r4.y, l(1.000000)
        else
          mov r4.y, l(0)
        endif
        lt r4.z, l(1.000000), |r4.x|
        lt r4.w, l(1.000000), |r3.x|
        or r4.z, r4.w, r4.z
        if_nz r4.z
          mov r4.w, r4.y
        endif
      else
        if_nz r1.x
          lt r5.x, l(1.000000), |r4.x|
          lt r5.z, l(1.000000), |r3.x|
          or r4.z, r5.z, r5.x
          if_nz r4.z
            mov r4.w, l(1.000000)
          endif
        else
          mov r4.z, l(0)
        endif
        mov r4.y, l(0)
      endif
      if_z r4.z
        if_nz r1.x
          add r4.x, r4.x, l(1.000000)
          mul r6.x, r4.x, l(0.500000)
          add r3.x, r3.x, l(-1.000000)
          mul r6.y, r3.x, l(-0.500000)
          sample_c_lz_indexable(texture2d)(float,float,float,float) r3.x, r6.xyxx, t0.xxxx, s0, r0.z
        else
          mov r3.x, l(0)
        endif
        add r3.x, r4.y, r3.x
        min r4.w, r3.x, l(1.000000)
      endif
      add r5.y, r4.w, r5.y
    endif
    if_nz r1.y
      rcp r1.y, r2.w
      mul r3.w, r1.y, r3.z
      dp2 r3.x, r3.ywyy, r3.ywyy
      sqrt r3.x, r3.x
      mad r2.w, r2.w, r2.w, l(1.000000)
      sqrt r2.w, r2.w
      mul r1.y, r1.y, r2.w
      mul r2.w, r1.y, cb2[2].z
      lt r3.w, r2.w, r3.x
      if_nz r3.w
        mad r2.w, r1.y, cb2[2].w, -r2.w
        lt r3.w, l(0.000000), r2.w
        mad r1.y, -r1.y, cb2[2].z, r3.x
        div r1.y, r1.y, r2.w
        min r1.y, r1.y, l(1.000000)
        movc r1.y, r3.w, r1.y, l(1.000000)
      else
        mov r1.y, l(0)
      endif
      lt r3.xw, l(1.000000, 0.000000, 0.000000, 1.000000), |r3.yyyz|
      or r2.w, r3.w, r3.x
      if_nz r2.w
        mov r3.x, r1.y
      endif
    else
      if_nz r1.x
        lt r4.xy, l(1.000000, 1.000000, 0.000000, 0.000000), |r3.yzyy|
        or r2.w, r4.y, r4.x
        if_nz r2.w
          mov r3.x, l(1.000000)
        endif
      else
        mov r2.w, l(0)
      endif
      mov r1.y, l(0)
    endif
    if_z r2.w
      if_nz r1.x
        add r3.yz, r3.yyzy, l(0.000000, 1.000000, -1.000000, 0.000000)
        mul r3.yz, r3.yyzy, l(0.000000, 0.500000, -0.500000, 0.000000)
        sample_c_lz_indexable(texture2d)(float,float,float,float) r0.z, r3.yzyy, t0.xxxx, s0, r0.z
      else
        mov r0.z, l(0)
      endif
      add r0.z, r1.y, r0.z
      min r3.x, r0.z, l(1.000000)
    endif
    add r0.z, r3.x, r5.y
    iadd r1.x, r2.x, l(1)
    utof r1.x, r1.x
    div r0.z, r0.z, r1.x
    add_sat r2.z, -r0.z, l(1.000000)
  endif
else
  lt r0.z, l(0.000000), r0.w
  and r2.z, r0.z, l(0x3f800000)
endif
if_nz r1.z
  mov r1.x, cb0[7].w
  mov r1.y, cb0[8].w
  mov r1.z, cb0[9].w
  add r1.xyz, r1.xyzx, -v0.xyzx
  dp3 r0.z, r1.xyzx, r1.xyzx
  rsq r0.z, r0.z
  mul r1.xyz, r0.zzzz, r1.xyzx
  dp3 r0.z, cb2[5].xyzx, r1.xyzx
  ge r1.x, r0.z, cb2[6].x
  if_nz r1.x
    mov r1.x, l(1.000000)
  else
    ge r1.y, r0.z, cb2[6].y
    if_nz r1.y
      add r0.z, r0.z, -cb2[6].y
      add r1.y, -cb2[6].y, cb2[6].x
      div r1.x, r0.z, r1.y
    else
      mov r1.x, l(0)
    endif
  endif
else
  mov r1.x, l(1.000000)
endif
if_nz r1.w
  mov r3.x, cb0[7].w
  mov r3.y, cb0[8].w
  mov r3.z, cb0[9].w
  add r1.yzw, -r3.xxyz, v0.xxyz
  dp3 r0.z, r1.yzwy, r1.yzwy
  sqrt r0.z, r0.z
  lt r1.y, r0.z, cb2[6].z
  lt r1.z, cb2[7].y, r0.z
  or r1.y, r1.z, r1.y
  if_nz r1.y
    mov r1.z, l(0)
  endif
  if_z r1.y
    lt r1.y, r0.z, cb2[6].w
    if_nz r1.y
      add r1.y, -cb2[6].z, cb2[6].w
      lt r1.w, l(0.000000), r1.y
      div r1.y, l(1.000000, 1.000000, 1.000000, 1.000000), r1.y
      and r1.y, r1.y, r1.w
      add r1.w, r0.z, -cb2[6].z
      mul r1.z, r1.y, r1.w
    else
      lt r1.y, cb2[7].x, r0.z
      if_nz r1.y
        add r1.y, -cb2[7].x, cb2[7].y
        lt r1.w, l(0.000000), r1.y
        div r1.y, l(1.000000, 1.000000, 1.000000, 1.000000), r1.y
        and r1.y, r1.y, r1.w
        add r0.z, r0.z, -cb2[7].x
        mul r0.z, r1.y, r0.z
        max r0.z, r0.z, l(0.000000)
        add r1.z, -r0.z, l(1.000000)
      else
        mov r1.z, l(1.000000)
      endif
    endif
  endif
  mul r1.x, r1.z, r1.x
endif
if_nz r2.y
  max r1.x, r1.x, cb2[7].z
endif
mul r3.xyzw, cb1[0].xyxy, l(0.500000, 0.500000, 0.250000, 0.250000)
div r0.x, r0.x, r0.w
mul r2.x, r3.x, r0.x
div r0.x, -r0.y, r0.w
mul r2.y, r3.y, r0.x
mad r0.xy, -r2.xyxx, cb2[0].xxxx, r2.xyxx
div r4.x, l(1.000000, 1.000000, 1.000000, 1.000000), cb2[8].y
mov r4.yw, l(0,1.000000,0,1.000000)
mul r0.zw, r0.xxxy, r4.xxxy
and r1.y, cb2[8].x, l(3)
ieq r1.z, r1.y, l(1)
if_nz r1.z
  mad r1.z, r2.x, r4.x, -r0.z
  mad r1.w, r2.y, r4.y, r0.w
  min r2.x, |r1.w|, |r1.z|
  max r2.y, |r1.w|, |r1.z|
  div r2.y, l(1.000000, 1.000000, 1.000000, 1.000000), r2.y
  mul r2.x, r2.y, r2.x
  mul r2.y, r2.x, r2.x
  mad r2.w, r2.y, l(0.0208350997), l(-0.085133)
  mad r2.w, r2.y, r2.w, l(0.180141)
  mad r2.w, r2.y, r2.w, l(-0.330299497)
  mad r2.y, r2.y, r2.w, l(0.999866)
  mul r2.w, r2.y, r2.x
  lt r4.x, |r1.w|, |r1.z|
  mad r2.w, r2.w, l(-2.000000), l(1.57079637)
  and r2.w, r4.x, r2.w
  mad r2.x, r2.x, r2.y, r2.w
  lt r2.y, r1.w, -r1.w
  and r2.y, r2.y, l(0xc0490fdb)
  add r2.x, r2.y, r2.x
  min r2.y, r1.w, r1.z
  max r1.z, r1.w, r1.z
  lt r1.w, r2.y, -r2.y
  ge r1.z, r1.z, -r1.z
  and r1.z, r1.z, r1.w
  movc r1.z, r1.z, -r2.x, r2.x
  add r1.z, r1.z, v3.z
else
  ieq r1.y, r1.y, l(2)
  if_nz r1.y
    min r1.y, |r0.w|, |r0.z|
    max r1.w, |r0.w|, |r0.z|
    div r1.w, l(1.000000, 1.000000, 1.000000, 1.000000), r1.w
    mul r1.y, r1.w, r1.y
    mul r1.w, r1.y, r1.y
    mad r2.x, r1.w, l(0.0208350997), l(-0.085133)
    mad r2.x, r1.w, r2.x, l(0.180141)
    mad r2.x, r1.w, r2.x, l(-0.330299497)
    mad r1.w, r1.w, r2.x, l(0.999866)
    mul r2.x, r1.w, r1.y
    lt r2.y, |r0.w|, |r0.z|
    mad r2.x, r2.x, l(-2.000000), l(1.57079637)
    and r2.x, r2.y, r2.x
    mad r1.y, r1.y, r1.w, r2.x
    lt r1.w, r0.w, -r0.w
    and r1.w, r1.w, l(0xc0490fdb)
    add r1.y, r1.w, r1.y
    min r1.w, r0.w, r0.z
    max r0.z, r0.w, r0.z
    lt r0.w, r1.w, -r1.w
    ge r0.z, r0.z, -r0.z
    and r0.z, r0.z, r0.w
    movc r0.z, r0.z, -r1.y, r1.y
    add r1.z, -r0.z, v3.z
  else
    mov r1.z, v3.z
  endif
endif
mad r0.zw, cb1[0].xxxy, cb2[0].wwww, r3.zzzw
mad r1.yw, cb1[0].xxxy, cb2[1].zzzz, r3.xxxy
add r1.yw, |r0.xxxy|, -r1.yyyw
add r1.yw, r0.zzzw, r1.yyyw
max r1.yw, r1.yyyw, l(0.000000, 0.000000, 0.000000, 0.000000)
div r0.zw, r1.yyyw, r0.zzzw
max r0.z, r0.w, r0.z
lt r0.w, l(1.000000), r0.z
add r1.y, -r0.z, l(2.000000)
movc r0.z, r0.w, r1.y, r0.z
max r0.z, r0.z, l(0.000000)
mul r2.xyw, v3.xyxw, cb2[0].zzzy
mad r2.xyw, r2.xyxw, r0.zzzz, v3.xyxw
max r0.z, r2.w, l(0.000000)
mul r1.yw, r2.xxxy, cb2[7].wwww
sincos r2.x, r3.x, r1.z
mul r2.yw, r1.yyyw, r3.xxxx
mad r4.x, -r2.x, r1.w, r2.y
mad r4.y, r2.x, r1.y, r2.w
mul r2.yw, r3.xxxx, cb2[3].xxxy
mul r2.yw, |r1.yyyw|, r2.yyyw
mul r0.w, -r2.x, cb2[3].y
mad r5.x, r0.w, |r1.w|, r2.y
mul r0.w, r2.x, cb2[3].x
mad r5.y, r0.w, |r1.y|, r2.w
add r2.yw, r4.xxxy, r5.xxxy
mad r2.yw, cb2[1].xxxy, cb2[7].wwww, r2.yyyw
mov r4.z, cb2[8].y
mad r0.xy, r2.ywyy, r4.zwzz, r0.xyxx
div r0.xy, r0.xyxx, cb1[0].xyxx
mul r0.y, r0.y, l(-2.000000)
add r0.w, cb2[1].w, l(-1.000000)
mul r1.z, |r1.w|, -r2.x
mad r1.y, r3.x, |r1.y|, r1.z
add r1.y, r1.y, r4.x
mul r0.w, r0.w, r1.y
div r0.w, r0.w, cb1[0].x
dp2 r0.w, r0.wwww, cb2[8].yyyy
mad o0.x, r0.x, l(2.000000), r0.w
mul r0.x, r1.x, r2.z
mul o1.xyzw, r0.zzzx, v1.xyzw
mov o0.y, r0.y
mov o0.zw, l(0,0,0,1.000000)
mov o2.xy, v2.xyxx
ret
// Approximately 1261 instruction slots used

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