// HUD - enemy markers (correct depth)
// ---- Created with 3Dmigoto v1.2.32 on Mon Mar 07 22:20:26 2016

cbuffer CViewportShaderParameterProvider : register(b0)
{
  float4x4 InvProjectionMatrix : packoffset(c0);
  float4x4 InvViewMatrix : packoffset(c4);
  float4x4 ProjectionMatrix : packoffset(c8);
  float4x4 ViewMatrix : packoffset(c12);
  float4x4 ViewProjectionMatrix : packoffset(c16);
  float4x4 ViewRotProjectionMatrix : packoffset(c20);
  float4x4 ViewRotProjectionMatrix_Previous : packoffset(c24);
  float4 AmbientSHR : packoffset(c28);
  float4 AmbientSHG : packoffset(c29);
  float4 AmbientSHB : packoffset(c30);
  float4 CameraDistances : packoffset(c31);
  float4 CameraNearPlaneSize : packoffset(c32);
  float4 DepthScale : packoffset(c33);
  float4 DepthTextureScaleOffset : packoffset(c34);
  float4 FogParams : packoffset(c35);
  float4 FogSHB : packoffset(c36);
  float4 FogSHG : packoffset(c37);
  float4 FogSHR : packoffset(c38);
  float4 HeightFogParams : packoffset(c39);
  float4 ViewportSize : packoffset(c40);
  float3 ViewPoint : packoffset(c41);
  float3 CameraPosition : packoffset(c42);
  float3 CameraPosition_Previous : packoffset(c43);
  float3 CameraPositionFractions : packoffset(c44);
  float3 CameraPositionFractions_Previous : packoffset(c45);
  float3 CameraRight : packoffset(c46);
  float3 CameraUp : packoffset(c47);
  float3 CameraDirection : packoffset(c48);
  float3 EnvironmentMapColorOffset : packoffset(c49);
  float3 EnvironmentMapColorScale : packoffset(c50);
  float3 AmbientOcclusionRanges : packoffset(c51);
  float3 DepthTextureRcpSize : packoffset(c52);
  float2 MotionVectorOffsets : packoffset(c53);
  float2 DepthRangeCompression : packoffset(c53.z);
  float ShadowProjDepthMinValue : packoffset(c54);
  float DistanceScale : packoffset(c54.y);
  float WorldSpaceZOffset : packoffset(c54.z);
  float WorldSpaceZOffset_Previous : packoffset(c54.w);
  float CameraFOVDeg : packoffset(c55);
  float EffectsEmissiveEVBias : packoffset(c55.y);
  float ShadowCSMLastSliceIndex : packoffset(c55.z);
  float UseNormalization : packoffset(c55.w);
  float FogUndergroundColorScale : packoffset(c56);
}

cbuffer CScenePrimitiveParameterProvider : register(b1)
{
  float4x4 Transform : packoffset(c0);
  float4 BinkUVTransforms : packoffset(c4);
  float4 ColorAdd : packoffset(c5);
  float4 ColorAdjustment : packoffset(c6);
  float4 ColorMultiplier : packoffset(c7);
  float Desaturation : packoffset(c8);
  float HDRFactor : packoffset(c8.y);
  float OutputOnlyAlpha : packoffset(c8.z);
  float UseAlpha : packoffset(c8.w);
}



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


void main( 
  float4 v0 : position0,
  float4 v1 : color0,
  float2 v2 : texcoord0,
  out float4 o0 : SV_Position0,
  out float4 o1 : TEXCOORD0,
  out float4 o2 : TEXCOORD1)
{
  float4 r0,r1;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.x = dot(v0.xyzw, Transform._m00_m10_m20_m30);
  r0.y = dot(v0.xyzw, Transform._m01_m11_m21_m31);
  r0.z = dot(v0.xyzw, Transform._m02_m12_m22_m32);
  r1.xyz = -CameraPosition.xyz + r0.xyz;
  r0.w = dot(r1.xyz, r1.xyz);
  r0.w = rsqrt(r0.w);
  r1.xyz = r1.xyz * r0.www;
  r0.xyz = r1.xyz * WorldSpaceZOffset + r0.xyz;
  r0.xyz = -CameraPosition.xyz + r0.xyz;
  r0.w = 1;
  r1.x = dot(r0.xyzw, ViewRotProjectionMatrix._m00_m10_m20_m30);
  r1.y = dot(r0.xyzw, ViewRotProjectionMatrix._m01_m11_m21_m31);
  o0.xy = r1.xy;
  o2.xy = r1.xy;
  o0.z = dot(r0.xyzw, ViewRotProjectionMatrix._m02_m12_m22_m32);
  o0.w = dot(r0.xyzw, ViewRotProjectionMatrix._m03_m13_m23_m33);

float4 stereo = StereoParams.Load(0);
o0.x += stereo.x * (o0.w - stereo.y);

  o1.xyzw = v1.xyzw;
  o2.zw = v2.xy;
  return;
}
