Irradiance works
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
#include "Graphics/Buffer.h"
|
||||
#include "Graphics/Descriptor.h"
|
||||
|
||||
|
||||
namespace Seele {
|
||||
DECLARE_REF(EnvironmentMapAsset)
|
||||
class LightEnvironment {
|
||||
public:
|
||||
LightEnvironment(Gfx::PGraphics graphics);
|
||||
@@ -16,12 +16,15 @@ class LightEnvironment {
|
||||
void commit();
|
||||
const Gfx::PDescriptorLayout getDescriptorLayout() const;
|
||||
Gfx::PDescriptorSet getDescriptorSet();
|
||||
PEnvironmentMapAsset getEnvironmentMap() { return environment; }
|
||||
|
||||
private:
|
||||
Gfx::OShaderBuffer directionalLights;
|
||||
Gfx::OShaderBuffer pointLights;
|
||||
Array<Component::DirectionalLight> dirs;
|
||||
Array<Component::PointLight> points;
|
||||
PEnvironmentMapAsset environment;
|
||||
Gfx::OSampler environmentSampler;
|
||||
Gfx::ODescriptorLayout layout;
|
||||
Gfx::PDescriptorSet set;
|
||||
Gfx::PGraphics graphics;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "Scene.h"
|
||||
#include "Actor/PointLightActor.h"
|
||||
#include "Asset/AssetRegistry.h"
|
||||
#include "Asset/MaterialAsset.h"
|
||||
#include "Asset/TextureAsset.h"
|
||||
#include "Component/DirectionalLight.h"
|
||||
@@ -13,7 +12,8 @@
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
Scene::Scene(Gfx::PGraphics graphics) : graphics(graphics), lightEnv(new LightEnvironment(graphics)), physics(registry) {}
|
||||
Scene::Scene(Gfx::PGraphics graphics)
|
||||
: graphics(graphics), lightEnv(new LightEnvironment(graphics)), physics(registry) {}
|
||||
|
||||
Scene::~Scene() {}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
#include "MinimalEngine.h"
|
||||
#include "Component/Skybox.h"
|
||||
#include "Graphics/Graphics.h"
|
||||
#include "LightEnvironment.h"
|
||||
#include "MinimalEngine.h"
|
||||
#include "Physics/PhysicsSystem.h"
|
||||
#include <entt/entt.hpp>
|
||||
#include <iostream>
|
||||
|
||||
Reference in New Issue
Block a user