// Halo around character in smoke, smoke on building
// ---- Created with 3Dmigoto v1.3.0 on Wed Jan 31 01:09:42 2018
Texture2D<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 cb3 : register(b3)
{
  float4 cb3[7];
}

cbuffer cb2 : register(b2)
{
  float4 cb2[1];
}

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

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




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


void main(
  float4 v0 : POSITION0,
  float4 v1 : TANGENT0,
  float4 v2 : COLOR0,
  float4 v3 : COLOR1,
  float2 v4 : TEXCOORD0,
  out float4 o0 : TEXCOORD0,
  out float3 o1 : TEXCOORD1,
  out float p1 : TEXCOORD3,
  out float4 o2 : TEXCOORD2,
  out float3 o3 : TEXCOORD5,
  out float4 o4 : SV_Position0)
{
  float4 r0,r1,r2,r3;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.xyzw = v2.xyzw + v2.xyzw;
  r1.xyzw = t2.SampleLevel(s2_s, v3.xy, 0, int2(0, 0)).xyzw;
  o0.xyzw = r1.xyzw * r0.xyzw;
  r0.xyzw = abs(v4.xxyy) * cb2[0].zzww + v4.xxyy;
  r0.xyzw = v1.xyzw * r0.xyzw;
  r0.xyzw = r0.xxyy + r0.zzww;
  r1.xyzw = t1.SampleLevel(s1_s, v3.xy, 0, int2(0, 0)).xyzw;
  r0.xyzw = r1.xyzw * r0.xyzw;
  r0.xy = r0.xy + r0.zw;
  r1.xyz = t0.SampleLevel(s0_s, v3.xy, 0, int2(0, 0)).xyz;
  r1.xyz = v0.xyz + r1.xyz;
  r0.z = dot(r1.xyz, cb1[1].xyz);
  r0.z = cb1[1].w + r0.z;
  r2.xyz = cb0[17].xyz * r0.zzz;
  r0.z = dot(r1.xyz, cb1[0].xyz);
  r0.w = dot(r1.xyz, cb1[2].xyz);
  r0.w = cb1[2].w + r0.w;
  r0.z = cb1[0].w + r0.z;
  r1.xyz = r0.zzz * cb0[16].xyz + r2.xyz;
  r1.xyz = r0.www * cb0[18].xyz + r1.xyz;
  r1.xyz = cb0[19].xyz + r1.xyz;
  r0.xy = r1.xy + r0.xy;
  r1.xyw = cb0[21].xyz * r0.yyy;
  r1.xyw = r0.xxx * cb0[20].xyz + r1.xyw;
  r1.xyw = r1.zzz * cb0[22].xyz + r1.xyw;
  r1.xyw = cb0[23].xyz + r1.xyw;
  r1.xyw = -cb0[8].xyz + r1.xyw;
  r0.z = cb3[6].y * r1.y;
  r0.w = dot(r1.xyw, r1.xyw);
  r0.z = max(-127, r0.z);
  r0.z = min(127, r0.z);
  r1.x = exp2(-r0.z);
  r1.x = 1 + -r1.x;
  r1.x = r1.x / r0.z;
  r0.z = cmp(9.99999997e-007 < abs(r0.z));
  r1.x = cb3[6].z * r1.x;
  r0.z = r0.z ? r1.x : cb3[6].z;
  r1.x = rsqrt(r0.w);
  r0.w = r0.w * r1.x + -cb3[5].w;
  r0.w = max(0, r0.w);
  r0.z = -r0.z * r0.w;
  r0.z = exp2(r0.z);
  p1.x = max(cb3[6].x, r0.z);
  r0.z = floor(v3.z);
  r0.z = r0.z / cb2[0].x;
  r0.w = cmp(r0.z >= -r0.z);
  r1.x = frac(abs(r0.z));
  r2.y = floor(r0.z);
  r0.z = r0.w ? r1.x : -r1.x;
  r0.z = cb2[0].x * r0.z;
  r2.x = floor(r0.z);
  r0.zw = float2(1,-1) + v4.xy;
  r1.xy = r0.zw * float2(0.5,-0.5) + r2.xy;
  r2.xy = float2(1,1) / cb2[0].xy;
  o1.xy = r2.xy * r1.xy;
  o1.z = v0.w;
  r1.x = v3.w / cb2[0].x;
  r1.y = cmp(r1.x >= -r1.x);
  r1.w = frac(abs(r1.x));
  r3.y = floor(r1.x);
  r1.x = r1.y ? r1.w : -r1.w;
  r1.x = cb2[0].x * r1.x;
  r3.x = floor(r1.x);
  r0.zw = r0.zw * float2(0.5,-0.5) + r3.xy;
  o2.xy = r0.zw * r2.xy;
  o2.z = frac(v3.z);
  r2.xyzw = cb0[13].xyzw * r0.yyyy;
  r0.xyzw = r0.xxxx * cb0[12].xyzw + r2.xyzw;
  r0.xyzw = r1.zzzz * cb0[14].xyzw + r0.xyzw;
  r0.xyzw = cb0[15].xyzw + r0.xyzw;
  
// Make textures all match
float depth = StereoParams.Load(0).x; 
float convergence = StereoParams.Load(0).y; 
r0.x += depth * (r0.w - convergence);

  r1.xyw = float3(0.5,0.5,0.5) * r0.xyw;
  r2.xy = r1.xy + r1.ww;
  r2.z = -r2.y + r0.w;
  r1.xy = cb0[9].zw * r0.ww;
  r1.xy = r2.xz * cb0[9].xy + r1.xy;
  o3.xy = r1.xy / r0.ww;
  o4.xyzw = r0.xyzw;
  r0.x = 1 / cb0[5].w;
  o3.z = -r1.z * r0.x;
  
// Remove driver level of stereoization, r0 above will handle it
o4.x -= depth * (o4.w - convergence);
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) D3D Shader Disassembler
//
//   using 3Dmigoto v1.3.0 on Wed Jan 31 01:09:42 2018
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// POSITION                 0   xyzw        0     NONE   float   xyzw
// TANGENT                  0   xyzw        1     NONE   float   xyzw
// COLOR                    0   xyzw        2     NONE   float   xyzw
// COLOR                    1   xyzw        3     NONE   float   xyzw
// TEXCOORD                 0   xy          4     NONE   float   xy  
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// TEXCOORD                 0   xyzw        0     NONE   float   xyzw
// TEXCOORD                 1   xyz         1     NONE   float   xyz 
// TEXCOORD                 3      w        1     NONE   float      w
// TEXCOORD                 2   xyz         2     NONE   float   xyz 
// TEXCOORD                 5   xyz         3     NONE   float   xyz 
// SV_Position              0   xyzw        4      POS   float   xyzw
//
vs_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[24], immediateIndexed
dcl_constantbuffer cb1[3], immediateIndexed
dcl_constantbuffer cb2[1], immediateIndexed
dcl_constantbuffer cb3[7], immediateIndexed
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_texture2d (float,float,float,float) t2
dcl_input v0.xyzw
dcl_input v1.xyzw
dcl_input v2.xyzw
dcl_input v3.xyzw
dcl_input v4.xy
dcl_output o0.xyzw
dcl_output o1.xyz
dcl_output o1.w
dcl_output o2.xyz
dcl_output o3.xyz
dcl_output_siv o4.xyzw, position
dcl_temps 4
add r0.xyzw, v2.xyzw, v2.xyzw
sample_l_aoffimmi_indexable(0,0,0)(texture2d)(float,float,float,float) r1.xyzw, v3.xyxx, t2.xyzw, s2, l(0.000000)
mul o0.xyzw, r0.xyzw, r1.xyzw
mad r0.xyzw, |v4.xxyy|, cb2[0].zzww, v4.xxyy
mul r0.xyzw, r0.xyzw, v1.xyzw
add r0.xyzw, r0.zzww, r0.xxyy
sample_l_aoffimmi_indexable(0,0,0)(texture2d)(float,float,float,float) r1.xyzw, v3.xyxx, t1.xyzw, s1, l(0.000000)
mul r0.xyzw, r0.xyzw, r1.xyzw
add r0.xy, r0.zwzz, r0.xyxx
sample_l_aoffimmi_indexable(0,0,0)(texture2d)(float,float,float,float) r1.xyz, v3.xyxx, t0.xyzw, s0, l(0.000000)
add r1.xyz, r1.xyzx, v0.xyzx
dp3 r0.z, r1.xyzx, cb1[1].xyzx
add r0.z, r0.z, cb1[1].w
mul r2.xyz, r0.zzzz, cb0[17].xyzx
dp3 r0.z, r1.xyzx, cb1[0].xyzx
dp3 r0.w, r1.xyzx, cb1[2].xyzx
add r0.w, r0.w, cb1[2].w
add r0.z, r0.z, cb1[0].w
mad r1.xyz, r0.zzzz, cb0[16].xyzx, r2.xyzx
mad r1.xyz, r0.wwww, cb0[18].xyzx, r1.xyzx
add r1.xyz, r1.xyzx, cb0[19].xyzx
add r0.xy, r0.xyxx, r1.xyxx
mul r1.xyw, r0.yyyy, cb0[21].xyxz
mad r1.xyw, r0.xxxx, cb0[20].xyxz, r1.xyxw
mad r1.xyw, r1.zzzz, cb0[22].xyxz, r1.xyxw
add r1.xyw, r1.xyxw, cb0[23].xyxz
add r1.xyw, r1.xyxw, -cb0[8].xyxz
mul r0.z, r1.y, cb3[6].y
dp3 r0.w, r1.xywx, r1.xywx
max r0.z, r0.z, l(-127.000000)
min r0.z, r0.z, l(127.000000)
exp r1.x, -r0.z
add r1.x, -r1.x, l(1.000000)
div r1.x, r1.x, r0.z
lt r0.z, l(0.000001), |r0.z|
mul r1.x, r1.x, cb3[6].z
movc r0.z, r0.z, r1.x, cb3[6].z
rsq r1.x, r0.w
mad r0.w, r0.w, r1.x, -cb3[5].w
max r0.w, r0.w, l(0.000000)
mul r0.z, r0.w, -r0.z
exp r0.z, r0.z
max o1.w, r0.z, cb3[6].x
round_ni r0.z, v3.z
div r0.z, r0.z, cb2[0].x
ge r0.w, r0.z, -r0.z
frc r1.x, |r0.z|
round_ni r2.y, r0.z
movc r0.z, r0.w, r1.x, -r1.x
mul r0.z, r0.z, cb2[0].x
round_ni r2.x, r0.z
add r0.zw, v4.xxxy, l(0.000000, 0.000000, 1.000000, -1.000000)
mad r1.xy, r0.zwzz, l(0.500000, -0.500000, 0.000000, 0.000000), r2.xyxx
div r2.xy, l(1.000000, 1.000000, 1.000000, 1.000000), cb2[0].xyxx
mul o1.xy, r1.xyxx, r2.xyxx
mov o1.z, v0.w
div r1.x, v3.w, cb2[0].x
ge r1.y, r1.x, -r1.x
frc r1.w, |r1.x|
round_ni r3.y, r1.x
movc r1.x, r1.y, r1.w, -r1.w
mul r1.x, r1.x, cb2[0].x
round_ni r3.x, r1.x
mad r0.zw, r0.zzzw, l(0.000000, 0.000000, 0.500000, -0.500000), r3.xxxy
mul o2.xy, r2.xyxx, r0.zwzz
frc o2.z, v3.z
mul r2.xyzw, r0.yyyy, cb0[13].xyzw
mad r0.xyzw, r0.xxxx, cb0[12].xyzw, r2.xyzw
mad r0.xyzw, r1.zzzz, cb0[14].xyzw, r0.xyzw
add r0.xyzw, r0.xyzw, cb0[15].xyzw
mul r1.xyw, r0.xyxw, l(0.500000, 0.500000, 0.000000, 0.500000)
add r2.xy, r1.wwww, r1.xyxx
add r2.z, r0.w, -r2.y
mul r1.xy, r0.wwww, cb0[9].zwzz
mad r1.xy, r2.xzxx, cb0[9].xyxx, r1.xyxx
div o3.xy, r1.xyxx, r0.wwww
mov o4.xyzw, r0.xyzw
div r0.x, l(1.000000, 1.000000, 1.000000, 1.000000), cb0[5].w
mul o3.z, r0.x, -r1.z
ret 
// Approximately 0 instruction slots used

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