//Yakuza 6 haloing when hitting enemies.
// ---- Created with 3Dmigoto v1.3.16 on Sat Apr 10 10:25:38 2021
Texture3D<float4> t2 : register(t2);

Texture2D<float4> t1 : register(t1);

Texture2D<float4> t0 : register(t0);

SamplerState s2_s : register(s2);

SamplerState s1_s : register(s1);

SamplerState s0_s : register(s0);

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

cbuffer cb9 : register(b9)
{
  float4 cb9[1];
}




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


void main(
  float4 v0 : TEXCOORD0,
  float4 v1 : TEXCOORD1,
  nointerpolation int v2 : TEXCOORD2,
  out float4 o0 : SV_Target0)
{
  float4 r0,r1,r2,r3;
  uint4 bitmask, uiDest;
  float4 fDest;
  
  float4 stereo = StereoParams.Load(0);
  v0.x+=stereo.x*(v0.z-stereo.y)*0.5;
  
  r0.w = 1;
  r1.xy = v0.xy / v0.zz;
  r1.z = t0.Sample(s0_s, r1.xy).x;
  r1.xy = t1.Sample(s1_s, r1.xy).xy;
  r1.xy = float2(4,4) * r1.xy;
  r1.z = cb9[0].x + r1.z;
  r1.z = -cb9[0].y / r1.z;
  r2.xyz = v1.xyz * r1.zzz;
  r2.xyz = r2.xyz / v1.zzz;
  r1.z = dot(r1.xy, r1.xy);
  r3.zw = -r1.zz * float2(0.25,0.5) + float2(1,1);
  r1.z = max(0, r3.z);
  r1.z = sqrt(r1.z);
  r3.xy = r1.xy * r1.zz;
  r1.x = (int)v2.x * 10;
  r0.xyz = r3.xyw * cb0[r1.x+9].xxx + r2.xyz;
  r2.x = dot(cb0[r1.x+0].xyzw, r0.xyzw);
  r2.y = dot(cb0[r1.x+1].xyzw, r0.xyzw);
  r2.z = dot(cb0[r1.x+2].xyzw, r0.xyzw);
  r0.w = dot(r2.xyz, r2.xyz);
  r0.w = sqrt(r0.w);
  r0.w = 1 + -r0.w;
  r1.y = cmp(r0.w < 0);
  if (r1.y != 0) discard;
  r1.yzw = r2.xyz * cb0[r1.x+6].xyz + cb0[r1.x+5].xyz;
  r2.xyz = r2.xyz * cb0[r1.x+4].xyz + cb0[r1.x+3].xyz;
  r2.x = t2.Sample(s2_s, r2.xyz).w;
  r1.y = t2.Sample(s2_s, r1.yzw).w;
  r1.y = r1.y + -r2.x;
  r1.y = cb0[r1.x+3].w * r1.y + r2.x;
  r1.z = -cb0[r1.x+5].w + 1;
  r1.z = cb0[r1.x+4].w + r1.z;
  r1.w = r0.w * r1.z + -cb0[r1.x+4].w;
  r2.x = cb0[r1.x+5].w + -cb0[r1.x+4].w;
  r0.w = r0.w * r2.x + cb0[r1.x+4].w;
  r0.w = r0.w * r1.y + r1.w;
  r1.y = cmp(r0.w < 0);
  if (r1.y != 0) discard;
  r1.y = dot(v1.xyz, v1.xyz);
  r1.y = rsqrt(r1.y);
  r2.yzw = v1.xyz * r1.yyy;
  r1.y = dot(r3.xyw, r2.yzw);
  r1.w = cb0[r1.x+9].y * r0.w;
  r0.w = saturate(cb0[r1.x+6].w * r0.w);
  r1.y = r1.w / r1.y;
  r3.xyz = r2.yzw * r1.yyy + r0.xyz;
  r3.w = 1;
  r0.x = dot(cb0[r1.x+0].xyzw, r3.xyzw);
  r0.y = dot(cb0[r1.x+1].xyzw, r3.xyzw);
  r0.z = dot(cb0[r1.x+2].xyzw, r3.xyzw);
  r2.yzw = r0.xyz * cb0[r1.x+6].xyz + cb0[r1.x+5].xyz;
  r1.y = t2.Sample(s2_s, r2.yzw).w;
  r2.yzw = r0.xyz * cb0[r1.x+4].xyz + cb0[r1.x+3].xyz;
  r0.x = dot(r0.xyz, r0.xyz);
  r0.x = sqrt(r0.x);
  r0.x = 1 + -r0.x;
  r0.x = max(0, r0.x);
  r0.y = t2.Sample(s2_s, r2.yzw).w;
  r0.z = r1.y + -r0.y;
  r0.y = cb0[r1.x+3].w * r0.z + r0.y;
  r0.z = r0.x * r2.x + cb0[r1.x+4].w;
  r0.x = r0.x * r1.z + -cb0[r1.x+4].w;
  r0.x = r0.z * r0.y + r0.x;
  r0.x = max(0, r0.x);
  r2.xyzw = cb0[r1.x+8].xyzw + -cb0[r1.x+7].xyzw;
  r1.xyzw = r0.xxxx * r2.xyzw + cb0[r1.x+7].xyzw;
  r1.xyzw = max(float4(0,0,0,0), r1.xyzw);
  r1.xyzw = float4(-0,-0,-0,-1) + r1.xyzw;
  o0.xyzw = r0.wwww * r1.xyzw + float4(0,0,0,1);
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) D3D Shader Disassembler
//
//   using 3Dmigoto v1.3.16 on Sat Apr 10 10:25:38 2021
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// TEXCOORD                 0   xyz         0     NONE   float   xyz
// TEXCOORD                 1   xyz         1     NONE   float   xyz
// TEXCOORD                 2   x           2     NONE     int   x
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
//
ps_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb9[1], immediateIndexed
dcl_constantbuffer cb0[250], dynamicIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_default
dcl_sampler s2, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t1
dcl_resource_texture3d (float,float,float,float) t2
dcl_input_ps linear v0.xyz
dcl_input_ps linear v1.xyz
dcl_input_ps constant v2.x
dcl_output o0.xyzw
dcl_temps 4
mov r0.w, l(1.000000)
div r1.xy, v0.xyxx, v0.zzzz
sample_indexable(texture2d)(float,float,float,float) r1.z, r1.xyxx, t0.yzxw, s0
sample_indexable(texture2d)(float,float,float,float) r1.xy, r1.xyxx, t1.xyzw, s1
mul r1.xy, r1.xyxx, l(4.000000, 4.000000, 0.000000, 0.000000)
add r1.z, r1.z, cb9[0].x
div r1.z, -cb9[0].y, r1.z
mul r2.xyz, r1.zzzz, v1.xyzx
div r2.xyz, r2.xyzx, v1.zzzz
dp2 r1.z, r1.xyxx, r1.xyxx
mad r3.zw, -r1.zzzz, l(0.000000, 0.000000, 0.250000, 0.500000), l(0.000000, 0.000000, 1.000000, 1.000000)
max r1.z, r3.z, l(0.000000)
sqrt r1.z, r1.z
mul r3.xy, r1.zzzz, r1.xyxx
imul null, r1.x, v2.x, l(10)
mad r0.xyz, r3.xywx, cb0[r1.x + 9].xxxx, r2.xyzx
dp4 r2.x, cb0[r1.x + 0].xyzw, r0.xyzw
dp4 r2.y, cb0[r1.x + 1].xyzw, r0.xyzw
dp4 r2.z, cb0[r1.x + 2].xyzw, r0.xyzw
dp3 r0.w, r2.xyzx, r2.xyzx
sqrt r0.w, r0.w
add r0.w, -r0.w, l(1.000000)
lt r1.y, r0.w, l(0.000000)
discard_nz r1.y
mad r1.yzw, r2.xxyz, cb0[r1.x + 6].xxyz, cb0[r1.x + 5].xxyz
mad r2.xyz, r2.xyzx, cb0[r1.x + 4].xyzx, cb0[r1.x + 3].xyzx
sample_indexable(texture3d)(float,float,float,float) r2.x, r2.xyzx, t2.wxyz, s2
sample_indexable(texture3d)(float,float,float,float) r1.y, r1.yzwy, t2.xwyz, s2
add r1.y, -r2.x, r1.y
mad r1.y, cb0[r1.x + 3].w, r1.y, r2.x
add r1.z, l(1.000000), -cb0[r1.x + 5].w
add r1.z, r1.z, cb0[r1.x + 4].w
mad r1.w, r0.w, r1.z, -cb0[r1.x + 4].w
add r2.x, -cb0[r1.x + 4].w, cb0[r1.x + 5].w
mad r0.w, r0.w, r2.x, cb0[r1.x + 4].w
mad r0.w, r0.w, r1.y, r1.w
lt r1.y, r0.w, l(0.000000)
discard_nz r1.y
dp3 r1.y, v1.xyzx, v1.xyzx
rsq r1.y, r1.y
mul r2.yzw, r1.yyyy, v1.xxyz
dp3 r1.y, r3.xywx, r2.yzwy
mul r1.w, r0.w, cb0[r1.x + 9].y
mul_sat r0.w, r0.w, cb0[r1.x + 6].w
div r1.y, r1.w, r1.y
mad r3.xyz, r2.yzwy, r1.yyyy, r0.xyzx
mov r3.w, l(1.000000)
dp4 r0.x, cb0[r1.x + 0].xyzw, r3.xyzw
dp4 r0.y, cb0[r1.x + 1].xyzw, r3.xyzw
dp4 r0.z, cb0[r1.x + 2].xyzw, r3.xyzw
mad r2.yzw, r0.xxyz, cb0[r1.x + 6].xxyz, cb0[r1.x + 5].xxyz
sample_indexable(texture3d)(float,float,float,float) r1.y, r2.yzwy, t2.xwyz, s2
mad r2.yzw, r0.xxyz, cb0[r1.x + 4].xxyz, cb0[r1.x + 3].xxyz
dp3 r0.x, r0.xyzx, r0.xyzx
sqrt r0.x, r0.x
add r0.x, -r0.x, l(1.000000)
max r0.x, r0.x, l(0.000000)
sample_indexable(texture3d)(float,float,float,float) r0.y, r2.yzwy, t2.xwyz, s2
add r0.z, -r0.y, r1.y
mad r0.y, cb0[r1.x + 3].w, r0.z, r0.y
mad r0.z, r0.x, r2.x, cb0[r1.x + 4].w
mad r0.x, r0.x, r1.z, -cb0[r1.x + 4].w
mad r0.x, r0.z, r0.y, r0.x
max r0.x, r0.x, l(0.000000)
add r2.xyzw, -cb0[r1.x + 7].xyzw, cb0[r1.x + 8].xyzw
mad r1.xyzw, r0.xxxx, r2.xyzw, cb0[r1.x + 7].xyzw
max r1.xyzw, r1.xyzw, l(0.000000, 0.000000, 0.000000, 0.000000)
add r1.xyzw, r1.xyzw, l(-0.000000, -0.000000, -0.000000, -1.000000)
mad o0.xyzw, r0.wwww, r1.xyzw, l(0.000000, 0.000000, 0.000000, 1.000000)
ret
// Approximately 0 instruction slots used

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