summaryrefslogtreecommitdiffstats
path: root/thirdparty/oidn/core/transfer_function.cpp
diff options
context:
space:
mode:
authorDario <dariosamo@gmail.com>2023-09-18 10:05:20 -0300
committerDario <dariosamo@gmail.com>2023-09-25 14:53:45 -0300
commitab65effed015df76b0858df27127f62b3aa94e0e (patch)
treecab7bbbdd2b63235b809560e47c3ac3784fa892b /thirdparty/oidn/core/transfer_function.cpp
parent1b2b726502eabaae4a15d544d92735cc2efe35b5 (diff)
downloadredot-engine-ab65effed015df76b0858df27127f62b3aa94e0e.tar.gz
Remove denoise module and thirdparty OIDN.
This is replaced by a much lighter weight and faster JNLM denoiser. OIDN is still much more accurate, and may be provided as an optional backend in the future, but the JNLM denoiser seems good enough for most use cases and removing OIDN reduces the build system complexity, binary size, and build times very significantly.
Diffstat (limited to 'thirdparty/oidn/core/transfer_function.cpp')
-rw-r--r--thirdparty/oidn/core/transfer_function.cpp103
1 files changed, 0 insertions, 103 deletions
diff --git a/thirdparty/oidn/core/transfer_function.cpp b/thirdparty/oidn/core/transfer_function.cpp
deleted file mode 100644
index ce5deca56b..0000000000
--- a/thirdparty/oidn/core/transfer_function.cpp
+++ /dev/null
@@ -1,103 +0,0 @@
-// ======================================================================== //
-// Copyright 2009-2019 Intel Corporation //
-// //
-// Licensed under the Apache License, Version 2.0 (the "License"); //
-// you may not use this file except in compliance with the License. //
-// You may obtain a copy of the License at //
-// //
-// http://www.apache.org/licenses/LICENSE-2.0 //
-// //
-// Unless required by applicable law or agreed to in writing, software //
-// distributed under the License is distributed on an "AS IS" BASIS, //
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
-// See the License for the specific language governing permissions and //
-// limitations under the License. //
-// ======================================================================== //
-
-#include "transfer_function.h"
-
-namespace oidn {
-
- const float LogTransferFunction::xScale = 1.f / log(LogTransferFunction::yMax + 1.f);
- const float PQXTransferFunction::xScale = 1.f / PQXTransferFunction::pqxForward(PQXTransferFunction::yMax * PQXTransferFunction::yScale);
-
- float AutoexposureNode::autoexposure(const Image& color)
- {
- assert(color.format == Format::Float3);
-
- constexpr float key = 0.18f;
- constexpr float eps = 1e-8f;
- constexpr int K = 16; // downsampling amount
-
- // Downsample the image to minimize sensitivity to noise
- const int H = color.height; // original height
- const int W = color.width; // original width
- const int HK = (H + K/2) / K; // downsampled height
- const int WK = (W + K/2) / K; // downsampled width
-
- // Compute the average log luminance of the downsampled image
- using Sum = std::pair<float, int>;
-
- // -- GODOT start --
- // Sum sum =
- // tbb::parallel_reduce(
- // tbb::blocked_range2d<int>(0, HK, 0, WK),
- // Sum(0.f, 0),
- // [&](const tbb::blocked_range2d<int>& r, Sum sum) -> Sum
- // {
- // // Iterate over blocks
- // for (int i = r.rows().begin(); i != r.rows().end(); ++i)
- // {
- // for (int j = r.cols().begin(); j != r.cols().end(); ++j)
- // {
-
- Sum sum = Sum(0.0f, 0);
-
- for (int i = 0; i != HK; ++i)
- {
- for (int j = 0; j != WK; ++j)
- {
- // Compute the average luminance in the current block
- const int beginH = int(ptrdiff_t(i) * H / HK);
- const int beginW = int(ptrdiff_t(j) * W / WK);
- const int endH = int(ptrdiff_t(i+1) * H / HK);
- const int endW = int(ptrdiff_t(j+1) * W / WK);
-
- float L = 0.f;
-
- for (int h = beginH; h < endH; ++h)
- {
- for (int w = beginW; w < endW; ++w)
- {
- const float* rgb = (const float*)color.get(h, w);
-
- const float r = maxSafe(rgb[0], 0.f);
- const float g = maxSafe(rgb[1], 0.f);
- const float b = maxSafe(rgb[2], 0.f);
-
- L += luminance(r, g, b);
- }
- }
-
- L /= (endH - beginH) * (endW - beginW);
-
- // Accumulate the log luminance
- if (L > eps)
- {
- sum.first += log2(L);
- sum.second++;
- }
- }
- }
-
- // return sum;
- // },
- // [](Sum a, Sum b) -> Sum { return Sum(a.first+b.first, a.second+b.second); },
- // tbb::static_partitioner()
- // );
- // -- GODOT end --
-
- return (sum.second > 0) ? (key / exp2(sum.first / float(sum.second))) : 1.f;
- }
-
-} // namespace oidn