//DMC2 shadows VS (update).
// ---- Created with 3Dmigoto v1.3.7 on Mon Apr 02 12:24:14 2018

cbuffer VS_CONSTANT_BUFFER : register(b0)
{
  float4x4 mOTP : packoffset(c0);
  int b_tc0 : packoffset(c4);
  int b_tc1 : packoffset(c4.y);
  int b_vc0 : packoffset(c4.z);
  int b_useVtxAlpha : packoffset(c4.w);
  int b_compressedNormals : packoffset(c5);
  int b_tex_off : packoffset(c5.y);
  int b_calcFog : packoffset(c5.z);
  int b_useFixedFog : packoffset(c5.w);
  float4 vFogConstants : packoffset(c6);
  float4 vFogColors : packoffset(c7);
  float4 vTexCoordOffsetAndScale : packoffset(c8);
}


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


void main(
  float3 v0 : POSITION0,
  float4 v1 : COLOR0,
  float4 v2 : COLOR1,
  out float4 o0 : SV_POSITION0,
  out float4 o1 : COLOR0,
  out float4 o2 : TEXCOORD0,
  out float4 o3 : TEXCOORD1,
  out float4 o4 : TEXCOORD2)
{
  float4 r0,r1,r2,r3,r4,r5,r6,r10;
  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));
  float4 iniparams7 = IniParams.Load(int2(7,0));
  
  r0.xyz = v0.xyz;
  r0.w = 1;
  
  //r1.xyzw = mOTP._m00_m10_m20_m30 * v0.xxxx;
  //r2.xyzw = mOTP._m01_m11_m21_m31 * v0.yyyy;
  //r1.xyzw = r2.xyzw + r1.xyzw;
  //r2.xyzw = mOTP._m02_m12_m22_m32 * v0.zzzz;
  //r1.xyzw = r2.xyzw + r1.xyzw;
  //r2.xyzw = mOTP._m03_m13_m23_m33 * r0.wwww;
  //r1.xyzw = r2.xyzw + r1.xyzw;
  
  if (r0.z>0.0001 || r0.z<-0.0001) {
    v0.x+=stereo.x*(1-stereo.y*(1-r0.z)*-iniparams7.z);
  }
  
  r1.xyzw = mOTP._m00_m10_m20_m30 * v0.xxxx;
  r2.xyzw = mOTP._m01_m11_m21_m31 * v0.yyyy;
  r1.xyzw = r2.xyzw + r1.xyzw;
  r2.xyzw = mOTP._m02_m12_m22_m32 * v0.zzzz;
  r1.xyzw = r2.xyzw + r1.xyzw;
  r2.xyzw = mOTP._m03_m13_m23_m33 * r0.wwww;
  r1.xyzw = r2.xyzw + r1.xyzw;
  r0.w = 1;
  r2.xyz = v1.xyz;
  r2.w = cmp(0 != b_useVtxAlpha);
  if (r2.w != 0) {
    r0.w = 1.9921875 * v1.w;
  }
  r2.w = 1 / r1.w;
  r3.xy = r2.ww * r1.xy;
  r3.xy = float2(1,1) + r3.xy;
  r3.xy = float2(0.5,0.5) * r3.xy;
  r3.zw = float2(0,0);
  r4.x = 0;
  r1.y = -r1.y;
  r4.y = cmp(0 != b_calcFog);
  if (r4.y != 0) {
    r4.y = cmp(0 < r1.w);
    r2.w = vFogConstants.y * r2.w;
    r2.w = vFogConstants.x + r2.w;
    r2.w = r2.w / 255;
    r2.w = max(0, r2.w);
    r2.w = min(1, r2.w);
    r5.w = r4.y ? r2.w : 1;
    r5.xyz = vFogColors.xyz;
  } else {
    r2.w = cmp(0 != b_useFixedFog);
    if (r2.w != 0) {
      r6.xyzw = max(float4(0,0,0,0), v2.xyzw);
      r5.xyzw = min(float4(1,1,1,1), r6.xyzw);
    } else {
      r5.w = 1;
      r5.xyz = float3(0,0,0);
    }
  }
  o0.xzw = r1.xzw;
  o0.y = r1.y;
  if (r0.z>0.0001 || r0.z<-0.0001)
  {
	//o0.x+=stereo.x;
	//r10.z=r0.z*10-9;
	////General.
	////o0.x-=stereo.x*(1-r10.z)*stereo.y*iniparams1.x*-0.1;
	////Specific value.
	//o0.x-=stereo.x*(1-r10.z)*stereo.y*iniparams7.z*-0.1;
  }
  else
  {
	o0.x+=stereo.x*iniparams.x;
	o0.x=o0.x*iniparams.y;
  }
  
  o1.xyz = r2.xyz;
  o1.w = r0.w;
  o2.xy = r3.xy;
  o2.zw = r3.zw;
  o3.x = r4.x;
  o3.yzw = r0.xyz;
  o4.xyzw = r5.xyzw;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
