lmgl 1.0.0
A lightweight OpenGL graphics engine library written in C++
Loading...
Searching...
No Matches
lmgl::renderer::ShadowRenderer Class Reference

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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ ShadowRenderer()

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.

Member Function Documentation

◆ get_light_space_matrix()

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.

Parameters
lightThe directional light.
scene_centerThe center of the scene's bounding sphere.
scene_radiusThe radius of the scene's bounding sphere.
Returns
The computed light space matrix.

◆ render_directional_shadow()

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.

Parameters
sceneThe scene to render.
lightThe directional light casting shadows.
shadow_mapThe shadow map to populate with depth information.

◆ render_point_shadow()

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.

Parameters
sceneThe scene to render.
lightThe point light casting shadows.
shadow_mapThe cubemap shadow map to populate with depth information.

The documentation for this class was generated from the following files: