Rise
The Vieneo Province
Toggle main menu visibility
Loading...
Searching...
No Matches
LightningAfterimage.h
Go to the documentation of this file.
1
#pragma once
2
#include <algorithm>
3
#include <cmath>
4
#include <cstdint>
5
6
// Display tuning for a human observer, not additional lightning emission or a
7
// physiological prediction. Vieneo's extinction is already in the captured bolt.
8
namespace
LightningAfterimage
9
{
10
inline
constexpr
float
PeakOpacity
=.12f;
11
inline
constexpr
double
DecaySeconds
=.9;
12
inline
constexpr
double
LifetimeSeconds
=4;
13
inline
constexpr
float
DarkLuminance
=.03f,
DayLuminance
=.18f;
14
inline
constexpr
float
CaptureThreshold
=.15f,
FullExposure
=2.f;
15
inline
float
NightGain
(
float
ambient)
16
{
17
return
std::isfinite(ambient) ?
18
(std::clamp)((
DayLuminance
-ambient)/(
DayLuminance
-
DarkLuminance
),0.f,1.f) : 0.f;
19
}
20
struct
State
21
{
22
double
time
=0,
lastCapture
=0;
23
uint64_t
viewer
=0;
24
float
gain
=0,
decay
=0;
25
bool
initialized
=
false
,
active
=
false
;
26
// Returns true when GPU history must be discarded. Time is wall-clock,
27
// so a pause/minimize cannot freeze a ghost and replay it on return.
28
bool
Begin
(
double
now,
bool
enabled,
float
ambient,uint64_t view)
29
{
30
const
float
nextGain=enabled ?
NightGain
(ambient) : 0;
31
const
double
dt=now-
time
;
32
const
bool
clear=!
initialized
|| !std::isfinite(now) || nextGain<=0 ||
gain
<=0 || view!=
viewer
33
|| dt<0 || dt>
LifetimeSeconds
|| (
active
&& now-
lastCapture
>=
LifetimeSeconds
);
34
if
(clear)
active
=
false
;
35
decay
=clear ? 0.f : float(std::exp(-dt/
DecaySeconds
));
36
gain
=std::isfinite(now) ? nextGain : 0;
37
time
=now;
viewer
=view;
initialized
=std::isfinite(now);
38
return
clear;
39
}
40
void
Capture
() {
if
(
gain
>0){
active
=
true
;
lastCapture
=
time
;}}
41
};
42
}
LightningAfterimage
Definition
LightningAfterimage.h:9
LightningAfterimage::NightGain
float NightGain(float ambient)
Definition
LightningAfterimage.h:15
LightningAfterimage::FullExposure
constexpr float FullExposure
Definition
LightningAfterimage.h:14
LightningAfterimage::DayLuminance
constexpr float DayLuminance
Definition
LightningAfterimage.h:13
LightningAfterimage::LifetimeSeconds
constexpr double LifetimeSeconds
Definition
LightningAfterimage.h:12
LightningAfterimage::DarkLuminance
constexpr float DarkLuminance
Definition
LightningAfterimage.h:13
LightningAfterimage::CaptureThreshold
constexpr float CaptureThreshold
Definition
LightningAfterimage.h:14
LightningAfterimage::PeakOpacity
constexpr float PeakOpacity
Definition
LightningAfterimage.h:10
LightningAfterimage::DecaySeconds
constexpr double DecaySeconds
Definition
LightningAfterimage.h:11
LightningAfterimage::State
Definition
LightningAfterimage.h:21
LightningAfterimage::State::Capture
void Capture()
Definition
LightningAfterimage.h:40
LightningAfterimage::State::viewer
uint64_t viewer
Definition
LightningAfterimage.h:23
LightningAfterimage::State::Begin
bool Begin(double now, bool enabled, float ambient, uint64_t view)
Definition
LightningAfterimage.h:28
LightningAfterimage::State::decay
float decay
Definition
LightningAfterimage.h:24
LightningAfterimage::State::time
double time
Definition
LightningAfterimage.h:22
LightningAfterimage::State::active
bool active
Definition
LightningAfterimage.h:25
LightningAfterimage::State::initialized
bool initialized
Definition
LightningAfterimage.h:25
LightningAfterimage::State::gain
float gain
Definition
LightningAfterimage.h:24
LightningAfterimage::State::lastCapture
double lastCapture
Definition
LightningAfterimage.h:22
Viewscreen
LightningAfterimage.h
Generated on
for Rise by
1.18.0