Refactoring graphics
This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
target_sources(Engine
|
||||
PRIVATE
|
||||
EventManager.h
|
||||
LightEnvironment.h
|
||||
LightEnvironment.cpp
|
||||
Util.h
|
||||
Scene.cpp
|
||||
Scene.h)
|
||||
Scene.h
|
||||
Scene.cpp)
|
||||
|
||||
target_sources(Engine
|
||||
PUBLIC FILE_SET HEADERS
|
||||
FILES
|
||||
EventManager.h
|
||||
LightEnvironment.h
|
||||
Util.h
|
||||
Scene.h)
|
||||
@@ -0,0 +1,35 @@
|
||||
#include "LightEnvironment.h"
|
||||
#include "Graphics/Graphics.h"
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
LightEnvironment::LightEnvironment(Gfx::PGraphics graphics)
|
||||
: graphics(graphics)
|
||||
{
|
||||
layout = graphics->createDescriptorLayout("LightEnvironment");
|
||||
layout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
layout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
layout->addDescriptorBinding(2, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
layout->addDescriptorBinding(3, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
}
|
||||
|
||||
LightEnvironment::~LightEnvironment()
|
||||
{
|
||||
}
|
||||
|
||||
void LightEnvironment::reset()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void LightEnvironment::addDirectionalLight(Component::DirectionalLight dirLight)
|
||||
{
|
||||
}
|
||||
|
||||
void LightEnvironment::addPointLight(Component::PointLight pointLight)
|
||||
{
|
||||
}
|
||||
|
||||
void LightEnvironment::commit()
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
#include "Graphics/Descriptor.h"
|
||||
#include "Graphics/Buffer.h"
|
||||
#include "Component/DirectionalLight.h"
|
||||
#include "Component/PointLight.h"
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
class LightEnvironment
|
||||
{
|
||||
public:
|
||||
LightEnvironment(Gfx::PGraphics graphics);
|
||||
~LightEnvironment();
|
||||
void reset();
|
||||
void addDirectionalLight(Component::DirectionalLight dirLight);
|
||||
void addPointLight(Component::PointLight pointLight);
|
||||
void commit();
|
||||
private:
|
||||
#define MAX_DIRECTIONAL_LIGHTS 4
|
||||
#define MAX_POINT_LIGHTS 256
|
||||
Gfx::PShaderBuffer directionalLights;
|
||||
Gfx::PUniformBuffer numDirectional;
|
||||
Gfx::PShaderBuffer pointLights;
|
||||
Gfx::PUniformBuffer numPoints;;
|
||||
Array<Component::DirectionalLight> dirs;
|
||||
Array<Component::PointLight> points;
|
||||
Gfx::PDescriptorLayout layout;
|
||||
Gfx::PDescriptorSet set;
|
||||
Gfx::PGraphics graphics;
|
||||
};
|
||||
DEFINE_REF(LightEnvironment)
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "Scene.h"
|
||||
#include "Graphics/Graphics.h"
|
||||
#include "Graphics/Mesh.h"
|
||||
#include "Component/StaticMesh.h"
|
||||
#include "Component/Mesh.h"
|
||||
#include "Component/Transform.h"
|
||||
#include "Asset/AssetRegistry.h"
|
||||
#include "Asset/TextureAsset.h"
|
||||
@@ -81,14 +81,3 @@ LightEnv Scene::getLightBuffer()
|
||||
});
|
||||
return lightEnv;
|
||||
}
|
||||
|
||||
|
||||
Component::Skybox Scene::getSkybox()
|
||||
{
|
||||
return Seele::Component::Skybox {
|
||||
.day = AssetRegistry::findTexture("FS000_Day_01")->getTexture().cast<Gfx::TextureCube>(),
|
||||
.night = AssetRegistry::findTexture("FS000_Night_01")->getTexture().cast<Gfx::TextureCube>(),
|
||||
.fogColor = Vector(0.2, 0.1, 0.6),
|
||||
.blendFactor = 0,
|
||||
};
|
||||
}
|
||||
@@ -2,25 +2,14 @@
|
||||
#include <entt/entt.hpp>
|
||||
#include "MinimalEngine.h"
|
||||
#include "Graphics/Graphics.h"
|
||||
#include "Graphics/MeshBatch.h"
|
||||
#include "Physics/PhysicsSystem.h"
|
||||
#include "Component/Skybox.h"
|
||||
#include "LightEnvironment.h"
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
DECLARE_REF(Material)
|
||||
DECLARE_REF(Entity)
|
||||
|
||||
#define MAX_DIRECTIONAL_LIGHTS 4
|
||||
#define MAX_POINT_LIGHTS 256
|
||||
struct LightEnv
|
||||
{
|
||||
Gfx::PShaderBuffer directionalLights;
|
||||
Gfx::PUniformBuffer numDirectional;
|
||||
Gfx::PShaderBuffer pointLights;
|
||||
Gfx::PUniformBuffer numPoints;
|
||||
};
|
||||
|
||||
class Scene
|
||||
{
|
||||
public:
|
||||
@@ -55,12 +44,11 @@ public:
|
||||
{
|
||||
registry.view<Component...>().each(func);
|
||||
}
|
||||
LightEnv getLightBuffer();
|
||||
Component::Skybox getSkybox();
|
||||
PLightEnvironment getLightEnvironment() { return lightEnv; }
|
||||
Gfx::PGraphics getGraphics() const { return graphics; }
|
||||
entt::registry registry;
|
||||
private:
|
||||
LightEnv lightEnv;
|
||||
PLightEnvironment lightEnv;
|
||||
PhysicsSystem physics;
|
||||
Gfx::PGraphics graphics;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user