//shadows matrix fix
// ---- Created with 3Dmigoto v0.6.164 on Fri Oct 24 01:36:37 2025
cbuffer cb2 : register(b2)
{
  float4 cb2[15];
}

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

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

cbuffer cb13 : register(b13)
{
  float4 cb13[10];
}




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

void main(
  float3 v0 : POSITION0,
  float3 v1 : NORMAL0,
  float4 v2 : TANGENT0,
  uint v3 : SV_InstanceID0,
  out float4 o0 : SV_POSITION0,
  out uint o1 : CUSTOM_INSTANCE_ID0,
  out float4 o2 : TEXCOORD0,
  out float4 o3 : TEXCOORD1,
  out float4 o4 : TEXCOORD2,
  out float3 o5 : TEXCOORD3)
{
// Needs manual fix for instruction:
// unknown dcl_: dcl_input_sgv v3.x, instance_id
  float4 r0,r1;
  uint4 bitmask, uiDest;
  float4 fDest;
  
  float4 s = StereoParams.Load(0);
  float4 testeo = IniParams.Load(int2(90,0));
  float fov = rsqrt(cb0[61].x * cb0[61].x + cb0[62].x * cb0[62].x + cb0[63].x * cb0[63].x);

  r0.x = (int)v3.x + asint(cb1[0].x);
  r0.x = (uint)r0.x << 3;
  r0.yzw = cb2[r0.x+1].xyz * v0.yyy;
  r0.yzw = cb2[r0.x+0].xyz * v0.xxx + r0.yzw;
  r0.yzw = cb2[r0.x+2].xyz * v0.zzz + r0.yzw;
  r0.yzw = cb2[r0.x+3].xyz + r0.yzw;
  r1.xyzw = cb0[62].xyzw * r0.zzzz;
  r1.xyzw = cb0[61].xyzw * r0.yyyy + r1.xyzw;
  r1.xyzw = cb0[63].xyzw * r0.wwww + r1.xyzw;
  o0.xyzw = cb0[64].xyzw + r1.xyzw;
  o1.x = v3.x;
  o2.xyz = r0.yzw;
    
  // ===== FIX ESTÉREO =====
  //matrix m = MATRIX(cb0, 61);
  //matrix im = inverse(m);
  //float4 t = mul(float4(o2.xyz, 1), m);
  //t.x += s.x * (t.w - s.y)  ;
  //o2.xyz = mul(t, im).xyz;
  // ===== FIN FIX =====
    
  

  o5.xyz = cb0[11].xyz + -r0.yzw;   
  r1.x = dot(v1.xyz, cb2[r0.x+4].xyz);
  r1.y = dot(v1.xyz, cb2[r0.x+5].xyz);
  r1.z = dot(v1.xyz, cb2[r0.x+6].xyz);
  r0.y = dot(r1.xyz, r1.xyz);
  r0.y = max(1.17549435e-38, r0.y);
  r0.y = rsqrt(r0.y);
  o3.xyz = r1.xyz * r0.yyy;
  r0.yzw = cb2[r0.x+1].xyz * v2.yyy;
  r0.yzw = cb2[r0.x+0].xyz * v2.xxx + r0.yzw;
  r0.xyz = cb2[r0.x+2].xyz * v2.zzz + r0.yzw;
  r0.w = dot(r0.xyz, r0.xyz);
  r0.w = max(1.17549435e-38, r0.w);
  r0.w = rsqrt(r0.w);
  o4.xyz = r0.xyz * r0.www;
  o4.w = v2.w;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) D3D Shader Disassembler
//
//   using 3Dmigoto v0.6.164 on Fri Oct 24 01:36:37 2025
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// POSITION                 0   xyz         0     NONE   float   xyz
// NORMAL                   0   xyz         1     NONE   float   xyz
// TANGENT                  0   xyzw        2     NONE   float   xyzw
// SV_InstanceID            0   x           3   INSTID    uint   x
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION              0   xyzw        0      POS   float   xyzw
// CUSTOM_INSTANCE_ID       0   x           1     NONE    uint   x
// TEXCOORD                 0   xyz         2     NONE   float   xyz
// TEXCOORD                 1   xyz         3     NONE   float   xyz
// TEXCOORD                 2   xyzw        4     NONE   float   xyzw
// TEXCOORD                 3   xyz         5     NONE   float   xyz
//
vs_4_0
dcl_constantbuffer CB0[65], immediateIndexed
dcl_constantbuffer CB1[1], immediateIndexed
dcl_constantbuffer CB2[15], dynamicIndexed
dcl_input v0.xyz
dcl_input v1.xyz
dcl_input v2.xyzw
dcl_input_sgv v3.x, instance_id
dcl_output_siv o0.xyzw, position
dcl_output o1.x
dcl_output o2.xyz
dcl_output o3.xyz
dcl_output o4.xyzw
dcl_output o5.xyz
dcl_temps 2
iadd r0.x, v3.x, cb1[0].x
ishl r0.x, r0.x, l(3)
mul r0.yzw, v0.yyyy, cb2[r0.x + 1].xxyz
mad r0.yzw, cb2[r0.x + 0].xxyz, v0.xxxx, r0.yyzw
mad r0.yzw, cb2[r0.x + 2].xxyz, v0.zzzz, r0.yyzw
add r0.yzw, r0.yyzw, cb2[r0.x + 3].xxyz
mul r1.xyzw, r0.zzzz, cb0[62].xyzw
mad r1.xyzw, cb0[61].xyzw, r0.yyyy, r1.xyzw
mad r1.xyzw, cb0[63].xyzw, r0.wwww, r1.xyzw
add o0.xyzw, r1.xyzw, cb0[64].xyzw
mov o1.x, v3.x
mov o2.xyz, r0.yzwy
add o5.xyz, -r0.yzwy, cb0[11].xyzx
dp3 r1.x, v1.xyzx, cb2[r0.x + 4].xyzx
dp3 r1.y, v1.xyzx, cb2[r0.x + 5].xyzx
dp3 r1.z, v1.xyzx, cb2[r0.x + 6].xyzx
dp3 r0.y, r1.xyzx, r1.xyzx
max r0.y, r0.y, l(1.175494351E-38)
rsq r0.y, r0.y
mul o3.xyz, r0.yyyy, r1.xyzx
mul r0.yzw, v2.yyyy, cb2[r0.x + 1].xxyz
mad r0.yzw, cb2[r0.x + 0].xxyz, v2.xxxx, r0.yyzw
mad r0.xyz, cb2[r0.x + 2].xyzx, v2.zzzz, r0.yzwy
dp3 r0.w, r0.xyzx, r0.xyzx
max r0.w, r0.w, l(1.175494351E-38)
rsq r0.w, r0.w
mul o4.xyz, r0.wwww, r0.xyzx
mov o4.w, v2.w
ret
// Approximately 0 instruction slots used

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