31 lines
1.3 KiB
Plaintext
31 lines
1.3 KiB
Plaintext
/*
|
|
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
|
* its licensors.
|
|
*
|
|
* For complete copyright and license terms please see the LICENSE at the root of this
|
|
* distribution (the "License"). All use of this software is governed by the License,
|
|
* or, if provided, by the license below or the license accompanying this file. Do not
|
|
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
*
|
|
*/
|
|
|
|
// 7-tap Gaussian Kernel (Sigma 1.1)
|
|
static const uint GaussianKernelSize = 7;
|
|
static const int2 TexelOffsetsV[GaussianKernelSize] = {{0, -3}, {0, -2}, {0, -1}, {0, 0}, {0, 1}, {0, 2}, {0, 3}};
|
|
static const int2 TexelOffsetsH[GaussianKernelSize] = {{-3, 0}, {-2, 0}, {-1, 0}, {0, 0}, {1, 0}, {2, 0}, {3, 0}};
|
|
static const float TexelWeights[GaussianKernelSize] = {0.010805f, 0.074929f, 0.238727f, 0.351078f, 0.238727f, 0.074929f, 0.010805f};
|
|
|
|
float3 GaussianFilter(uint2 screenCoords, int2 texelOffsets[GaussianKernelSize], RWTexture2D<float4> inputImage)
|
|
{
|
|
float3 result = float3(0.0f, 0.0f, 0.0f);
|
|
|
|
[unroll]
|
|
for (uint i = 0; i < GaussianKernelSize; ++i)
|
|
{
|
|
result += inputImage[screenCoords + texelOffsets[i]].rgb * TexelWeights[i];
|
|
}
|
|
|
|
return result;
|
|
}
|