Shadow buffer

This commit is contained in:
Confideo-IOM
2026-07-28 19:02:45 +01:00
parent d48097c645
commit 299ad1d9c7
46 changed files with 693 additions and 603 deletions
@@ -18,6 +18,7 @@ private:
uint32_t m_min_filter;
uint32_t m_mag_filter;
uint32_t m_levels;
uint32_t m_target;
void *m_data;
HydraID *m_texture_id;
@@ -35,10 +36,10 @@ public:
m_data_type,
m_mip_levels,
m_data);
GetEngine()->TextureBufferManager()->BindTexture(*m_texture_id);
GetEngine()->TextureBufferManager()->BindTexture(*m_texture_id, GL_TEXTURE_2D);
}
void Initialise(std::string texture_name,
void Initialise(std::string texture_name,
uint32_t width,
uint32_t height,
uint32_t internal_format,
@@ -37,7 +37,7 @@ public:
m_data);
}
void Initialise(std::string texture_name,
void Initialise(std::string texture_name,
uint32_t width,
uint32_t height,
uint32_t internal_format,
@@ -51,6 +51,7 @@ public:
HydraID *texture_id)
{
m_texture_name = texture_name;
m_width = width;
m_height = height;
m_internal_format = internal_format;
@@ -1,19 +0,0 @@
#ifndef HYDRABEGINRENDERTASK
#define HYDRABEGINRENDERTASK
#include "../HydraTask.h"
#include "../../engine/HydraEngine.h"
#include "../../renderer/HydraRenderer.h"
class HydraBeginRenderTask : public HydraTask
{
private:
protected:
public:
virtual void Process() override
{
GetEngine()->Renderer()->BeginFrame();
}
};
#endif /* HYDRABEGINRENDERTASK */
@@ -0,0 +1,61 @@
#ifndef HYDRACREATESHADOWFRAMEBUFFER
#define HYDRACREATESHADOWFRAMEBUFFER
#include "../HydraTask.h"
#include "../../engine/HydraEngine.h"
#include "../../renderer/HydraRenderer.h"
#include <GLMIncludes.h>
#include "../../GlewIncludes.h"
class HydraCreateShadowFrameBuffer : public HydraTask
{
private:
uint32_t *m_texture_id = 0;
uint32_t *m_frame_buffer_id = nullptr;
protected:
public:
void Process() override
{
HydraEngine *engine = GetEngine();
HydraTextureBufferManager *tex_buffer_manager = engine->TextureBufferManager();
HydraRenderSettings render_settings = engine->RenderSettings();
*m_texture_id = tex_buffer_manager->CreateTextureArray("shadow_FB",
SHADOW_MAP_SIZE, SHADOW_MAP_SIZE,
GL_DEPTH_COMPONENT24,
GL_NEAREST,
GL_NEAREST,
6);
HydraTextureBuffer texture = tex_buffer_manager->GetTexture(*m_texture_id);
glGenFramebuffers(1, m_frame_buffer_id);
glBindFramebuffer(GL_FRAMEBUFFER, *m_frame_buffer_id);
glNamedFramebufferDrawBuffer(*m_frame_buffer_id, GL_NONE);
glNamedFramebufferReadBuffer(*m_frame_buffer_id, GL_NONE);
glBindTexture(GL_TEXTURE_2D_ARRAY, texture.gl_tex_id);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, texture.gl_tex_id, 0);
GLenum status = glCheckNamedFramebufferStatus(*m_frame_buffer_id, GL_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE)
{
std::cout << "Framebuffer error: " << status << std::endl;
}
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindTexture(GL_TEXTURE_2D_ARRAY, 0);
tex_buffer_manager->BindTexture(*m_texture_id, GL_TEXTURE_2D_ARRAY);
}
void Initialise(uint32_t *texture_id, uint32_t *frame_buffer_id)
{
m_texture_id = texture_id;
m_frame_buffer_id = frame_buffer_id;
}
};
#endif /* HYDRACREATESHADOWFRAMEBUFFER */
@@ -10,8 +10,7 @@ class HydraRenderTask : public HydraTask
protected:
public:
virtual void Process() override
{
GetEngine()->Renderer()->BeginFrame();
{
GetEngine()->Renderer()->EndFrame();
}
};