Rise
The Vieneo Province
Toggle main menu visibility
Loading...
Searching...
No Matches
NightVisionExposure.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <algorithm>
4
5
namespace
NightVisionExposure
6
{
7
// flashStimulus must come from lightning that actually illuminates this frame,
8
// not the legacy above-cloud flashes whose rendering is disabled.
9
inline
void
Update
(
bool
active,
float
flashStimulus,
float
ambientLuminance,
10
float
elapsedSeconds,
float
& exposure,
float
& holdSeconds)
11
{
12
if
(!active)
13
{
14
exposure = holdSeconds = 0.0f;
15
return
;
16
}
17
18
// Always advance recovery. A weaker flash must not keep an earlier, stronger
19
// whiteout alive, including when emerging from dark clouds into daylight.
20
const
float
elapsed = (std::max)(0.0f, elapsedSeconds);
21
const
float
held = (std::min)(holdSeconds, elapsed);
22
holdSeconds -= held;
23
exposure = (std::max)(0.0f, exposure - (elapsed - held) * 0.30f);
24
25
if
(flashStimulus > 0.03f)
26
{
27
// Preserve the reduced daytime sensitivity, using pre-flash luminance.
28
const
float
lowLightAdaptation = std::clamp((0.35f - ambientLuminance) / 0.30f, 0.0f, 1.0f);
29
const
float
sensorSensitivity = 0.15f + 0.85f * lowLightAdaptation;
30
const
float
saturation = std::clamp((flashStimulus - 0.03f) * 2.5f, 0.0f, 1.0f) * sensorSensitivity;
31
if
(saturation >= exposure)
32
{
33
exposure = saturation;
34
holdSeconds = 0.15f + 0.50f * saturation;
35
}
36
}
37
}
38
}
NightVisionExposure
Definition
NightVisionExposure.h:6
NightVisionExposure::Update
void Update(bool active, float flashStimulus, float ambientLuminance, float elapsedSeconds, float &exposure, float &holdSeconds)
Definition
NightVisionExposure.h:9
Viewscreen
NightVisionExposure.h
Generated on
for Rise by
1.18.0