//Image sharpening
// ---- Created with 3Dmigoto v1.3.14 on Mon Jan 14 22:41:03 2019

cbuffer SceneInfo : register(b0)
{
  row_major float4x4 viewProjMat : packoffset(c0);
  row_major float3x4 transposeViewMat : packoffset(c4);
  row_major float3x4 transposeViewInvMat : packoffset(c7);
  float4 projElement[2] : packoffset(c10);
  float4 projInvElements[2] : packoffset(c12);
  row_major float4x4 viewProjInvMat : packoffset(c14);
  row_major float4x4 prevViewProjMat : packoffset(c18);
  float3 ZToLinear : packoffset(c22);
  float subdivisionLevel : packoffset(c22.w);
  float2 screenSize : packoffset(c23);
  float2 screenInverseSize : packoffset(c23.z);
  float2 cullingHelper : packoffset(c24);
  float cameraNearPlane : packoffset(c24.z);
  float cameraFarPlane : packoffset(c24.w);
  float4 viewFrustum[6] : packoffset(c25);
  float4 clipplane : packoffset(c31);
}

cbuffer Tonemap : register(b1)
{
  float exposureAdjustment : packoffset(c0);
  float tonemapRange : packoffset(c0.y);
  float sharpness : packoffset(c0.z);
  float preTonemapRange : packoffset(c0.w);
  int useAutoExposure : packoffset(c1);
  float echoBlend : packoffset(c1.y);
  float AABlend : packoffset(c1.z);
  float AASubPixel : packoffset(c1.w);
  float ResponsiveAARate : packoffset(c2);
}

SamplerState PointBorder_s : register(s0);
SamplerState BilinearClamp_s : register(s1);
Texture2D<float4> HDRImage : register(t0);


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


void main(
  float4 v0 : SV_Position0,
  float2 v1 : TEXCOORD0,
  out float4 o0 : SV_Target0)
{
  float4 r0,r1,r2,r3;
  uint4 bitmask, uiDest;
  float4 fDest;

  float4 iniparams10 = IniParams.Load(int2(10,0));
  
  r0.xyzw = screenInverseSize.xyxy * float4(0.5,-0.5,0.5,0.5) + v1.xyxy;
  r1.xyz = HDRImage.SampleLevel(BilinearClamp_s, r0.zw, 0).xyz;
  r0.xyz = HDRImage.SampleLevel(BilinearClamp_s, r0.xy, 0).xyz;
  r2.xyz = HDRImage.SampleLevel(PointBorder_s, v1.xy, 0).xyz;
  r0.xyz = r2.xyz * float3(5,5,5) + -r0.xyz;
  r0.xyz = r0.xyz + -r1.xyz;
  r1.xyzw = screenInverseSize.xyxy * float4(-0.5,-0.5,-0.5,0.5) + v1.xyxy;
  r3.xyz = HDRImage.SampleLevel(BilinearClamp_s, r1.xy, 0).xyz;
  r1.xyz = HDRImage.SampleLevel(BilinearClamp_s, r1.zw, 0).xyz;
  r0.xyz = -r3.xyz + r0.xyz;
  r0.xyz = saturate(r0.xyz + -r1.xyz);
  r0.xyz = r0.xyz + -r2.xyz;
  o0.xyz = sharpness * r0.xyz * iniparams10.z + r2.xyz;
  o0.w = 0;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 10.1
//
//   using 3Dmigoto v1.3.14 on Mon Jan 14 22:41:03 2019
//
//
// Buffer Definitions:
//
// cbuffer SceneInfo
// {
//
//   row_major float4x4 viewProjMat;    // Offset:    0 Size:    64 [unused]
//   row_major float3x4 transposeViewMat;// Offset:   64 Size:    48 [unused]
//   row_major float3x4 transposeViewInvMat;// Offset:  112 Size:    48 [unused]
//   float4 projElement[2];             // Offset:  160 Size:    32 [unused]
//   float4 projInvElements[2];         // Offset:  192 Size:    32 [unused]
//   row_major float4x4 viewProjInvMat; // Offset:  224 Size:    64 [unused]
//   row_major float4x4 prevViewProjMat;// Offset:  288 Size:    64 [unused]
//   float3 ZToLinear;                  // Offset:  352 Size:    12 [unused]
//   float subdivisionLevel;            // Offset:  364 Size:     4 [unused]
//   float2 screenSize;                 // Offset:  368 Size:     8 [unused]
//   float2 screenInverseSize;          // Offset:  376 Size:     8
//   float2 cullingHelper;              // Offset:  384 Size:     8 [unused]
//   float cameraNearPlane;             // Offset:  392 Size:     4 [unused]
//   float cameraFarPlane;              // Offset:  396 Size:     4 [unused]
//   float4 viewFrustum[6];             // Offset:  400 Size:    96 [unused]
//   float4 clipplane;                  // Offset:  496 Size:    16 [unused]
//
// }
//
// cbuffer Tonemap
// {
//
//   float exposureAdjustment;          // Offset:    0 Size:     4 [unused]
//   float tonemapRange;                // Offset:    4 Size:     4 [unused]
//   float sharpness;                   // Offset:    8 Size:     4
//   float preTonemapRange;             // Offset:   12 Size:     4 [unused]
//   int useAutoExposure;               // Offset:   16 Size:     4 [unused]
//   float echoBlend;                   // Offset:   20 Size:     4 [unused]
//   float AABlend;                     // Offset:   24 Size:     4 [unused]
//   float AASubPixel;                  // Offset:   28 Size:     4 [unused]
//   float ResponsiveAARate;            // Offset:   32 Size:     4 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// PointBorder                       sampler      NA          NA    0        1
// BilinearClamp                     sampler      NA          NA    1        1
// HDRImage                          texture  float4          2d    0        1
// SceneInfo                         cbuffer      NA          NA    0        1
// Tonemap                           cbuffer      NA          NA    1        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float
// TEXCOORD                 0   xy          1     NONE   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[24], immediateIndexed
dcl_constantbuffer cb1[1], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_input_ps linear v1.xy
dcl_output o0.xyzw
dcl_temps 4
mad r0.xyzw, cb0[23].zwzw, l(0.500000, -0.500000, 0.500000, 0.500000), v1.xyxy
sample_l_indexable(texture2d)(float,float,float,float) r1.xyz, r0.zwzz, t0.xyzw, s1, l(0.000000)
sample_l_indexable(texture2d)(float,float,float,float) r0.xyz, r0.xyxx, t0.xyzw, s1, l(0.000000)
sample_l_indexable(texture2d)(float,float,float,float) r2.xyz, v1.xyxx, t0.xyzw, s0, l(0.000000)
mad r0.xyz, r2.xyzx, l(5.000000, 5.000000, 5.000000, 0.000000), -r0.xyzx
add r0.xyz, -r1.xyzx, r0.xyzx
mad r1.xyzw, cb0[23].zwzw, l(-0.500000, -0.500000, -0.500000, 0.500000), v1.xyxy
sample_l_indexable(texture2d)(float,float,float,float) r3.xyz, r1.xyxx, t0.xyzw, s1, l(0.000000)
sample_l_indexable(texture2d)(float,float,float,float) r1.xyz, r1.zwzz, t0.xyzw, s1, l(0.000000)
add r0.xyz, r0.xyzx, -r3.xyzx
add_sat r0.xyz, -r1.xyzx, r0.xyzx
add r0.xyz, -r2.xyzx, r0.xyzx
mad o0.xyz, cb1[0].zzzz, r0.xyzx, r2.xyzx
mov o0.w, l(0)
ret
// Approximately 15 instruction slots used

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