//Specular VS 2. Characters.
// ---- Created with 3Dmigoto v1.3.16 on Fri Sep 02 19:35:43 2022

cbuffer perMaterialBuffer : register(b0)
{
  float4 g_fogColor : packoffset(c0);
  float4 g_fogParam : packoffset(c1);
  float4 g_ambientColor : packoffset(c2);
  float4 g_lightColor : packoffset(c3);
  float4 g_lightDirection : packoffset(c4);
  float3 g_pointLightPos0 : packoffset(c5);
  float3 g_pointLightColor0 : packoffset(c6);
  float4 g_pointLightParam0 : packoffset(c7);
  float3 g_pointLightPos1 : packoffset(c8);
  float3 g_pointLightColor1 : packoffset(c9);
  float4 g_pointLightParam1 : packoffset(c10);
  float3 g_pointLightPos2 : packoffset(c11);
  float3 g_pointLightColor2 : packoffset(c12);
  float4 g_pointLightParam2 : packoffset(c13);
  float3 g_pointLightPos3 : packoffset(c14);
  float3 g_pointLightColor3 : packoffset(c15);
  float4 g_pointLightParam3 : packoffset(c16);
  row_major float4x4 g_matWorldViewProj : packoffset(c17);
  float4 g_commonParam : packoffset(c21);
  float4 g_lightingParam : packoffset(c22);
  float4 g_msParam0 : packoffset(c23);
  float4 g_specularParam : packoffset(c24);
  float4 g_hatchingParam : packoffset(c25);
  float4 g_outline0Param : packoffset(c26);
  float4 g_outemiParam : packoffset(c27);
  float4 g_waterParam0 : packoffset(c28);
  float4 g_waterParam1 : packoffset(c29);
  row_major float4x4 g_matWorldInvTrans : packoffset(c30);
  float4 g_uvOffset0 : packoffset(c34);
  float3 g_eyePos : packoffset(c35);
  float4 g_ScreenToUV : packoffset(c36);
  float4 g_outlineParam : packoffset(c37);
  float4 g_cparaColor1 : packoffset(c38);
  row_major float4x4 g_matWorld : packoffset(c39);
}

//cbuffer perMaterialBuffer : register(b13)
//{
//  float4 ng_commonParam : packoffset(c0);
//  float4 ng_fogColor : packoffset(c1);
//  float4 ng_fogParam : packoffset(c2);
//  float4 ng_ambientColor : packoffset(c3);
//  row_major float4x4 ng_matWorldViewProj : packoffset(c4);
//  row_major float4x4 ng_matWorld : packoffset(c8);
//  row_major float4x4 ng_matWorldInvTrans : packoffset(c12);
//  float4 ng_eyePos : packoffset(c16);
//  float4 ng_uvOffset0 : packoffset(c17);
//  float4 ng_uvOffset1 : packoffset(c18);
//  float4 ng_waterColor : packoffset(c19);
//  float4 ng_waterParam : packoffset(c20);
//}

cbuffer perMaterialBuffer : register(b13)
{
  float4 ng_commonParam : packoffset(c0);
  float4 ng_fogColor : packoffset(c1);
  float4 ng_fogParam : packoffset(c2);
  float4 ng_ambientColor : packoffset(c3);
  float3 ng_pointLightPos0 : packoffset(c4);
  float3 ng_pointLightColor0 : packoffset(c5);
  float4 ng_pointLightParam0 : packoffset(c6);
  float3 ng_pointLightPos1 : packoffset(c7);
  float3 ng_pointLightColor1 : packoffset(c8);
  float4 ng_pointLightParam1 : packoffset(c9);
  float3 ng_pointLightPos2 : packoffset(c10);
  float3 ng_pointLightColor2 : packoffset(c11);
  float4 ng_pointLightParam2 : packoffset(c12);
  float3 ng_pointLightPos3 : packoffset(c13);
  float3 ng_pointLightColor3 : packoffset(c14);
  float4 ng_pointLightParam3 : packoffset(c15);
  row_major float4x4 ng_matWorldViewProj : packoffset(c16);
  float4 ng_uvOffset0 : packoffset(c20);
  float4 ng_uvOffset1 : packoffset(c21);
  float4 ng_blendRate : packoffset(c22);
  float4 ng_blendType : packoffset(c23);
  float4 ng_multColor : packoffset(c24);
  row_major float4x4 ng_matWorld : packoffset(c25);
  row_major float4x4 ng_matWorldInvTrans : packoffset(c29);
  row_major float4x4 ng_matShadowProj0 : packoffset(c33);
  row_major float4x4 ng_matShadowProj1 : packoffset(c37);
  row_major float4x4 ng_matShadowProj2 : packoffset(c41);
  row_major float4x4 ng_matShadowProj3 : packoffset(c45);
  float4 ng_shadowParam : packoffset(c49);
  float4 ng_shadowColor : packoffset(c50);
}

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


