2023-10-26 18:37:29 +02:00
|
|
|
#pragma once
|
|
|
|
|
#include "Component/DirectionalLight.h"
|
|
|
|
|
#include "Component/PointLight.h"
|
2025-05-07 16:08:12 +02:00
|
|
|
#include "Component/Transform.h"
|
2024-06-09 12:20:04 +02:00
|
|
|
#include "Graphics/Buffer.h"
|
|
|
|
|
#include "Graphics/Descriptor.h"
|
2023-10-26 18:37:29 +02:00
|
|
|
|
2024-06-09 12:20:04 +02:00
|
|
|
namespace Seele {
|
2025-04-06 09:57:47 +02:00
|
|
|
DECLARE_REF(EnvironmentMapAsset)
|
2024-06-09 12:20:04 +02:00
|
|
|
class LightEnvironment {
|
|
|
|
|
public:
|
2025-05-07 16:08:12 +02:00
|
|
|
struct ShaderDirectionalLight {
|
|
|
|
|
Vector4 color;
|
|
|
|
|
Vector4 direction;
|
|
|
|
|
Matrix4 lightSpaceMatrix;
|
|
|
|
|
};
|
|
|
|
|
struct ShaderPointLight {
|
|
|
|
|
Vector4 position_WS;
|
|
|
|
|
Vector4 colorRange;
|
|
|
|
|
};
|
2023-10-26 18:37:29 +02:00
|
|
|
LightEnvironment(Gfx::PGraphics graphics);
|
|
|
|
|
~LightEnvironment();
|
|
|
|
|
void reset();
|
2025-05-07 16:08:12 +02:00
|
|
|
void addDirectionalLight(const Component::DirectionalLight& dirLight, const Component::Transform& transform);
|
|
|
|
|
void addPointLight(const Component::PointLight& pointLight, const Component::Transform& transform);
|
2023-10-26 18:37:29 +02:00
|
|
|
void commit();
|
2023-11-05 10:36:01 +01:00
|
|
|
const Gfx::PDescriptorLayout getDescriptorLayout() const;
|
2025-05-07 16:08:12 +02:00
|
|
|
const ShaderDirectionalLight& getDirectionalLight(uint32 lightIndex) const { return dirs[lightIndex]; }
|
|
|
|
|
const Component::Transform& getDirectionalTransform(uint32 lightIndex) const { return directionalTransforms[lightIndex]; }
|
2023-11-05 10:36:01 +01:00
|
|
|
Gfx::PDescriptorSet getDescriptorSet();
|
2025-04-06 09:57:47 +02:00
|
|
|
PEnvironmentMapAsset getEnvironmentMap() { return environment; }
|
2025-05-06 19:36:43 +02:00
|
|
|
uint64 getNumDirectionalLights() const { return dirs.size(); }
|
2025-05-07 16:08:12 +02:00
|
|
|
const Array<Gfx::OTexture2D>& getShadowMaps() const { return shadowMaps; }
|
2024-06-09 12:20:04 +02:00
|
|
|
|
|
|
|
|
private:
|
2023-11-01 23:12:30 +01:00
|
|
|
Gfx::OShaderBuffer directionalLights;
|
2025-05-07 16:08:12 +02:00
|
|
|
Array<Gfx::OTexture2D> shadowMaps;
|
|
|
|
|
Array<Gfx::OSampler> shadowSamplers;
|
2023-11-01 23:12:30 +01:00
|
|
|
Gfx::OShaderBuffer pointLights;
|
2025-05-07 16:08:12 +02:00
|
|
|
Array<ShaderDirectionalLight> dirs;
|
|
|
|
|
Array<Component::Transform> directionalTransforms;
|
|
|
|
|
Array<ShaderPointLight> points;
|
2025-04-06 09:57:47 +02:00
|
|
|
PEnvironmentMapAsset environment;
|
|
|
|
|
Gfx::OSampler environmentSampler;
|
2023-11-01 23:12:30 +01:00
|
|
|
Gfx::ODescriptorLayout layout;
|
2023-11-05 10:36:01 +01:00
|
|
|
Gfx::PDescriptorSet set;
|
2023-10-26 18:37:29 +02:00
|
|
|
Gfx::PGraphics graphics;
|
|
|
|
|
};
|
|
|
|
|
DEFINE_REF(LightEnvironment)
|
2024-06-09 12:20:04 +02:00
|
|
|
} // namespace Seele
|