25#include <Gfx/Graph/Scale.hpp>
86 std::lock_guard lk{m_mutex};
91 m_generation.fetch_add(1, std::memory_order_release);
98 const auto gen = m_generation.load(std::memory_order_acquire);
102 std::lock_guard lk{m_mutex};
111 std::lock_guard lk{m_mutex};
115 std::uint32_t generation() const noexcept
117 return m_generation.load(std::memory_order_acquire);
121 mutable std::mutex m_mutex;
122 CaptureAdjust m_value;
123 std::atomic<std::uint32_t> m_generation{0};
143 float scale[2]{1.f, 1.f};
144 float textureSize[2]{1.f, 1.f};
145 float blackLevel[4]{0.f, 0.f, 0.f, 0.f};
146 float whiteBalance[4]{1.f, 1.f, 1.f, 0.f};
152static_assert(
sizeof(CaptureMaterialUBO) == 64);
153static_assert(offsetof(CaptureMaterialUBO, blackLevel) == 16);
154static_assert(offsetof(CaptureMaterialUBO, whiteBalance) == 32);
155static_assert(offsetof(CaptureMaterialUBO, params) == 48);
160 for(
int i = 0; i < 3; ++i)
162 ubo.blackLevel[i] = a.blackLevel[i];
163 ubo.whiteBalance[i] = a.whiteBalance[i];
165 ubo.params[0] = a.exposure;
166 ubo.params[1] = a.gamma;
167 ubo.params[2] = a.saturation;
180 constexpr float eps = 1.f / 65535.f;
182 for(
int i = 0; i < 3; ++i)
184 const float bl = a.blackLevel[i];
185 float c = (rgb[i] - bl) / std::max(eps, 1.f - bl);
186 c *= a.whiteBalance[i];
188 rgb[i] = std::max(0.f, c);
192 = 0.2126f * rgb[0] + 0.7152f * rgb[1] + 0.0722f * rgb[2];
193 for(
int i = 0; i < 3; ++i)
194 rgb[i] = std::max(0.f, l + (rgb[i] - l) * a.saturation);
196 const float inv = 1.f / std::max(a.gamma, eps);
197 for(
int i = 0; i < 3; ++i)
198 rgb[i] = std::clamp(std::pow(rgb[i], inv), 0.f, 1.f);
Cross-thread handoff for CaptureAdjust.
Definition CaptureAdjust.hpp:80
bool poll(CaptureAdjust &out, std::uint32_t &lastSeen) const
Definition CaptureAdjust.hpp:96
void set(const CaptureAdjust &v)
Writer side. Any thread.
Definition CaptureAdjust.hpp:83
Graphics rendering pipeline for ossia score.
Definition Filter/PreviewWidget.hpp:11
void adjustCaptureReference(const CaptureAdjust &a, float rgb[3]) noexcept
The corrections, on the CPU, in the same order the shader applies them.
Definition CaptureAdjust.hpp:178
ScaleMode
How to resize a texture to adapt it to a viewport.
Definition Scale.hpp:10
void applyTo(const CaptureAdjust &a, CaptureMaterialUBO &ubo) noexcept
Fills the correction half of ubo. The geometry half is the caller's.
Definition CaptureAdjust.hpp:158
Sensor-side corrections, in the order the shader applies them.
Definition CaptureAdjust.hpp:39
float saturation
0 collapses to luma, 1 leaves it alone.
Definition CaptureAdjust.hpp:57
float gamma
Definition CaptureAdjust.hpp:54
float exposure
Linear multiplier, after white balance.
Definition CaptureAdjust.hpp:50
ScaleMode scaleMode
Definition CaptureAdjust.hpp:64
float whiteBalance[3]
Definition CaptureAdjust.hpp:47
float blackLevel[3]
Definition CaptureAdjust.hpp:43
The capture path's material block: the shared one, plus corrections.
Definition CaptureAdjust.hpp:142
float params[4]
exposure, gamma, saturation, unused
Definition CaptureAdjust.hpp:148