fix: shader fade animation linear curve
This commit is contained in:
@@ -29,9 +29,4 @@ inline std::array<float, 3> kelvinToGain(int kelvin) {
|
|||||||
return {static_cast<float>(r), static_cast<float>(g), static_cast<float>(b)};
|
return {static_cast<float>(r), static_cast<float>(g), static_cast<float>(b)};
|
||||||
}
|
}
|
||||||
|
|
||||||
inline float easeInOutCubic(float x) {
|
|
||||||
return x < 0.5f ? 4.f * x * x * x
|
|
||||||
: 1.f - std::pow(-2.f * x + 2.f, 3.f) / 2.f;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace ZShell::services
|
} // namespace ZShell::services
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ extern "C" {
|
|||||||
|
|
||||||
#include "colortemp.hpp"
|
#include "colortemp.hpp"
|
||||||
|
|
||||||
using ZShell::services::easeInOutCubic;
|
|
||||||
using ZShell::services::kelvinToGain;
|
using ZShell::services::kelvinToGain;
|
||||||
|
|
||||||
using Render::IFramebuffer;
|
using Render::IFramebuffer;
|
||||||
@@ -241,17 +240,16 @@ static void hkBegin(
|
|||||||
.count();
|
.count();
|
||||||
const float t =
|
const float t =
|
||||||
std::clamp(elapsed / g_transition.durationSec, 0.f, 1.f);
|
std::clamp(elapsed / g_transition.durationSec, 0.f, 1.f);
|
||||||
const float e = easeInOutCubic(t);
|
|
||||||
|
|
||||||
for (size_t i = 0; i < 3; ++i)
|
for (size_t i = 0; i < 3; ++i)
|
||||||
g_currentGain[i] =
|
g_currentGain[i] =
|
||||||
g_transition.fromGain[i] +
|
g_transition.fromGain[i] +
|
||||||
(g_transition.toGain[i] - g_transition.fromGain[i]) * e;
|
(g_transition.toGain[i] - g_transition.fromGain[i]) * t;
|
||||||
|
|
||||||
if (g_uniformMode) {
|
if (g_uniformMode) {
|
||||||
setUniformGain(g_currentGain);
|
setUniformGain(g_currentGain);
|
||||||
} else {
|
} else {
|
||||||
const int step = static_cast<int>(e * BAKED_STEPS);
|
const int step = static_cast<int>(t * BAKED_STEPS);
|
||||||
if (step != g_transition.lastBakedStep) {
|
if (step != g_transition.lastBakedStep) {
|
||||||
g_transition.lastBakedStep = step;
|
g_transition.lastBakedStep = step;
|
||||||
ensureShaderFile(
|
ensureShaderFile(
|
||||||
|
|||||||
Reference in New Issue
Block a user