/* SPDX-FileCopyrightText: 2023 Blender Authors
 *
 * SPDX-License-Identifier: GPL-2.0-or-later */

#include "infos/compositor_smaa_infos.hh"

COMPUTE_SHADER_CREATE_INFO(compositor_smaa_neighborhood_blending_float)

#include "gpu_shader_compositor_texture_utilities.glsl"
#include "gpu_shader_smaa_lib.glsl"

void main()
{
  int2 texel = int2(gl_GlobalInvocationID.xy);

  /* Add 0.5 to evaluate the input sampler at the center of the pixel and divide by the image size
   * to get the coordinates into the sampler's expected [0, 1] range. */
  float2 coordinates = (float2(texel) + float2(0.5f)) / float2(texture_size(input_tx));

  float4 offset;
  SMAANeighborhoodBlendingVS(coordinates, offset);

  float4 result = SMAANeighborhoodBlendingPS(coordinates, offset, input_tx, weights_tx);
  imageStore(output_img, texel, result);
}
