Rise
The Vieneo Province
Loading...
Searching...
No Matches
NightVisionGain.h
Go to the documentation of this file.
1#pragma once
2#include <algorithm>
3
5{
6struct Response
7{
8 float red=1, green=1, blue=1;
9 bool clouds=false;
10};
11
12inline Response Calculate(bool active, bool simulator, float luminance)
13{
14 if (!active) return {};
15 const float blend=std::clamp((.35f-luminance)/.30f,0.f,1.f);
16 // Display calibration, not a physical atmospheric or sensor coefficient.
17 // The existing .90 target must remain reachable at the cloud model's
18 // ~.0025 twilight ambient. A .001 signal floor bounds gain at 900 and
19 // lets still fainter signals fade to black without adding illumination.
20 // Preserve the simulator's original 24x response and .01 signal floor.
21 const float target=simulator
22 ? (std::min)(24.f,.90f/(std::max)(luminance,.01f))
23 : .90f/(std::max)(luminance,.001f);
24 const float gain=1.f+((std::max)(1.f,target)-1.f)*blend;
25 return {gain*(1.f-.15f*blend),gain*(1.f+.10f*blend),
26 gain*(1.f+.20f*blend),!simulator && blend>0};
27}
28}
Response Calculate(bool active, bool simulator, float luminance)