Antkeeper  0.0.1
cascaded-shadow-map-stage.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_RENDER_CASCADED_SHADOW_MAP_STAGE_HPP
21 #define ANTKEEPER_RENDER_CASCADED_SHADOW_MAP_STAGE_HPP
22 
23 #include <engine/render/stage.hpp>
27 #include <engine/gl/pipeline.hpp>
30 #include <memory>
31 #include <string>
32 #include <unordered_map>
33 
34 namespace render {
35 
40 {
41 public:
49 
50  void execute(render::context& ctx) override;
51 
59  void set_max_bone_count(std::size_t bone_count);
60 
62  [[nodiscard]] inline constexpr std::size_t get_max_bone_count() const noexcept
63  {
64  return m_max_bone_count;
65  }
66 
67 private:
71  void queue(render::context& ctx, scene::directional_light& light, const math::fmat4& light_view_projection);
72 
79  void render_shadow_atlas(render::context& ctx, scene::directional_light& light);
80 
82  void rebuild_static_mesh_shader_program();
83 
85  void rebuild_skeletal_mesh_shader_program();
86 
87  gl::pipeline* m_pipeline;
88 
89  std::size_t m_max_bone_count{64};
90 
91  std::unordered_map<std::string, std::string> m_shader_template_definitions;
92 
93  std::shared_ptr<gl::shader_template> m_static_mesh_shader_template;
94  std::unique_ptr<gl::shader_program> m_static_mesh_shader_program;
95  const gl::shader_variable* m_static_mesh_model_view_projection_var;
96 
97  std::shared_ptr<gl::shader_template> m_skeletal_mesh_shader_template;
98  std::unique_ptr<gl::shader_program> m_skeletal_mesh_shader_program;
99  const gl::shader_variable* m_skeletal_mesh_model_view_projection_var;
100  const gl::shader_variable* m_skeletal_mesh_matrix_palette_var;
101 };
102 
103 } // namespace render
104 
105 #endif // ANTKEEPER_RENDER_CASCADED_SHADOW_MAP_STAGE_HPP
Graphics pipeline interface.
Definition: pipeline.hpp:48
Shader program variable.
Renders cascaded shadow maps for directional lights.
constexpr std::size_t get_max_bone_count() const noexcept
Returns the maximum bone count for shadow-casting skeletal meshes.
void execute(render::context &ctx) override
Executes the render stage.
void set_max_bone_count(std::size_t bone_count)
Sets the maximum bone count for shadow-casting skeletal meshes.
cascaded_shadow_map_stage(gl::pipeline &pipeline, ::resource_manager &resource_manager)
Constructs a cascaded shadow map stage.
Abstract base class for a single stage in a render pipeline.
Definition: stage.hpp:31
Manages the loading, caching, and saving of resources.
Light source with parallel rays and constant intensity.
High-level rendering.
n by m column-major matrix.
Definition: math/matrix.hpp:44
Context of a renderer.
Definition: context.hpp:40