Light tweeks

This commit is contained in:
Confideo-IOM
2026-08-17 14:12:11 +01:00
parent 98ff54c106
commit 139fb149b2
55 changed files with 593 additions and 265 deletions
+4 -2
View File
@@ -44,8 +44,10 @@ const uint32_t MAX_LIGHTS = 500;
const uint32_t MAX_DIRECTIONAL_SHADOWS = 10;
const uint32_t MAX_SPOT_SHADOWS = 10;
const uint32_t MAX_POINT_SHADOWS = 10;
const uint32_t SHADOW_MAP_SIZE = 1024;
//const uint32_t SHADOW_MAP_SIZE = 1024;
const uint32_t DIRECTIONAL_SHADOW_MAP_SIZE = 4096;
const uint32_t SPOT_SHADOW_MAP_SIZE = 1024;
const uint32_t POINT_SHADOW_MAP_SIZE = 1024;
enum class HYDRA_RENDERABLE_TYPE
{
@@ -327,12 +327,26 @@ float SampleCascadeShadow(vec4 frag_clip_space, sampler2DArray sampler_shadow_ma
float shadow_map_depth = texture(sampler_shadow_map, vec3(frag_light_space.xy, shadow_trans_idx)).r;
// calculate bias (based on depth map resolution and slope)
float bias = max(0.0005 * (1.0 - dot(normal, light_dir)), 0.00005);
float mapped_distance = (shadow_trans_idx*2);
float bias = 0.0f;//max(0.0001 * (1.0 - dot(normal, light_dir)), 0.00001);
// check whether current frag pos is in shadow
// float shadow = currentDepth - bias > closestDepth ? 1.0 : 0.0;
// PCF
//bias = 0;
if(shadow_trans_idx < 3)
{
bias = 0.00001;
}
else if(shadow_trans_idx == 3)
{
bias = 0.0001;// + (0.000001 * mapped_distance);
}
else
{
bias = 0.0005;
}
float shadow = 0.0;
vec2 texel_size = 1.0 / textureSize(sampler_shadow_map, 0).xy;
if((frag_light_space.x >= 0.0)&&(frag_light_space.y >= 0.0)
@@ -343,7 +357,7 @@ float SampleCascadeShadow(vec4 frag_clip_space, sampler2DArray sampler_shadow_ma
for(int y = -1; y <= 1; ++y)
{
shadow_map_depth = texture(sampler_shadow_map, vec3(frag_light_space.xy + vec2(x, y) * texel_size, shadow_trans_idx)).r;
shadow += frag_light_space.z - bias > shadow_map_depth ? 1.0 : 0.0;
shadow += (frag_light_space.z - bias) > shadow_map_depth ? 1.0 : 0.0;
}
}
shadow /= 9.0;
@@ -414,14 +428,39 @@ vec3 CalculateDirectionalShadow(vec4 world_pos, uint shadow_idx, vec3 normal, ve
if(ignore_shadow == 1)
{
vec4 translated_pixel = directional_shadows[shadow_idx].light_space_proj[shadow_trans_idx] *
directional_shadows[shadow_idx].light_space_view[shadow_trans_idx] *
world_pos;
uvec2 shadow_handle = textures[directional_shadows[shadow_idx].shadow_texture_id];
shadow = 1.0 - SampleCascadeShadow(translated_pixel, sampler2DArray(shadow_handle), shadow_trans_idx, normal, light_dir);
}
return vec3(shadow);
if(shadow_trans_idx == 0)
{
return vec3(1,0,0);
}
if(shadow_trans_idx == 1)
{
return vec3(0,1,0);
}
if(shadow_trans_idx == 2)
{
return vec3(0,0,1);
}
if(shadow_trans_idx == 3)
{
return vec3(1,1,0);
}
if(shadow_trans_idx == 4)
{
return vec3(1,0,1);
}
if(shadow_trans_idx == 5)
{
return vec3(0,1,1);
}
}
float CalculateSpotShadow(vec4 world_pos, uint shadow_idx, vec3 normal, vec3 light_dir, vec3 viewer_pos)
{
@@ -460,7 +499,7 @@ float SampleCubemapShadow(vec3 frag_to_light, float far_plane, float view_distan
for(int i = 0; i < samples; ++i)
{
//float closest_depth = texture(sampler_shadow_map, frag_to_light).r;
float closest_depth = texture(sampler_shadow_map, frag_to_light + sample_offset_directions[i] * disk_radius).r;
closest_depth *= far_plane; // undo mapping [0;1]
if(frag_depth - bias > closest_depth)
@@ -468,15 +507,7 @@ float SampleCubemapShadow(vec3 frag_to_light, float far_plane, float view_distan
}
shadow /= float(samples);
return shadow;
// float frag_depth = length(frag_to_light);
// closest_depth = closest_depth * far_plane;
// float bias = 0.05f;
// float shadow = (frag_depth - bias) > closest_depth ? 1.0 : 0.0;
// return shadow;
}
float CalculatePointShadow(vec3 world_pos, uint shadow_idx, float view_distance, vec3 light_position)
@@ -515,15 +546,17 @@ void main()
mat4 model = model_matrix[lights[i].entity_id];
mat3 rot_mat = GetRotationOnlyMatrix(model);
vec3 light_direction = normalize(rot_mat * vec3(0,0,1));
vec3 light_pos = model[3].xyz;
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);
Lo *= lights[i].diffuse.xyz;
if(lights[i].shadow_caster == 1)
{
vec3 shadow = CalculateDirectionalShadow(vec4(world_pos, 1.0), lights[i].shadow_map_id, normal, light_direction, ubo_per_frame.viewer_pos);
Lo = Lo * shadow;
}
}
else if(lights[i].light_type == HYDRA_LIGHT_POINT)
@@ -575,7 +608,7 @@ void main()
lights[i].quadratic,
world_pos,
ubo_per_frame.viewer_pos,
shadow);
shadow) * lights[i].diffuse.xyz;
}
@@ -21,8 +21,8 @@ void HydraDirectionalLightActor::InitialiseComponents()
HydraLightComponent light_comp = {};
HydraECS *ecs = GetEngine()->ECS();
light_comp.diffuse = glm::vec4(1,1,1,1);
light_comp.intensity = 10000.0f;
light_comp.diffuse = glm::vec4(1.0,0.8,0.6,1);
light_comp.intensity = 100000.0f;
light_comp.light_type = static_cast<uint32_t>(HYDRA_LIGHT_TYPE::HYDRA_LIGHT_DIRECTIONAL);
light_comp.entity_id = GetID();
light_comp.shadow_caster =1;
+1 -1
View File
@@ -165,7 +165,7 @@ void HydraPlaneActor::_CreateMaterial()
{
HydraEngine *engine = GetEngine();
std::string filename = std::string(texture_base) + std::string("/DesignArea/DesignArea_Albedo.png");
std::string filename = std::string(texture_base) + std::string("/DesignArea/DesignArea_Albedo_white.png");
HydraID tex_id = engine->TextureBufferManager()->LoadTexture(filename);
@@ -21,7 +21,7 @@ void HydraSpotLightActor::InitialiseComponents()
HydraLightComponent light_comp = {};
HydraECS *ecs = GetEngine()->ECS();
light_comp.diffuse = glm::vec4(1,1,1,1);
light_comp.diffuse = glm::vec4(1.0f,1.0f,1.0f,1);
light_comp.intensity = 10000.0f;
light_comp.light_type = static_cast<uint32_t>(HYDRA_LIGHT_TYPE::HYDRA_LIGHT_SPOT);
light_comp.cutoff = glm::cos(glm::radians(10.0f));
@@ -0,0 +1,191 @@
#include "HydraTestLightActor.h"
#include "../engine/HydraEngine.h"
#include "../actor/HydraActorManager.h"
#include "../task/HydraTask.h"
#include "../ecs/HydraECS.h"
#include "../ecs/components/HydraPositionComponent.h"
#include "../ecs/components/HydraMeshComponent.h"
#include "../ecs/components/HydraRenderableComponent.h"
#include "../ecs/components/HydraMaterialComponent.h"
#include "../buffer/HydraMaterialBufferManager.h"
#include "../buffer/HydraTextureBufferManager.h"
#include "../buffer/HydraMaterialBuffer.h"
#include "../mesh/HydraMeshManager.h"
#include "../mesh/HydraMesh.h"
void HydraTestLightActor::InitialiseComponents()
{
// HydraECS* ecs = GetEngine()->ECS();
// HydraID entity_id = ecs->CreateEntity();
_CreatePosition();
// _CreatePhysics();
_CreateMaterial();
_CreateMesh();
_CreateRenderableComponent();
}
void HydraTestLightActor::DeferredInitialiseComponents()
{
}
void HydraTestLightActor::_CreatePosition()
{
HydraECS *ecs = GetEngine()->ECS();
HydraPositionComponent position_component;
ecs->AddComponent<HydraPositionComponent>(GetID(), position_component);
}
void HydraTestLightActor::_CreateMesh()
{
HydraMeshManager *mesh_manager = GetEngine()->MeshManager();
HydraID mesh_id = mesh_manager->CreateMesh();
HydraMesh *mesh = mesh_manager->GetMesh(mesh_id);
HydraMaterialComponent mat_comp = GetEngine()->ECS()->GetComponent<HydraMaterialComponent>(GetID());
mesh->vertexes.resize(24);
mesh->indexes.resize(36);
float scale_x = 1.0f;
float scale_y = 1.0f;
float scale_z = 1.0f;
float min_x = -0.5f * scale_x;
float min_y = -0.5f * scale_y;
float min_z = -0.5f * scale_z;
float max_x = 0.5f * scale_x;
float max_y = 0.5f * scale_y;
float max_z = 0.5f * scale_z;
float min_u = 1;
float min_v = 1;
float max_u = 0;
float max_v = 0;
// 1---2 5---6
//| / | | / |
// 0---3 4---7
HydraID actor_id = GetID();
mesh->vertexes[0] = {min_x, min_y, min_z, min_u, min_v, actor_id, mat_comp.material_id, 0};
mesh->vertexes[1] = {min_x, max_y, min_z, min_u, max_v, actor_id, mat_comp.material_id, 0};
mesh->vertexes[2] = {max_x, max_y, min_z, max_u, max_v, actor_id, mat_comp.material_id, 0};
mesh->vertexes[3] = {max_x, min_y, min_z, max_u, min_v, actor_id, mat_comp.material_id, 0};
// Face 0
mesh->indexes[0] = 0;
mesh->indexes[1] = 1;
mesh->indexes[2] = 2;
mesh->indexes[3] = 0;
mesh->indexes[4] = 2;
mesh->indexes[5] = 3;
mesh->vertexes[4] = {max_x, min_y, min_z, min_u, min_v, actor_id, mat_comp.material_id, 0};
mesh->vertexes[5] = {max_x, max_y, min_z, min_u, max_v, actor_id, mat_comp.material_id, 0};
mesh->vertexes[6] = {max_x, max_y, max_z, max_u, max_v, actor_id, mat_comp.material_id, 0};
mesh->vertexes[7] = {max_x, min_y, max_z, max_u, min_v, actor_id, mat_comp.material_id, 0};
mesh->indexes[6] = 4;
mesh->indexes[7] = 5;
mesh->indexes[8] = 6;
mesh->indexes[9] = 4;
mesh->indexes[10] = 6;
mesh->indexes[11] = 7;
// Back Face
mesh->vertexes[8] = {max_x, min_y, max_z, min_u, min_v, actor_id, mat_comp.material_id, 0};
mesh->vertexes[9] = {max_x, max_y, max_z, min_u, max_v, actor_id, mat_comp.material_id, 0};
mesh->vertexes[10] = {min_x, max_y, max_z, max_u, max_v, actor_id, mat_comp.material_id, 0};
mesh->vertexes[11] = {min_x, min_y, max_z, max_u, min_v, actor_id, mat_comp.material_id, 0};
mesh->indexes[12] = 8;
mesh->indexes[13] = 9;
mesh->indexes[14] = 10;
mesh->indexes[15] = 8;
mesh->indexes[16] = 10;
mesh->indexes[17] = 11;
mesh->vertexes[12] = {min_x, min_y, max_z, min_u, min_v, actor_id, mat_comp.material_id, 0};
mesh->vertexes[13] = {min_x, max_y, max_z, min_u, max_v, actor_id, mat_comp.material_id, 0};
mesh->vertexes[14] = {min_x, max_y, min_z, max_u, max_v, actor_id, mat_comp.material_id, 0};
mesh->vertexes[15] = {min_x, min_y, min_z, max_u, min_v, actor_id, mat_comp.material_id, 0};
mesh->indexes[18] = 12;
mesh->indexes[19] = 13;
mesh->indexes[20] = 14;
mesh->indexes[21] = 12;
mesh->indexes[22] = 14;
mesh->indexes[23] = 15;
mesh->vertexes[16] = {min_x, max_y, min_z, min_u, min_v, actor_id, mat_comp.material_id, 0};
mesh->vertexes[17] = {min_x, max_y, max_z, min_u, max_v, actor_id, mat_comp.material_id, 0};
mesh->vertexes[18] = {max_x, max_y, max_z, max_u, max_v, actor_id, mat_comp.material_id, 0};
mesh->vertexes[19] = {max_x, max_y, min_z, max_u, min_v, actor_id, mat_comp.material_id, 0};
mesh->indexes[24] = 16;
mesh->indexes[25] = 17;
mesh->indexes[26] = 18;
mesh->indexes[27] = 16;
mesh->indexes[28] = 18;
mesh->indexes[29] = 19;
mesh->vertexes[20] = {min_x, min_y, min_z, min_u, min_v, actor_id, mat_comp.material_id, 0};
mesh->vertexes[21] = {max_x, min_y, min_z, min_u, max_v, actor_id, mat_comp.material_id, 0};
mesh->vertexes[22] = {max_x, min_y, max_z, max_u, max_v, actor_id, mat_comp.material_id, 0};
mesh->vertexes[23] = {min_x, min_y, max_z, max_u, min_v, actor_id, mat_comp.material_id, 0};
mesh->indexes[30] = 20;
mesh->indexes[31] = 21;
mesh->indexes[32] = 22;
mesh->indexes[33] = 20;
mesh->indexes[34] = 22;
mesh->indexes[35] = 23;
mesh_manager->CalculateNormals(mesh->mesh_id);
HydraECS *ecs = GetEngine()->ECS();
HydraMeshComponent mesh_comp;
mesh_comp.mesh_id = mesh_id;
mesh_comp.mesh_state = HYDRA_STATE::Waiting;
ecs->AddComponent<HydraMeshComponent>(GetID(), mesh_comp);
}
void HydraTestLightActor::_CreateMaterial()
{
HydraEngine *engine = GetEngine();
std::string filename = std::string(texture_base) + std::string("/DesignArea/DesignArea_Albedo.png");
HydraID tex_id = engine->TextureBufferManager()->LoadTexture(filename);
HydraMaterialBuffer material = {};
material.diffuse_texture_id = tex_id;
material.diffuse_colour = glm::vec4(1, 1, 1, 1);
material.metalic_rough = glm::vec4(0, 0.5, 0.3, 1);
HydraID mat_id = engine->MaterialBufferManager()->CreateMaterial(material);
HydraMaterialComponent mat_comp = {};
mat_comp.material_id = mat_id;
engine->ECS()->AddComponent<HydraMaterialComponent>(GetID(), mat_comp);
}
void HydraTestLightActor::_CreateRenderableComponent()
{
HydraRenderableComponent render_comp;
HydraECS *ecs = GetEngine()->ECS();
render_comp.renderable_types.set((uint32_t)HYDRA_RENDERABLE_TYPE::HYDRA_COLOUR, true);
ecs->AddComponent<HydraRenderableComponent>(GetID(), render_comp);
}
@@ -0,0 +1,28 @@
#ifndef HYDRALIGHTTESTACTOR
#define HYDRALIGHTTESTACTOR
#include "HydraActor.h"
class CLASS_DEFINE HydraTestLightActor : public HydraActor
{
private:
double m_scale = 1.0;
double m_widthscale = 1.0f;
HydraID m_material_component = INVALID_HYDRA_ID;
HydraID m_position_component = INVALID_HYDRA_ID;
HydraID m_mesh_component = INVALID_HYDRA_ID;
protected:
void _CreatePosition();
void _CreateMesh();
void _CreateMaterial();
void _CreateRenderableComponent();
public:
virtual void InitialiseComponents();
virtual void DeferredInitialiseComponents();
virtual void Destroy(){}
};
#endif /* HYDRALIGHTTESTACTOR */
@@ -150,7 +150,7 @@ HydraID HydraTextureBufferManager::CreateCubemapTexture(std::string texture_name
for(uint32_t i = 0; i < 6; i++)
{
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, internal_format, SHADOW_MAP_SIZE, SHADOW_MAP_SIZE, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, internal_format, POINT_SHADOW_MAP_SIZE, POINT_SHADOW_MAP_SIZE, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);
}
@@ -18,6 +18,8 @@
#include "../../task/renderer/HydraCreateCascadeShadowFrameBuffer.hpp"
#include "../../task/renderer/HydraCreateShadowFrameBuffer.hpp"
#include "../../actor/HydraActorManager.h"
#include "../../actor/HydraTestCubeActor.h"
void HydraDirectionalShadowSourceSystem::Initialise()
{
@@ -41,6 +43,9 @@ void HydraDirectionalShadowSourceSystem::InitialiseComponent(HydraID entity_id)
shadow_comp.shadow_id = shadow_id;
_InitialiseShadowMap(entity_id);
// m_shadow_actor_id = GetEngine()->ActorManager()->CreateActor<HydraTestCubeActor>();
// GetEngine()->ActorManager()->InitialiseActor(m_shadow_actor_id);
// GetEngine()->ActorManager()->SetPosition(m_shadow_actor_id, glm::dvec3(0, 0, 0));
}
void HydraDirectionalShadowSourceSystem::UpdateSystem(float delta_t_seconds)
@@ -58,39 +63,43 @@ void HydraDirectionalShadowSourceSystem::_UpdateShadowMap(HydraID entity_id)
HydraPositionComponent pos_comp = ecs->GetComponent<HydraPositionComponent>(entity_id);
HydraDirectionalShadowSourceComponent &shad_comp = ecs->GetComponent<HydraDirectionalShadowSourceComponent>(entity_id);
float view_size = 4.0f;
float view_near = 0.1f;
float view_far = 4.0f;
float view_size = 4.0f;
float shadow_distance = 4.0f;
float max_shadow_range = 100000.0f;
glm::mat4 light_rot = glm::eulerAngleXYZ(pos_comp.orientation.x, pos_comp.orientation.y, pos_comp.orientation.z);
glm::vec3 light_dir = glm::normalize(glm::vec3(light_rot * glm::vec4(0.0f, 0.0f, -1.0f, 0.0f)));
glm::vec3 camera_pos = GetEngine()->Camera()->GetPosition();
glm::vec3 light_pos = (camera_pos - (light_dir * 1000.0f));
glm::vec3 target_pos = light_pos + light_dir;
glm::vec3 up_vector = glm::vec3(0.0f, 1.0f, 0.0f);
if (glm::abs(glm::dot(light_dir, up_vector)) > 0.99f)
{
up_vector = glm::vec3(1.0f, 0.0f, 0.0f); // Prevent gimbal lock
}
glm::mat4 view = glm::lookAt(light_pos, target_pos, up_vector);
for (uint32_t i = 0; i < 6; i++)
{
glm::vec3 light_pos = camera_pos;//- (light_dir * 2.0f);
glm::vec3 target_pos = light_pos + light_dir;
glm::vec3 up_vector = glm::vec3(0.0f, 1.0f, 0.0f);
float view_near = 0.1f;//max_shadow_range - shadow_distance;
float view_far = 2000.0f;// max_shadow_range + shadow_distance;
if (glm::abs(glm::dot(light_dir, up_vector)) > 0.99f)
{
up_vector = glm::vec3(1.0f, 0.0f, 0.0f); // Prevent gimbal lock
}
glm::mat4 view = glm::lookAt(light_pos, target_pos, up_vector);
glm::mat4 proj = glm::ortho(-view_size, view_size, -view_size, view_size, view_near, view_far);
// Save data to component
shad_comp.far_plane[i] = view_far;
shad_comp.near_plane[i] = view_near;
shad_comp.far_plane[i] = shadow_distance;
shad_comp.near_plane[i] = 0;
shad_comp.light_space_proj[i] = proj;
shad_comp.light_space_view[i] = view;
// Scale bounds exponentially for the next cascade tier
view_size *= 3.0f;
view_far *= 3.0f;
shadow_distance *= 3.0f;
}
// GetEngine()->ActorManager()->SetPosition(m_shadow_actor_id, light_pos);
// GetEngine()->ActorManager()->SetOrientation(m_shadow_actor_id, pos_comp.orientation.x, pos_comp.orientation.y, pos_comp.orientation.z);
GetEngine()->ShadowBufferManager()->UpdateDirectionalShadow(shad_comp.shadow_id, shad_comp);
}
@@ -18,6 +18,7 @@ class HydraDirectionalShadowSourceSystem : public HydraSystem
private:
void _UpdateShadowMap(HydraID entity_id);
void _InitialiseShadowMap(HydraID entity_id);
HydraID m_shadow_actor_id = INVALID_HYDRA_ID;
std::mutex m_mutex;
};
@@ -40,5 +40,5 @@ void HydraMeshSystem::InitialiseComponent(HydraID entity_id)
HydraUpdateVertexBufferTask *vertex_update_task = static_cast<HydraUpdateVertexBufferTask *>(task_scheduler->GetTask(update_buffer_task_id));
vertex_update_task->Intialise(mesh_comp.vertex_buffer_id, &mesh->vertexes[0], &mesh->indexes[0]);
task_scheduler->WaitForTask(update_buffer_task_id);
mesh_comp.mesh_state = HYDRA_STATE::Ready;
}
@@ -63,8 +63,8 @@ void HydraPointShadowSourceSystem::_UpdateShadowMap(HydraID entity_id)
glm::vec3 camera_pos = GetEngine()->Camera()->GetPosition();
float aspect = (float)SHADOW_MAP_SIZE/(float)SHADOW_MAP_SIZE;
float width = SHADOW_MAP_SIZE;
float aspect = (float)POINT_SHADOW_MAP_SIZE/(float)POINT_SHADOW_MAP_SIZE;
float width = POINT_SHADOW_MAP_SIZE;
float fov = glm::radians(90.0f);
glm::mat4 shadow_proj = glm::perspectiveFovLH<float>(fov, width, width, view_near, view_far);
@@ -115,12 +115,14 @@ void HydraRenderStage::Render(std::set<HydraID>& entities, uint32_t framebuffer_
if((render_comp.renderable_types & signature) == signature)
{
HydraMeshComponent mesh_comp = ecs->GetComponent<HydraMeshComponent>(entity_id);
HydraVertexBuffer& vertex_buffer = vert_buffer_mananger->GetVertexBuffer(mesh_comp.vertex_buffer_id);
if(mesh_comp.mesh_state == HYDRA_STATE::Ready)
{
HydraVertexBuffer& vertex_buffer = vert_buffer_mananger->GetVertexBuffer(mesh_comp.vertex_buffer_id);
glBindVertexArray(vertex_buffer.vao);
glDrawElements(GL_TRIANGLES, vertex_buffer.triangle_count, GL_UNSIGNED_INT, (void*)0 );
glBindVertexArray(0);
glBindVertexArray(vertex_buffer.vao);
glDrawElements(GL_TRIANGLES, vertex_buffer.triangle_count, GL_UNSIGNED_INT, (void*)0 );
glBindVertexArray(0);
}
}
}
glBindFramebuffer(GL_FRAMEBUFFER, 0);
@@ -34,7 +34,7 @@ void HydraShadowPipeline::Shutdown()
void HydraShadowPipeline::Render()
{
glViewport(0, 0, SHADOW_MAP_SIZE, SHADOW_MAP_SIZE);
glEnable(GL_DEPTH_TEST); // Depth testing must be active
glDepthMask(GL_TRUE); // Depth buffer must be writable
@@ -51,7 +51,7 @@ void HydraShadowPipeline::_RenderPointShadowMaps()
HydraECS *ecs = GetEngine()->ECS();
std::shared_ptr<HydraRenderSystem> render_system = ecs->GetSystem<HydraRenderSystem>();
std::shared_ptr<HydraPointShadowSourceSystem> shadow_system = ecs->GetSystem<HydraPointShadowSourceSystem>();
glViewport(0, 0, POINT_SHADOW_MAP_SIZE, POINT_SHADOW_MAP_SIZE);
for (HydraID entity_id : shadow_system->Entities)
{
HydraPointShadowSourceComponent shad_comp = GetEngine()->ECS()->GetComponent<HydraPointShadowSourceComponent>(entity_id);
@@ -74,7 +74,7 @@ void HydraShadowPipeline::_RenderDirectionalShadowMaps()
HydraECS *ecs = GetEngine()->ECS();
std::shared_ptr<HydraRenderSystem> render_system = ecs->GetSystem<HydraRenderSystem>();
std::shared_ptr<HydraDirectionalShadowSourceSystem> shadow_system = ecs->GetSystem<HydraDirectionalShadowSourceSystem>();
glViewport(0, 0, DIRECTIONAL_SHADOW_MAP_SIZE, DIRECTIONAL_SHADOW_MAP_SIZE);
for (HydraID entity_id : shadow_system->Entities)
{
HydraDirectionalShadowSourceComponent shad_comp = GetEngine()->ECS()->GetComponent<HydraDirectionalShadowSourceComponent>(entity_id);
@@ -95,7 +95,7 @@ void HydraShadowPipeline::_RenderSpotShadowMaps()
HydraECS *ecs = GetEngine()->ECS();
std::shared_ptr<HydraRenderSystem> render_system = ecs->GetSystem<HydraRenderSystem>();
std::shared_ptr<HydraSpotShadowSourceSystem> shadow_system = ecs->GetSystem<HydraSpotShadowSourceSystem>();
glViewport(0, 0, SPOT_SHADOW_MAP_SIZE, SPOT_SHADOW_MAP_SIZE);
for (HydraID entity_id : shadow_system->Entities)
{
HydraSpotShadowSourceComponent shad_comp = GetEngine()->ECS()->GetComponent<HydraSpotShadowSourceComponent>(entity_id);
@@ -25,7 +25,7 @@ public:
HydraRenderSettings render_settings = engine->RenderSettings();
*m_texture_id = tex_buffer_manager->CreateTextureArray("shadow_FB",
SHADOW_MAP_SIZE, SHADOW_MAP_SIZE,
DIRECTIONAL_SHADOW_MAP_SIZE, DIRECTIONAL_SHADOW_MAP_SIZE,
GL_RGBA8,
GL_NEAREST,
GL_NEAREST,
@@ -34,7 +34,7 @@ public:
HydraTextureBuffer texture = tex_buffer_manager->GetTexture(*m_texture_id);
*m_depth_texture_id = tex_buffer_manager->CreateTextureArray("shadow_depth_buffer",
SHADOW_MAP_SIZE, SHADOW_MAP_SIZE,
DIRECTIONAL_SHADOW_MAP_SIZE, DIRECTIONAL_SHADOW_MAP_SIZE,
GL_DEPTH_COMPONENT32F,
GL_NEAREST,
GL_NEAREST,
@@ -27,7 +27,7 @@ public:
HydraTextureBuffer texture = tex_buffer_manager->GetTexture(*m_texture_id);
*m_depth_texture_id = tex_buffer_manager->CreateCubemapTexture("shadow_depth_buffer",
SHADOW_MAP_SIZE, SHADOW_MAP_SIZE,
POINT_SHADOW_MAP_SIZE, POINT_SHADOW_MAP_SIZE,
GL_DEPTH_COMPONENT32F,
GL_NEAREST,
GL_NEAREST);
@@ -35,7 +35,7 @@ public:
// HydraTextureBuffer texture = tex_buffer_manager->GetTexture(*m_texture_id);
*m_depth_texture_id = tex_buffer_manager->CreateTexture("shadow_depth_buffer",
SHADOW_MAP_SIZE, SHADOW_MAP_SIZE,
SPOT_SHADOW_MAP_SIZE, SPOT_SHADOW_MAP_SIZE,
GL_DEPTH_COMPONENT32F,
GL_NEAREST,
GL_NEAREST,