//
//   using 3Dmigoto v1.3.7 on Mon Apr 02 12:24:14 2018
//
//
// Buffer Definitions:
//
// cbuffer VS_CONSTANT_BUFFER
// {
//
//   float4x4 mOTP;                     // Offset:    0 Size:    64
//   int b_tc0;                         // Offset:   64 Size:     4 [unused]
//   int b_tc1;                         // Offset:   68 Size:     4 [unused]
//   int b_vc0;                         // Offset:   72 Size:     4 [unused]
//   int b_useVtxAlpha;                 // Offset:   76 Size:     4
//   int b_compressedNormals;           // Offset:   80 Size:     4 [unused]
//   int b_tex_off;                     // Offset:   84 Size:     4 [unused]
//   int b_calcFog;                     // Offset:   88 Size:     4
//   int b_useFixedFog;                 // Offset:   92 Size:     4
//   float4 vFogConstants;              // Offset:   96 Size:    16
//   float4 vFogColors;                 // Offset:  112 Size:    16
//   float4 vTexCoordOffsetAndScale;    // Offset:  128 Size:    16 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// VS_CONSTANT_BUFFER                cbuffer      NA          NA    0        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// POSITION                 0   xyz         0     NONE   float   xyz
// COLOR                    0   xyzw        1     NONE   float   xyzw
// COLOR                    1   xyzw        2     NONE   float   xyzw
//
//
// 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   xyzw        2     NONE   float   xyzw
// TEXCOORD                 1   xyzw        3     NONE   float   xyzw
// TEXCOORD                 2   xyzw        4     NONE   float   xyzw
//
vs_5_0
dcl_globalFlags refactoringAllowed | skipOptimization
dcl_constantbuffer cb0[8], immediateIndexed
dcl_input v0.xyz
dcl_input v1.xyzw
dcl_input v2.xyzw
dcl_output_siv o0.xyzw, position
dcl_output o1.xyzw
dcl_output o2.xyzw
dcl_output o3.xyzw
dcl_output o4.xyzw
dcl_temps 7
//
// Initial variable locations:
//   v0.x <- vi.Pos.x; v0.y <- vi.Pos.y; v0.z <- vi.Pos.z;
//   v1.x <- vi.Color.x; v1.y <- vi.Color.y; v1.z <- vi.Color.z; v1.w <- vi.Color.w;
//   v2.x <- vi.FogColors_Amount.x; v2.y <- vi.FogColors_Amount.y; v2.z <- vi.FogColors_Amount.z; v2.w <- vi.FogColors_Amount.w;
//   o4.x <- <main return value>.FogColors__Amount.x; o4.y <- <main return value>.FogColors__Amount.y; o4.z <- <main return value>.FogColors__Amount.z; o4.w <- <main return value>.FogColors__Amount.w;
//   o3.x <- <main return value>.NormalZ__ObjPosXYZ.x; o3.y <- <main return value>.NormalZ__ObjPosXYZ.y; o3.z <- <main return value>.NormalZ__ObjPosXYZ.z; o3.w <- <main return value>.NormalZ__ObjPosXYZ.w;
//   o2.x <- <main return value>.TexCoords_or_ScreenPos__NormalXY.x; o2.y <- <main return value>.TexCoords_or_ScreenPos__NormalXY.y; o2.z <- <main return value>.TexCoords_or_ScreenPos__NormalXY.z; o2.w <- <main return value>.TexCoords_or_ScreenPos__NormalXY.w;
//   o1.x <- <main return value>.Color.x; o1.y <- <main return value>.Color.y; o1.z <- <main return value>.Color.z; o1.w <- <main return value>.Color.w;
//   o0.x <- <main return value>.Pos.x; o0.y <- <main return value>.Pos.y; o0.z <- <main return value>.Pos.z; o0.w <- <main return value>.Pos.w
//
#line 29 "C:\dev\dmc\dmc2\code\dmc2\source\common\Shaders\hlsl\VS\V00040003.hlsl"
mov r0.xyz, v0.xyzx  // r0.x <- vo.NormalZ__ObjPosXYZ.y; r0.y <- vo.NormalZ__ObjPosXYZ.z; r0.z <- vo.NormalZ__ObjPosXYZ.w
itof r0.w, l(1)
mul r1.xyzw, v0.xxxx, cb0[0].xyzw
mul r2.xyzw, v0.yyyy, cb0[1].xyzw
add r1.xyzw, r1.xyzw, r2.xyzw
mul r2.xyzw, v0.zzzz, cb0[2].xyzw
add r1.xyzw, r1.xyzw, r2.xyzw
mul r2.xyzw, r0.wwww, cb0[3].xyzw
add r1.xyzw, r1.xyzw, r2.xyzw  // r1.x <- vo.Pos.x; r1.y <- vo.Pos.y; r1.z <- vo.Pos.z; r1.w <- vo.Pos.w
mov r0.w, l(1.000000)  // r0.w <- vo.Color.w
mov r2.xyz, v1.xyzx  // r2.x <- vo.Color.x; r2.y <- vo.Color.y; r2.z <- vo.Color.z
ine r2.w, l(0, 0, 0, 0), cb0[4].w
if_nz r2.w

