Cleanup
This commit is contained in:
@@ -128,6 +128,13 @@ const float PI = 3.14159265358979323846;
|
||||
const float M_INV_PI = 0.31830988618379067153776752674503;
|
||||
float sqr(float x) { return x*x; }
|
||||
|
||||
|
||||
vec3 GetPositionFromView(mat4 view)
|
||||
{
|
||||
mat3 rot_mat = mat3(view);
|
||||
vec3 d = vec3(view[3]); // Column-major translation column
|
||||
return -d * rot_mat;
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
float DistributionGGX(vec3 N, vec3 H, float roughness)
|
||||
{
|
||||
@@ -490,7 +497,7 @@ float SampleCubemapShadow(vec3 frag_to_light, float far_plane, float view_distan
|
||||
);
|
||||
|
||||
float shadow = 0.0;
|
||||
float bias = 0.05;
|
||||
float bias = 0.0005;
|
||||
int samples = 20;
|
||||
|
||||
|
||||
@@ -547,7 +554,8 @@ void main()
|
||||
mat3 rot_mat = GetRotationOnlyMatrix(model);
|
||||
vec3 light_direction = normalize(rot_mat * vec3(0,0,1));
|
||||
|
||||
vec3 light_pos = model[3].xyz;
|
||||
vec3 light_pos = GetPositionFromView(model);
|
||||
light_pos = model[3].xyx;
|
||||
if(lights[i].light_type == HYDRA_LIGHT_DIRECTIONAL)
|
||||
{
|
||||
Lo += DirectionalShading(normal, diffuse.xyz, rough, metal, lights[i].intensity, light_direction, light_pos, world_pos, ubo_per_frame.viewer_pos);
|
||||
@@ -562,10 +570,11 @@ void main()
|
||||
else if(lights[i].light_type == HYDRA_LIGHT_POINT)
|
||||
{
|
||||
float shadow = 0;
|
||||
|
||||
if(lights[i].shadow_caster == 1)
|
||||
{
|
||||
float view_to_frag = length(light_pos - ubo_per_frame.viewer_pos );
|
||||
shadow = CalculatePointShadow(world_pos, i, view_to_frag, light_pos);
|
||||
shadow = CalculatePointShadow(world_pos, lights[i].shadow_map_id, view_to_frag, light_pos);
|
||||
}
|
||||
|
||||
Lo += PointShading(normal,
|
||||
@@ -579,7 +588,7 @@ void main()
|
||||
lights[i].quadratic,
|
||||
world_pos,
|
||||
ubo_per_frame.viewer_pos,
|
||||
shadow);
|
||||
shadow);
|
||||
|
||||
}
|
||||
else if(lights[i].light_type == HYDRA_LIGHT_SPOT)
|
||||
@@ -609,8 +618,6 @@ void main()
|
||||
world_pos,
|
||||
ubo_per_frame.viewer_pos,
|
||||
shadow) * lights[i].diffuse.xyz;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
#include "HydraActor.h"
|
||||
#include "HydraActorManager.h"
|
||||
#include "../engine/HydraEngine.h"
|
||||
#include "../ecs/HydraECS.h"
|
||||
void HydraActor::Delete()
|
||||
{
|
||||
GetEngine()->ECS()->DestroyEntity(GetID());
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ class CLASS_DEFINE HydraActor : public HydraObject
|
||||
std::vector<HydraID> m_children;
|
||||
std::vector<uint32_t> m_component_types;
|
||||
uint32_t m_components_waiting = 0;
|
||||
void Delete();
|
||||
friend class HydraActorManager;
|
||||
friend class HydraDeleteActorTask;
|
||||
protected:
|
||||
@@ -27,7 +28,8 @@ class CLASS_DEFINE HydraActor : public HydraObject
|
||||
virtual void DeferredInitialiseComponents() {};
|
||||
HydraID GetID() {return m_id;}
|
||||
virtual void FixedTick(float delta_t) {};
|
||||
virtual void Destroy()= 0;
|
||||
|
||||
virtual void _Cleanup(){};
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ void HydraActorManager::DeleteActor(HydraID actorID)
|
||||
if(m_actors[actorID] != nullptr)
|
||||
{
|
||||
|
||||
m_actors[actorID]->Destroy();
|
||||
m_actors[actorID]->Delete();
|
||||
_SetActorDeleted(actorID);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "../ecs/components/HydraDirectionalShadowSourceComponent.h"
|
||||
|
||||
#include "../buffer/HydraLightBufferManager.h"
|
||||
#include "../buffer/HydraLightBuffer.h"
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -35,8 +35,3 @@ void HydraDirectionalLightActor::InitialiseComponents()
|
||||
HydraDirectionalShadowSourceComponent shadow_component = {};
|
||||
ecs->AddComponent<HydraDirectionalShadowSourceComponent>(GetID(), shadow_component);
|
||||
}
|
||||
|
||||
void HydraDirectionalLightActor::Destroy()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ class CLASS_DEFINE HydraDirectionalLightActor : public HydraActor
|
||||
|
||||
public:
|
||||
virtual void InitialiseComponents() override;
|
||||
virtual void Destroy() override;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ class CLASS_DEFINE HydraGLTFActor : public HydraActor
|
||||
|
||||
public:
|
||||
virtual void InitialiseComponents() override {}
|
||||
virtual void Destroy() override {}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "../ecs/components/HydraPointShadowSourceComponent.h"
|
||||
#include "../ecs/components/HydraLightComponent.h"
|
||||
#include "../buffer/HydraLightBufferManager.h"
|
||||
#include "../buffer/HydraLightBuffer.h"
|
||||
|
||||
|
||||
|
||||
void HydraPointLightActor::InitialiseComponents()
|
||||
@@ -32,7 +32,3 @@ void HydraPointLightActor::InitialiseComponents()
|
||||
ecs->AddComponent<HydraPointShadowSourceComponent>(GetID(), shadow_component);
|
||||
}
|
||||
|
||||
void HydraPointLightActor::Destroy()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ class CLASS_DEFINE HydraPointLightActor : public HydraActor
|
||||
|
||||
public:
|
||||
virtual void InitialiseComponents() override;
|
||||
virtual void Destroy() override;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "../ecs/components/HydraSpotShadowSourceComponent.h"
|
||||
|
||||
#include "../buffer/HydraLightBufferManager.h"
|
||||
#include "../buffer/HydraLightBuffer.h"
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -37,7 +37,3 @@ void HydraSpotLightActor::InitialiseComponents()
|
||||
ecs->AddComponent<HydraSpotShadowSourceComponent>(GetID(), shadow_component);
|
||||
}
|
||||
|
||||
void HydraSpotLightActor::Destroy()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ class CLASS_DEFINE HydraSpotLightActor : public HydraActor
|
||||
|
||||
public:
|
||||
virtual void InitialiseComponents() override;
|
||||
virtual void Destroy() override;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
#ifndef HYDRALIGHTBUFFER
|
||||
#define HYDRALIGHTBUFFER
|
||||
|
||||
|
||||
#include <GLMIncludes.h>
|
||||
|
||||
struct HydraLightBuffer
|
||||
{
|
||||
alignas(16) glm::vec3 light_direction;
|
||||
alignas(16) glm::vec3 light_colour;
|
||||
uint32_t light_type;
|
||||
float light_intensity;
|
||||
float padding[2];
|
||||
};
|
||||
|
||||
#endif /* HYDRALIGHTBUFFER */
|
||||
@@ -1,44 +1,99 @@
|
||||
#include "HydraLightBufferManager.h"
|
||||
#include "../scheduler/HydraTaskScheduler.h"
|
||||
#include "../engine/HydraEngine.h"
|
||||
#include "../task/buffer/HydraCreateGPUBufferTask.hpp"
|
||||
#include "../task/buffer/HydraDeleteGPUBufferTask.hpp"
|
||||
#include "../task/buffer/HydraUpdatePartialGPUBufferTask.hpp"
|
||||
#include "../ecs/components/HydraLightComponent.h"
|
||||
|
||||
void HydraLightBufferManager::Initialise()
|
||||
{
|
||||
m_light_lookup.resize(MAX_LIGHTS);
|
||||
m_lights.resize(MAX_LIGHTS);
|
||||
|
||||
for(uint32_t i = 0; i < MAX_LIGHTS; i ++)
|
||||
{
|
||||
m_available_lights.push(i);
|
||||
m_light_lookup[i] = INVALID_HYDRA_ID;
|
||||
}
|
||||
|
||||
HydraTaskScheduler *task_scheduler = GetEngine()->TaskScheduler();
|
||||
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("LightBuffer", 1, MAX_LIGHTS * sizeof(HydraLightComponent), &m_light_buffer_id, HYDRA_BUFFER_TYPE::HYDRA_SSBO_BUFFER);
|
||||
task_scheduler->WaitForTask(create_gpu_buffer_task_id);
|
||||
}
|
||||
|
||||
void HydraLightBufferManager::Shutdown()
|
||||
{
|
||||
HydraTaskScheduler *task_scheduler = GetEngine()->TaskScheduler();
|
||||
HydraID delete_gpu_buffer_task_id = task_scheduler->CreateTask<HydraDeleteGPUBufferTask>(HydraThreadAffinity::Render);
|
||||
HydraDeleteGPUBufferTask *task = static_cast<HydraDeleteGPUBufferTask *>(task_scheduler->GetTask(delete_gpu_buffer_task_id));
|
||||
task->Intialise(m_light_buffer_id);
|
||||
task_scheduler->WaitForTask(delete_gpu_buffer_task_id);
|
||||
}
|
||||
|
||||
HydraID HydraLightBufferManager::CreateLight(HydraLightBuffer light_buffer)
|
||||
void HydraLightBufferManager::UpdateBuffer()
|
||||
{
|
||||
void *buffer = static_cast<void *>(m_lights.data());
|
||||
HydraTaskScheduler *task_scheduler = GetEngine()->TaskScheduler();
|
||||
|
||||
HydraID update_buffer_task_id = task_scheduler->CreateTask<HydraUpdatePartialGPUBufferTask>(HydraThreadAffinity::Render);
|
||||
HydraUpdatePartialGPUBufferTask *task = static_cast<HydraUpdatePartialGPUBufferTask *>(task_scheduler->GetTask(update_buffer_task_id));
|
||||
task->Intialise(m_light_buffer_id, 0, sizeof(HydraLightComponent) * m_lights.size(), buffer);
|
||||
task_scheduler->WaitForTask(update_buffer_task_id);
|
||||
}
|
||||
|
||||
void HydraLightBufferManager::AddLight(HydraLightComponent light)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
if(m_available_lights.size() > 0)
|
||||
if(m_available_lights.size() == 0)
|
||||
{
|
||||
HydraID light_id = m_available_lights.front();
|
||||
m_available_lights.pop();
|
||||
m_lights[m_light_count] = light_buffer;
|
||||
m_light_lookup[light_id] = m_light_count;
|
||||
m_light_count++;
|
||||
return light_id;
|
||||
return;
|
||||
}
|
||||
|
||||
return INVALID_HYDRA_ID;
|
||||
auto it = std::find(m_light_lookup.begin(), m_light_lookup.end(), light.entity_id);
|
||||
|
||||
if(it == m_light_lookup.end())
|
||||
{
|
||||
//light ID is not the index in the light buffer - this has to stay contiguous
|
||||
m_lights.push_back(light);
|
||||
m_light_lookup[m_light_count] = light.entity_id;
|
||||
m_light_count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_lights[m_light_lookup[*it]] = light;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
HydraLightBuffer *const HydraLightBufferManager::GetLightBufferBase()
|
||||
//Remove the light from the buffer and shuffle all of the others down to keep
|
||||
//the light buffer contiguous.
|
||||
void HydraLightBufferManager::RemoveLight(HydraID entity_id)
|
||||
{
|
||||
return &m_lights[0];
|
||||
}
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
auto it = std::find(m_light_lookup.begin(), m_light_lookup.end(), entity_id);
|
||||
if(it != m_light_lookup.end())
|
||||
{
|
||||
uint32_t remove_idx = it - m_light_lookup.begin();
|
||||
//end one - easy
|
||||
if(remove_idx == m_light_count-1)
|
||||
{
|
||||
m_lights.erase(m_lights.end()-1);
|
||||
m_light_count--;
|
||||
return;
|
||||
}
|
||||
|
||||
HydraLightBuffer &HydraLightBufferManager::GetLightBuffer(HydraID light_id)
|
||||
{
|
||||
HydraID light_idx = m_light_lookup[light_id];
|
||||
return m_lights[light_idx];
|
||||
|
||||
HydraLightComponent light_to_delete = m_lights[remove_idx];
|
||||
HydraLightComponent light_to_move = m_lights[m_light_count-1];
|
||||
|
||||
m_lights[remove_idx] = light_to_move;
|
||||
m_lights.erase(m_lights.end()-1);
|
||||
m_light_lookup[m_light_count-1] = INVALID_HYDRA_ID;
|
||||
m_light_lookup[remove_idx] = light_to_move.entity_id;
|
||||
m_light_count--;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t HydraLightBufferManager::GetLightCount()
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
#define HYDRALIGHTBUFFERMANAGER
|
||||
|
||||
#include "../engine/HydraObject.h"
|
||||
#include "HydraLightBuffer.h"
|
||||
#include "../ecs/components/HydraLightComponent.h"
|
||||
|
||||
#include <vector>
|
||||
#include <queue>
|
||||
#include <mutex>
|
||||
@@ -11,17 +12,18 @@ class HydraLightBufferManager : public HydraObject
|
||||
{
|
||||
public:
|
||||
void Initialise();
|
||||
void Shutdown();
|
||||
HydraID CreateLight(HydraLightBuffer light_buffer);
|
||||
HydraLightBuffer* const GetLightBufferBase();
|
||||
HydraLightBuffer& GetLightBuffer(HydraID light_id);
|
||||
void Shutdown();
|
||||
uint32_t GetLightCount();
|
||||
void UpdateBuffer();
|
||||
void AddLight(HydraLightComponent light);
|
||||
void RemoveLight(HydraID entity_id);
|
||||
private:
|
||||
std::mutex m_mutex;
|
||||
uint32_t m_light_count = 0;
|
||||
std::vector<HydraLightBuffer> m_lights;
|
||||
std::vector<HydraLightComponent> m_lights;
|
||||
std::queue<HydraID> m_available_lights;
|
||||
std::vector<HydraID> m_light_lookup;
|
||||
HydraID m_light_buffer_id = INVALID_HYDRA_ID;
|
||||
};
|
||||
|
||||
#endif /* HYDRALIGHTBUFFERMANAGER */
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
#include "../task/buffer/HydraUpdateWholeGPUBufferTask.hpp"
|
||||
#include "../task/buffer/HydraUpdatePartialGPUBufferTask.hpp"
|
||||
#include "../task/buffer/HydraCreateUnBoundTextureTask.hpp"
|
||||
#include "../task/buffer/HydraDeleteGPUBufferTask.hpp"
|
||||
#include "../task/renderer/HydraCreateCascadeShadowFrameBuffer.hpp"
|
||||
#include "../task/renderer/HydraCreateCubemapShadowFrameBuffer.hpp"
|
||||
#include "../task/renderer/HydraCreateShadowFrameBuffer.hpp"
|
||||
#include "../task/renderer/HydraDeleteShadowFrameBufferTask.hpp"
|
||||
#include "../ecs/components/HydraDirectionalShadowSourceComponent.h"
|
||||
@@ -52,9 +54,24 @@ void HydraShadowBufferManager::Initialise()
|
||||
}
|
||||
void HydraShadowBufferManager::Shutdown()
|
||||
{
|
||||
|
||||
HydraTaskScheduler *task_scheduler = GetEngine()->TaskScheduler();
|
||||
|
||||
uint32_t delete_gpu_buffer_task_id = task_scheduler->CreateTask<HydraDeleteGPUBufferTask>(HydraThreadAffinity::Render);
|
||||
HydraDeleteGPUBufferTask *point_task = static_cast<HydraDeleteGPUBufferTask *>(task_scheduler->GetTask(delete_gpu_buffer_task_id));
|
||||
point_task->Intialise(m_point_shadow_buffer_id);
|
||||
task_scheduler->WaitForTask(delete_gpu_buffer_task_id);
|
||||
|
||||
delete_gpu_buffer_task_id = task_scheduler->CreateTask<HydraDeleteGPUBufferTask>(HydraThreadAffinity::Render);
|
||||
HydraDeleteGPUBufferTask *dir_task = static_cast<HydraDeleteGPUBufferTask *>(task_scheduler->GetTask(delete_gpu_buffer_task_id));
|
||||
dir_task->Intialise(m_directional_shadow_buffer_id);
|
||||
task_scheduler->WaitForTask(delete_gpu_buffer_task_id);
|
||||
|
||||
delete_gpu_buffer_task_id = task_scheduler->CreateTask<HydraDeleteGPUBufferTask>(HydraThreadAffinity::Render);
|
||||
HydraDeleteGPUBufferTask *spot_task = static_cast<HydraDeleteGPUBufferTask *>(task_scheduler->GetTask(delete_gpu_buffer_task_id));
|
||||
spot_task->Intialise(m_point_shadow_buffer_id);
|
||||
task_scheduler->WaitForTask(delete_gpu_buffer_task_id);
|
||||
}
|
||||
HydraID HydraShadowBufferManager::AddDirectionalShadow(HydraDirectionalShadowSourceComponent shadow)
|
||||
HydraID HydraShadowBufferManager::AddDirectionalShadow(HydraDirectionalShadowSourceComponent& shadow)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
if(m_available_dir.size() == 0)
|
||||
@@ -65,9 +82,27 @@ HydraID HydraShadowBufferManager::AddDirectionalShadow(HydraDirectionalShadowSou
|
||||
HydraID shadow_id = m_available_dir.front();
|
||||
shadow.shadow_id = shadow_id;
|
||||
m_directional_shadow_buffer[shadow_id] = shadow;
|
||||
|
||||
HydraEngine *engine = GetEngine();
|
||||
HydraECS *ecs = engine->ECS();
|
||||
|
||||
HydraTaskScheduler *task_scheduler = GetEngine()->TaskScheduler();
|
||||
|
||||
uint32_t depth_texture_id = 0;
|
||||
uint32_t frame_buffer_id = 0;
|
||||
|
||||
HydraID create_framebuffer_task_id = task_scheduler->CreateTask<HydraCreateCascadeShadowFrameBuffer>(HydraThreadAffinity::Render);
|
||||
HydraCreateCascadeShadowFrameBuffer *fb_task = static_cast<HydraCreateCascadeShadowFrameBuffer *>(task_scheduler->GetTask(create_framebuffer_task_id));
|
||||
|
||||
fb_task->Initialise(&depth_texture_id, &frame_buffer_id);
|
||||
|
||||
task_scheduler->WaitForTask(create_framebuffer_task_id);
|
||||
shadow.shadow_texture_id = depth_texture_id;
|
||||
shadow.frame_buffer_id = frame_buffer_id;
|
||||
|
||||
return shadow_id;
|
||||
}
|
||||
HydraID HydraShadowBufferManager::AddSpotShadow(HydraSpotShadowSourceComponent shadow)
|
||||
HydraID HydraShadowBufferManager::AddSpotShadow(HydraSpotShadowSourceComponent& shadow)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
if(m_available_spot.size() == 0)
|
||||
@@ -77,10 +112,26 @@ HydraID HydraShadowBufferManager::AddSpotShadow(HydraSpotShadowSourceComponent s
|
||||
|
||||
HydraID shadow_id = m_available_spot.front();
|
||||
m_spot_shadow_buffer[shadow_id] = shadow;
|
||||
|
||||
HydraEngine *engine = GetEngine();
|
||||
HydraECS *ecs = engine->ECS();
|
||||
|
||||
HydraTaskScheduler *task_scheduler = GetEngine()->TaskScheduler();
|
||||
|
||||
uint32_t depth_texture_id = 0;
|
||||
uint32_t frame_buffer_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(&depth_texture_id, &frame_buffer_id);
|
||||
|
||||
task_scheduler->WaitForTask(create_framebuffer_task_id);
|
||||
shadow.shadow_texture_id = depth_texture_id;
|
||||
shadow.frame_buffer_id = frame_buffer_id;
|
||||
|
||||
return shadow_id;
|
||||
}
|
||||
|
||||
HydraID HydraShadowBufferManager::AddPointShadow(HydraPointShadowSourceComponent shadow)
|
||||
HydraID HydraShadowBufferManager::AddPointShadow(HydraPointShadowSourceComponent& shadow)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
if(m_available_point.size() == 0)
|
||||
@@ -90,6 +141,24 @@ HydraID HydraShadowBufferManager::AddPointShadow(HydraPointShadowSourceComponent
|
||||
|
||||
HydraID shadow_id = m_available_point.front();
|
||||
m_point_shadow_buffer[shadow_id] = shadow;
|
||||
|
||||
HydraEngine *engine = GetEngine();
|
||||
HydraECS *ecs = engine->ECS();
|
||||
|
||||
|
||||
|
||||
HydraTaskScheduler *task_scheduler = GetEngine()->TaskScheduler();
|
||||
|
||||
uint32_t depth_texture_id = 0;
|
||||
uint32_t frame_buffer_id = 0;
|
||||
HydraID create_framebuffer_task_id = task_scheduler->CreateTask<HydraCreateCubemapShadowFrameBuffer>(HydraThreadAffinity::Render);
|
||||
HydraCreateCubemapShadowFrameBuffer *fb_task = static_cast<HydraCreateCubemapShadowFrameBuffer *>(task_scheduler->GetTask(create_framebuffer_task_id));
|
||||
fb_task->Initialise( &depth_texture_id, &frame_buffer_id);
|
||||
|
||||
task_scheduler->WaitForTask(create_framebuffer_task_id);
|
||||
shadow.shadow_texture_id = depth_texture_id;
|
||||
shadow.frame_buffer_id = frame_buffer_id;
|
||||
|
||||
return shadow_id;
|
||||
}
|
||||
|
||||
@@ -131,6 +200,7 @@ void HydraShadowBufferManager::DeleteDirectionalShadow(HydraID shadow_id)
|
||||
|
||||
fb_task->Initialise(shadow_comp.shadow_texture_id, shadow_comp.frame_buffer_id);
|
||||
task_scheduler->WaitForTask(delete_frame_buffer_task_id);
|
||||
m_available_dir.push(shadow_id);
|
||||
}
|
||||
void HydraShadowBufferManager::DeleteSpotShadow(HydraID shadow_id)
|
||||
{
|
||||
@@ -143,6 +213,7 @@ void HydraShadowBufferManager::DeleteSpotShadow(HydraID shadow_id)
|
||||
|
||||
fb_task->Initialise(shadow_comp.shadow_texture_id, shadow_comp.frame_buffer_id);
|
||||
task_scheduler->WaitForTask(delete_frame_buffer_task_id);
|
||||
m_available_spot.push(shadow_id);
|
||||
}
|
||||
|
||||
void HydraShadowBufferManager::DeletePointShadow(HydraID shadow_id)
|
||||
@@ -156,6 +227,7 @@ void HydraShadowBufferManager::DeletePointShadow(HydraID shadow_id)
|
||||
|
||||
fb_task->Initialise(shadow_comp.shadow_texture_id, shadow_comp.frame_buffer_id);
|
||||
task_scheduler->WaitForTask(delete_frame_buffer_task_id);
|
||||
m_available_point.push(shadow_id);
|
||||
}
|
||||
|
||||
void HydraShadowBufferManager::UpdateShadowBuffer()
|
||||
|
||||
@@ -15,9 +15,9 @@ class HydraShadowBufferManager : public HydraObject
|
||||
public:
|
||||
void Initialise();
|
||||
void Shutdown();
|
||||
HydraID AddDirectionalShadow(HydraDirectionalShadowSourceComponent shadow);
|
||||
HydraID AddSpotShadow(HydraSpotShadowSourceComponent shadow);
|
||||
HydraID AddPointShadow(HydraPointShadowSourceComponent shadow);
|
||||
HydraID AddDirectionalShadow(HydraDirectionalShadowSourceComponent& shadow);
|
||||
HydraID AddSpotShadow(HydraSpotShadowSourceComponent& shadow);
|
||||
HydraID AddPointShadow(HydraPointShadowSourceComponent& shadow);
|
||||
|
||||
void UpdateDirectionalShadow(HydraID shadow_id, HydraDirectionalShadowSourceComponent shadow);
|
||||
void UpdateSpotShadow(HydraID shadow_id, HydraSpotShadowSourceComponent shadow);
|
||||
@@ -29,6 +29,8 @@ class HydraShadowBufferManager : public HydraObject
|
||||
|
||||
void UpdateShadowBuffer();
|
||||
private:
|
||||
|
||||
|
||||
std::vector<HydraDirectionalShadowSourceComponent> m_directional_shadow_buffer;
|
||||
std::vector<HydraSpotShadowSourceComponent> m_spot_shadow_buffer;
|
||||
std::vector<HydraPointShadowSourceComponent> m_point_shadow_buffer;
|
||||
@@ -39,6 +41,7 @@ class HydraShadowBufferManager : public HydraObject
|
||||
uint32_t m_spot_shadow_buffer_id;
|
||||
uint32_t m_point_shadow_buffer_id;
|
||||
std::mutex m_mutex;
|
||||
|
||||
|
||||
};
|
||||
#endif /* HYDRASHADOWBUFFERMANAGER */
|
||||
|
||||
@@ -242,19 +242,15 @@ void HydraTextureBufferManager::BindTexture(HydraID texture_id, uint32_t target)
|
||||
HydraTextureBuffer texture = m_textures[texture_id];
|
||||
glBindTexture(target, texture.gl_tex_id);
|
||||
|
||||
// glTextureParameteri(texture.gl_tex_id, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
// glTextureParameteri(texture.gl_tex_id, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
// glTextureParameteri(texture.gl_tex_id, GL_TEXTURE_MIN_FILTER, texture.min_filter);
|
||||
// glTextureParameteri(texture.gl_tex_id, GL_TEXTURE_MAG_FILTER, texture.mag_filter);
|
||||
|
||||
texture.texture_binding = glGetTextureHandleARB(texture.gl_tex_id);
|
||||
glMakeTextureHandleResidentARB(texture.texture_binding);
|
||||
m_bindless_texture_ids[texture_id] = texture.texture_binding;
|
||||
}
|
||||
|
||||
void HydraTextureBufferManager::UnbindTexture(HydraID texture_id)
|
||||
void HydraTextureBufferManager::UnbindTexture(HydraID gl_texture_id)
|
||||
{
|
||||
glMakeTextureHandleNonResidentARB(texture_id);
|
||||
glMakeTextureHandleNonResidentARB(gl_texture_id);
|
||||
|
||||
}
|
||||
|
||||
void HydraTextureBufferManager::DeleteTexture(HydraID texture_id)
|
||||
@@ -262,6 +258,7 @@ void HydraTextureBufferManager::DeleteTexture(HydraID texture_id)
|
||||
if (m_bindless_texture_ids[texture_id] != 0)
|
||||
{
|
||||
UnbindTexture(m_bindless_texture_ids[texture_id]);
|
||||
m_bindless_texture_ids[texture_id]=0;
|
||||
}
|
||||
glDeleteTextures(1, &m_textures[texture_id].gl_tex_id);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,10 @@ class HydraComponentArray : public IHydraComponentArray
|
||||
void RemoveComponent(HydraID entity_id)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
assert(m_entity_to_component.find(entity_id) == m_entity_to_component.end() && "Trying to remove a component that doesnt exist");
|
||||
if(m_entity_to_component.find(entity_id) == m_entity_to_component.end())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
HydraID component_index = m_entity_to_component[entity_id];
|
||||
HydraID last_component_index = m_component_count -1;
|
||||
@@ -80,15 +83,8 @@ class HydraComponentArray : public IHydraComponentArray
|
||||
|
||||
void EntityDeleted(HydraID entity_id)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
if(m_entity_to_component.find(entity_id) != m_entity_to_component.end())
|
||||
{
|
||||
RemoveComponent(entity_id);
|
||||
}
|
||||
RemoveComponent(entity_id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif /* HYDRACOMPONENTARRAY */
|
||||
|
||||
@@ -24,9 +24,8 @@ public:
|
||||
void DestroyEntity(HydraID entity_id)
|
||||
{
|
||||
m_system_manager->EntityDeleted(entity_id);
|
||||
m_entity_manager->DeleteEntity(entity_id);
|
||||
m_component_manager->EntityDeleted(entity_id);
|
||||
|
||||
m_entity_manager->DeleteEntity(entity_id);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
||||
@@ -36,13 +36,17 @@ void HydraDirectionalShadowSourceSystem::InitialiseComponent(HydraID entity_id)
|
||||
|
||||
HydraDirectionalShadowSourceComponent& shadow_comp = ecs->GetComponent<HydraDirectionalShadowSourceComponent>(entity_id);
|
||||
|
||||
//light_comp.shadow_map_id = shadow_id;
|
||||
light_comp.shadow_caster = 1;
|
||||
//shadow_comp.shadow_id = shadow_id;
|
||||
shadow_comp.entity_id = entity_id;
|
||||
|
||||
HydraID shadow_id = GetEngine()->ShadowBufferManager()->AddDirectionalShadow(shadow_comp);
|
||||
assert(shadow_id != INVALID_HYDRA_ID && "Add directional Shadow - out of shadows!");
|
||||
|
||||
light_comp.shadow_map_id = shadow_id;
|
||||
light_comp.shadow_caster = 1;
|
||||
shadow_comp.shadow_id = shadow_id;
|
||||
_InitialiseShadowMap(entity_id);
|
||||
|
||||
|
||||
//_InitialiseShadowMap(entity_id);
|
||||
}
|
||||
|
||||
void HydraDirectionalShadowSourceSystem::DestroyComponent(HydraID entity_id)
|
||||
@@ -50,8 +54,7 @@ void HydraDirectionalShadowSourceSystem::DestroyComponent(HydraID entity_id)
|
||||
HydraEngine *engine = GetEngine();
|
||||
HydraECS *ecs = engine->ECS();
|
||||
HydraDirectionalShadowSourceComponent& shadow_comp = ecs->GetComponent<HydraDirectionalShadowSourceComponent>(entity_id);
|
||||
GetEngine()->ShadowBufferManager()->DeleteDirectionalShadow(shadow_comp.shadow_id);
|
||||
|
||||
GetEngine()->ShadowBufferManager()->DeleteDirectionalShadow(shadow_comp.shadow_id);
|
||||
}
|
||||
|
||||
void HydraDirectionalShadowSourceSystem::UpdateSystem(float delta_t_seconds)
|
||||
@@ -110,24 +113,3 @@ void HydraDirectionalShadowSourceSystem::_UpdateShadowMap(HydraID entity_id)
|
||||
}
|
||||
|
||||
|
||||
void HydraDirectionalShadowSourceSystem::_InitialiseShadowMap(HydraID entity_id)
|
||||
{
|
||||
HydraEngine *engine = GetEngine();
|
||||
HydraECS *ecs = engine->ECS();
|
||||
HydraTextureBufferManager *tex_man = engine->TextureBufferManager();
|
||||
HydraDirectionalShadowSourceComponent &shad_comp = ecs->GetComponent<HydraDirectionalShadowSourceComponent>(entity_id);
|
||||
HydraLightComponent &light_comp = ecs->GetComponent<HydraLightComponent>(entity_id);
|
||||
|
||||
shad_comp.entity_id = entity_id;
|
||||
|
||||
HydraTaskScheduler *task_scheduler = GetEngine()->TaskScheduler();
|
||||
|
||||
uint32_t depth_texture_id = 0;
|
||||
HydraID create_framebuffer_task_id = task_scheduler->CreateTask<HydraCreateCascadeShadowFrameBuffer>(HydraThreadAffinity::Render);
|
||||
HydraCreateCascadeShadowFrameBuffer *fb_task = static_cast<HydraCreateCascadeShadowFrameBuffer *>(task_scheduler->GetTask(create_framebuffer_task_id));
|
||||
fb_task->Initialise(&depth_texture_id, &shad_comp.frame_buffer_id);
|
||||
|
||||
task_scheduler->WaitForTask(create_framebuffer_task_id);
|
||||
shad_comp.shadow_texture_id = depth_texture_id;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,7 @@ class HydraDirectionalShadowSourceSystem : public HydraSystem
|
||||
void UpdateSystem(float delta_t_seconds) override;
|
||||
private:
|
||||
void _UpdateShadowMap(HydraID entity_id);
|
||||
|
||||
void _InitialiseShadowMap(HydraID entity_id);
|
||||
|
||||
HydraID m_shadow_actor_id = INVALID_HYDRA_ID;
|
||||
std::mutex m_mutex;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "../components/HydraLightComponent.h"
|
||||
#include "../components/HydraPositionComponent.h"
|
||||
#include "../../buffer/HydraLightBufferManager.h"
|
||||
#include "../../buffer/HydraLightBuffer.h"
|
||||
|
||||
|
||||
#include "../../scheduler/HydraTaskScheduler.h"
|
||||
#include "../../task/buffer/HydraCreateGPUBufferTask.hpp"
|
||||
@@ -15,51 +15,27 @@
|
||||
|
||||
void HydraLightSystem::Initialise()
|
||||
{
|
||||
HydraTaskScheduler *task_scheduler = GetEngine()->TaskScheduler();
|
||||
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("LightBuffer", 1, MAX_LIGHTS * sizeof(HydraLightComponent), &m_light_buffer_id, HYDRA_BUFFER_TYPE::HYDRA_SSBO_BUFFER);
|
||||
task_scheduler->WaitForTask(create_gpu_buffer_task_id);
|
||||
|
||||
}
|
||||
|
||||
uint32_t HydraLightSystem::GetLightCount()
|
||||
{
|
||||
return m_lights.size();
|
||||
}
|
||||
|
||||
void HydraLightSystem::InitialiseComponent(HydraID entity_id)
|
||||
{
|
||||
HydraLightBufferManager *light_man = GetEngine()->LightBufferManager();
|
||||
uint32_t light_count = light_man->GetLightCount();
|
||||
HydraECS *ecs = GetEngine()->ECS();
|
||||
|
||||
HydraPositionComponent &pos_comp = ecs->GetComponent<HydraPositionComponent>(entity_id);
|
||||
HydraLightComponent &light_comp = ecs->GetComponent<HydraLightComponent>(entity_id);
|
||||
|
||||
m_lights.push_back(light_comp);
|
||||
light_man->AddLight(light_comp);
|
||||
}
|
||||
|
||||
void HydraLightSystem::FreeSystemResources()
|
||||
void HydraLightSystem::DestroyComponent(HydraID actor_id)
|
||||
{
|
||||
HydraTaskScheduler *task_scheduler = GetEngine()->TaskScheduler();
|
||||
HydraID delete_gpu_buffer_task_id = task_scheduler->CreateTask<HydraDeleteGPUBufferTask>(HydraThreadAffinity::Render);
|
||||
HydraDeleteGPUBufferTask *task = static_cast<HydraDeleteGPUBufferTask *>(task_scheduler->GetTask(delete_gpu_buffer_task_id));
|
||||
task->Intialise(m_light_buffer_id);
|
||||
task_scheduler->WaitForTask(delete_gpu_buffer_task_id);
|
||||
HydraLightBufferManager *light_man = GetEngine()->LightBufferManager();
|
||||
light_man->RemoveLight(actor_id);
|
||||
}
|
||||
|
||||
void HydraLightSystem::UpdateSystem(float delta_t_seconds)
|
||||
{
|
||||
_WriteToGPU();
|
||||
HydraLightBufferManager *light_man = GetEngine()->LightBufferManager();
|
||||
light_man->UpdateBuffer();
|
||||
}
|
||||
|
||||
void HydraLightSystem::_WriteToGPU()
|
||||
{
|
||||
void *buffer = static_cast<void *>(m_lights.data());
|
||||
HydraTaskScheduler *task_scheduler = GetEngine()->TaskScheduler();
|
||||
|
||||
HydraID update_buffer_task_id = task_scheduler->CreateTask<HydraUpdatePartialGPUBufferTask>(HydraThreadAffinity::Render);
|
||||
HydraUpdatePartialGPUBufferTask *task = static_cast<HydraUpdatePartialGPUBufferTask *>(task_scheduler->GetTask(update_buffer_task_id));
|
||||
task->Intialise(m_light_buffer_id, 0, sizeof(HydraLightComponent) * m_lights.size(), buffer);
|
||||
task_scheduler->WaitForTask(update_buffer_task_id);
|
||||
}
|
||||
@@ -14,15 +14,15 @@ class HydraLightSystem : public HydraSystem
|
||||
{
|
||||
public:
|
||||
void Initialise() override;
|
||||
uint32_t GetLightCount();
|
||||
//uint32_t GetLightCount();
|
||||
protected:
|
||||
void InitialiseComponent(HydraID entity_id) override;
|
||||
void FreeSystemResources() override;
|
||||
void DestroyComponent(HydraID actor_id) override;
|
||||
virtual void UpdateSystem(float delta_t_seconds);
|
||||
private:
|
||||
void _WriteToGPU();
|
||||
|
||||
HydraID m_light_buffer_id = INVALID_HYDRA_ID;
|
||||
std::vector<HydraLightComponent> m_lights;
|
||||
|
||||
|
||||
};
|
||||
#endif /* HYDRALIGHTSYSTEM */
|
||||
|
||||
@@ -37,8 +37,9 @@ void HydraPointShadowSourceSystem::InitialiseComponent(HydraID entity_id)
|
||||
|
||||
light_comp.shadow_map_id = shadow_id;
|
||||
light_comp.shadow_caster = 1;
|
||||
shadow_comp.shadow_id = shadow_id;
|
||||
_InitialiseShadowMap(entity_id);
|
||||
shadow_comp.entity_id = entity_id;
|
||||
//shadow_comp.shadow_id = shadow_id;
|
||||
//_InitialiseShadowMap(entity_id);
|
||||
}
|
||||
|
||||
void HydraPointShadowSourceSystem::UpdateSystem(float delta_t_seconds)
|
||||
@@ -51,7 +52,7 @@ void HydraPointShadowSourceSystem::UpdateSystem(float delta_t_seconds)
|
||||
|
||||
void HydraPointShadowSourceSystem::DestroyComponent(HydraID entity_id)
|
||||
{
|
||||
HydraEngine *engine = GetEngine();
|
||||
HydraEngine *engine = GetEngine();
|
||||
HydraECS *ecs = engine->ECS();
|
||||
HydraPointShadowSourceComponent& shadow_comp = ecs->GetComponent<HydraPointShadowSourceComponent>(entity_id);
|
||||
GetEngine()->ShadowBufferManager()->DeletePointShadow(shadow_comp.shadow_id);
|
||||
@@ -85,7 +86,7 @@ void HydraPointShadowSourceSystem::_UpdateShadowMap(HydraID entity_id)
|
||||
//GL_TEXTURE_CUBE_MAP_NEGATIVE_X - right
|
||||
shad_comp.light_space_view[1] = glm::lookAt(light_pos, light_pos + glm::vec3(-1.0, 0.0, 0.0), glm::vec3(0.0, 1.0, 0.0));
|
||||
//GL_TEXTURE_CUBE_MAP_POSITIVE_Y - Up
|
||||
shad_comp.light_space_view[2] = glm::lookAt(light_pos, light_pos + glm::vec3(0.0, 1.0, 0.0), glm::vec3(0.0, 0.0, 1.0));
|
||||
shad_comp.light_space_view[2] = glm::lookAt(light_pos, light_pos + glm::vec3(0.0, 1.0, 0.0), glm::vec3(0.0, 0.0, -1.0));
|
||||
//GL_TEXTURE_CUBE_MAP_NEGATIVE_Y - down
|
||||
shad_comp.light_space_view[3] = glm::lookAt(light_pos, light_pos + glm::vec3(0.0, -1.0, 0.0), glm::vec3(0.0, 0.0, 1.0));
|
||||
//GL_TEXTURE_CUBE_MAP_POSITIVE_Z - back
|
||||
@@ -101,22 +102,22 @@ void HydraPointShadowSourceSystem::_UpdateShadowMap(HydraID entity_id)
|
||||
|
||||
void HydraPointShadowSourceSystem::_InitialiseShadowMap(HydraID entity_id)
|
||||
{
|
||||
HydraEngine *engine = GetEngine();
|
||||
HydraECS *ecs = engine->ECS();
|
||||
HydraTextureBufferManager *tex_man = engine->TextureBufferManager();
|
||||
HydraPointShadowSourceComponent &shad_comp = ecs->GetComponent<HydraPointShadowSourceComponent>(entity_id);
|
||||
HydraLightComponent &light_comp = ecs->GetComponent<HydraLightComponent>(entity_id);
|
||||
// HydraEngine *engine = GetEngine();
|
||||
// HydraECS *ecs = engine->ECS();
|
||||
// HydraTextureBufferManager *tex_man = engine->TextureBufferManager();
|
||||
// HydraPointShadowSourceComponent &shad_comp = ecs->GetComponent<HydraPointShadowSourceComponent>(entity_id);
|
||||
// HydraLightComponent &light_comp = ecs->GetComponent<HydraLightComponent>(entity_id);
|
||||
|
||||
shad_comp.entity_id = entity_id;
|
||||
// shad_comp.entity_id = entity_id;
|
||||
|
||||
HydraTaskScheduler *task_scheduler = GetEngine()->TaskScheduler();
|
||||
// HydraTaskScheduler *task_scheduler = GetEngine()->TaskScheduler();
|
||||
|
||||
uint32_t depth_texture_id = 0;
|
||||
HydraID create_framebuffer_task_id = task_scheduler->CreateTask<HydraCreateCubemapShadowFrameBuffer>(HydraThreadAffinity::Render);
|
||||
HydraCreateCubemapShadowFrameBuffer *fb_task = static_cast<HydraCreateCubemapShadowFrameBuffer *>(task_scheduler->GetTask(create_framebuffer_task_id));
|
||||
fb_task->Initialise(&shad_comp.shadow_texture_id, &depth_texture_id, &shad_comp.frame_buffer_id);
|
||||
// uint32_t depth_texture_id = 0;
|
||||
// HydraID create_framebuffer_task_id = task_scheduler->CreateTask<HydraCreateCubemapShadowFrameBuffer>(HydraThreadAffinity::Render);
|
||||
// HydraCreateCubemapShadowFrameBuffer *fb_task = static_cast<HydraCreateCubemapShadowFrameBuffer *>(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;
|
||||
// task_scheduler->WaitForTask(create_framebuffer_task_id);
|
||||
// shad_comp.shadow_texture_id = depth_texture_id;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ void HydraSpotShadowSourceSystem::InitialiseComponent(HydraID entity_id)
|
||||
|
||||
light_comp.shadow_map_id = shadow_id;
|
||||
light_comp.shadow_caster = 1;
|
||||
shadow_comp.shadow_id = shadow_id;
|
||||
shadow_comp.entity_id = entity_id;
|
||||
_InitialiseShadowMap(entity_id);
|
||||
|
||||
}
|
||||
@@ -103,22 +103,22 @@ void HydraSpotShadowSourceSystem::_UpdateShadowMap(HydraID entity_id)
|
||||
|
||||
void HydraSpotShadowSourceSystem::_InitialiseShadowMap(HydraID entity_id)
|
||||
{
|
||||
HydraEngine *engine = GetEngine();
|
||||
HydraECS *ecs = engine->ECS();
|
||||
HydraTextureBufferManager *tex_man = engine->TextureBufferManager();
|
||||
HydraSpotShadowSourceComponent &shad_comp = ecs->GetComponent<HydraSpotShadowSourceComponent>(entity_id);
|
||||
HydraLightComponent &light_comp = ecs->GetComponent<HydraLightComponent>(entity_id);
|
||||
// HydraEngine *engine = GetEngine();
|
||||
// HydraECS *ecs = engine->ECS();
|
||||
// HydraTextureBufferManager *tex_man = engine->TextureBufferManager();
|
||||
// HydraSpotShadowSourceComponent &shad_comp = ecs->GetComponent<HydraSpotShadowSourceComponent>(entity_id);
|
||||
// HydraLightComponent &light_comp = ecs->GetComponent<HydraLightComponent>(entity_id);
|
||||
|
||||
shad_comp.entity_id = entity_id;
|
||||
// shad_comp.entity_id = entity_id;
|
||||
|
||||
HydraTaskScheduler *task_scheduler = GetEngine()->TaskScheduler();
|
||||
// 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);
|
||||
// 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;
|
||||
// task_scheduler->WaitForTask(create_framebuffer_task_id);
|
||||
// shad_comp.shadow_texture_id = depth_texture_id;
|
||||
}
|
||||
|
||||
|
||||
@@ -175,7 +175,7 @@ float HydraEngine::GetDeltaT()
|
||||
|
||||
uint32_t HydraEngine::GetLightCount()
|
||||
{
|
||||
return m_light_system->GetLightCount();
|
||||
return m_light_buffer_manager->GetLightCount();
|
||||
}
|
||||
|
||||
void HydraEngine::_CreateManagers()
|
||||
@@ -430,6 +430,9 @@ void HydraEngine::_Shutdown()
|
||||
{
|
||||
m_actor_manager->Shutdown();
|
||||
m_ecs->Shutdown();
|
||||
m_input_manager->Shutdown();
|
||||
m_window_manager->Shutdown();
|
||||
|
||||
|
||||
//Shutdown the buffer and vertex buffer managers
|
||||
|
||||
@@ -443,14 +446,16 @@ void HydraEngine::_Shutdown()
|
||||
|
||||
m_task_scheduler->Shutdown();
|
||||
|
||||
|
||||
delete m_actor_manager;
|
||||
delete m_ecs;
|
||||
delete m_input_manager;
|
||||
delete m_window_manager;
|
||||
|
||||
delete m_pipeline;
|
||||
delete m_task_scheduler;
|
||||
delete m_buffer_manager;
|
||||
delete m_vertex_buffer_manager;
|
||||
delete m_pipeline;
|
||||
delete m_vertex_buffer_manager;
|
||||
delete m_texture_buffer_manager;
|
||||
delete m_material_buffer_manager;
|
||||
delete m_light_buffer_manager;
|
||||
|
||||
@@ -25,7 +25,7 @@ class HydraInputManager : public HydraObject
|
||||
void ProcessInput();
|
||||
bool KeyPressed(HYDRA_KEY_CODES key);
|
||||
glm::vec2 MouseChange() {return m_mouse_change;}
|
||||
|
||||
void Shutdown() {}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -14,6 +14,11 @@ class HydraShutdownBufferManagerTask : public HydraTask
|
||||
{
|
||||
GetEngine()->BufferManager()->Shutdown();
|
||||
GetEngine()->VertexBufferManager()->Shutdown();
|
||||
GetEngine()->LightBufferManager()->Shutdown();
|
||||
GetEngine()->MaterialBufferManager()->Shutdown();
|
||||
GetEngine()->ShadowBufferManager()->Shutdown();
|
||||
GetEngine()->TextureBufferManager()->Shutdown();
|
||||
|
||||
}
|
||||
};
|
||||
#endif /* HYDRASHUTDOWNBUFFERMANAGERTASK */
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
class HydraCreateCubemapShadowFrameBuffer : public HydraTask
|
||||
{
|
||||
private:
|
||||
uint32_t *m_texture_id = 0;
|
||||
|
||||
uint32_t *m_depth_texture_id = 0;
|
||||
uint32_t *m_frame_buffer_id = nullptr;
|
||||
|
||||
@@ -24,7 +24,7 @@ public:
|
||||
HydraTextureBufferManager *tex_buffer_manager = engine->TextureBufferManager();
|
||||
HydraRenderSettings render_settings = engine->RenderSettings();
|
||||
|
||||
HydraTextureBuffer texture = tex_buffer_manager->GetTexture(*m_texture_id);
|
||||
|
||||
|
||||
*m_depth_texture_id = tex_buffer_manager->CreateCubemapTexture("shadow_depth_buffer",
|
||||
POINT_SHADOW_MAP_SIZE, POINT_SHADOW_MAP_SIZE,
|
||||
@@ -49,9 +49,8 @@ public:
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
tex_buffer_manager->BindTexture(*m_depth_texture_id, GL_TEXTURE_CUBE_MAP);
|
||||
}
|
||||
void Initialise(uint32_t *texture_id, uint32_t *depth_texture_id, uint32_t *frame_buffer_id)
|
||||
void Initialise( uint32_t *depth_texture_id, uint32_t *frame_buffer_id)
|
||||
{
|
||||
m_texture_id = texture_id;
|
||||
m_frame_buffer_id = frame_buffer_id;
|
||||
m_depth_texture_id = depth_texture_id;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
class HydraCreateShadowFrameBuffer : public HydraTask
|
||||
{
|
||||
private:
|
||||
uint32_t *m_texture_id = 0;
|
||||
|
||||
uint32_t *m_depth_texture_id = 0;
|
||||
uint32_t *m_frame_buffer_id = nullptr;
|
||||
|
||||
@@ -77,9 +77,8 @@ public:
|
||||
tex_buffer_manager->BindTexture(*m_depth_texture_id, GL_TEXTURE_2D);
|
||||
|
||||
}
|
||||
void Initialise(uint32_t *texture_id, uint32_t *depth_texture_id, uint32_t *frame_buffer_id)
|
||||
void Initialise(uint32_t *depth_texture_id, uint32_t *frame_buffer_id)
|
||||
{
|
||||
m_texture_id = texture_id;
|
||||
m_frame_buffer_id = frame_buffer_id;
|
||||
m_depth_texture_id = depth_texture_id;
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ bool HydraWindowManager::HandleMessages()
|
||||
|
||||
void HydraWindowManager::Shutdown()
|
||||
{
|
||||
// GetEngine()->UIManager()->ShutdownGUI();
|
||||
|
||||
|
||||
glfwTerminate();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user