Name change, but backwards

This commit is contained in:
Confideo-IOM
2026-08-04 18:32:37 +01:00
parent 3e8b8952f7
commit 2b3785e6af
45 changed files with 1079 additions and 498 deletions
@@ -1,9 +1,9 @@
#ifndef HYDRASOURCECOMPONENT
#define HYDRASOURCECOMPONENT
#ifndef HYDRADIRECTIONALSHADOWSOURCECOMPONENT
#define HYDRADIRECTIONALSHADOWSOURCECOMPONENT
#include "../../engine/HydraEngine.h"
struct HydraShadowSourceComponent
struct HydraDirectionalShadowSourceComponent
{
uint32_t entity_id;
uint32_t cascade_count;
@@ -1,8 +1,8 @@
#include "HydraShadowSourceSystem.h"
#include "HydraDirectionalShadowSourceSystem.h"
#include "../../engine/HydraEngine.h"
#include "../../camera/HydraCamera.h"
#include "../HydraECS.h"
#include "../components/HydraShadowSourceComponent.h"
#include "../components/HydraDirectionalShadowSourceComponent.h"
#include "../components/HydraPositionComponent.h"
#include "../components/HydraLightComponent.h"
@@ -18,7 +18,7 @@
#include "../../task/renderer/HydraCreateShadowFrameBuffer.hpp"
#include "../../actor/HydraActorManager.h"
void HydraShadowSourceSystem::Initialise()
void HydraDirectionalShadowSourceSystem::Initialise()
{
HydraTaskScheduler *task_scheduler = GetEngine()->TaskScheduler();
@@ -31,11 +31,11 @@ void HydraShadowSourceSystem::Initialise()
HydraID create_gpu_buffer_task_id = task_scheduler->CreateTask<HydraCreateGPUBufferTask>(HydraThreadAffinity::Render);
HydraCreateGPUBufferTask *task = static_cast<HydraCreateGPUBufferTask *>(task_scheduler->GetTask(create_gpu_buffer_task_id));
task->Intialise("ShadowBuffer", 1, MAX_SHADOWS * sizeof(HydraShadowSourceComponent), &m_shadow_buffer_id, HYDRA_BUFFER_TYPE::HYDRA_SSBO_BUFFER);
task->Intialise("ShadowBuffer", 1, MAX_SHADOWS * sizeof(HydraDirectionalShadowSourceComponent), &m_shadow_buffer_id, HYDRA_BUFFER_TYPE::HYDRA_SSBO_BUFFER);
task_scheduler->WaitForTask(create_gpu_buffer_task_id);
}
void HydraShadowSourceSystem::InitialiseComponent(HydraID entity_id)
void HydraDirectionalShadowSourceSystem::InitialiseComponent(HydraID entity_id)
{
HydraEngine *engine = GetEngine();
HydraECS *ecs = engine->ECS();
@@ -59,11 +59,11 @@ void HydraShadowSourceSystem::InitialiseComponent(HydraID entity_id)
}
void HydraShadowSourceSystem::UpdateSystem(float delta_t_seconds)
void HydraDirectionalShadowSourceSystem::UpdateSystem(float delta_t_seconds)
{
HydraEngine *engine = GetEngine();
HydraECS *ecs = engine->ECS();
std::vector<HydraShadowSourceComponent> shadows;
std::vector<HydraDirectionalShadowSourceComponent> shadows;
for (HydraID entity_id : Entities)
{
@@ -75,18 +75,18 @@ void HydraShadowSourceSystem::UpdateSystem(float delta_t_seconds)
break;
}
HydraShadowSourceComponent shad_comp = ecs->GetComponent<HydraShadowSourceComponent>(entity_id);
HydraDirectionalShadowSourceComponent shad_comp = ecs->GetComponent<HydraDirectionalShadowSourceComponent>(entity_id);
m_shadows[light_comp.shadow_map_id] = shad_comp;
}
_WriteToGPU();
}
void HydraShadowSourceSystem::_UpdateDirectionalLight(HydraID entity_id)
void HydraDirectionalShadowSourceSystem::_UpdateDirectionalLight(HydraID entity_id)
{
HydraEngine *engine = GetEngine();
HydraECS *ecs = engine->ECS();
HydraPositionComponent pos_comp = ecs->GetComponent<HydraPositionComponent>(entity_id);
HydraShadowSourceComponent &shad_comp = ecs->GetComponent<HydraShadowSourceComponent>(entity_id);
HydraDirectionalShadowSourceComponent &shad_comp = ecs->GetComponent<HydraDirectionalShadowSourceComponent>(entity_id);
float view_size = 20.0f;
float view_near = -10.0f;
@@ -104,6 +104,7 @@ void HydraShadowSourceSystem::_UpdateDirectionalLight(HydraID entity_id)
light_dir = glm::normalize(light_dir);
glm::vec3 camera_pos = GetEngine()->Camera()->GetPosition();
float light_distance = 2;
for (uint32_t i = 0; i < 6; i++)
{
glm::vec3 light_pos = camera_pos - (light_dir * light_distance);
@@ -125,36 +126,18 @@ void HydraShadowSourceSystem::_UpdateDirectionalLight(HydraID entity_id)
}
}
void HydraShadowSourceSystem::_UpdateSpotLight(HydraID entity_id)
{
// HydraEngine *engine = GetEngine();
// HydraECS *ecs = engine->ECS();
// HydraPositionComponent pos_comp = ecs->GetComponent<HydraPositionComponent>(entity_id);
// HydraShadowSourceComponent &shad_comp = ecs->GetComponent<HydraShadowSourceComponent>(entity_id);
// HydraLightComponent light_comp = ecs->GetComponent<HydraLightComponent>(entity_id);
// float view_size = 50.0f;
// float view_near = -100.0f;
// float view_far = 100.0f;
// glm::mat4 view = pos_comp.transform;
// glm::mat4 proj = glm::ortho<float>(-view_size, view_size, view_size, -view_size, view_near, view_far);
// shad_comp.far_plane[0] = view_far;
// shad_comp.near_plane[0] = view_near;
// shad_comp.light_space_proj[0] = proj;
// shad_comp.light_space_view[0] = view;
}
void HydraShadowSourceSystem::_InitialiseDirectionalLight(HydraID entity_id)
void HydraDirectionalShadowSourceSystem::_InitialiseDirectionalLight(HydraID entity_id)
{
HydraEngine *engine = GetEngine();
HydraECS *ecs = engine->ECS();
HydraTextureBufferManager *tex_man = engine->TextureBufferManager();
HydraShadowSourceComponent &shad_comp = ecs->GetComponent<HydraShadowSourceComponent>(entity_id);
HydraDirectionalShadowSourceComponent &shad_comp = ecs->GetComponent<HydraDirectionalShadowSourceComponent>(entity_id);
HydraLightComponent &light_comp = ecs->GetComponent<HydraLightComponent>(entity_id);
light_comp.shadow_caster = 1;
shad_comp.entity_id = entity_id;
shad_comp.cascade_count = 6;
HydraTaskScheduler *task_scheduler = GetEngine()->TaskScheduler();
uint32_t depth_texture_id = 0;
@@ -165,26 +148,8 @@ void HydraShadowSourceSystem::_InitialiseDirectionalLight(HydraID entity_id)
task_scheduler->WaitForTask(create_framebuffer_task_id);
shad_comp.shadow_texture_id = depth_texture_id;
}
void HydraShadowSourceSystem::_InitialiseSpotLight(HydraID entity_id)
{
// HydraEngine *engine = GetEngine();
// HydraECS *ecs = engine->ECS();
// HydraTextureBufferManager *tex_man = engine->TextureBufferManager();
// HydraShadowSourceComponent &shad_comp = ecs->GetComponent<HydraShadowSourceComponent>(entity_id);
// shad_comp.entity_id = entity_id;
// shad_comp.cascade_count = 6;
// HydraTaskScheduler *task_scheduler = GetEngine()->TaskScheduler();
// uint32_t depth_texture_id = 0;
// HydraID create_framebuffer_task_id = task_scheduler->CreateTask<HydraCreateShadowFrameBuffer>(HydraThreadAffinity::Render);
// HydraCreateShadowFrameBuffer *fb_task = static_cast<HydraCreateShadowFrameBuffer *>(task_scheduler->GetTask(create_framebuffer_task_id));
// fb_task->Initialise(&shad_comp.shadow_texture_id, &depth_texture_id, &shad_comp.frame_buffer_id);
// task_scheduler->WaitForTask(create_framebuffer_task_id);
// shad_comp.shadow_texture_id = depth_texture_id;
}
void HydraShadowSourceSystem::_WriteToGPU()
void HydraDirectionalShadowSourceSystem::_WriteToGPU()
{
HydraEngine *engine = GetEngine();
HydraECS *ecs = engine->ECS();
@@ -1,14 +1,14 @@
#ifndef HYDRASHADOWSOURCESYSTEM
#define HYDRASHADOWSOURCESYSTEM
#ifndef HYDRADIRECTIONALSHADOWSOURCESYSTEM
#define HYDRADIRECTIONALSHADOWSOURCESYSTEM
#include "../../engine/HydraObject.h"
#include "../HydraSystem.h"
#include "../components/HydraShadowSourceComponent.h"
#include "../components/HydraDirectionalShadowSourceComponent.h"
#include <GLMIncludes.h>
#include <queue>
#include <vector>
#include <mutex>
class HydraShadowSourceSystem : public HydraSystem
class HydraDirectionalShadowSourceSystem : public HydraSystem
{
public:
virtual void Initialise() override;
@@ -17,13 +17,11 @@ class HydraShadowSourceSystem : public HydraSystem
void UpdateSystem(float delta_t_seconds) override;
private:
void _UpdateDirectionalLight(HydraID entity_id);
void _UpdateSpotLight(HydraID entity_id);
void _InitialiseDirectionalLight(HydraID entity_id);
void _InitialiseSpotLight(HydraID entity_id);
void _WriteToGPU();
HydraID m_shadow_buffer_id = INVALID_HYDRA_ID;
std::queue<HydraID> m_available_shadows;
std::vector<HydraShadowSourceComponent> m_shadows;
std::vector<HydraDirectionalShadowSourceComponent> m_shadows;
std::mutex m_mutex;
};