//Geometry VS.
// ---- Created with 3Dmigoto v1.3.11 on Thu Aug 09 17:21:41 2018

cbuffer _Globals : register(b0)
{
  float4 uClipPlane0 : packoffset(c0);
  float4 uClipPlane1 : packoffset(c1);
  float4 uClipPlane2 : packoffset(c2);
  float4 uClipPlane3 : packoffset(c3);
  int uReflective : packoffset(c4);
  float3 uLightDirection : packoffset(c4.y);
  float4 uLightDirectionColor : packoffset(c5);
}

cbuffer RenderView : register(b1)
{
  float4x4 uProjectionMatrix : packoffset(c0);
  float4x4 uModelViewMatrix : packoffset(c4);
  float4x4 uInverseProjectionMatrix : packoffset(c8);
  float4x4 uPrevProjection : packoffset(c12);
  float4x4 uInverseModelViewMatrix : packoffset(c16);
  float4x4 uPrevModelView : packoffset(c20);
  float4x4 uRotationMatrix : packoffset(c24);
  float4x4 uInverseRotationMatrix : packoffset(c28);
  float4x4 uTransposedRotationMatrix : packoffset(c32);
  float4x4 uClipMatrix : packoffset(c36);
  float4x4 uInverseClipMatrix : packoffset(c40);
  float4x4 uPrevClipMatrix : packoffset(c44);
  float4x4 uNormalMatrix : packoffset(c48);
  float3 uViewOrigin : packoffset(c52);
  float uViewWidth : packoffset(c52.w);
  float uViewHeight : packoffset(c53);
  float uZNear : packoffset(c53.y);
  float uZFar : packoffset(c53.z);
  float2 uInvFocalCoords : packoffset(c54);
  float4 uFrustumCorners[4] : packoffset(c55);
}



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


