2#ifndef LIBSBX_MODELS_STATIC_MESH_MATERIAL_SUBRENDERER_HPP_
3#define LIBSBX_MODELS_STATIC_MESH_MATERIAL_SUBRENDERER_HPP_
7#include <unordered_set>
11#include <easy/profiler.h>
13#include <fmt/format.h>
15#include <range/v3/view/enumerate.hpp>
17#include <libsbx/utility/logger.hpp>
18#include <libsbx/utility/enum.hpp>
20#include <libsbx/reflection/description.hpp>
22#include <libsbx/memory/tracking_allocator.hpp>
24#include <libsbx/containers/octree.hpp>
27#include <libsbx/math/vector3.hpp>
28#include <libsbx/math/matrix4x4.hpp>
29#include <libsbx/math/volume.hpp>
31#include <libsbx/utility/logger.hpp>
32#include <libsbx/utility/timer.hpp>
33#include <libsbx/utility/layout.hpp>
34#include <libsbx/utility/iterator.hpp>
36#include <libsbx/core/engine.hpp>
38#include <libsbx/graphics/graphics_module.hpp>
39#include <libsbx/graphics/subrenderer.hpp>
40#include <libsbx/graphics/draw_list.hpp>
42#include <libsbx/graphics/pipeline/pipeline.hpp>
43#include <libsbx/graphics/pipeline/graphics_pipeline.hpp>
45#include <libsbx/graphics/descriptor/descriptor_handler.hpp>
47#include <libsbx/graphics/buffers/uniform_handler.hpp>
48#include <libsbx/graphics/buffers/storage_handler.hpp>
49#include <libsbx/graphics/buffers/storage_buffer.hpp>
51#include <libsbx/graphics/images/image2d.hpp>
52#include <libsbx/graphics/images/separate_image2d_array.hpp>
53#include <libsbx/graphics/images/sampler_state.hpp>
55#include <libsbx/assets/assets_module.hpp>
57#include <libsbx/scenes/scenes_module.hpp>
58#include <libsbx/scenes/scene.hpp>
59#include <libsbx/scenes/node.hpp>
61#include <libsbx/scenes/components/static_mesh.hpp>
62#include <libsbx/scenes/components/id.hpp>
63#include <libsbx/scenes/components/camera.hpp>
64#include <libsbx/scenes/components/tag.hpp>
65#include <libsbx/scenes/components/point_light.hpp>
66#include <libsbx/scenes/components/global_transform.hpp>
68#include <libsbx/models/vertex3d.hpp>
69#include <libsbx/models/mesh.hpp>
70#include <libsbx/models/material.hpp>
71#include <libsbx/models/material_draw_list.hpp>
72#include <libsbx/models/static_mesh_material_draw_list.hpp>
73#include <libsbx/models/frustum_culling_task.hpp>
75namespace sbx::models {
80 .depth = graphics::depth::read_write,
81 .uses_transparency =
false,
83 .polygon_mode = graphics::polygon_mode::fill,
84 .cull_mode = graphics::cull_mode::back,
85 .front_face = graphics::front_face::counter_clockwise
89 inline static constexpr auto default_pipeline_path = std::string_view{
"engine://shaders/deferred_pbr_material"};
93 static_mesh_material_subrenderer(
const std::vector<graphics::attachment_description>& attachments,
const static_mesh_material_draw_list::bucket bucket,
const std::filesystem::path& base_pipeline = default_pipeline_path);
101 struct pipeline_data {
108 push_handler{pipeline} { }
112 struct descriptor_data {
119 : scene_descriptor_handler{handle, 0u},
120 sampler_descriptor_handler{handle, 1u},
121 image_descriptor_handler{handle, 2u} { }
125 auto _get_or_create_pipeline(
const material_key& key) -> pipeline_data&;
129 inline static const auto _entry_point = std::array<std::string, 3u>{
135 std::vector<graphics::attachment_description> _attachments;
136 std::filesystem::path _base_pipeline;
137 static_mesh_material_draw_list::bucket _bucket;
139 inline static auto _pipeline_cache = std::unordered_map<material_key, pipeline_data, material_key_hash>{};
141 std::unordered_map<graphics::graphics_pipeline_handle, descriptor_data> _descriptor_cache{};
150 static constexpr auto name() -> std::string_view {
151 return "material_feature";
154 static constexpr auto enumerators() {
155 return std::make_tuple(
156 enumerator{
"cast_shadow", sbx::models::material_feature::cast_shadow},
157 enumerator{
"receive_shadow", sbx::models::material_feature::receive_shadow},
158 enumerator{
"invert_backface_normals", sbx::models::material_feature::invert_backface_normals}
Definition: command_buffer.hpp:15
Definition: descriptor_handler.hpp:26
Definition: push_handler.hpp:18
Definition: resource_storage.hpp:18
Definition: subrenderer.hpp:14
Definition: static_mesh_material_subrenderer.hpp:77
RGBA color representation and utilities.
Definition: graphics_pipeline.hpp:106
Definition: graphics_pipeline.hpp:67
Definition: material.hpp:87
Definition: description.hpp:16
Definition: enumerator.hpp:10