4 #include <initializer_list> 5 #include <unordered_map> 9 #include <mos/gfx/models.hpp> 10 #include <mos/gfx/scenes.hpp> 12 #include <mos/gl/buffer.hpp> 13 #include <mos/gl/render_buffers.hpp> 14 #include <mos/gl/vertex_arrays.hpp> 15 #include <mos/gl/texture_buffers.hpp> 16 #include <mos/gl/frame_buffers.hpp> 17 #include <mos/gl/array_buffers.hpp> 18 #include <mos/gl/element_array_buffers.hpp> 20 #include <mos/gl/light_uniforms.hpp> 22 #include <mos/gl/cloud_program.hpp> 23 #include <mos/gl/bloom_program.hpp> 24 #include <mos/gl/compositing_program.hpp> 25 #include <mos/gl/blur_program.hpp> 26 #include <mos/gl/depth_program.hpp> 27 #include <mos/gl/standard_program.hpp> 29 #include <mos/gl/standard_target.hpp> 30 #include <mos/gl/blit_target.hpp> 31 #include <mos/gl/post_target.hpp> 32 #include <mos/gl/shadow_map_target.hpp> 33 #include <mos/gl/environment_map_target.hpp> 35 #include <mos/gl/quad.hpp> 43 explicit Renderer(
const glm::ivec2 &resolution,
const int samples = 1);
54 auto load(
const gfx::Models & models) -> gpu::Models;
60 auto load(
const gfx::Shared_mesh &mesh) -> void;
66 auto load(
const gfx::Shared_texture_2D &texture) -> void;
72 auto unload(
const gfx::Shared_texture_2D &texture) -> void;
76 const glm::vec4 &color = {0.0f, 0.0f, 0.0f, 1.0f},
77 const glm::ivec2 &resolution = glm::ivec2(128, 128)) ->
void;
83 static GLuint generate(
const std::function<
void(GLsizei, GLuint*)> & f);
84 static GLuint wrap_convert(
const gfx::Texture::Wrap& w);
85 static GLuint filter_convert(
const gfx::Texture::Filter &f);
86 static GLuint filter_convert_mip(
const gfx::Texture::Filter &f);
89 using Time_point = std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>;
94 GLint internal_format;
98 auto render_texture_targets(
const gfx::Scene &scene) -> void;
102 const glm::ivec2 &resolution) -> void;
104 auto render_shadow_maps(
const std::vector<gpu::Model> &models,
105 const gfx::Spot_lights &spot_lights) -> void;
107 auto render_cascaded_shadow_maps(
const std::vector<gpu::Model> &models,
111 auto render_environment(
const gfx::Scene &scene,
112 const glm::vec4 &clear_color) -> void;
117 const glm::vec2 &resolution,
122 const gfx::Spot_lights &spot_lights,
123 const gfx::Environment_lights &environment_lights,
125 const glm::ivec2 &resolution,
127 const GLenum &draw_mode) -> void;
130 const glm::mat4 &transform,
132 const gfx::Spot_lights &spot_lights,
133 const gfx::Environment_lights &environment_lights,
135 const glm::vec2 &resolution,
138 auto render_model_depth(
const gpu::Model &model,
139 const glm::mat4 &transform,
141 const glm::vec2 &resolution,
145 auto clear(
const glm::vec4 &color) -> void;
146 auto clear_depth() -> void;
147 auto clear_color(
const glm::vec4 &color) -> void;
148 auto blur(GLuint input_texture,
151 float iterations = 6) -> void;
155 const Shader functions_shader_;
164 Frame_buffers frame_buffers_;
165 Render_buffers render_buffers_;
166 Texture_buffers textures_;
167 Array_buffers array_buffers_;
168 Element_array_buffers element_array_buffers_;
169 Vertex_arrays vertex_arrays_;
182 std::array<int,2> cube_camera_index_;
186 const std::array<Shadow_map_target, 4> shadow_maps_;
189 const std::array<Post_target, 4> shadow_map_blur_targets_;
193 const std::array<Environment_map_target, 2> environment_maps_targets_;
195 static constexpr
const int cascade_count{4};
197 const std::array<Shadow_map_target, cascade_count> cascaded_shadow_maps_;
199 const std::array<Post_target, 4> cascaded_shadow_map_blur_targets_;
201 glm::vec4 cascade_splits{};
202 std::array<glm::mat4, cascade_count> directional_light_ortho_matrices{};
203 std::array<glm::mat4, cascade_count> light_view_matrix{};
Container.
Definition: container.hpp:12
Definition: compositing_program.hpp:7
Fog with exponential falloff and near/far color blending.
Definition: fog.hpp:7
Definition: texture_buffer_2d.hpp:8
Definition: blur_program.hpp:7
Rendering camera view.
Definition: camera.hpp:12
Definition: depth_program.hpp:7
Definition: directional_light.hpp:8
Scene for rendering.
Definition: scene.hpp:21
auto load(const gfx::Model &model) -> gpu::Model
Loads a model into GPU memory.
Definition: post_target.hpp:8
Definition: bloom_program.hpp:7
auto unload(const gfx::Mesh &mesh) -> void
Unloads a mesh from GPU memory.
auto render(const gfx::Scenes &scenes, const glm::vec4 &color={0.0f, 0.0f, 0.0f, 1.0f}, const glm::ivec2 &resolution=glm::ivec2(128, 128)) -> void
Render multiple scenes.
Geometric data description, vertices and indices.
Definition: mesh.hpp:22
auto clear_buffers() -> void
Clear all GPU buffers/memory.
Definition: render_buffer.hpp:7
Definition: array_buffers.hpp:5
Texture in two dimension.
Definition: texture_2d.hpp:17
Uniforms for the standard shader.
Definition: standard_program.hpp:10
Uniforms for the particle shader program.
Definition: cloud_program.hpp:10
Render geometry shapes with OpenGL.
Definition: renderer.hpp:40
auto load_or_update(const gfx::Texture_2D &texture) -> void
Loads a texture into GPU memory.
Definition: standard_target.hpp:7
Definition: blit_target.hpp:8
Renderer(const glm::ivec2 &resolution, const int samples=1)
Inits the renderer, creates an OpenGL context with GLAD.
Collection of properties for a renderable object.
Definition: model.hpp:24