Oxygen Engine
Modern C++ 3D Engine using OpenGL
Loading...
Searching...
No Matches
lighting.h
1#ifndef OE_SCENE_COMPONENT_LIGHTING_H
2#define OE_SCENE_COMPONENT_LIGHTING_H
3
4#include <map>
5
6#include "../manager.h"
7#include "../node.h"
8
9#include "../../render/pbr.h"
10
11namespace oe::render
12{
13 class Shader;
14 class Texture;
15 class Cubemap;
16 class TextureManager;
17}
18
19namespace oe::component
20{
21 class PointLight;
22 class AreaLight;
23
28 {
29 std::shared_ptr<oe::render::Cubemap> irradiance = nullptr;
30 std::shared_ptr<oe::render::Cubemap> specular = nullptr;
31 };
32
39 {
40 public:
46
53 virtual void onUpdate(const double /*delta*/, const int8_t /*flags = 0*/) override;
54
59 void fillShader(oe::render::ShaderBase& shader) const noexcept;
60
65 void fillReflectionsShader(oe::render::ShaderBase& shader) const noexcept;
66
71 void fillTransparencyShader(oe::render::ShaderBase& shader) const noexcept;
72
79 void setRefractionTexture(const std::shared_ptr<oe::render::Texture>& refraction_texture)
80 {
81 _refraction_texture = refraction_texture;
82 }
83
88 const std::vector<glm::mat4> getAreaLights() const
89 {
90 return _area_light_matrices;
91 }
92
96 void setDefaultReflectionProbe(std::shared_ptr<oe::render::Cubemap> cubemap);
97
99 int8_t match_flags = 0;
100
101 protected:
102 std::vector<std::pair<PointLight*, oe::scene::Node*>> _point_lights;
103 std::vector<std::pair<AreaLight*, oe::scene::Node*>> _area_lights;
104
105 std::vector<glm::vec3> _point_light_positions;
106 std::vector<glm::vec3> _point_light_colors;
107
108 std::vector<glm::mat4> _area_light_matrices;
109
110 ReflectionProbe _default_reflection_probe;
111
112 oe::render::TextureManager& _texture_manager;
113
114 oe::render::Pbr _pbr;
115
116 std::shared_ptr<oe::render::Texture> _brdf_texture;
117 std::shared_ptr<oe::render::Texture> _refraction_texture;
118
119 friend PointLight;
120 friend AreaLight;
121 };
122
129 {
130 public:
132
136 glm::vec3 color = glm::vec3(1.0);
137 };
138
145 {
146 public:
147
151 glm::vec3 color = glm::vec3(1.0);
152 };
153}
154
155#endif
Area light component.
Definition lighting.h:145
glm::vec3 color
Definition lighting.h:151
Lighting component.
Definition lighting.h:39
void fillReflectionsShader(oe::render::ShaderBase &shader) const noexcept
Send Reflection probes data to the shader.
void fillShader(oe::render::ShaderBase &shader) const noexcept
Send All lights data to the shader.
void setRefractionTexture(const std::shared_ptr< oe::render::Texture > &refraction_texture)
Set texture that will be used as source for refractive surfaces.
Definition lighting.h:79
void setDefaultReflectionProbe(std::shared_ptr< oe::render::Cubemap > cubemap)
Set Default reflection source.
virtual void onUpdate(const double, const int8_t) override
Update lighting.
void fillTransparencyShader(oe::render::ShaderBase &shader) const noexcept
Send Transparency data (ie refractive buffer) to the shader.
Lighting(oe::scene::Manager &, oe::render::TextureManager &texture_manager)
Create the component.
int8_t match_flags
Do not update lighting unless flags is same as this value.
Definition lighting.h:99
const std::vector< glm::mat4 > getAreaLights() const
Get Area lights Each one packed as a matrix where each xyz rows are the light edges,...
Definition lighting.h:88
Point light component.
Definition lighting.h:129
glm::vec3 color
Definition lighting.h:136
Physically Based Rendering.
Definition pbr.h:14
Shader class.
Definition shader_base.h:33
handles the load and deletion of textures/cubemaps
Definition texture_manager.h:51
Scene manager.
Definition manager.h:21
Parent class of components that can be bound to a Node.
Definition node.h:15
Definition node.h:31
Parent class of components that can be bound to a scene::Manager.
Definition scene.h:15
Scene / node components (camera, lighting, ...)
Definition pipeline.h:9
Render related abstractions (Shader, Framebuffer, Cubemaps, Textures)
Definition opengl.h:10
A reflection environment.
Definition lighting.h:28