11#include <glm/gtc/type_ptr.hpp>
17 static inline std::string
_debugName =
"DirectionalLightsBuffer";
27 std::array<GPUDirectionalLight, Utils::MAX_DIRECTIONAL_LIGHTS>
lights;
66 "Cannot update a GPU directional lights buffer that is not created.");
76 uint32_t skippedCount = 0;
86 const auto &color = light.
color;
88 data.lights[index].viewProjectionMatrix = viewProjectionMatrix;
89 data.lights[index].color = color;
90 data.lights[index].direction = direction;
98 Log::Warning(fmt::format(
"Maximum number of directional lights ({}) reached. {} light(s) skipped.",
115 bufferDesc.usage = wgpu::BufferUsage::CopyDst | wgpu::BufferUsage::Uniform;
119 return context.
GetDevice()->createBuffer(bufferDesc);
const wgpu::Buffer & GetBuffer() const override
Definition DirectionalLightsBuffer.hpp:105
bool IsCreated(Engine::Core &core) const override
Definition DirectionalLightsBuffer.hpp:59
wgpu::Buffer _CreateBuffer(const Graphic::Resource::DeviceContext &context)
Definition DirectionalLightsBuffer.hpp:112
wgpu::Buffer _buffer
Definition DirectionalLightsBuffer.hpp:122
static uint32_t GPUSize()
Definition DirectionalLightsBuffer.hpp:109
bool _isCreated
Definition DirectionalLightsBuffer.hpp:123
static std::string _debugName
Definition DirectionalLightsBuffer.hpp:17
~DirectionalLightsBuffer() override
Definition DirectionalLightsBuffer.hpp:34
void Destroy(Engine::Core &core) override
Definition DirectionalLightsBuffer.hpp:48
void Create(Engine::Core &core) override
Definition DirectionalLightsBuffer.hpp:36
void Destroy()
Definition DirectionalLightsBuffer.hpp:50
DirectionalLightsBuffer()=default
void Update(Engine::Core &core) override
Definition DirectionalLightsBuffer.hpp:61
std::string_view GetDebugName() const
Definition DirectionalLightsBuffer.hpp:107
The core is the place where all the data of the engine is stored. It contains the registry (entities)...
Definition Core.hpp:33
TResource & GetResource()
Get a reference of a resource.
Definition Core.inl:14
Registry & GetRegistry()
Get the entt::registry that contains all components. It should be used to update component through sy...
Definition Core.hpp:50
Definition UpdateBufferError.hpp:7
Definition AGPUBuffer.hpp:7
Definition AmbientLight.cpp:6
static constexpr size_t MAX_DIRECTIONAL_LIGHTS
Definition DirectionalLights.hpp:8
void Warning(const T &msg) noexcept
Definition Logger.hpp:49
constexpr DefaultFlag Default
Definition webgpu.hpp:78
StringView(const std::string_view &cpp)
Definition webgpu.hpp:618
Definition GPUDirectionalLight.hpp:11
uint32_t shadowTextureIndex
Definition GPUDirectionalLight.hpp:18
glm::mat4 viewProjectionMatrix
Definition GPUDirectionalLight.hpp:14
Definition DirectionalLightsBuffer.hpp:19
uint32_t shadowIndex
Definition DirectionalLightsBuffer.hpp:23
glm::vec3 direction
Definition DirectionalLightsBuffer.hpp:22
glm::mat4 viewProjectionMatrix
Definition DirectionalLightsBuffer.hpp:20
glm::vec4 color
Definition DirectionalLightsBuffer.hpp:21
Definition DirectionalLightsBuffer.hpp:26
std::array< GPUDirectionalLight, Utils::MAX_DIRECTIONAL_LIGHTS > lights
Definition DirectionalLightsBuffer.hpp:27
std::array< float, 3 > _padding
Definition DirectionalLightsBuffer.hpp:29
uint32_t count
Definition DirectionalLightsBuffer.hpp:28
Definition DeviceContext.hpp:7
auto & GetDevice()
Definition DeviceContext.hpp:13
Definition DirectionalLight.hpp:8
glm::vec4 color
Definition DirectionalLight.hpp:9