Unravel Engine C++ Reference
Loading...
Searching...
No Matches
assao_component.cpp
Go to the documentation of this file.
1#include "assao_component.hpp"
3
6
7namespace unravel
8{
9
11{
13 // Register assao_pass::settings class with entt
14 entt::meta_factory<assao_pass::settings>{}
15 .type("assao_pass::settings"_hs)
17 entt::attribute{"name", "assao_pass::settings"},
18 entt::attribute{"pretty_name", "SSAO Settings"},
19 })
20 .data<&settings::radius>("radius"_hs)
22 entt::attribute{"name", "radius"},
23 entt::attribute{"pretty_name", "Radius"},
24 entt::attribute{"tooltip", "World (view) space size of the occlusion sphere.\nRange: [0.0, ∞)"},
25 })
26 .data<&settings::shadow_multiplier>("shadow_multiplier"_hs)
28 entt::attribute{"name", "shadow_multiplier"},
29 entt::attribute{"pretty_name", "Shadow Multiplier"},
30 entt::attribute{"min", 0.0f},
31 entt::attribute{"max", 5.0f},
32 entt::attribute{"tooltip", "Effect strength linear multiplier.\nRange: [0.0, 5.0]"},
33 })
34 .data<&settings::shadow_power>("shadow_power"_hs)
36 entt::attribute{"name", "shadow_power"},
37 entt::attribute{"pretty_name", "Shadow Power"},
38 entt::attribute{"min", 0.5f},
39 entt::attribute{"max", 5.0f},
40 entt::attribute{"tooltip", "Effect strength power modifier.\nRange: [0.5, 5.0]"},
41 })
42 .data<&settings::shadow_clamp>("shadow_clamp"_hs)
44 entt::attribute{"name", "shadow_clamp"},
45 entt::attribute{"pretty_name", "Shadow Clamp"},
46 entt::attribute{"min", 0.0f},
47 entt::attribute{"max", 1.0f},
48 entt::attribute{"tooltip", "Effect max limit (applied after multiplier but before blur).\nRange: [0.0, 1.0]"},
49 })
50 .data<&settings::horizon_angle_threshold>("horizon_angle_threshold"_hs)
52 entt::attribute{"name", "horizon_angle_threshold"},
53 entt::attribute{"pretty_name", "Horizon Angle Threshold"},
54 entt::attribute{"min", 0.0f},
55 entt::attribute{"max", 0.2f},
56 entt::attribute{"tooltip", "Limits self-shadowing. Makes sampling cone narrower to avoid artifacts.\nRange: [0.0, 0.2]"},
57 })
58 .data<&settings::fade_out_from>("fade_out_from"_hs)
60 entt::attribute{"name", "fade_out_from"},
61 entt::attribute{"pretty_name", "Fade Out From"},
62 entt::attribute{"tooltip", "Distance to start fading out the effect.\nRange: [0.0, ∞)"},
63 })
64 .data<&settings::fade_out_to>("fade_out_to"_hs)
66 entt::attribute{"name", "fade_out_to"},
67 entt::attribute{"pretty_name", "Fade Out To"},
68 entt::attribute{"tooltip", "Distance at which the effect is fully faded out.\nRange: [0.0, ∞)"},
69 })
70 .data<&settings::quality_level>("quality_level"_hs)
72 entt::attribute{"name", "quality_level"},
73 entt::attribute{"pretty_name", "Quality Level"},
74 entt::attribute{"min", -1},
75 entt::attribute{"max", 3},
76 entt::attribute{"tooltip", "-1: Lowest (low, half-res checkerboard)\n 0: Low\n 1: Medium\n 2: High\n 3: Very High / Adaptive\nRange: [-1, 3]"},
77 })
78 .data<&settings::adaptive_quality_limit>("adaptive_quality_limit"_hs)
80 entt::attribute{"name", "adaptive_quality_limit"},
81 entt::attribute{"pretty_name", "Adaptive Q Limit"},
82 entt::attribute{"min", 0.0f},
83 entt::attribute{"max", 1.0f},
84 entt::attribute{"tooltip", "Adaptive quality limit (only for Quality Level 3).\nRange: [0.0, 1.0]"},
85 })
86 .data<&settings::blur_pass_count>("blur_pass_count"_hs)
88 entt::attribute{"name", "blur_pass_count"},
89 entt::attribute{"pretty_name", "Blur Pass Count"},
90 entt::attribute{"min", 0},
91 entt::attribute{"max", 6},
92 entt::attribute{"tooltip", "Number of edge-sensitive blur passes.\nQuality 0 uses a single 'dumb' blur pass instead of smart passes.\nRange: [0, 6]"},
93 })
94 .data<&settings::sharpness>("sharpness"_hs)
96 entt::attribute{"name", "sharpness"},
97 entt::attribute{"pretty_name", "Sharpness"},
98 entt::attribute{"min", 0.0f},
99 entt::attribute{"max", 1.0f},
100 entt::attribute{"tooltip", "Sharpness (bleed over edges):\n 1.0 = Not at all\n 0.5 = Half-half\n 0.0 = Ignore edges entirely\nRange: [0.0, 1.0]"},
101 })
102 .data<&settings::temporal_supersampling_angle_offset>("temporal_supersampling_angle_offset"_hs)
104 entt::attribute{"name", "temporal_supersampling_angle_offset"},
105 entt::attribute{"pretty_name", "Temporal SSAO Angle Offset"},
106 entt::attribute{"min", 0.0f},
107 entt::attribute{"max", 3.14159265358979323846f},
108 entt::attribute{"tooltip", "Rotate sampling kernel. If using temporal AA/supersampling, recommended:\n ((frame % 3) / 3.0 * π) or similar.\nRange: [0.0, π]"},
109 })
110 .data<&settings::temporal_supersampling_radius_offset>("temporal_supersampling_radius_offset"_hs)
112 entt::attribute{"name", "temporal_supersampling_radius_offset"},
113 entt::attribute{"pretty_name", "Temporal SSAO Radius Offset"},
114 entt::attribute{"min", 0.0f},
115 entt::attribute{"max", 2.0f},
116 entt::attribute{"tooltip", "Scale sampling kernel. If using temporal AA/supersampling, recommended:\n (1.0 + (((frame % 3) - 1.0) / 3.0) * 0.1) or similar.\nRange: [0.0, 2.0]"},
117 })
118 .data<&settings::detail_shadow_strength>("detail_shadow_strength"_hs)
120 entt::attribute{"name", "detail_shadow_strength"},
121 entt::attribute{"pretty_name", "Detail Shadow Strength"},
122 entt::attribute{"min", 0.0f},
123 entt::attribute{"max", 5.0f},
124 entt::attribute{"tooltip", "High-res detail AO using neighboring depth pixels.\nAdds detail but reduces temporal stability (adds aliasing).\nRange: [0.0, 5.0]"},
125 })
126 .data<&settings::generate_normals>("generate_normals"_hs)
128 entt::attribute{"name", "generate_normals"},
129 entt::attribute{"pretty_name", "Generate Normals"},
130 entt::attribute{"tooltip", "If true, normals are generated from depth. Disable if precomputed normals are available."},
131 });
132}
133
135{
136 try_save(ar, ser20::make_nvp("radius", obj.radius));
137 try_save(ar, ser20::make_nvp("shadow_multiplier", obj.shadow_multiplier));
138 try_save(ar, ser20::make_nvp("shadow_power", obj.shadow_power));
139 try_save(ar, ser20::make_nvp("shadow_clamp", obj.shadow_clamp));
140 try_save(ar, ser20::make_nvp("horizon_angle_threshold", obj.horizon_angle_threshold));
141 try_save(ar, ser20::make_nvp("fade_out_from", obj.fade_out_from));
142 try_save(ar, ser20::make_nvp("fade_out_to", obj.fade_out_to));
143 try_save(ar, ser20::make_nvp("quality_level", obj.quality_level));
144 try_save(ar, ser20::make_nvp("adaptive_quality_limit", obj.adaptive_quality_limit));
145 try_save(ar, ser20::make_nvp("blur_pass_count", obj.blur_pass_count));
146 try_save(ar, ser20::make_nvp("sharpness", obj.sharpness));
147 try_save(ar, ser20::make_nvp("temporal_supersampling_angle_offset", obj.temporal_supersampling_angle_offset));
148 try_save(ar, ser20::make_nvp("temporal_supersampling_radius_offset", obj.temporal_supersampling_radius_offset));
149 try_save(ar, ser20::make_nvp("detail_shadow_strength", obj.detail_shadow_strength));
150 try_save(ar, ser20::make_nvp("generate_normals", obj.generate_normals));
151}
154
156{
157 try_load(ar, ser20::make_nvp("radius", obj.radius));
158 try_load(ar, ser20::make_nvp("shadow_multiplier", obj.shadow_multiplier));
159 try_load(ar, ser20::make_nvp("shadow_power", obj.shadow_power));
160 try_load(ar, ser20::make_nvp("shadow_clamp", obj.shadow_clamp));
161 try_load(ar, ser20::make_nvp("horizon_angle_threshold", obj.horizon_angle_threshold));
162 try_load(ar, ser20::make_nvp("fade_out_from", obj.fade_out_from));
163 try_load(ar, ser20::make_nvp("fade_out_to", obj.fade_out_to));
164 try_load(ar, ser20::make_nvp("quality_level", obj.quality_level));
165 try_load(ar, ser20::make_nvp("adaptive_quality_limit", obj.adaptive_quality_limit));
166 try_load(ar, ser20::make_nvp("blur_pass_count", obj.blur_pass_count));
167 try_load(ar, ser20::make_nvp("sharpness", obj.sharpness));
168 try_load(ar, ser20::make_nvp("temporal_supersampling_angle_offset", obj.temporal_supersampling_angle_offset));
169 try_load(ar, ser20::make_nvp("temporal_supersampling_radius_offset", obj.temporal_supersampling_radius_offset));
170 try_load(ar, ser20::make_nvp("detail_shadow_strength", obj.detail_shadow_strength));
171 try_load(ar, ser20::make_nvp("generate_normals", obj.generate_normals));
172}
175
177{
178 entt::meta_factory<assao_component>{}
179 .type("assao_component"_hs)
181 entt::attribute{"name", "assao_component"},
182 entt::attribute{"category", "RENDERING"},
183 entt::attribute{"pretty_name", "ASSAO"},
184 })
185 .func<&component_meta<assao_component>::exists>("component_exists"_hs)
186 .func<&component_meta<assao_component>::add>("component_add"_hs)
187 .func<&component_meta<assao_component>::save>("component_save"_hs)
188 .func<&component_meta<assao_component>::load>("component_load"_hs)
189 .func<&component_meta<assao_component>::remove>("component_remove"_hs)
190 .data<&assao_component::enabled>("enabled"_hs)
191 .custom<entt::attributes>(entt::attributes{
192 entt::attribute{"name", "enabled"},
193 entt::attribute{"pretty_name", "Enabled"},
194 entt::attribute{"tooltip", "Enable/disable ASSAO ambient occlusion"},
195 })
196 .data<&assao_component::settings>("settings"_hs)
198 entt::attribute{"name", "settings"},
199 entt::attribute{"pretty_name", "Settings"},
200 entt::attribute{"flattable", true},
201 });
202}
203
205{
206 try_save(ar, ser20::make_nvp("enabled", obj.enabled));
207 try_save(ar, ser20::make_nvp("settings", obj.settings));
208}
211
213{
214 try_load(ar, ser20::make_nvp("enabled", obj.enabled));
215 try_load(ar, ser20::make_nvp("settings", obj.settings));
216}
219} // namespace unravel
bool enabled
Whether ASSAO is enabled.
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:133
#define REFLECT_INLINE(cls)
Definition reflection.h:128
#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