Rise
The Vieneo Province
Loading...
Searching...
No Matches
CloudNightVision.h
Go to the documentation of this file.
1#pragma once
2#include "CloudVolume.h"
3#include "NightVisionGain.h"
4
5// Display calibration for the visible cloud medium. Object/cockpit lighting
6// keeps its own meter: airglow is visible emission, not a cabin light source.
8{
9inline float Luminance(CloudVolume::Point light)
10{
11 return .2126f*light.x+.7152f*light.y+.0722f*light.z;
12}
13
15{
16 if (!gain.clouds) return light;
17 const CloudVolume::Point boosted{light.x*gain.red,light.y*gain.green,light.z*gain.blue};
18 const float peak=(std::max)({boosted.x,boosted.y,boosted.z});
19 // One shoulder for all channels preserves hue and bright-cloud detail.
20 // Keep an already-bright source unchanged at identity gain. The .90 knee
21 // is a display choice matching the existing exposure target, not physics.
22 const float knee=(std::min)(1.f,(std::max)({.90f,light.x,light.y,light.z}));
23 const float headroom=1.f-knee;
24 const float mapped=peak>knee ? 1.f-headroom*headroom/(peak-knee+headroom) : peak;
25 return CloudVolume::Scale(boosted,peak>0 ? mapped/peak : 1.f);
26}
27
33
34inline Lighting Evaluate(bool active, bool simulator, CloudVolume::Point scattered,
35 CloudVolume::Point airglow, float sunCosine, float altitude, float base, float top)
36{
37 const auto visible=CloudVolume::WithAirglow(scattered,airglow,sunCosine,altitude,base,top);
38 // Meter the same unamplified mixture that the cloud actually displays.
39 // The old ambient-only meter overexposed brighter airglow by orders of magnitude.
40 const auto gain=NightVisionGain::Calculate(active,simulator,Luminance(visible));
41 return {Amplify(visible,gain),gain};
42}
43}
CloudVolume::Point Amplify(CloudVolume::Point light, const NightVisionGain::Response &gain)
float Luminance(CloudVolume::Point light)
Lighting Evaluate(bool active, bool simulator, CloudVolume::Point scattered, CloudVolume::Point airglow, float sunCosine, float altitude, float base, float top)
Point Scale(Point p, float s)
Definition CloudVolume.h:93
Point WithAirglow(Point scattered, Point airglow, float sunCosine, float altitude, float base, float top)
Response Calculate(bool active, bool simulator, float luminance)
NightVisionGain::Response gain