AMFP Enhanced
C++ reference: the code this unofficial fork added
Loading...
Searching...
No Matches
LuxComfortFx.h
Go to the documentation of this file.
1/*
2 * AMFP-2026: comfort pass helpers for the screen effects (shake, image trail, radial blur) in
3 * LuxEffectHandler.cpp. Pure, unit tested in tests/cpp/test_comfort_fx.cpp. Shared profile values
4 * and the general helpers live in LuxComfort.h.
5 */
6#ifndef LUX_COMFORT_FX_H
7#define LUX_COMFORT_FX_H
8
9#include "LuxComfort.h"
10#include <cmath>
11
12// Full scale per effect for LuxComfortRemoved (the removed amount that gives the full edge cue).
13// Shake: amount is the head offset in metres per axis; 0.1 m is a violent shake (scripts mostly use
14// a few cm), so a typical shake removed under Comfort gives a light cue.
15// Image trail: amount 1 is a heavy smear at 60 fps (new frame weight exp(-0.9) = 0.4); the infection
16// code goes up to 1.6 (clamped to the full cue).
17// Radial blur: the code-started blurs use 0.12-0.15 (enemy in view, emotion flash), so 0.25 makes the
18// strongest of those, removed under Comfort, give about half the cue.
19static const float kLuxComfortShakeFullScale = 0.1f;
20static const float kLuxComfortTrailFullScale = 1.0f;
21static const float kLuxComfortBlurFullScale = 0.25f;
22
23/** Time constant (s) of the shake jitter low-pass at shake 0; it shrinks to 0 (no smoothing) at 1. */
24static const float kLuxComfortShakeSmoothTime = 0.08f;
25
26/** Share of the new random shake sample taken this frame: 1 = raw per-frame jitter (vanilla, at
27 * shake >= 1); lower shake smooths the jitter into a slower wobble, frame rate independent. */
28inline float LuxComfortShakeBlend(float afShake, float afTimeStep)
29{
30 if(afShake >= 1.0f) return 1.0f;
31 float fTau = kLuxComfortShakeSmoothTime * (1.0f - LuxComfortClamp01(afShake));
32 if(fTau <= 0 || afTimeStep <= 0) return afTimeStep <= 0 ? 0.0f : 1.0f;
33 return 1.0f - std::exp(-afTimeStep / fTau);
34}
35
36/** One low-pass step; a blend of 1 returns the target exactly (vanilla jitter). */
37inline float LuxComfortLowPass(float afPrev, float afTarget, float afBlend)
38{
39 if(afBlend >= 1.0f) return afTarget;
40 return afPrev + (afTarget - afPrev) * afBlend;
41}
42
43#endif
the comfort pass (PLAN.md "Comfort pass").
float LuxComfortClamp01(float x)
Definition LuxComfort.h:72
static const float kLuxComfortTrailFullScale
float LuxComfortLowPass(float afPrev, float afTarget, float afBlend)
One low-pass step; a blend of 1 returns the target exactly (vanilla jitter).
static const float kLuxComfortShakeFullScale
float LuxComfortShakeBlend(float afShake, float afTimeStep)
Share of the new random shake sample taken this frame: 1 = raw per-frame jitter (vanilla,...
static const float kLuxComfortShakeSmoothTime
Time constant (s) of the shake jitter low-pass at shake 0; it shrinks to 0 (no smoothing) at 1.
static const float kLuxComfortBlurFullScale