//Yakuza 6 blood VS 3 (convergence scaling).
// ---- Created with 3Dmigoto v1.3.16 on Sat Apr 10 17:10:55 2021
Buffer<uint4> t17 : register(t17);

struct t16_t {
  float val[52];
};
StructuredBuffer<t16_t> t16 : register(t16);

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

cbuffer cb12 : register(b12)
{
  float4 cb12[4];
}

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


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


void main(
  float4 v0 : POSITION0,
  float3 v1 : NORMAL0,
  float3 v2 : TANGENT0,
  float4 v3 : TEXCOORD0,
  float4 v4 : TEXCOORD1,
  uint v5 : SV_InstanceID0,
  out float4 o0 : TEXCOORD0,
  out float4 o1 : TEXCOORD1,
  out float4 o2 : TEXCOORD2,
  out float4 o3 : SV_POSITION0)
{
// Needs manual fix for instruction:
// unknown dcl_: dcl_input_sgv v5.x, instance_id
  float4 r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10;
  uint4 bitmask, uiDest;
  float4 fDest;
  
  float4 stereo = StereoParams.Load(0);
  
  r0.x = 0x00040000 & asint(cb0[1].w);
  if (r0.x != 0) {
    r0.x = t17.Load(v5.x).x;
  } else {
    r0.x = v5.x;
  }
  r1.x = t16[r0.x].val[0/4];
  r1.y = t16[r0.x].val[0/4+1];
  r1.z = t16[r0.x].val[0/4+2];
  r1.w = t16[r0.x].val[0/4+3];
  r0.y = cmp(r1.w != 0.000000);
  if (r0.y != 0) {
    r2.x = t16[r0.x].val[32/4];
    r2.y = t16[r0.x].val[32/4+1];
    r2.z = t16[r0.x].val[32/4+2];
    r2.w = t16[r0.x].val[32/4+3];
    r0.y = t16[r0.x].val[48/4];
    r0.z = t16[r0.x].val[48/4+1];
    r0.w = t16[r0.x].val[48/4+2];
    r3.xyz = int3(128,4096,256) & asint(cb0[1].www);
    if (r3.x != 0) {
      r4.x = t16[r0.x].val[176/4];
      r4.y = t16[r0.x].val[176/4+1];
      r4.z = t16[r0.x].val[176/4+2];
      r5.x = t16[r0.x].val[192/4];
      r5.y = t16[r0.x].val[192/4+1];
      r5.z = t16[r0.x].val[192/4+2];
      r6.x = 1;
    } else {
      r4.xyz = float3(0,0,0);
      r5.xyz = float3(0,0,0);
      r6.x = 0;
    }
    r3.w = r3.y ? 1 : 0;
    r7.xyz = r3.yyy ? cb0[2].xyz : float3(0,0,0);
    r8.xyz = r3.yyy ? cb0[3].xyz : float3(0,0,0);
    r0.yz = v0.xy * r0.yz;
    r4.xyz = r0.yyy * r4.xyz;
    r4.xyz = r0.zzz * r5.xyz + r4.xyz;
    r6.y = 0;
    r4.xyz = v0.zzz * r6.yyx + r4.xyz;
    sincos(r0.w, r5.x, r6.x);
    r9.x = -r5.x;
    r9.y = r6.x;
    r6.x = dot(r9.yx, r0.yz);
    r9.z = r5.x;
    r6.y = dot(r9.zy, r0.yz);
    r6.z = v0.z;
    r0.yzw = r3.xxx ? r4.xyz : r6.xyz;
    r4.x = r3.w * r0.y;
    r4.y = dot(r7.xyz, r0.yzw);
    r4.z = dot(r8.xyz, r0.yzw);
    r0.yzw = r3.yyy ? r4.xyz : r0.yzw;
    r0.yz = cb0[0].xy * r0.yz;
    r2.xyz = r2.xyz + r0.yzw;
	
	//r10.z = dot(cb12[3].xyzw, r2.xyzw);
	//r2.x+=stereo.x*(r0.z-stereo.y);
	
    o3.x = dot(cb12[0].xyzw, r2.xyzw);
    o3.y = dot(cb12[1].xyzw, r2.xyzw);
    r0.y = dot(cb12[2].xyzw, r2.xyzw);
    r0.z = dot(cb12[3].xyzw, r2.xyzw);
    r2.x = t16[r0.x].val[64/4];
    r2.y = t16[r0.x].val[64/4+1];
    r2.z = t16[r0.x].val[64/4+2];
    r2.w = t16[r0.x].val[64/4+3];
    o1.xyzw = v3.xyzw + r2.xyzw;
    r2.x = r0.y / r0.z;
    if (r3.z != 0) {
      r2.y = t16[r0.x].val[60/4];
    } else {
      r2.y = 0;
    }
    o3.z = r0.z * cb0[0].z + r0.y;
    o3.w = r0.z;
	
	o3.x+=stereo.x*(0-stereo.y)*cb12[0].x/cb13[0].x;
	
  } else {
    o1.xyzw = float4(0,0,0,0);
    o3.xyzw = float4(0,0,0,0);
    r2.xy = float2(0,0);
  }
  o0.xyzw = r1.xyzw;
  o2.xz = r2.xy;
  o2.yw = float2(0,0);
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) D3D Shader Disassembler
//
//   using 3Dmigoto v1.3.16 on Sat Apr 10 17:10:55 2021
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// POSITION                 0   xyzw        0     NONE   float   xyz
// NORMAL                   0   xyz         1     NONE   float
// TANGENT                  0   xyz         2     NONE   float
// TEXCOORD                 0   xyzw        3     NONE   float   xyzw
// TEXCOORD                 1   xyzw        4     NONE   float
// SV_InstanceID            0   x           5   INSTID    uint   x
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// TEXCOORD                 0   xyzw        0     NONE   float   xyzw
// TEXCOORD                 1   xyzw        1     NONE   float   xyzw
// TEXCOORD                 2   xyzw        2     NONE   float   xyzw
// SV_POSITION              0   xyzw        3      POS   float   xyzw
//
vs_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb12[4], immediateIndexed
dcl_constantbuffer cb0[4], immediateIndexed
dcl_resource_structured t16, 208
dcl_resource_buffer (uint,uint,uint,uint) t17
dcl_input v0.xyz
dcl_input v3.xyzw
dcl_input_sgv v5.x, instance_id
dcl_output o0.xyzw
dcl_output o1.xyzw
dcl_output o2.xyzw
dcl_output_siv o3.xyzw, position
dcl_temps 10
and r0.x, l(0x00040000), cb0[1].w
if_nz r0.x
  ld_indexable(buffer)(uint,uint,uint,uint) r0.x, v5.xxxx, t17.xyzw
