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

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

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


Texture2D<float4> StereoParams : register(t125);
Texture1D<float4> IniParams : register(t120);

void main( 
  float4 v0 : POSITION0,
  float3 v1 : NORMAL0,
  float2 v2 : TEXCOORD0,
  out float4 o0 : SV_POSITION0,
  out float4 o1 : TEXCOORD0,
  out float4 o2 : TEXCOORD1,
  out float2 o3 : TEXCOORD2)
{
  float4 r0,r1;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.xyzw = cb2[1].xyzw * v0.yyyy;
  r0.xyzw = cb2[0].xyzw * v0.xxxx + r0.xyzw;
  r0.xyzw = cb2[2].xyzw * v0.zzzz + r0.xyzw;
  r0.xyzw = cb2[3].xywz * v0.wwww + r0.xywz;
  o0.xyzw = r0.xywz;
float4 stereo = StereoParams.Load(0);
r0.x += stereo.x*(r0.w - stereo.y);
  r1.xyz = cb2[1].xyw * v1.yyy;
  r1.xyz = cb2[0].xyw * v1.xxx + r1.xyz;
  r1.xyz = cb2[2].xyw * v1.zzz + r1.xyz;
  r1.xyz = cb2[3].xyw + r1.xyz;
  r1.w = -r1.y;
  r1.xy = r1.xw / r1.zz;
  r1.zw = float2(1,-1) * r0.xy;
  r1.zw = r1.zw / r0.zz;
  r1.xy = r1.zw + -r1.xy;
  r1.xy = cb0[11].yy * r1.xy;
  r1.z = dot(r1.xy, r1.xy);
  r1.z = sqrt(r1.z);
  r1.w = r1.z < cb0[11].z;
  r1.w = r1.w ? 0 : r1.z;
  r1.xy = r1.xy / r1.zz;
  o1.xy = r1.xy * float2(0.5,0.5) + float2(0.5,0.5);
  r1.x = min(cb0[11].w, r1.w);
  r1.x = -cb0[11].z + r1.x;
  r1.x = max(0, r1.x);
  o1.z = cb0[12].x * r1.x;
  o1.w = cb0[11].x;
  r1.x = 0 < cb1[5].x;
  r0.y = r1.x ? -r0.y : r0.y;
  o2.zw = r0.wz;
  r1.xz = float2(0.5,0.5);
  r1.y = cb1[5].x;
  r0.xyz = r1.xyz * r0.xyz;
  r0.w = 0.5 * r0.y;
  o2.xy = r0.xw + r0.zz;
  o3.xy = v2.xy * cb0[13].xy + cb0[13].zw;
  return;
}