import vertSingleNotTransformed from '../shaders/vertex/singleNotTransformed.js'

import fragConvolutionSmooth from '../shaders/fragment/convolutionSmooth.js'

/**
 * The resulting Regl DrawCommand is for using a convolution kernel to smooth the input data.
 * Currently hard-coded the kernel and positions in the shader to reduce number of uniforms.
 */
export function createConvolutionSmoothCommand (regl, commonConfig) {
  return regl({
    vert: vertSingleNotTransformed,
    frag: fragConvolutionSmooth,
    uniforms: {
      ...commonConfig.uniforms,
      texture: regl.prop('texture'),
      textureSize: regl.prop('textureSize'),
      kernelSize: regl.prop('kernelSize')
    },
    attributes: {
      texCoord: [0, 1, 1, 1, 0, 0, 1, 0],
      position: [-1, 1, 1, 1, -1, -1, 1, -1]
    },
    depth: { enable: false },
    primitive: 'triangle strip',
    count: 4
  })
}
