ADD: CSM with normal shadow

This commit is contained in:
2025-10-22 10:23:43 +09:00
parent 4c41c93d44
commit 7edcfe1a20
2 changed files with 6 additions and 6 deletions

View File

@@ -10,10 +10,10 @@ inline constexpr bool kUseValidationLayers = true;
// Shadow mapping configuration
inline constexpr int kShadowCascadeCount = 4;
// Maximum shadow distance for CSM in view-space units
inline constexpr float kShadowCSMFar = 200.0f;
inline constexpr float kShadowCSMFar = 400.0f;
// Shadow map resolution used for stabilization (texel snapping). Must match actual image size.
inline constexpr float kShadowMapResolution = 2048.0f;
// Extra XY expansion for cascade footprint (safety against FOV/aspect changes)
inline constexpr float kShadowCascadeRadiusScale = 1.25f;
inline constexpr float kShadowCascadeRadiusScale = 2.5f;
// Additive XY margin in world units (light-space) beyond scaled radius
inline constexpr float kShadowCascadeRadiusMargin = 20.0f;
inline constexpr float kShadowCascadeRadiusMargin = 40.0f;

View File

@@ -124,10 +124,10 @@ void SceneManager::update_scene()
// 0) Legacy near/simple shadow (cascade 0 그대로)
{
const float orthoRange = 20.0f;
const float orthoRange = 10.0f;
const float nearDist = 0.1f;
const float farDist = 200.0f;
const glm::vec3 lightPos = camPos - L * 80.0f;
const glm::vec3 lightPos = camPos - L * 180.0f;
const glm::mat4 viewLight = glm::lookAtRH(lightPos, camPos, up);
// ⚠️ API에 맞게 ZO/NO를 고르세요 (Vulkan/D3D: ZO, OpenGL 기본: NO)
@@ -179,7 +179,7 @@ void SceneManager::update_scene()
glm::vec3 center(0.0f);
for (auto &p: ws) center += p;
center *= (1.0f / 8.0f);
const float lightPullback = 30.0f; // 충분히 뒤로 빼서 안정화
const float lightPullback = 50.0f; // 충분히 뒤로 빼서 안정화
glm::mat4 V = glm::lookAtRH(center - L * lightPullback, center, up);
// 라이트 공간으로 투영 후 AABB