Oxygen Engine
Modern C++ 3D Engine using OpenGL
Loading...
Searching...
No Matches
lighting.h
1#ifndef OE_RENDER_LIGHTING_H
2#define OE_RENDER_LIGHTING_H
3
4#include <map>
5
6#include "../scene/lighting.h"
7#include "pbr.h"
8
9#include "shader_base.h"
10
11namespace oe::render
12{
13 class Texture;
14 class Cubemap;
15}
16
17namespace oe::render
18{
23 {
24 std::shared_ptr<Cubemap> irradiance = nullptr;
25 std::shared_ptr<Cubemap> specular = nullptr;
26 };
27
34 {
35 public:
40
47 void update(); //const std::chrono::nanoseconds /*delta*/, const int8_t /*flags = 0*/);
48
53 void fillShader(ShaderBase* shader) const noexcept
54 {
55 shader->setVec3Array("uPointLightPositions", _point_light_positions);
56 shader->setVec3Array("uPointLightColors", _point_light_colors);
57
58 shader->fillTextures({
59 {"uBRDF", {10, _brdf_texture.get()}}
60 });
61 }
62
67 void fillReflectionsShader(ShaderBase* shader) const noexcept
68 {
69 if (!_default_reflection_probe.specular || !_default_reflection_probe.irradiance)
70 {
71 return;
72 }
73
74 shader->fillCubemaps({
75 {"uDefaultIrradiance", {12, _default_reflection_probe.irradiance.get()}},
76 {"uDefaultSpecular", {13, _default_reflection_probe.specular.get()}}
77 });
78 }
79
84 void fillTransparencyShader(ShaderBase* shader) const noexcept
85 {
86 shader->fillTextures({
87 {"uScreenTransparency", {15, _refraction_texture.get()}}
88 });
89 }
90
97 void setRefractionTexture(const std::shared_ptr<Texture>& refraction_texture)
98 {
99 _refraction_texture = refraction_texture;
100 }
101
106 const std::vector<glm::mat4> getAreaLights() const
107 {
108 return _area_light_matrices;
109 }
110
114 void setDefaultReflectionProbe(Cubemap* cubemap, const uint32_t specular_size = 256);
115
116 protected:
117 std::vector<glm::vec3> _point_light_positions;
118 std::vector<glm::vec3> _point_light_colors;
119
120 std::vector<glm::mat4> _area_light_matrices;
121
122 ReflectionProbe _default_reflection_probe;
123
124 Pbr _pbr;
125
126 std::shared_ptr<Texture> _brdf_texture;
127 std::shared_ptr<Texture> _refraction_texture;
128 };
129}
130
131#endif
Definition cubemap.h:9
Lighting manager (rendering)
Definition lighting.h:34
void fillShader(ShaderBase *shader) const noexcept
Send All lights data to the shader.
Definition lighting.h:53
void fillReflectionsShader(ShaderBase *shader) const noexcept
Send Reflection probes data to the shader.
Definition lighting.h:67
void setRefractionTexture(const std::shared_ptr< Texture > &refraction_texture)
Set texture that will be used as source for refractive surfaces.
Definition lighting.h:97
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:106
Lighting()
Create the component.
void setDefaultReflectionProbe(Cubemap *cubemap, const uint32_t specular_size=256)
Set Default reflection source.
void update()
Update lighting.
void fillTransparencyShader(ShaderBase *shader) const noexcept
Send Transparency data (ie refractive buffer) to the shader.
Definition lighting.h:84
Physically Based Rendering.
Definition pbr.h:16
Shader class.
Definition shader_base.h:32
Render related abstractions (Shader, Framebuffer, Cubemaps, Textures)
Definition opengl.h:10
A reflection environment.
Definition lighting.h:23
Lighting manager (scene)
Definition lighting.h:66