#line 41
  mul r0.w, v1.w, l(1.992188)
endif

#line 45
div r2.w, l(1.000000), r1.w  // r2.w <- rhw

#line 48
mul r3.xy, r1.xyxx, r2.wwww
add r3.xy, r3.xyxx, l(1.000000, 1.000000, 0.000000, 0.000000)
mul r3.xy, r3.xyxx, l(0.500000, 0.500000, 0.000000, 0.000000)  // r3.x <- vo.TexCoords_or_ScreenPos__NormalXY.x; r3.y <- vo.TexCoords_or_ScreenPos__NormalXY.y
mov r3.zw, l(0,0,0,0)  // r3.z <- vo.TexCoords_or_ScreenPos__NormalXY.z; r3.w <- vo.TexCoords_or_ScreenPos__NormalXY.w
mov r4.x, l(0)  // r4.x <- vo.NormalZ__ObjPosXYZ.x

#line 55
mov r1.y, -r1.y

#line 58
ine r4.y, l(0, 0, 0, 0), cb0[5].z
if_nz r4.y

#line 62
  lt r4.y, l(0.000000), r1.w
  mul r2.w, r2.w, cb0[6].y
  add r2.w, r2.w, cb0[6].x
  div r2.w, r2.w, l(255.000000)
  max r2.w, r2.w, l(0.000000)
  min r2.w, r2.w, l(1.000000)
  movc r5.w, r4.y, r2.w, l(1.000000)  // r5.w <- vo.FogColors__Amount.w
  mov r5.xyz, cb0[7].xyzx  // r5.x <- vo.FogColors__Amount.x; r5.y <- vo.FogColors__Amount.y; r5.z <- vo.FogColors__Amount.z
else   // Prior locations: r2.w <- rhw
  ine r2.w, l(0, 0, 0, 0), cb0[5].w
  if_nz r2.w
    max r6.xyzw, v2.xyzw, l(0.000000, 0.000000, 0.000000, 0.000000)
    min r5.xyzw, r6.xyzw, l(1.000000, 1.000000, 1.000000, 1.000000)  // r5.w <- vo.FogColors__Amount.w; r5.x <- vo.FogColors__Amount.x; r5.y <- vo.FogColors__Amount.y; r5.z <- vo.FogColors__Amount.z
  else

#line 71
    mov r5.w, l(1.000000)  // r5.w <- vo.FogColors__Amount.w
    mov r5.xyz, l(0,0,0,0)  // r5.x <- vo.FogColors__Amount.x; r5.y <- vo.FogColors__Amount.y; r5.z <- vo.FogColors__Amount.z
  endif
endif

#line 76
mov o0.xzw, r1.xxzw
mov o0.y, r1.y
mov o1.xyz, r2.xyzx
mov o1.w, r0.w
mov o2.xy, r3.xyxx
mov o2.zw, r3.zzzw
mov o3.x, r4.x
mov o3.yzw, r0.xxyz
mov o4.xyzw, r5.xyzw
ret
// Approximately 52 instruction slots used

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