21 static inline float DistanceFromTarget = 512.0f;
23 Sun(glm::ivec2 resolution,
25 const glm::vec3& direction = glm::vec3(0.0f, -1.0f, 0.0f));
32 void setTarget(
const Camera* target);
33 void setDirection(
const glm::vec3& direction);
34 void setLightColor(
const glm::vec3& color,
float intensity);
36 glm::vec3 lightPosition(glm::vec3& outLookAtPos)
const;
37 glm::vec3 direction()
const {
return m_direction; }
38 glm::vec3 lightColor()
const {
return m_lightColor; }
39 float lightIntensity()
const {
return m_lightIntensity; }
40 glm::ivec2 resolution()
const {
return m_resolution; }
42 void update(
float dt)
override;
44 const std::vector<Cascade>& cascadeSplits()
const {
return m_cascadeSplits; }
45 gl::TextureRef cascadeShadowMaps()
const;
47 const gl::FBO* shadowFBO()
const {
return &m_depthFBO; }
48 Material* shadowMaterial() {
return &m_depthShader; }
51 std::vector<Cascade> m_cascadeSplits = {
52 Cascade{16.0f, glm::mat4(1)},
53 Cascade{64.0f, glm::mat4(1)},
54 Cascade{128.0f, glm::mat4(1)},
55 Cascade{256.0f, glm::mat4(1)}
57 glm::ivec2 m_resolution;
59 const Camera* m_target;
60 glm::vec3 m_direction;
66 gl::UBO m_lightSpaceUBO;
68 Material m_depthShader;
70 glm::vec3 m_lightColor = glm::vec3(1.0f, 1.0f, 1.0f);
71 float m_lightIntensity = 1.0f;
73 void calculateLightSpaceMatrices();