Unravel Engine C++ Reference
Loading...
Searching...
No Matches
reflection_probe_component.h
Go to the documentation of this file.
1#pragma once
2#include <base/basetypes.hpp>
5
8
9#include <array>
10
11namespace unravel
12{
13
18class reflection_probe_component : public component_crtp<reflection_probe_component>
19{
20public:
25 auto get_probe() const -> const reflection_probe&;
26
31 void set_probe(const reflection_probe& probe);
32
36 auto get_bounds() const -> math::bbox;
37
48 const math::vec3& position,
49 const math::vec3& scale,
50 const math::vec3& view_origin,
51 const math::transform& view,
52 const math::transform& proj) const -> int;
53
59 auto get_render_view(size_t idx) -> gfx::render_view&;
60
66 auto get_cubemap() -> const gfx::texture::ptr&;
67
72 auto get_cubemap_fbo(size_t face) -> const gfx::frame_buffer::ptr&;
73
78 void update(float dt);
79 void release_resources();
80
85 auto already_generated() const -> bool;
86
91 auto already_generated(size_t face) const -> bool;
92
96 void set_generation_frame(size_t face, uint64_t frame);
97
106 void mark_dirty(bool force_full_first_frame = false);
107
111 auto is_dirty() const -> bool;
112
116 auto is_bake_cycle_unstarted() const -> bool;
117
121 auto is_bake_complete() const -> bool;
122
127 auto get_faces_per_frame() const -> size_t { return faces_per_frame_; }
128
133 void set_faces_per_frame(size_t faces) { faces_per_frame_ = faces; }
134
139 auto get_apply_prefilter() const -> bool { return apply_prefilter_; }
140
145 void set_apply_prefilter(bool apply) { apply_prefilter_ = apply; }
146
150 auto get_update_mode() const -> probe_update_mode { return update_mode_; }
151
158
162 auto get_update_interval() const -> float { return update_interval_; }
163
168 void set_update_interval(float seconds) { update_interval_ = seconds; }
169
173 auto get_resolution() const -> probe_resolution { return resolution_; }
174
178 void set_resolution(probe_resolution resolution);
179
183 auto get_capture_sky() const -> bool { return capture_sky_; }
184
189 void set_capture_sky(bool capture);
190
194 auto get_capture_shadows() const -> bool { return capture_shadows_; }
195
199 void set_capture_shadows(bool capture);
200
201private:
205 reflection_probe probe_;
206
210 std::array<gfx::render_view, 6> face_rviews_;
211 gfx::render_view rview_;
212
213 std::array<uint64_t, 6> generated_frame_{uint64_t(-1),
214 uint64_t(-1),
215 uint64_t(-1),
216 uint64_t(-1),
217 uint64_t(-1),
218 uint64_t(-1)};
219
220 bool apply_prefilter_{true};
223 size_t faces_per_frame_ = 1;
225 size_t generated_faces_count_ = 0;
228 bool first_generation_{true};
230 float time_since_last_refresh_ = 0.0f;
234 bool has_pending_bake_{false};
235
242 float update_interval_{0.0f};
246 bool capture_sky_{true};
248 bool capture_shadows_{true};
249};
250
251} // namespace unravel
General purpose transformation class designed to maintain each component of the transformation separa...
Definition transform.hpp:27
Class that contains core reflection probe data, used for rendering and other purposes.
auto is_dirty() const -> bool
Returns true if the probe has pending or in-flight cubemap generation work.
auto compute_projected_sphere_rect(irect32_t &rect, const math::vec3 &position, const math::vec3 &scale, const math::vec3 &view_origin, const math::transform &view, const math::transform &proj) const -> int
Computes the projected sphere rectangle.
auto get_resolution() const -> probe_resolution
Gets the cubemap face resolution.
void set_apply_prefilter(bool apply)
Sets whether to apply prefiltering.
void mark_dirty(bool force_full_first_frame=false)
Requests the probe to rebuild its cubemap.
void set_capture_sky(bool capture)
Sets whether the atmospheric sky pass runs during cubemap capture. Disable for interior/local probes ...
void set_faces_per_frame(size_t faces)
Sets the number of faces generated per frame.
auto get_update_interval() const -> float
Gets the realtime refresh interval in seconds. Only consulted for realtime probes.
auto get_cubemap_fbo(size_t face) -> const gfx::frame_buffer::ptr &
Gets the cubemap frame buffer object (FBO).
auto get_bounds() const -> math::bbox
Gets the bounding box of the probe object.
auto is_bake_complete() const -> bool
Returns true when all six cubemap faces have been rendered in the current bake cycle.
void set_update_interval(float seconds)
Sets the realtime refresh interval in seconds.
auto get_apply_prefilter() const -> bool
Gets whether prefiltering is applied.
auto get_probe() const -> const reflection_probe &
Gets the reflection probe object.
void set_resolution(probe_resolution resolution)
Sets the cubemap face resolution. Triggers a rebuild when changed.
auto get_capture_sky() const -> bool
Returns true when the atmospheric sky pass is included during cubemap capture.
auto get_cubemap_prefiltered() -> const gfx::texture::ptr &
Gets the cubemap texture.
auto get_update_mode() const -> probe_update_mode
Gets the probe's update policy.
void set_capture_shadows(bool capture)
Sets whether shadow maps are built and sampled during cubemap capture.
void update(float dt)
Advances the probe's update bookkeeping. Called once per frame by reflection_probe_system.
auto is_bake_cycle_unstarted() const -> bool
Returns true when a bake has been requested but no cubemap face has been emitted yet.
void set_generation_frame(size_t face, uint64_t frame)
marks the genrerated face this frame
void set_update_mode(probe_update_mode mode)
Sets the probe's update policy. Switching INTO on_demand leaves the current bake state as-is; switchi...
auto get_capture_shadows() const -> bool
Returns true when shadow maps are rendered during cubemap capture.
auto get_render_view(size_t idx) -> gfx::render_view &
Gets the render view.
auto get_faces_per_frame() const -> size_t
Gets the number of faces generated per frame.
auto already_generated() const -> bool
Check if the cubemap was generated this frame.
auto get_cubemap() -> const gfx::texture::ptr &
void set_probe(const reflection_probe &probe)
Sets the reflection probe object.
math::vec3 position
Definition defaults.cpp:52
uint16_t view
uint32_t frame
Definition graphics.cpp:23
probe_update_mode
Enum class describing when a reflection probe refreshes its cubemap.
@ once
Bakes once on load (or when edited in the editor), then stops refreshing until marked dirty.
probe_resolution
Fixed cubemap face resolutions supported by reflection probes.
std::vector< float > scale
Storage for box vector values and wraps up common functionality.
Definition bbox.h:21
CRTP (Curiously Recurring Template Pattern) base structure for components.
Structure representing a reflection probe.