MOS
spot_light.hpp
1 #pragma once
2 
3 #include <glm/glm.hpp>
4 #include <glm/gtc/constants.hpp>
5 #include <mos/gfx/camera.hpp>
6 #include <mos/gfx/target.hpp>
7 #include <mos/gfx/texture_2d.hpp>
8 
9 namespace mos::gfx {
10 
12 class Spot_light final {
13 public:
14  explicit Spot_light(const glm::vec3 &position = glm::vec3(0.0f, 0.0f, 2.0f),
15  const glm::vec3 &center = glm::vec3(0.0f, 0.0f, 0.0f),
16  float angle = glm::half_pi<float>(),
17  const glm::vec3 &color = glm::vec3(0.0f),
18  float strength = 0.0f, float near = 0.1f,
19  float far = 10.0f, float blend = 0.15);
20 
21  static auto load(const std::string &directory, const std::string &path,
22  const glm::mat4 &parent_transform = glm::mat4(1.0f))
23  -> Spot_light;
24 
26  auto blend(float blend) -> void;
27 
28  auto blend() const -> float;
29 
31  auto angle(float angle) -> void;
32 
33  auto angle() const -> float;
34 
36  auto position(const glm::vec3 &position) -> void;
37 
38  auto position() const -> glm::vec3;
39 
41  auto direction(const glm::vec3 &direction) -> void;
42 
43  auto direction() const -> glm::vec3;
44 
46  auto near_far(float near, float far) -> void;
47 
48  glm::vec3 color = glm::vec3(0.0f);
49 
51  float strength;
52 
55 
56 private:
57  float angle_;
58  float near_;
59  float far_;
60  float blend_ = 0.15;
61 };
62 } // namespace mos::gfx
Rendering camera view.
Definition: camera.hpp:12
auto blend(float blend) -> void
Set blend factor.
auto near_far(float near, float far) -> void
Set near and far plane.
Definition: assets.hpp:17
auto direction(const glm::vec3 &direction) -> void
Set center/focus point.
auto position(const glm::vec3 &position) -> void
Set position.
Camera camera
Camera for shadow map rendering.
Definition: spot_light.hpp:54
auto angle(float angle) -> void
Set spot angle, in radans.
Spotlight.
Definition: spot_light.hpp:12
float strength
Strength of the lamp in watts.
Definition: spot_light.hpp:51