2#ifndef LIBSBX_SCENES_SKYBOX_SUBRENDERER_HPP_
3#define LIBSBX_SCENES_SKYBOX_SUBRENDERER_HPP_
5#include <libsbx/graphics/subrenderer.hpp>
7#include <libsbx/graphics/images/cube_image.hpp>
9#include <libsbx/graphics/pipeline/graphics_pipeline.hpp>
10#include <libsbx/graphics/pipeline/vertex_input_description.hpp>
11#include <libsbx/graphics/pipeline/mesh.hpp>
13#include <libsbx/graphics/descriptor/descriptor_handler.hpp>
15#include <libsbx/graphics/buffers/uniform_handler.hpp>
17#include <libsbx/assets/assets_module.hpp>
19#include <libsbx/scenes/components/skybox.hpp>
20#include <libsbx/scenes/components/camera.hpp>
22namespace sbx::scenes {
32 mesh(std::vector<vertex3d>&& vertices, std::vector<std::uint32_t>&& indices)
35 ~mesh()
override =
default;
42 .depth = graphics::depth::read_only,
43 .compare_operation = graphics::compare_operation::less_or_equal,
44 .uses_transparency =
false,
46 .polygon_mode = graphics::polygon_mode::fill,
47 .cull_mode = graphics::cull_mode::none,
48 .front_face = graphics::front_face::counter_clockwise
52 inline static constexpr auto default_shader_path = std::string_view{
"engine://shaders/skybox"};
56 skybox_subrenderer(
const std::vector<graphics::attachment_description>& attachments,
const std::filesystem::path& path = default_shader_path)
58 _pipeline{path, attachments, pipeline_definition},
59 _descriptor_handler{_pipeline, 0u},
60 _push_handler{_pipeline} { }
65 EASY_BLOCK(
"skybox_subrenderer::render", profiler::colors::Indigo500);
67 auto& assets_module = core::engine::get_module<assets::assets_module>();
68 auto& graphics_module = core::engine::get_module<graphics::graphics_module>();
69 auto&
scenes_module = core::engine::get_module<scenes::scenes_module>();
72 auto& environment =
scene.environment();
73 auto& graph =
scene.graph();
75 const auto camera_node = environment.camera();
78 utility::logger<
"scenes">::warn(
"Skybox subrenderer: No camera node with skybox component found");
84 _pipeline.bind(command_buffer);
86 _descriptor_handler.push(
"scene", environment.uniform_handler());
89 _push_handler.push(
"tint",
skybox.tint);
91 if (!_descriptor_handler.update(_pipeline)) {
95 _descriptor_handler.bind_descriptors(command_buffer);
96 _push_handler.bind(command_buffer);
98 command_buffer.draw(3u, 1u, 0u, 0u);
Definition: command_buffer.hpp:15
Definition: cube_image.hpp:21
Definition: descriptor_handler.hpp:26
Definition: graphics_pipeline.hpp:115
Definition: push_handler.hpp:18
Definition: subrenderer.hpp:14
Definition: vector3.hpp:23
Definition: skybox_subrenderer.hpp:28
Definition: scenes_module.hpp:26
Definition: skybox_subrenderer.hpp:39
Definition: logger.hpp:124
Definition: graphics_pipeline.hpp:106
Definition: graphics_pipeline.hpp:67
Definition: skybox.hpp:13
Definition: skybox_subrenderer.hpp:24