void main(
  float4 v0 : POSITION0,
  float2 v1 : TEXCOORD0,
  float3 v2 : NORMAL0,
  float3 v3 : TANGENT0,
  float3 v4 : BINORMAL0,
  out float4 o0 : SV_Position0,
  out float4 o1 : TEXCOORD0,
  out float4 o2 : TEXCOORD1,
  out float4 o3 : TEXCOORD2,
  out float4 o4 : TEXCOORD3,
  out float4 o5 : TEXCOORD5,
  out float4 o6 : TEXCOORD6,
  out float3 o7 : TEXCOORD7,
  out float3 o8 : COLOR1,
  out float4 o9 : TEXCOORD8,
  out float4 o10 : TEXCOORD9,
  out float4 o11 : COLOR0,
  out float4 o12 : TEXCOORD4)
{
  float4 r0,r1,r2,r3,r4,r10;
  uint4 bitmask, uiDest;
  float4 fDest;
  
  float4 stereo = StereoParams.Load(0);
  //float fov = g_matWorldViewProj._m00*g_matWorldViewProj._m00+g_matWorldViewProj._m10*g_matWorldViewProj._m10+g_matWorldViewProj._m20*g_matWorldViewProj._m20;
  //r10.xyz = g_lightDirection.xyz;
  
  
  r0.xyzw = g_matWorldViewProj._m10_m11_m12_m13 * v0.yyyy;
  r0.xyzw = v0.xxxx * g_matWorldViewProj._m00_m01_m02_m03 + r0.xyzw;
  r0.xyzw = v0.zzzz * g_matWorldViewProj._m20_m21_m22_m23 + r0.xyzw;
  o0.xyzw = v0.wwww * g_matWorldViewProj._m30_m31_m32_m33 + r0.xyzw;
  o1.xyzw = float4(1,1,1,1);
  o2.xy = v1.xy;
  r0.xyz = g_matWorldInvTrans._m10_m11_m12 * -g_lightDirection.yyy;
  r0.xyz = -g_lightDirection.xxx * g_matWorldInvTrans._m00_m01_m02 + r0.xyz;
  r0.xyz = -g_lightDirection.zzz * g_matWorldInvTrans._m20_m21_m22 + r0.xyz;
  
  
  
  r0.w = dot(r0.xyz, r0.xyz);
  r0.w = rsqrt(r0.w);
  o3.xyz = r0.xyz * r0.www;
  
  
  
  r0.xyz = g_matWorld._m10_m11_m12 * v0.yyy;
  r0.xyz = v0.xxx * g_matWorld._m00_m01_m02 + r0.xyz;
  r0.xyz = v0.zzz * g_matWorld._m20_m21_m22 + r0.xyz;
  r0.xyz = v0.www * g_matWorld._m30_m31_m32 + r0.xyz;
  
  float fov = ng_matWorldViewProj._m00*ng_matWorldViewProj._m00+ng_matWorldViewProj._m10*ng_matWorldViewProj._m10+ng_matWorldViewProj._m20*ng_matWorldViewProj._m20;
  //r0.xyz-=stereo.x*stereo.y*ng_matWorldViewProj._m00_m10_m20/fov;
  
  r1.xyz = g_eyePos.xyz + -r0.xyz;
  
  
  
  r0.w = dot(r1.xyz, r1.xyz);
  r0.w = rsqrt(r0.w);
  o4.xyz = r1.xyz * r0.www;
  r1.xyz = g_matWorldInvTrans._m10_m11_m12 * v4.yyy;
  r1.xyz = v4.xxx * g_matWorldInvTrans._m00_m01_m02 + r1.xyz;
  o5.xyz = v4.zzz * g_matWorldInvTrans._m20_m21_m22 + r1.xyz;
  r1.xyz = g_matWorldInvTrans._m10_m11_m12 * v3.yyy;
  r1.xyz = v3.xxx * g_matWorldInvTrans._m00_m01_m02 + r1.xyz;
  o6.xyz = v3.zzz * g_matWorldInvTrans._m20_m21_m22 + r1.xyz;
  r1.xyz = g_matWorldInvTrans._m10_m11_m12 * v2.yyy;
  r1.xyz = v2.xxx * g_matWorldInvTrans._m00_m01_m02 + r1.xyz;
  r1.xyz = v2.zzz * g_matWorldInvTrans._m20_m21_m22 + r1.xyz;
  
  //r0.xyz+=stereo.x*stereo.y*g_matWorldViewProj._m00_m10_m20/fov;
  
  o7.xyz = r1.xyz;
  r0.w = dot(r1.xyz, r1.xyz);
  r0.w = rsqrt(r0.w);
  r1.xyz = r1.xyz * r0.www;
  r2.xyz = g_pointLightPos1.xyz + -r0.xyz;
  r0.w = dot(r2.xyz, r2.xyz);
  r0.w = sqrt(r0.w);
  r3.xyz = r2.xyz / r0.www;
  r1.w = cmp(0 < r0.w);
  r0.w = g_pointLightParam1.z + -r0.w;
  r0.w = saturate(g_pointLightParam1.w * r0.w);
  r2.xyz = r1.www ? r3.xyz : r2.xyz;
  r1.w = saturate(dot(r2.xyz, r1.xyz));
  r0.w = r1.w * r0.w;
  r2.xyz = g_pointLightParam1.xxx * g_pointLightColor1.xyz;
  r2.xyz = r2.xyz * r0.www;
  r3.xyz = g_pointLightPos0.xyz + -r0.xyz;
  r0.w = dot(r3.xyz, r3.xyz);
  r0.w = sqrt(r0.w);
  r4.xyz = r3.xyz / r0.www;
  r1.w = cmp(0 < r0.w);
  r0.w = g_pointLightParam0.z + -r0.w;
  r0.w = saturate(g_pointLightParam0.w * r0.w);
  r3.xyz = r1.www ? r4.xyz : r3.xyz;
  r1.w = saturate(dot(r3.xyz, r1.xyz));
  r0.w = r1.w * r0.w;
  r3.xyz = g_pointLightParam0.xxx * g_pointLightColor0.xyz;
  r2.xyz = r3.xyz * r0.www + r2.xyz;
  r3.xyz = g_pointLightPos2.xyz + -r0.xyz;
  r0.xyz = g_pointLightPos3.xyz + -r0.xyz;
  r0.w = dot(r3.xyz, r3.xyz);
  r0.w = sqrt(r0.w);
  r4.xyz = r3.xyz / r0.www;
  r1.w = cmp(0 < r0.w);
  r0.w = g_pointLightParam2.z + -r0.w;
  r0.w = saturate(g_pointLightParam2.w * r0.w);
  r3.xyz = r1.www ? r4.xyz : r3.xyz;
  r1.w = saturate(dot(r3.xyz, r1.xyz));
  r0.w = r1.w * r0.w;
  r3.xyz = g_pointLightParam2.xxx * g_pointLightColor2.xyz;
  r2.xyz = r3.xyz * r0.www + r2.xyz;
  r0.w = dot(r0.xyz, r0.xyz);
  r0.w = sqrt(r0.w);
  r3.xyz = r0.xyz / r0.www;
  r1.w = cmp(0 < r0.w);
  r0.w = g_pointLightParam3.z + -r0.w;
  r0.w = saturate(g_pointLightParam3.w * r0.w);
  r0.xyz = r1.www ? r3.xyz : r0.xyz;
  r0.x = saturate(dot(r0.xyz, r1.xyz));
  r0.x = r0.w * r0.x;
  r0.yzw = g_pointLightParam3.xxx * g_pointLightColor3.xyz;
  o8.xyz = r0.yzw * r0.xxx + r2.xyz;
  o9.xyz = g_fogColor.xyz;
  o9.w = g_fogParam.z;
  o10.xyz = g_cparaColor1.xyz;
  o10.w = g_outlineParam.z;
  o11.xyzw = g_commonParam.xyzw;
  r0.xyz = float3(-3,-2,-1) + g_outlineParam.xxx;
  r0.xyz = float3(1,1,1) + -abs(r0.xyz);
  o12.xyz = max(float3(0,0,0), r0.xyz);
  o12.w = g_outlineParam.y;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
//
//   using 3Dmigoto v1.3.16 on Fri Sep 02 19:35:43 2022
//
//
// Buffer Definitions:
//
// cbuffer perMaterialBuffer
// {
//
//   float4 g_fogColor;                 // Offset:    0 Size:    16
//   float4 g_fogParam;                 // Offset:   16 Size:    16
//   float4 g_ambientColor;             // Offset:   32 Size:    16 [unused]
//   float4 g_lightColor;               // Offset:   48 Size:    16 [unused]
//   float4 g_lightDirection;           // Offset:   64 Size:    16
//   float3 g_pointLightPos0;           // Offset:   80 Size:    12
//   float3 g_pointLightColor0;         // Offset:   96 Size:    12
//   float4 g_pointLightParam0;         // Offset:  112 Size:    16
//   float3 g_pointLightPos1;           // Offset:  128 Size:    12
//   float3 g_pointLightColor1;         // Offset:  144 Size:    12
//   float4 g_pointLightParam1;         // Offset:  160 Size:    16
//   float3 g_pointLightPos2;           // Offset:  176 Size:    12
//   float3 g_pointLightColor2;         // Offset:  192 Size:    12
//   float4 g_pointLightParam2;         // Offset:  208 Size:    16
//   float3 g_pointLightPos3;           // Offset:  224 Size:    12
//   float3 g_pointLightColor3;         // Offset:  240 Size:    12
//   float4 g_pointLightParam3;         // Offset:  256 Size:    16
//   row_major float4x4 g_matWorldViewProj;// Offset:  272 Size:    64
//   float4 g_commonParam;              // Offset:  336 Size:    16
//   float4 g_lightingParam;            // Offset:  352 Size:    16 [unused]
//   float4 g_msParam0;                 // Offset:  368 Size:    16 [unused]
//   float4 g_specularParam;            // Offset:  384 Size:    16 [unused]
//   float4 g_hatchingParam;            // Offset:  400 Size:    16 [unused]
//   float4 g_outline0Param;            // Offset:  416 Size:    16 [unused]
//   float4 g_outemiParam;              // Offset:  432 Size:    16 [unused]
//   float4 g_waterParam0;              // Offset:  448 Size:    16 [unused]
//   float4 g_waterParam1;              // Offset:  464 Size:    16 [unused]
//   row_major float4x4 g_matWorldInvTrans;// Offset:  480 Size:    64
//   float4 g_uvOffset0;                // Offset:  544 Size:    16 [unused]
//   float3 g_eyePos;                   // Offset:  560 Size:    12
//   float4 g_ScreenToUV;               // Offset:  576 Size:    16 [unused]
//   float4 g_outlineParam;             // Offset:  592 Size:    16
//   float4 g_cparaColor1;              // Offset:  608 Size:    16
//   row_major float4x4 g_matWorld;     // Offset:  624 Size:    64
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// perMaterialBuffer                 cbuffer      NA          NA    0        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// POSITION                 0   xyzw        0     NONE   float   xyzw
// TEXCOORD                 0   xy          1     NONE   float   xy
// NORMAL                   0   xyz         2     NONE   float   xyz
// TANGENT                  0   xyz         3     NONE   float   xyz
// BINORMAL                 0   xyz         4     NONE   float   xyz
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float   xyzw
// TEXCOORD                 0   xyzw        1     NONE   float   xyzw
// TEXCOORD                 1   xy          2     NONE   float   xy
// TEXCOORD                 2   xyz         3     NONE   float   xyz
// TEXCOORD                 3   xyz         4     NONE   float   xyz
// TEXCOORD                 5   xyz         5     NONE   float   xyz
// TEXCOORD                 6   xyz         6     NONE   float   xyz
// TEXCOORD                 7   xyz         7     NONE   float   xyz
// COLOR                    1   xyz         8     NONE   float   xyz
// TEXCOORD                 8   xyzw        9     NONE   float   xyzw
// TEXCOORD                 9   xyzw       10     NONE   float   xyzw
// COLOR                    0   xyzw       11     NONE   float   xyzw
// TEXCOORD                 4   xyzw       12     NONE   float   xyzw
//
vs_4_0
dcl_constantbuffer cb0[43], immediateIndexed
dcl_input v0.xyzw
dcl_input v1.xy
dcl_input v2.xyz
dcl_input v3.xyz
dcl_input v4.xyz
dcl_output_siv o0.xyzw, position
dcl_output o1.xyzw
dcl_output o2.xy
dcl_output o3.xyz
dcl_output o4.xyz
dcl_output o5.xyz
dcl_output o6.xyz
dcl_output o7.xyz
dcl_output o8.xyz
dcl_output o9.xyzw
dcl_output o10.xyzw
dcl_output o11.xyzw
dcl_output o12.xyzw
dcl_temps 5
mul r0.xyzw, v0.yyyy, cb0[18].xyzw
mad r0.xyzw, v0.xxxx, cb0[17].xyzw, r0.xyzw
mad r0.xyzw, v0.zzzz, cb0[19].xyzw, r0.xyzw
mad o0.xyzw, v0.wwww, cb0[20].xyzw, r0.xyzw
mov o1.xyzw, l(1.000000,1.000000,1.000000,1.000000)
mov o2.xy, v1.xyxx
mul r0.xyz, -cb0[4].yyyy, cb0[31].xyzx
mad r0.xyz, -cb0[4].xxxx, cb0[30].xyzx, r0.xyzx
mad r0.xyz, -cb0[4].zzzz, cb0[32].xyzx, r0.xyzx
dp3 r0.w, r0.xyzx, r0.xyzx
rsq r0.w, r0.w
mul o3.xyz, r0.wwww, r0.xyzx
mul r0.xyz, v0.yyyy, cb0[40].xyzx
mad r0.xyz, v0.xxxx, cb0[39].xyzx, r0.xyzx
mad r0.xyz, v0.zzzz, cb0[41].xyzx, r0.xyzx
mad r0.xyz, v0.wwww, cb0[42].xyzx, r0.xyzx
add r1.xyz, -r0.xyzx, cb0[35].xyzx
dp3 r0.w, r1.xyzx, r1.xyzx
rsq r0.w, r0.w
mul o4.xyz, r0.wwww, r1.xyzx
mul r1.xyz, v4.yyyy, cb0[31].xyzx
mad r1.xyz, v4.xxxx, cb0[30].xyzx, r1.xyzx
mad o5.xyz, v4.zzzz, cb0[32].xyzx, r1.xyzx
mul r1.xyz, v3.yyyy, cb0[31].xyzx
mad r1.xyz, v3.xxxx, cb0[30].xyzx, r1.xyzx
mad o6.xyz, v3.zzzz, cb0[32].xyzx, r1.xyzx
mul r1.xyz, v2.yyyy, cb0[31].xyzx
mad r1.xyz, v2.xxxx, cb0[30].xyzx, r1.xyzx
mad r1.xyz, v2.zzzz, cb0[32].xyzx, r1.xyzx
mov o7.xyz, r1.xyzx
dp3 r0.w, r1.xyzx, r1.xyzx
rsq r0.w, r0.w
mul r1.xyz, r0.wwww, r1.xyzx
add r2.xyz, -r0.xyzx, cb0[8].xyzx
dp3 r0.w, r2.xyzx, r2.xyzx
sqrt r0.w, r0.w
div r3.xyz, r2.xyzx, r0.wwww
lt r1.w, l(0.000000), r0.w
add r0.w, -r0.w, cb0[10].z
mul_sat r0.w, r0.w, cb0[10].w
movc r2.xyz, r1.wwww, r3.xyzx, r2.xyzx
dp3_sat r1.w, r2.xyzx, r1.xyzx
mul r0.w, r0.w, r1.w
mul r2.xyz, cb0[9].xyzx, cb0[10].xxxx
mul r2.xyz, r0.wwww, r2.xyzx
add r3.xyz, -r0.xyzx, cb0[5].xyzx
dp3 r0.w, r3.xyzx, r3.xyzx
sqrt r0.w, r0.w
div r4.xyz, r3.xyzx, r0.wwww
lt r1.w, l(0.000000), r0.w
add r0.w, -r0.w, cb0[7].z
mul_sat r0.w, r0.w, cb0[7].w
movc r3.xyz, r1.wwww, r4.xyzx, r3.xyzx
dp3_sat r1.w, r3.xyzx, r1.xyzx
mul r0.w, r0.w, r1.w
mul r3.xyz, cb0[6].xyzx, cb0[7].xxxx
mad r2.xyz, r3.xyzx, r0.wwww, r2.xyzx
add r3.xyz, -r0.xyzx, cb0[11].xyzx
add r0.xyz, -r0.xyzx, cb0[14].xyzx
dp3 r0.w, r3.xyzx, r3.xyzx
sqrt r0.w, r0.w
div r4.xyz, r3.xyzx, r0.wwww
lt r1.w, l(0.000000), r0.w
add r0.w, -r0.w, cb0[13].z
mul_sat r0.w, r0.w, cb0[13].w
movc r3.xyz, r1.wwww, r4.xyzx, r3.xyzx
dp3_sat r1.w, r3.xyzx, r1.xyzx
mul r0.w, r0.w, r1.w
mul r3.xyz, cb0[12].xyzx, cb0[13].xxxx
mad r2.xyz, r3.xyzx, r0.wwww, r2.xyzx
dp3 r0.w, r0.xyzx, r0.xyzx
sqrt r0.w, r0.w
div r3.xyz, r0.xyzx, r0.wwww
lt r1.w, l(0.000000), r0.w
add r0.w, -r0.w, cb0[16].z
mul_sat r0.w, r0.w, cb0[16].w
movc r0.xyz, r1.wwww, r3.xyzx, r0.xyzx
dp3_sat r0.x, r0.xyzx, r1.xyzx
mul r0.x, r0.x, r0.w
mul r0.yzw, cb0[15].xxyz, cb0[16].xxxx
mad o8.xyz, r0.yzwy, r0.xxxx, r2.xyzx
mov o9.xyz, cb0[0].xyzx
mov o9.w, cb0[1].z
mov o10.xyz, cb0[38].xyzx
mov o10.w, cb0[37].z
mov o11.xyzw, cb0[21].xyzw
add r0.xyz, cb0[37].xxxx, l(-3.000000, -2.000000, -1.000000, 0.000000)
add r0.xyz, -|r0.xyzx|, l(1.000000, 1.000000, 1.000000, 0.000000)
max o12.xyz, r0.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000)
mov o12.w, cb0[37].y
ret
// Approximately 91 instruction slots used

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