|
lmgl 1.0.0
A lightweight OpenGL graphics engine library written in C++
|
Renders shadows for directional and point lights using shadow maps. More...
#include <shadow_map.hpp>
Public Member Functions | |
| ShadowRenderer () | |
| Constructs a ShadowRenderer and initializes depth shaders. | |
| ~ShadowRenderer ()=default | |
| Destructor for ShadowRenderer. | |
| void | render_directional_shadow (std::shared_ptr< scene::Scene > scene, std::shared_ptr< scene::Light > light, std::shared_ptr< ShadowMap > shadow_map) |
| Renders the shadow map for a directional light. | |
| void | render_point_shadow (std::shared_ptr< scene::Scene > scene, std::shared_ptr< scene::Light > light, std::shared_ptr< CubemapShadowMap > shadow_map) |
| Renders the shadow map for a point light. | |
| glm::mat4 | get_light_space_matrix (std::shared_ptr< scene::Light > light, const glm::vec3 &scene_center, float scene_radius) |
| Computes the light space matrix for a directional light. | |
Renders shadows for directional and point lights using shadow maps.
This class provides methods to render shadows for both directional lights and point lights using the respective shadow maps. It utilizes depth shaders to render the scene from the light's perspective and generate the shadow maps.
| lmgl::renderer::ShadowRenderer::ShadowRenderer | ( | ) |
Constructs a ShadowRenderer and initializes depth shaders.
Initializes the depth shaders used for rendering shadows. The default constructor sets up the necessary shaders for both directional and point light shadow mapping.
| glm::mat4 lmgl::renderer::ShadowRenderer::get_light_space_matrix | ( | std::shared_ptr< scene::Light > | light, |
| const glm::vec3 & | scene_center, | ||
| float | scene_radius ) |
Computes the light space matrix for a directional light.
This method calculates the light space transformation matrix used for shadow mapping based on the light's direction and the scene's bounding sphere.
| light | The directional light. |
| scene_center | The center of the scene's bounding sphere. |
| scene_radius | The radius of the scene's bounding sphere. |
| void lmgl::renderer::ShadowRenderer::render_directional_shadow | ( | std::shared_ptr< scene::Scene > | scene, |
| std::shared_ptr< scene::Light > | light, | ||
| std::shared_ptr< ShadowMap > | shadow_map ) |
Renders the shadow map for a directional light.
This method renders the scene from the perspective of the directional light and populates the provided shadow map with depth information.
| scene | The scene to render. |
| light | The directional light casting shadows. |
| shadow_map | The shadow map to populate with depth information. |
| void lmgl::renderer::ShadowRenderer::render_point_shadow | ( | std::shared_ptr< scene::Scene > | scene, |
| std::shared_ptr< scene::Light > | light, | ||
| std::shared_ptr< CubemapShadowMap > | shadow_map ) |
Renders the shadow map for a point light.
This method renders the scene from the perspective of the point light and populates the provided cubemap shadow map with depth information.
| scene | The scene to render. |
| light | The point light casting shadows. |
| shadow_map | The cubemap shadow map to populate with depth information. |