Shkyera Engine
Easy to use, game engine for Python
Loading...
Searching...
No Matches
SpotLightComponent.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <iostream>
4#include <string>
5
6#include <glm/glm.hpp>
7#include <glm/gtc/matrix_transform.hpp>
8
9namespace shkyera {
10
12 public:
13 float intensity = 1;
14 float range = 5;
15 float innerCutoff = glm::radians(15.0f);
16 float outerCutoff = glm::radians(25.0f);
17 glm::vec3 color = {1, 1, 1};
18
19 glm::mat4 getLightSpaceMatrix(const glm::mat4& transformMatrix) const {
20 const auto lightPosition = glm::vec3{transformMatrix[3]};
21 const auto projection = glm::perspective(2 * outerCutoff, 1.0f, 0.01f, range);
22 const auto lightDirection = glm::normalize(glm::vec3{1, 0, 0} * glm::mat3{glm::inverse(transformMatrix)});
23 const auto lightSpaceMatrix =
24 projection * glm::lookAt(lightPosition, lightPosition + lightDirection, glm::vec3{0, 1, 0});
25 return lightSpaceMatrix;
26 }
27};
28
29} // namespace shkyera
Definition Asset.hpp:6
Definition Clock.hpp:9
Definition SpotLightComponent.hpp:11
glm::mat4 getLightSpaceMatrix(const glm::mat4 &transformMatrix) const
Definition SpotLightComponent.hpp:19
float intensity
Definition SpotLightComponent.hpp:13
glm::vec3 color
Definition SpotLightComponent.hpp:17
float range
Definition SpotLightComponent.hpp:14
float innerCutoff
Definition SpotLightComponent.hpp:15
float outerCutoff
Definition SpotLightComponent.hpp:16