Unravel Engine C++ Reference
Loading...
Searching...
No Matches
bloom_component.cpp
Go to the documentation of this file.
1#include "bloom_component.hpp"
6namespace unravel
7{
8
10{
11 entt::meta_factory<bloom_pass::settings>{}
12 .type("bloom_settings"_hs)
14 entt::attribute{"name", "bloom_settings"},
15 entt::attribute{"pretty_name", "Bloom Settings"},
16 })
17 .data<&bloom_pass::settings::threshold>("threshold"_hs)
19 entt::attribute{"name", "threshold"},
20 entt::attribute{"pretty_name", "Threshold"},
21 entt::attribute{"min", 0.0f},
22 entt::attribute{"step", 0.1f},
23 entt::attribute{"tooltip", "Minimum brightness (HDR luminance) for a pixel to contribute to bloom. Higher values restrict bloom to only the brightest highlights. 0 = all pixels bloom (not recommended). Typical range: 0.5 - 2.0."},
24 })
25 .data<&bloom_pass::settings::soft_knee>("soft_knee"_hs)
27 entt::attribute{"name", "soft_knee"},
28 entt::attribute{"pretty_name", "Soft Knee"},
29 entt::attribute{"min", 0.0f},
30 entt::attribute{"max", 1.0f},
31 entt::attribute{"step", 0.05f},
32 entt::attribute{"tooltip", "Controls the transition width around the threshold. 0 = hard cutoff (sharp bloom boundary, can cause flickering), 1 = maximum smoothing (gradual fade-in, reduces specular flicker). Keep at 1.0 unless you specifically want a harder cutoff."},
33 })
34 .data<&bloom_pass::settings::clamp>("clamp"_hs)
36 entt::attribute{"name", "clamp"},
37 entt::attribute{"pretty_name", "Clamp"},
38 entt::attribute{"min", 0.0f},
39 entt::attribute{"step", 1.0f},
40 entt::attribute{"tooltip", "Soft compression limit for pixel brightness before bloom processing. Uses Reinhard-style compression to smoothly attenuate extreme values. Prevents firefly artifacts from very bright sub-pixel highlights (e.g. sun reflections, emissives). 0 = disabled. Typical range: 5 - 50."},
41 })
42 .data<&bloom_pass::settings::intensity>("intensity"_hs)
44 entt::attribute{"name", "intensity"},
45 entt::attribute{"pretty_name", "Intensity"},
46 entt::attribute{"min", 0.0f},
47 entt::attribute{"step", 0.1f},
48 entt::attribute{"tooltip", "Global multiplier for the entire bloom effect. Scales all per-mip contributions uniformly. 0 = no bloom, 1 = standard, >1 = exaggerated glow. This is the main knob for overall bloom strength."},
49 })
50 .data<&bloom_pass::settings::mip_count>("mip_count"_hs)
52 entt::attribute{"name", "mip_count"},
53 entt::attribute{"pretty_name", "Mip Count"},
54 entt::attribute{"min", 2},
55 entt::attribute{"max", 10},
56 entt::attribute{"tooltip", "Number of downsample levels in the bloom pyramid. More mips = wider bloom spread but more GPU cost. 5-7 is typical. Each additional mip doubles the maximum bloom radius."},
57 })
58 .data<&bloom_pass::settings::mip0_tint>("mip0_tint"_hs)
60 entt::attribute{"name", "mip0_tint"},
61 entt::attribute{"pretty_name", "Mip 0 Tint (1/2)"},
62 entt::attribute{"group", "Per-Mip Tint"},
63 entt::attribute{"tooltip", "Tint and weight for the 1/2 resolution bloom layer (tightest halo). RGB controls color, Alpha controls contribution weight (0 = off, 1 = full). This is the sharpest, closest bloom around bright objects."},
64 })
65 .data<&bloom_pass::settings::mip1_tint>("mip1_tint"_hs)
67 entt::attribute{"name", "mip1_tint"},
68 entt::attribute{"pretty_name", "Mip 1 Tint (1/4)"},
69 entt::attribute{"group", "Per-Mip Tint"},
70 entt::attribute{"tooltip", "Tint and weight for the 1/4 resolution bloom layer. RGB controls color, Alpha controls contribution weight. Produces a medium-tight bloom halo."},
71 })
72 .data<&bloom_pass::settings::mip2_tint>("mip2_tint"_hs)
74 entt::attribute{"name", "mip2_tint"},
75 entt::attribute{"pretty_name", "Mip 2 Tint (1/8)"},
76 entt::attribute{"group", "Per-Mip Tint"},
77 entt::attribute{"tooltip", "Tint and weight for the 1/8 resolution bloom layer. RGB controls color, Alpha controls contribution weight. Mid-range bloom spread."},
78 })
79 .data<&bloom_pass::settings::mip3_tint>("mip3_tint"_hs)
81 entt::attribute{"name", "mip3_tint"},
82 entt::attribute{"pretty_name", "Mip 3 Tint (1/16)"},
83 entt::attribute{"group", "Per-Mip Tint"},
84 entt::attribute{"tooltip", "Tint and weight for the 1/16 resolution bloom layer. RGB controls color, Alpha controls contribution weight. Wide soft glow."},
85 })
86 .data<&bloom_pass::settings::mip4_tint>("mip4_tint"_hs)
88 entt::attribute{"name", "mip4_tint"},
89 entt::attribute{"pretty_name", "Mip 4 Tint (1/32)"},
90 entt::attribute{"group", "Per-Mip Tint"},
91 entt::attribute{"tooltip", "Tint and weight for the 1/32 resolution bloom layer. RGB controls color, Alpha controls contribution weight. Very wide atmospheric glow."},
92 })
93 .data<&bloom_pass::settings::mip5_tint>("mip5_tint"_hs)
95 entt::attribute{"name", "mip5_tint"},
96 entt::attribute{"pretty_name", "Mip 5 Tint (1/64)"},
97 entt::attribute{"group", "Per-Mip Tint"},
98 entt::attribute{"tooltip", "Tint and weight for the 1/64 resolution bloom layer (widest bloom). RGB controls color, Alpha controls contribution weight. Controls the large-scale ambient glow that fills the screen. Reduce alpha to tighten bloom, increase for a dreamy look."},
99 })
100 .data<&bloom_pass::settings::dirt_intensity>("dirt_intensity"_hs)
102 entt::attribute{"name", "dirt_intensity"},
103 entt::attribute{"pretty_name", "Dirt Intensity"},
104 entt::attribute{"min", 0.0f},
105 entt::attribute{"step", 0.1f},
106 entt::attribute{"tooltip", "Strength of the lens dirt mask effect. Modulates bloom through a screen-space dirt texture to simulate smudges and scratches on the camera lens. 0 = disabled. Requires a dirt mask texture to be assigned (future feature)."},
107 });
108}
109
111{
112 try_save(ar, ser20::make_nvp("threshold", obj.threshold));
113 try_save(ar, ser20::make_nvp("soft_knee", obj.soft_knee));
114 try_save(ar, ser20::make_nvp("clamp", obj.clamp));
115 try_save(ar, ser20::make_nvp("intensity", obj.intensity));
116 try_save(ar, ser20::make_nvp("mip_count", obj.mip_count));
117 try_save(ar, ser20::make_nvp("mip0_tint", obj.mip0_tint));
118 try_save(ar, ser20::make_nvp("mip1_tint", obj.mip1_tint));
119 try_save(ar, ser20::make_nvp("mip2_tint", obj.mip2_tint));
120 try_save(ar, ser20::make_nvp("mip3_tint", obj.mip3_tint));
121 try_save(ar, ser20::make_nvp("mip4_tint", obj.mip4_tint));
122 try_save(ar, ser20::make_nvp("mip5_tint", obj.mip5_tint));
123 try_save(ar, ser20::make_nvp("dirt_intensity", obj.dirt_intensity));
124}
127
129{
130 try_load(ar, ser20::make_nvp("threshold", obj.threshold));
131 try_load(ar, ser20::make_nvp("soft_knee", obj.soft_knee));
132 try_load(ar, ser20::make_nvp("clamp", obj.clamp));
133 try_load(ar, ser20::make_nvp("intensity", obj.intensity));
134 try_load(ar, ser20::make_nvp("mip_count", obj.mip_count));
135 try_load(ar, ser20::make_nvp("mip0_tint", obj.mip0_tint));
136 try_load(ar, ser20::make_nvp("mip1_tint", obj.mip1_tint));
137 try_load(ar, ser20::make_nvp("mip2_tint", obj.mip2_tint));
138 try_load(ar, ser20::make_nvp("mip3_tint", obj.mip3_tint));
139 try_load(ar, ser20::make_nvp("mip4_tint", obj.mip4_tint));
140 try_load(ar, ser20::make_nvp("mip5_tint", obj.mip5_tint));
141 try_load(ar, ser20::make_nvp("dirt_intensity", obj.dirt_intensity));
142}
145
147{
148 entt::meta_factory<bloom_component>{}
149 .type("bloom_component"_hs)
151 entt::attribute{"name", "bloom_component"},
152 entt::attribute{"category", "RENDERING"},
153 entt::attribute{"pretty_name", "Bloom"},
154 })
155 .func<&component_meta<bloom_component>::exists>("component_exists"_hs)
156 .func<&component_meta<bloom_component>::add>("component_add"_hs)
157 .func<&component_meta<bloom_component>::remove>("component_remove"_hs)
158 .func<&component_meta<bloom_component>::save>("component_save"_hs)
159 .func<&component_meta<bloom_component>::load>("component_load"_hs)
160 .data<&bloom_component::enabled>("enabled"_hs)
161 .custom<entt::attributes>(entt::attributes{
162 entt::attribute{"name", "enabled"},
163 entt::attribute{"pretty_name", "Enabled"},
164 entt::attribute{"tooltip", "Enable/disable bloom post-processing"},
165 })
166 .data<&bloom_component::settings>("settings"_hs)
168 entt::attribute{"name", "settings"},
169 entt::attribute{"pretty_name", "Settings"},
170 entt::attribute{"flattable", true},
171 });
172}
173
175{
176 try_save(ar, ser20::make_nvp("enabled", obj.enabled));
177 try_save(ar, ser20::make_nvp("settings", obj.settings));
178}
181
183{
184 try_load(ar, ser20::make_nvp("enabled", obj.enabled));
185 try_load(ar, ser20::make_nvp("settings", obj.settings));
186}
189
190} // 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