//Sharpening. Enabled when TAA is enabled.
// ---- Created with 3Dmigoto v1.3.16 on Wed Oct  6 23:15:19 2021

cbuffer fblock : register(b0)
{
  float4 positiontoviewtexture : packoffset(c0);
  float4 downsampletype : packoffset(c1);
  float4 noiseparm : packoffset(c2);
  float4 viewrandom : packoffset(c3);
  float4 noisecolor : packoffset(c4);
  float4 noiseparm2 : packoffset(c5);
}

SamplerState viewcolormap_samp_state_s : register(s0);
SamplerState noisemappbr_samp_state_s : register(s1);
Texture2D<float4> viewcolormap_samp : register(t0);
Texture2D<float4> noisemappbr_samp : register(t1);


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


void main(
  float4 v0 : SV_Position0,
  out float4 o0 : SV_Target0)
{
  float4 r0,r1,r2,r3,r4;
  uint4 bitmask, uiDest;
  float4 fDest;
  
  float4 iniparams5 = IniParams.Load(int2(5,0));
  
  r0.xy = v0.xy * positiontoviewtexture.zw + positiontoviewtexture.xy;
  r1.xyz = viewcolormap_samp.SampleLevel(viewcolormap_samp_state_s, r0.xy, 0).xyz;
  r2.xyzw = positiontoviewtexture.zwzw * float4(0,-1,-1,0) + r0.xyxy;
  r3.xyz = viewcolormap_samp.SampleLevel(viewcolormap_samp_state_s, r2.xy, 0).xyz;
  r2.xyz = viewcolormap_samp.SampleLevel(viewcolormap_samp_state_s, r2.zw, 0).xyz;
  r2.xyz = r2.xyz * r2.xyz;
  r2.xyz = r3.xyz * r3.xyz + r2.xyz;
  r2.xyz = r1.xyz * r1.xyz + r2.xyz;
  r3.xyzw = positiontoviewtexture.zwzw * float4(1,0,0,1) + r0.xyxy;
  r4.xyz = viewcolormap_samp.SampleLevel(viewcolormap_samp_state_s, r3.xy, 0).xyz;
  r2.xyz = r4.xyz * r4.xyz + r2.xyz;
  r3.xyz = viewcolormap_samp.SampleLevel(viewcolormap_samp_state_s, r3.zw, 0).xyz;
  r2.xyz = r3.xyz * r3.xyz + r2.xyz;
  r2.xyz = float3(0.200000003,0.200000003,0.200000003) * r2.xyz;
  r0.z = 1 + downsampletype.w * iniparams5.z;
  r1.xyz = r1.xyz * r1.xyz + -r2.xyz;
  r1.xyz = r0.zzz * r1.xyz + r2.xyz;
  r1.xyz = max(float3(0,0,0), r1.xyz);
  r0.z = cmp(downsampletype.z == 1.000000);
  if (r0.z != 0) {
    r0.z = dot(r1.xyz, float3(0.212599993,0.715200007,0.0722000003));
    r0.xy = r0.xy * noiseparm.xy + viewrandom.xy;
    r0.xyw = noisemappbr_samp.SampleLevel(noisemappbr_samp_state_s, r0.xy, 0).xyz;
    r0.xyw = noisecolor.xyz * r0.xyw;
    r0.z = 1 + -r0.z;
    r0.z = max(0, r0.z);
    r0.z = log2(r0.z);
    r0.z = noiseparm2.y * r0.z;
    r0.z = exp2(r0.z);
    r0.z = noiseparm.z * r0.z + -noiseparm.z;
    r0.z = noiseparm2.x * r0.z + noiseparm.z;
    r1.w = downsampletype.y * r0.z;
    r2.x = cmp(noiseparm2.z == 1.000000);
    if (r2.x != 0) {
      r2.xyz = r1.www * r0.xyw;
      r1.xyz = r2.xyz * noisecolor.xyz + r1.xyz;
    } else {
      r0.z = -r0.z * downsampletype.y + 1;
      r0.xyw = r0.xyw * r1.xyz;
      r0.xyw = r0.xyw * r1.www;
      r1.xyz = r1.xyz * r0.zzz + r0.xyw;
    }
  }
  r0.xyz = max(float3(0,0,0), r1.xyz);
  r0.xyz = log2(r0.xyz);
  r0.xyz = float3(0.454545468,0.454545468,0.454545468) * r0.xyz;
  o0.xyz = exp2(r0.xyz);
  o0.w = 1;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
//
//   using 3Dmigoto v1.3.16 on Wed Oct  6 23:15:19 2021
//
//
// Buffer Definitions:
//
// cbuffer fblock
// {
//
//   float4 positiontoviewtexture;      // Offset:    0 Size:    16
//   float4 downsampletype;             // Offset:   16 Size:    16
//   float4 noiseparm;                  // Offset:   32 Size:    16
//   float4 viewrandom;                 // Offset:   48 Size:    16
//   float4 noisecolor;                 // Offset:   64 Size:    16
//   float4 noiseparm2;                 // Offset:   80 Size:    16
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// viewcolormap_samp_state           sampler      NA          NA    0        1
// noisemappbr_samp_state            sampler      NA          NA    1        1
// viewcolormap_samp                 texture  float4          2d    0        1
// noisemappbr_samp                  texture  float4          2d    1        1
// fblock                            cbuffer      NA          NA    0        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float   xy
//
//
// 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 cb0[6], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t1
dcl_input_ps_siv linear noperspective v0.xy, position
dcl_output o0.xyzw
dcl_temps 5
mad r0.xy, v0.xyxx, cb0[0].zwzz, cb0[0].xyxx
sample_l_indexable(texture2d)(float,float,float,float) r1.xyz, r0.xyxx, t0.xyzw, s0, l(0.000000)
mad r2.xyzw, cb0[0].zwzw, l(0.000000, -1.000000, -1.000000, 0.000000), r0.xyxy
sample_l_indexable(texture2d)(float,float,float,float) r3.xyz, r2.xyxx, t0.xyzw, s0, l(0.000000)
sample_l_indexable(texture2d)(float,float,float,float) r2.xyz, r2.zwzz, t0.xyzw, s0, l(0.000000)
mul r2.xyz, r2.xyzx, r2.xyzx
mad r2.xyz, r3.xyzx, r3.xyzx, r2.xyzx
mad r2.xyz, r1.xyzx, r1.xyzx, r2.xyzx
mad r3.xyzw, cb0[0].zwzw, l(1.000000, 0.000000, 0.000000, 1.000000), r0.xyxy
sample_l_indexable(texture2d)(float,float,float,float) r4.xyz, r3.xyxx, t0.xyzw, s0, l(0.000000)
mad r2.xyz, r4.xyzx, r4.xyzx, r2.xyzx
sample_l_indexable(texture2d)(float,float,float,float) r3.xyz, r3.zwzz, t0.xyzw, s0, l(0.000000)
mad r2.xyz, r3.xyzx, r3.xyzx, r2.xyzx
mul r2.xyz, r2.xyzx, l(0.200000, 0.200000, 0.200000, 0.000000)
add r0.z, cb0[1].w, l(1.000000)
mad r1.xyz, r1.xyzx, r1.xyzx, -r2.xyzx
mad r1.xyz, r0.zzzz, r1.xyzx, r2.xyzx
max r1.xyz, r1.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000)
eq r0.z, cb0[1].z, l(1.000000)
if_nz r0.z
  dp3 r0.z, r1.xyzx, l(0.212600, 0.715200, 0.072200, 0.000000)
  mad r0.xy, r0.xyxx, cb0[2].xyxx, cb0[3].xyxx
  sample_l_indexable(texture2d)(float,float,float,float) r0.xyw, r0.xyxx, t1.xywz, s1, l(0.000000)
  mul r0.xyw, r0.xyxw, cb0[4].xyxz
  add r0.z, -r0.z, l(1.000000)
  max r0.z, r0.z, l(0.000000)
  log r0.z, r0.z
  mul r0.z, r0.z, cb0[5].y
  exp r0.z, r0.z
  mad r0.z, cb0[2].z, r0.z, -cb0[2].z
  mad r0.z, cb0[5].x, r0.z, cb0[2].z
  mul r1.w, r0.z, cb0[1].y
  eq r2.x, cb0[5].z, l(1.000000)
  if_nz r2.x
    mul r2.xyz, r0.xywx, r1.wwww
    mad r1.xyz, r2.xyzx, cb0[4].xyzx, r1.xyzx
  else
    mad r0.z, -r0.z, cb0[1].y, l(1.000000)
    mul r0.xyw, r1.xyxz, r0.xyxw
    mul r0.xyw, r1.wwww, r0.xyxw
    mad r1.xyz, r1.xyzx, r0.zzzz, r0.xywx
  endif
endif
max r0.xyz, r1.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000)
log r0.xyz, r0.xyzx
mul r0.xyz, r0.xyzx, l(0.454545468, 0.454545468, 0.454545468, 0.000000)
exp o0.xyz, r0.xyzx
mov o0.w, l(1.000000)
ret
// Approximately 49 instruction slots used

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