Irradiance works

This commit is contained in:
Dynamitos
2025-04-06 09:57:47 +02:00
parent aa1f037cb5
commit f21606379c
28 changed files with 524 additions and 401 deletions
+16 -1
View File
@@ -1,9 +1,12 @@
#include "LightEnvironment.h"
#include "Asset/EnvironmentMapAsset.h"
#include "Graphics/Graphics.h"
#include "Asset/AssetRegistry.h"
using namespace Seele;
LightEnvironment::LightEnvironment(Gfx::PGraphics graphics) : graphics(graphics) {
LightEnvironment::LightEnvironment(Gfx::PGraphics graphics)
: graphics(graphics), environment(AssetRegistry::findEnvironmentMap("", "newport_loft")) {
layout = graphics->createDescriptorLayout("pLightEnv");
layout->addDescriptorBinding(Gfx::DescriptorBinding{
.name = "directionalLights",
@@ -21,6 +24,10 @@ LightEnvironment::LightEnvironment(Gfx::PGraphics graphics) : graphics(graphics)
.name = "numPointLights",
.uniformLength = sizeof(uint32),
});
layout->addDescriptorBinding(Gfx::DescriptorBinding{
.name = "irradianceMap",
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
});
layout->create();
directionalLights = graphics->createShaderBuffer(ShaderBufferCreateInfo{
@@ -29,6 +36,13 @@ LightEnvironment::LightEnvironment(Gfx::PGraphics graphics) : graphics(graphics)
pointLights = graphics->createShaderBuffer(ShaderBufferCreateInfo{
.name = "PointLights",
});
environmentSampler = graphics->createSampler({
.magFilter = Gfx::SE_FILTER_LINEAR,
.minFilter = Gfx::SE_FILTER_LINEAR,
.addressModeU = Gfx::SE_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
.addressModeV = Gfx::SE_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
.addressModeW = Gfx::SE_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
});
}
LightEnvironment::~LightEnvironment() {}
@@ -63,6 +77,7 @@ void LightEnvironment::commit() {
set->updateBuffer("pointLights", 0, pointLights);
set->updateConstants("numDirectionalLights", 0, &numDirectionalLights);
set->updateBuffer("directionalLights", 0, directionalLights);
set->updateTexture("irradianceMap", 0, environment->getIrradianceMap());
set->writeChanges();
}