You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.6 KiB
Plaintext
47 lines
1.6 KiB
Plaintext
/*
|
|
* Copyright (c) Contributors to the Open 3D Engine Project.
|
|
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
*
|
|
*/
|
|
|
|
// Gaussian Kernel Radius 9, Sigma 1.8
|
|
static const uint GaussianKernelSize = 19;
|
|
static const int2 TexelOffsetsV[GaussianKernelSize] = {{0, -9}, {0, -8}, {0, -7}, {0, -6}, {0, -5}, {0, -4}, {0, -3}, {0, -2}, {0, -1}, {0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 6}, {0, 7}, {0, 8}, {0, 9}};
|
|
static const int2 TexelOffsetsH[GaussianKernelSize] = {{-9, 0}, {-8, 0}, {-7, 0}, {-6, 0}, {-5, 0}, {-4, 0}, {-3, 0}, {-2, 0}, {-1, 0}, {0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0}, {7, 0}, {8, 0}, {9, 0}};
|
|
static const float TexelWeights[GaussianKernelSize] = {
|
|
0.0000011022801820635918f,
|
|
0.000014295732881160677f,
|
|
0.0001370168487067367f,
|
|
0.0009708086495991633f,
|
|
0.005086391900047703f,
|
|
0.019711193240183777f,
|
|
0.056512463228943335f,
|
|
0.11989501853796679f,
|
|
0.18826323520204147f,
|
|
0.21881694875889543f,
|
|
0.18826323520204147f,
|
|
0.11989501853796679f,
|
|
0.056512463228943335f,
|
|
0.019711193240183777f,
|
|
0.005086391900047703f,
|
|
0.0009708086495991633f,
|
|
0.0001370168487067367f,
|
|
0.000014295732881160677f,
|
|
0.0000011022801820635918f
|
|
};
|
|
|
|
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;
|
|
}
|