else
  mov r0.x, v5.x
endif
ld_structured_indexable(structured_buffer, stride=208)(mixed,mixed,mixed,mixed) r1.xyzw, r0.x, l(0), t16.xyzw
ne r0.y, r1.w, l(0.000000)
if_nz r0.y
  ld_structured_indexable(structured_buffer, stride=208)(mixed,mixed,mixed,mixed) r2.xyzw, r0.x, l(32), t16.xyzw
  ld_structured_indexable(structured_buffer, stride=208)(mixed,mixed,mixed,mixed) r0.yzw, r0.x, l(48), t16.xxyz
  and r3.xyz, l(128, 4096, 256, 0), cb0[1].wwww
  if_nz r3.x
    ld_structured_indexable(structured_buffer, stride=208)(mixed,mixed,mixed,mixed) r4.xyz, r0.x, l(176), t16.xyzx
    ld_structured_indexable(structured_buffer, stride=208)(mixed,mixed,mixed,mixed) r5.xyz, r0.x, l(192), t16.xyzx
    mov r6.x, l(1.000000)
  else
    mov r4.xyz, l(0,0,0,0)
    mov r5.xyz, l(0,0,0,0)
    mov r6.x, l(0)
  endif
  movc r3.w, r3.y, l(1.000000), l(0)
  movc r7.xyz, r3.yyyy, cb0[2].xyzx, l(0,0,0,0)
  movc r8.xyz, r3.yyyy, cb0[3].xyzx, l(0,0,0,0)
  mul r0.yz, r0.yyzy, v0.xxyx
  mul r4.xyz, r4.xyzx, r0.yyyy
  mad r4.xyz, r0.zzzz, r5.xyzx, r4.xyzx
  mov r6.y, l(0)
  mad r4.xyz, v0.zzzz, r6.yyxy, r4.xyzx
  sincos r5.x, r6.x, r0.w
  mov r9.x, -r5.x
  mov r9.y, r6.x
  dp2 r6.x, r9.yxyy, r0.yzyy
  mov r9.z, r5.x
  dp2 r6.y, r9.zyzz, r0.yzyy
  mov r6.z, v0.z
  movc r0.yzw, r3.xxxx, r4.xxyz, r6.xxyz
  mul r4.x, r0.y, r3.w
  dp3 r4.y, r7.xyzx, r0.yzwy
  dp3 r4.z, r8.xyzx, r0.yzwy
  movc r0.yzw, r3.yyyy, r4.xxyz, r0.yyzw
  mul r0.yz, r0.yyzy, cb0[0].xxyx
  add r2.xyz, r0.yzwy, r2.xyzx
  dp4 o3.x, cb12[0].xyzw, r2.xyzw
  dp4 o3.y, cb12[1].xyzw, r2.xyzw
  dp4 r0.y, cb12[2].xyzw, r2.xyzw
  dp4 r0.z, cb12[3].xyzw, r2.xyzw
  ld_structured_indexable(structured_buffer, stride=208)(mixed,mixed,mixed,mixed) r2.xyzw, r0.x, l(64), t16.xyzw
  add o1.xyzw, r2.xyzw, v3.xyzw
  div r2.x, r0.y, r0.z
  if_nz r3.z
    ld_structured_indexable(structured_buffer, stride=208)(mixed,mixed,mixed,mixed) r2.y, r0.x, l(60), t16.xxxx
  else
    mov r2.y, l(0)
  endif
  mad o3.z, r0.z, cb0[0].z, r0.y
  mov o3.w, r0.z
else
  mov o1.xyzw, l(0,0,0,0)
  mov o3.xyzw, l(0,0,0,0)
  mov r2.xy, l(0,0,0,0)
endif
mov o0.xyzw, r1.xyzw
mov o2.xz, r2.xxyx
mov o2.yw, l(0,0,0,0)
ret
// Approximately 0 instruction slots used

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