Spot started
This commit is contained in:
@@ -50,12 +50,8 @@ void HydraDirectionalShadowSourceSystem::InitialiseComponent(HydraID entity_id)
|
||||
light_comp.shadow_caster = 1;
|
||||
}
|
||||
|
||||
switch (light_comp.light_type)
|
||||
{
|
||||
case (int)HYDRA_LIGHT_TYPE::HYDRA_LIGHT_DIRECTIONAL:
|
||||
_InitialiseDirectionalLight(entity_id);
|
||||
break;
|
||||
}
|
||||
|
||||
_InitialiseShadowMap(entity_id);
|
||||
|
||||
}
|
||||
|
||||
@@ -68,12 +64,8 @@ void HydraDirectionalShadowSourceSystem::UpdateSystem(float delta_t_seconds)
|
||||
{
|
||||
|
||||
HydraLightComponent &light_comp = ecs->GetComponent<HydraLightComponent>(entity_id);
|
||||
switch (light_comp.light_type)
|
||||
{
|
||||
case (int)HYDRA_LIGHT_TYPE::HYDRA_LIGHT_DIRECTIONAL:
|
||||
_UpdateDirectionalLight(entity_id);
|
||||
break;
|
||||
}
|
||||
|
||||
_UpdateShadowMap(entity_id);
|
||||
|
||||
HydraDirectionalShadowSourceComponent shad_comp = ecs->GetComponent<HydraDirectionalShadowSourceComponent>(entity_id);
|
||||
m_shadows[light_comp.shadow_map_id] = shad_comp;
|
||||
@@ -81,19 +73,16 @@ void HydraDirectionalShadowSourceSystem::UpdateSystem(float delta_t_seconds)
|
||||
_WriteToGPU();
|
||||
}
|
||||
|
||||
void HydraDirectionalShadowSourceSystem::_UpdateDirectionalLight(HydraID entity_id)
|
||||
void HydraDirectionalShadowSourceSystem::_UpdateShadowMap(HydraID entity_id)
|
||||
{
|
||||
HydraEngine *engine = GetEngine();
|
||||
HydraECS *ecs = engine->ECS();
|
||||
HydraPositionComponent pos_comp = ecs->GetComponent<HydraPositionComponent>(entity_id);
|
||||
HydraDirectionalShadowSourceComponent &shad_comp = ecs->GetComponent<HydraDirectionalShadowSourceComponent>(entity_id);
|
||||
|
||||
float view_size = 20.0f;
|
||||
float view_size = 4.0f;
|
||||
float view_near = 0.1f;
|
||||
float view_far = 20.0f;
|
||||
|
||||
float PI = 3.1415927;
|
||||
float TWO_PI = 6.2831854;
|
||||
float view_far = 4.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)));
|
||||
@@ -102,7 +91,7 @@ void HydraDirectionalShadowSourceSystem::_UpdateDirectionalLight(HydraID entity_
|
||||
|
||||
for (uint32_t i = 0; i < 6; i++)
|
||||
{
|
||||
glm::vec3 light_pos = camera_pos - (light_dir * 2.0f);
|
||||
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);
|
||||
|
||||
@@ -121,20 +110,19 @@ void HydraDirectionalShadowSourceSystem::_UpdateDirectionalLight(HydraID entity_
|
||||
shad_comp.light_space_view[i] = view;
|
||||
|
||||
// Scale bounds exponentially for the next cascade tier
|
||||
view_size *= 3.5f;
|
||||
view_far *= 3.5f;
|
||||
view_size *= 3.0f;
|
||||
view_far *= 3.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void HydraDirectionalShadowSourceSystem::_InitialiseDirectionalLight(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;
|
||||
shad_comp.cascade_count = 6;
|
||||
|
||||
Reference in New Issue
Block a user