Unravel Engine C++ Reference
Loading...
Searching...
No Matches
auto_exposure_component.cpp
Go to the documentation of this file.
2
5
6namespace unravel
7{
8
10{
11 entt::meta_factory<exposure_metering_mode>{}
12 .type("exposure_metering_mode"_hs)
14 entt::attribute{"name", "exposure_metering_mode"},
15 entt::attribute{"pretty_name", "Metering Mode"},
16 })
17 .data<exposure_metering_mode::average>("average"_hs)
19 entt::attribute{"name", "average"},
20 entt::attribute{"pretty_name", "Average"},
21 })
22 .data<exposure_metering_mode::center_weighted>("center_weighted"_hs)
24 entt::attribute{"name", "center_weighted"},
25 entt::attribute{"pretty_name", "Center Weighted"},
26 })
27 .data<exposure_metering_mode::spot>("spot"_hs)
29 entt::attribute{"name", "spot"},
30 entt::attribute{"pretty_name", "Spot"},
31 });
32
33 entt::meta_factory<auto_exposure_pass::settings>{}
34 .type("auto_exposure_settings"_hs)
36 entt::attribute{"name", "auto_exposure_settings"},
37 entt::attribute{"pretty_name", "Auto Exposure Settings"},
38 })
39 .data<&auto_exposure_pass::settings::min_ev>("min_ev"_hs)
41 entt::attribute{"name", "min_ev"},
42 entt::attribute{"pretty_name", "Min EV"},
43 entt::attribute{"min", -10.0f},
44 entt::attribute{"max", 20.0f},
45 entt::attribute{"step", 0.5f},
46 entt::attribute{"tooltip", "Lower clamp for metered scene brightness (relative EV). "
47 "Controls how much the system can BRIGHTEN dark scenes: a LOWER value allows "
48 "more brightening (more upward adaptation headroom when moving into shadow/interiors). "
49 "Default -1 keeps it subtle (~1 stop). Only engages when the scene meters below this value."},
50 })
51 .data<&auto_exposure_pass::settings::max_ev>("max_ev"_hs)
53 entt::attribute{"name", "max_ev"},
54 entt::attribute{"pretty_name", "Max EV"},
55 entt::attribute{"min", -10.0f},
56 entt::attribute{"max", 24.0f},
57 entt::attribute{"step", 0.5f},
58 entt::attribute{"tooltip", "Upper clamp for metered scene brightness (relative EV). "
59 "Controls how much the system can DARKEN bright scenes: a HIGHER value allows "
60 "more darkening. Lighting here is authored at a fixed reference exposure (not "
61 "physical cd/m2), so the default 0 pins the bright end at the authored daylight "
62 "level. Raise it only if very bright scenes should tone down below that. "
63 "Use Compensation to shift overall brightness."},
64 })
65 .data<&auto_exposure_pass::settings::compensation>("compensation"_hs)
67 entt::attribute{"name", "compensation"},
68 entt::attribute{"pretty_name", "Compensation"},
69 entt::attribute{"min", -10.0f},
70 entt::attribute{"max", 10.0f},
71 entt::attribute{"step", 0.1f},
72 entt::attribute{"tooltip", "Global exposure bias in EV stops, applied on top of the auto-exposure result."
73 "Use this to make the scene uniformly brighter or darker."
74 "+1 = twice as bright, -1 = half as bright."
75 "This is the main knob for adjusting overall scene brightness."},
76 })
77 .data<&auto_exposure_pass::settings::adaptation_speed_up>("adaptation_speed_up"_hs)
79 entt::attribute{"name", "adaptation_speed_up"},
80 entt::attribute{"pretty_name", "Adaptation Time Up"},
81 entt::attribute{"min", 0.01f},
82 entt::attribute{"step", 0.1f},
83 entt::attribute{"tooltip", "Time constant in SECONDS for exposure to increase (scene getting darker, e.g. walking indoors). "
84 "Higher = slower adaptation, mimicking human eye dilation. Adaptation happens in EV/log space. "
85 "Typically 2-5 seconds."},
86 })
87 .data<&auto_exposure_pass::settings::adaptation_speed_down>("adaptation_speed_down"_hs)
89 entt::attribute{"name", "adaptation_speed_down"},
90 entt::attribute{"pretty_name", "Adaptation Time Down"},
91 entt::attribute{"min", 0.01f},
92 entt::attribute{"step", 0.1f},
93 entt::attribute{"tooltip", "Time constant in SECONDS for exposure to decrease (scene getting brighter, e.g. walking outdoors). "
94 "Lower = faster adaptation, mimicking quick pupil constriction. Adaptation happens in EV/log space. "
95 "Typically 0.5-2 seconds."},
96 })
97 .data<&auto_exposure_pass::settings::low_percentile>("low_percentile"_hs)
99 entt::attribute{"name", "low_percentile"},
100 entt::attribute{"pretty_name", "Low Percentile"},
101 entt::attribute{"min", 0.0f},
102 entt::attribute{"max", 0.95f},
103 entt::attribute{"step", 0.01f},
104 entt::attribute{"tooltip", "Fraction of darkest pixels to exclude from the exposure calculation."
105 "Higher values ignore more shadows, keeping them dark and natural."
106 "At 0.50 the darkest half of all pixels are excluded."
107 "Unreal uses ~0.80, Unity uses ~0.40."
108 "Increase this if auto-exposure is washing out shadows."},
109 })
110 .data<&auto_exposure_pass::settings::high_percentile>("high_percentile"_hs)
112 entt::attribute{"name", "high_percentile"},
113 entt::attribute{"pretty_name", "High Percentile"},
114 entt::attribute{"min", 0.5f},
115 entt::attribute{"max", 1.0f},
116 entt::attribute{"step", 0.01f},
117 entt::attribute{"tooltip", "Fraction of pixels to include before cutting off the brightest."
118 "Pixels above this percentile (sky, sun, specular highlights) are excluded."
119 "At 0.95 the brightest 5% of pixels are ignored."
120 "Lower this if bright sky or highlights are driving the exposure too low."},
121 })
122 .data<&auto_exposure_pass::settings::metering_mode>("metering_mode"_hs)
124 entt::attribute{"name", "metering_mode"},
125 entt::attribute{"pretty_name", "Metering Mode"},
126 entt::attribute{"tooltip", "How pixels are spatially weighted when measuring scene brightness. "
127 "Average = whole frame equally. "
128 "Center Weighted = smooth falloff toward the edges (recommended, avoids sky/edges dominating). "
129 "Spot = only a central circle is measured."},
130 })
131 .data<&auto_exposure_pass::settings::metering_area>("metering_area"_hs)
133 entt::attribute{"name", "metering_area"},
134 entt::attribute{"pretty_name", "Metering Area"},
135 entt::attribute{"min", 0.05f},
136 entt::attribute{"max", 1.5f},
137 entt::attribute{"step", 0.05f},
138 entt::attribute{"tooltip", "Size of the metering region (in screen-normalized units). "
139 "For Center Weighted this is the Gaussian falloff radius; for Spot it is the hard cutoff radius. "
140 "Has no effect in Average mode."},
141 });
142}
143
145{
146 try_save(ar, ser20::make_nvp("min_ev", obj.min_ev));
147 try_save(ar, ser20::make_nvp("max_ev", obj.max_ev));
148 try_save(ar, ser20::make_nvp("compensation", obj.compensation));
149 try_save(ar, ser20::make_nvp("adaptation_speed_up", obj.adaptation_speed_up));
150 try_save(ar, ser20::make_nvp("adaptation_speed_down", obj.adaptation_speed_down));
151 try_save(ar, ser20::make_nvp("low_percentile", obj.low_percentile));
152 try_save(ar, ser20::make_nvp("high_percentile", obj.high_percentile));
153 try_save(ar, ser20::make_nvp("metering_mode", obj.metering_mode));
154 try_save(ar, ser20::make_nvp("metering_area", obj.metering_area));
155}
158
160{
161 try_load(ar, ser20::make_nvp("min_ev", obj.min_ev));
162 try_load(ar, ser20::make_nvp("max_ev", obj.max_ev));
163 try_load(ar, ser20::make_nvp("compensation", obj.compensation));
164 try_load(ar, ser20::make_nvp("adaptation_speed_up", obj.adaptation_speed_up));
165 try_load(ar, ser20::make_nvp("adaptation_speed_down", obj.adaptation_speed_down));
166 try_load(ar, ser20::make_nvp("low_percentile", obj.low_percentile));
167 try_load(ar, ser20::make_nvp("high_percentile", obj.high_percentile));
168 try_load(ar, ser20::make_nvp("metering_mode", obj.metering_mode));
169 try_load(ar, ser20::make_nvp("metering_area", obj.metering_area));
170}
173
175{
176 entt::meta_factory<auto_exposure_component>{}
177 .type("auto_exposure_component"_hs)
179 entt::attribute{"name", "auto_exposure_component"},
180 entt::attribute{"category", "RENDERING"},
181 entt::attribute{"pretty_name", "Auto Exposure"},
182 })
183 .func<&component_meta<auto_exposure_component>::exists>("component_exists"_hs)
184 .func<&component_meta<auto_exposure_component>::add>("component_add"_hs)
185 .func<&component_meta<auto_exposure_component>::remove>("component_remove"_hs)
186 .func<&component_meta<auto_exposure_component>::save>("component_save"_hs)
187 .func<&component_meta<auto_exposure_component>::load>("component_load"_hs)
188 .data<&auto_exposure_component::enabled>("enabled"_hs)
189 .custom<entt::attributes>(entt::attributes{
190 entt::attribute{"name", "enabled"},
191 entt::attribute{"pretty_name", "Enabled"},
192 entt::attribute{"tooltip", "Enable histogram-based auto exposure (eye adaptation). When enabled, the camera dynamically adjusts exposure based on scene brightness using a log2 luminance histogram with percentile trimming."},
193 })
194 .data<&auto_exposure_component::settings>("settings"_hs)
196 entt::attribute{"name", "settings"},
197 entt::attribute{"pretty_name", "Settings"},
198 entt::attribute{"flattable", true},
199 });
200}
201
203{
204 try_save(ar, ser20::make_nvp("enabled", obj.enabled));
205 try_save(ar, ser20::make_nvp("settings", obj.settings));
206}
209
211{
212 try_load(ar, ser20::make_nvp("enabled", obj.enabled));
213 try_load(ar, ser20::make_nvp("settings", obj.settings));
214}
217
218} // namespace unravel
attributes::value_type attribute
Definition reflection.h:19
std::map< std::string, meta_any > attributes
Definition reflection.h:18
BinaryInputArchive iarchive_binary_t
simd::JSONOutputArchive oarchive_associative_t
BinaryOutputArchive oarchive_binary_t
simd::JSONInputArchive iarchive_associative_t
#define REFLECT(cls)
Definition reflection.h:149
#define REFLECT_INLINE(cls)
Definition reflection.h:144
#define SAVE_INSTANTIATE(cls, Archive)
#define LOAD(cls)
auto try_save(Archive &ar, ser20::NameValuePair< T > &&t, const hpp::source_location &loc=hpp::source_location::current()) -> bool
#define LOAD_INSTANTIATE(cls, Archive)
#define SAVE(cls)
#define LOAD_INLINE(cls)
#define SAVE_INLINE(cls)
auto try_load(Archive &ar, ser20::NameValuePair< T > &&t, const hpp::source_location &loc=hpp::source_location::current()) -> bool