Rendu
A lightweight rendering engine for experimentations
Loading...
Searching...
No Matches
DirectionalLight.hpp
1#pragma once
2
3#include "scene/lights/Light.hpp"
4#include "scene/Animated.hpp"
5#include "scene/Object.hpp"
6
13class DirectionalLight final : public Light {
14
15public:
17 DirectionalLight() = default;
18
23 DirectionalLight(const glm::vec3 & worldDirection, const glm::vec3 & color);
24
28 void draw(LightRenderer & renderer) override;
29
33 void update(double fullTime, double frameTime) override;
34
38 void setScene(const BoundingBox & sceneBox) override;
39
43 glm::vec3 sample(const glm::vec3 & position, float & dist, float & attenuation) const override;
44
57 bool decode(const KeyValues & params);
58
62 KeyValues encode() const override;
63
67 const glm::vec3 & direction() const { return _lightDirection; }
68
69private:
70
71 glm::mat4 _projectionMatrix = glm::mat4(1.0f);
72 glm::mat4 _viewMatrix = glm::mat4(1.0f);
73 Animated<glm::vec3> _lightDirection { glm::vec3(0.0f, 0.0f, 1.0f) };
74};
Wraps an animated property so that the initial value is preserved.
Definition: Animated.hpp:11
Represent the smallest axis-aligne box containing a given object or region of space.
Definition: Bounds.hpp:28
A directional light, where all light rays have the same direction.
Definition: DirectionalLight.hpp:13
Animated< glm::vec3 > _lightDirection
Light direction.
Definition: DirectionalLight.hpp:73
DirectionalLight()=default
glm::mat4 _viewMatrix
Light view matrix.
Definition: DirectionalLight.hpp:72
const glm::vec3 & direction() const
Definition: DirectionalLight.hpp:67
bool decode(const KeyValues &params)
Definition: DirectionalLight.cpp:46
glm::vec3 sample(const glm::vec3 &position, float &dist, float &attenuation) const override
Definition: DirectionalLight.cpp:40
void update(double fullTime, double frameTime) override
Definition: DirectionalLight.cpp:13
void draw(LightRenderer &renderer) override
Definition: DirectionalLight.cpp:9
KeyValues encode() const override
Definition: DirectionalLight.cpp:61
glm::mat4 _projectionMatrix
Light projection matrix.
Definition: DirectionalLight.hpp:71
void setScene(const BoundingBox &sceneBox) override
Definition: DirectionalLight.cpp:22
A general light with adjustable color intensity, that can cast shadows.
Definition: Light.hpp:20
Base structure of a per-light specialized renderer.
Definition: LightRenderer.hpp:13
Represent a key-values tuple.
Definition: Config.hpp:9