Antkeeper  0.0.1
light-probe.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 Christopher J. Howard
3  *
4  * This file is part of Antkeeper source code.
5  *
6  * Antkeeper source code is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Antkeeper source code is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef ANTKEEPER_SCENE_LIGHT_PROBE_HPP
21 #define ANTKEEPER_SCENE_LIGHT_PROBE_HPP
22 
23 #include <engine/scene/object.hpp>
24 #include <engine/gl/texture.hpp>
26 #include <engine/math/matrix.hpp>
27 #include <memory>
28 #include <span>
29 #include <vector>
30 
31 namespace scene {
32 
36 class light_probe: public object<light_probe>
37 {
38 public:
40  light_probe();
41 
48 
57  void set_luminance_texture(std::shared_ptr<gl::texture_cube> texture);
58 
64  void set_luminance_outdated(bool outdated);
65 
71  void set_illuminance_outdated(bool outdated);
72 
74  [[nodiscard]] inline const std::shared_ptr<gl::texture_cube>& get_luminance_texture() const noexcept
75  {
76  return m_luminance_texture;
77  }
78 
80  [[nodiscard]] inline const std::vector<std::shared_ptr<gl::framebuffer>>& get_luminance_framebuffers() const noexcept
81  {
82  return m_luminance_framebuffers;
83  }
84 
90  [[nodiscard]] inline const std::shared_ptr<gl::texture_1d>& get_illuminance_texture() const noexcept
91  {
92  return m_illuminance_texture;
93  }
94 
96  [[nodiscard]] inline const std::shared_ptr<gl::framebuffer>& get_illuminance_framebuffer() const noexcept
97  {
98  return m_illuminance_framebuffer;
99  }
100 
110  [[nodiscard]] inline std::span<const math::fmat4, 3> get_illuminance_matrices() const noexcept
111  {
112  return m_illuminance_matrices;
113  }
114 
116  [[nodiscard]] inline bool is_luminance_outdated() const noexcept
117  {
118  return m_luminance_outdated;
119  }
120 
122  [[nodiscard]] inline bool is_illuminance_outdated() const noexcept
123  {
124  return m_illuminance_outdated;
125  }
126 
127  [[nodiscard]] inline const aabb_type& get_bounds() const noexcept override
128  {
129  return m_bounds;
130  }
131 
132 private:
133  void transformed() override;
134  aabb_type m_bounds{};
135  std::shared_ptr<gl::texture_cube> m_luminance_texture;
136  std::vector<std::shared_ptr<gl::framebuffer>> m_luminance_framebuffers;
137  std::shared_ptr<gl::texture_1d> m_illuminance_texture;
138  std::shared_ptr<gl::framebuffer> m_illuminance_framebuffer;
139  math::fmat4 m_illuminance_matrices[3];
140  bool m_luminance_outdated{};
141  bool m_illuminance_outdated{};
142 };
143 
144 } // namespace scene
145 
146 #endif // ANTKEEPER_SCENE_LIGHT_PROBE_HPP
const std::shared_ptr< gl::framebuffer > & get_illuminance_framebuffer() const noexcept
Returns the light probe's illuminance framebuffer.
Definition: light-probe.hpp:96
const aabb_type & get_bounds() const noexcept override
Returns the bounds of the object.
bool is_luminance_outdated() const noexcept
Returns true if the light probe's luminance is outdated.
void set_luminance_texture(std::shared_ptr< gl::texture_cube > texture)
Sets the light probe's luminance texture.
Definition: light-probe.cpp:79
const std::shared_ptr< gl::texture_cube > & get_luminance_texture() const noexcept
Returns the light probe's luminance texture.
Definition: light-probe.hpp:74
void update_illuminance_matrices()
Updates the light probe's illuminance matrices from its illuminance texture.
Definition: light-probe.cpp:63
std::span< const math::fmat4, 3 > get_illuminance_matrices() const noexcept
Returns the light probe's illuminance matrices.
const std::shared_ptr< gl::texture_1d > & get_illuminance_texture() const noexcept
Returns the light probe's illuminance texture.
Definition: light-probe.hpp:90
void set_illuminance_outdated(bool outdated)
Marks the light probe's illuminance as either outdated or current.
bool is_illuminance_outdated() const noexcept
Returns true if the light probe's illuminance is outdated.
light_probe()
Constructs a light probe.
Definition: light-probe.cpp:24
const std::vector< std::shared_ptr< gl::framebuffer > > & get_luminance_framebuffers() const noexcept
Returns the light probe's luminance framebuffers.
Definition: light-probe.hpp:80
void set_luminance_outdated(bool outdated)
Marks the light probe's luminance as either outdated or current.
geom::box< float > aabb_type
Definition: object.hpp:42
Abstract base class for lights, cameras, model instances, and other scene objects.
Definition: object.hpp:172
3D scene.
Definition: context.hpp:28
n-dimensional axis-aligned rectangle.
n by m column-major matrix.
Definition: math/matrix.hpp:44