void main(
  float3 v0 : ATTRIB0,
  float2 v1 : ATTRIB1,
  float3 v2 : ATTRIB3,
  float4 v3 : ATTRIB2,
  out float4 o0 : SV_POSITION0,
  out float2 o1 : TEXCOORD0,
  out float4 o2 : COLOR0,
  out float4 o3 : DIRCOLOR0,
  out float3 o4 : POSITION0,
  out float o5 : SV_ClipDistance0)
{
  float4 r0,r1,r2;
  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));
  
  r0.xyzw = uModelViewMatrix._m01_m11_m21_m31 * v0.yyyy;
  r0.xyzw = uModelViewMatrix._m00_m10_m20_m30 * v0.xxxx + r0.xyzw;
  r0.xyzw = uModelViewMatrix._m02_m12_m22_m32 * v0.zzzz + r0.xyzw;
  r0.xyzw = uModelViewMatrix._m03_m13_m23_m33 + r0.xyzw;
  r1.xyzw = uProjectionMatrix._m01_m11_m21_m31 * r0.yyyy;
  r1.xyzw = uProjectionMatrix._m00_m10_m20_m30 * r0.xxxx + r1.xyzw;
  r1.xyzw = uProjectionMatrix._m02_m12_m22_m32 * r0.zzzz + r1.xyzw;
  o0.xyzw = uProjectionMatrix._m03_m13_m23_m33 * r0.wwww + r1.xyzw;
  o1.xy = v1.xy;
  o2.xyzw = v3.xyzw;
  r1.xyz = uNormalMatrix._m11_m11_m11 * uModelViewMatrix._m01_m11_m21;
  r1.xyz = uModelViewMatrix._m00_m10_m20 * uNormalMatrix._m01_m01_m01 + r1.xyz;
  r1.xyz = uModelViewMatrix._m02_m12_m22 * uNormalMatrix._m21_m21_m21 + r1.xyz;
  r1.xyz = uModelViewMatrix._m03_m13_m23 * uNormalMatrix._m31_m31_m31 + r1.xyz;
  r1.xyz = v2.yyy * r1.xyz;
  r2.xyz = uNormalMatrix._m10_m10_m10 * uModelViewMatrix._m01_m11_m21;
  r2.xyz = uModelViewMatrix._m00_m10_m20 * uNormalMatrix._m00_m00_m00 + r2.xyz;
  r2.xyz = uModelViewMatrix._m02_m12_m22 * uNormalMatrix._m20_m20_m20 + r2.xyz;
  r2.xyz = uModelViewMatrix._m03_m13_m23 * uNormalMatrix._m30_m30_m30 + r2.xyz;
  r1.xyz = r2.xyz * v2.xxx + r1.xyz;
  r2.xyz = uNormalMatrix._m12_m12_m12 * uModelViewMatrix._m01_m11_m21;
  r2.xyz = uModelViewMatrix._m00_m10_m20 * uNormalMatrix._m02_m02_m02 + r2.xyz;
  r2.xyz = uModelViewMatrix._m02_m12_m22 * uNormalMatrix._m22_m22_m22 + r2.xyz;
  r2.xyz = uModelViewMatrix._m03_m13_m23 * uNormalMatrix._m32_m32_m32 + r2.xyz;
  r1.xyz = r2.xyz * v2.zzz + r1.xyz;
  r1.w = dot(r1.xyz, r1.xyz);
  r1.w = rsqrt(r1.w);
  r1.xyz = r1.xyz * r1.www;
  r1.x = dot(r1.xyz, uLightDirection.xyz);
  r1.x = max(0, r1.x);
  o3.xyzw = uLightDirectionColor.xyzw * r1.xxxx;
  o4.xyz = r0.xyz;
  o5.x = dot(r0.xyzw, uClipPlane0.xyzw);
  //if (iniparams.z>=1 && (iniparams3.w!=2 || iniparams.z==4))
  if (iniparams.z>=1 && iniparams3.w==2)
  {
	o0.x-=stereo.x*stereo.y*iniparams1.z;
	o4.x-=stereo.x*stereo.y*iniparams1.z;
  }
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.18773
//
//   using 3Dmigoto v1.3.11 on Thu Aug 09 17:21:41 2018
//
//
// Buffer Definitions:
//
// cbuffer $Globals
// {
//
//   float4 uClipPlane0;                // Offset:    0 Size:    16
//   float4 uClipPlane1;                // Offset:   16 Size:    16 [unused]
//   float4 uClipPlane2;                // Offset:   32 Size:    16 [unused]
//   float4 uClipPlane3;                // Offset:   48 Size:    16 [unused]
//   int uReflective;                   // Offset:   64 Size:     4 [unused]
//   float3 uLightDirection;            // Offset:   68 Size:    12
//   float4 uLightDirectionColor;       // Offset:   80 Size:    16
//
// }
//
// cbuffer RenderView
// {
//
//   float4x4 uProjectionMatrix;        // Offset:    0 Size:    64
//   float4x4 uModelViewMatrix;         // Offset:   64 Size:    64
//   float4x4 uInverseProjectionMatrix; // Offset:  128 Size:    64 [unused]
//   float4x4 uPrevProjection;          // Offset:  192 Size:    64 [unused]
//   float4x4 uInverseModelViewMatrix;  // Offset:  256 Size:    64 [unused]
//   float4x4 uPrevModelView;           // Offset:  320 Size:    64 [unused]
//   float4x4 uRotationMatrix;          // Offset:  384 Size:    64 [unused]
//   float4x4 uInverseRotationMatrix;   // Offset:  448 Size:    64 [unused]
//   float4x4 uTransposedRotationMatrix;// Offset:  512 Size:    64 [unused]
//   float4x4 uClipMatrix;              // Offset:  576 Size:    64 [unused]
//   float4x4 uInverseClipMatrix;       // Offset:  640 Size:    64 [unused]
//   float4x4 uPrevClipMatrix;          // Offset:  704 Size:    64 [unused]
//   float4x4 uNormalMatrix;            // Offset:  768 Size:    64
//   float3 uViewOrigin;                // Offset:  832 Size:    12 [unused]
//   float uViewWidth;                  // Offset:  844 Size:     4 [unused]
//   float uViewHeight;                 // Offset:  848 Size:     4 [unused]
//   float uZNear;                      // Offset:  852 Size:     4 [unused]
//   float uZFar;                       // Offset:  856 Size:     4 [unused]
//   float2 uInvFocalCoords;            // Offset:  864 Size:     8 [unused]
//   float4 uFrustumCorners[4];         // Offset:  880 Size:    64 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// $Globals                          cbuffer      NA          NA    0        1
// RenderView                        cbuffer      NA          NA    1        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// ATTRIB                   0   xyz         0     NONE   float   xyz
// ATTRIB                   1   xy          1     NONE   float   xy
// ATTRIB                   3   xyz         2     NONE   float   xyz
// ATTRIB                   2   xyzw        3     NONE   float   xyzw
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION              0   xyzw        0      POS   float   xyzw
// TEXCOORD                 0   xy          1     NONE   float   xy
// COLOR                    0   xyzw        2     NONE   float   xyzw
// DIRCOLOR                 0   xyzw        3     NONE   float   xyzw
// POSITION                 0   xyz         4     NONE   float   xyz
// SV_ClipDistance          0   x           5  CLIPDST   float   x
//
vs_4_0
dcl_constantbuffer cb0[6], immediateIndexed
dcl_constantbuffer cb1[51], immediateIndexed
dcl_input v0.xyz
dcl_input v1.xy
dcl_input v2.xyz
dcl_input v3.xyzw
dcl_output_siv o0.xyzw, position
dcl_output o1.xy
dcl_output o2.xyzw
dcl_output o3.xyzw
dcl_output o4.xyz
dcl_output_siv o5.x, clip_distance
dcl_temps 3
mul r0.xyzw, v0.yyyy, cb1[5].xyzw
mad r0.xyzw, cb1[4].xyzw, v0.xxxx, r0.xyzw
mad r0.xyzw, cb1[6].xyzw, v0.zzzz, r0.xyzw
add r0.xyzw, r0.xyzw, cb1[7].xyzw
mul r1.xyzw, r0.yyyy, cb1[1].xyzw
mad r1.xyzw, cb1[0].xyzw, r0.xxxx, r1.xyzw
mad r1.xyzw, cb1[2].xyzw, r0.zzzz, r1.xyzw
mad o0.xyzw, cb1[3].xyzw, r0.wwww, r1.xyzw
mov o1.xy, v1.xyxx
mov o2.xyzw, v3.xyzw
mul r1.xyz, cb1[5].xyzx, cb1[49].yyyy
mad r1.xyz, cb1[4].xyzx, cb1[49].xxxx, r1.xyzx
mad r1.xyz, cb1[6].xyzx, cb1[49].zzzz, r1.xyzx
mad r1.xyz, cb1[7].xyzx, cb1[49].wwww, r1.xyzx
mul r1.xyz, r1.xyzx, v2.yyyy
mul r2.xyz, cb1[5].xyzx, cb1[48].yyyy
mad r2.xyz, cb1[4].xyzx, cb1[48].xxxx, r2.xyzx
mad r2.xyz, cb1[6].xyzx, cb1[48].zzzz, r2.xyzx
mad r2.xyz, cb1[7].xyzx, cb1[48].wwww, r2.xyzx
mad r1.xyz, r2.xyzx, v2.xxxx, r1.xyzx
mul r2.xyz, cb1[5].xyzx, cb1[50].yyyy
mad r2.xyz, cb1[4].xyzx, cb1[50].xxxx, r2.xyzx
mad r2.xyz, cb1[6].xyzx, cb1[50].zzzz, r2.xyzx
mad r2.xyz, cb1[7].xyzx, cb1[50].wwww, r2.xyzx
mad r1.xyz, r2.xyzx, v2.zzzz, r1.xyzx
dp3 r1.w, r1.xyzx, r1.xyzx
rsq r1.w, r1.w
mul r1.xyz, r1.wwww, r1.xyzx
dp3 r1.x, r1.xyzx, cb0[4].yzwy
max r1.x, r1.x, l(0.000000)
mul o3.xyzw, r1.xxxx, cb0[5].xyzw
mov o4.xyz, r0.xyzx
dp4 o5.x, r0.xyzw, cb0[0].xyzw
ret
// Approximately 34 instruction slots used

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