From f0c056bd75dc168cfee3f8d0700fc9b1dca8254b Mon Sep 17 00:00:00 2001 From: Chanbin Kim <127280695+JinhoBa@users.noreply.github.com> Date: Sun, 28 Dec 2025 14:43:24 +0900 Subject: [PATCH] [add] Light and Volumetric Setting --- .../Client/Private/Level_GamePlay.cpp | 64 ++++++++++++++++++- Jusin154_Team3D/Client/Private/Light_Main.cpp | 18 +++--- .../Client/Public/Level_GamePlay.h | 3 + Jusin154_Team3D/Client/Public/Light_Main.h | 4 +- Jusin154_Team3D/Editor/Private/MainLight.cpp | 13 ++-- Jusin154_Team3D/Engine/Private/Light.cpp | 7 ++ Jusin154_Team3D/Engine/Private/Volumetric.cpp | 6 +- Jusin154_Team3D/Engine/Public/Volumetric.h | 8 +-- 8 files changed, 96 insertions(+), 27 deletions(-) diff --git a/Jusin154_Team3D/Client/Private/Level_GamePlay.cpp b/Jusin154_Team3D/Client/Private/Level_GamePlay.cpp index c98d3dc69..262556efd 100644 --- a/Jusin154_Team3D/Client/Private/Level_GamePlay.cpp +++ b/Jusin154_Team3D/Client/Private/Level_GamePlay.cpp @@ -42,10 +42,31 @@ CLevel_GamePlay::CLevel_GamePlay(ID3D11Device* pDevice, ID3D11DeviceContext* pCo HRESULT CLevel_GamePlay::Initialize(void* pArg) { + // 낮, 밤 설정 +#ifdef gimch + m_isDay = false; +#endif // gimch +#ifdef Bin + m_isDay = true; +#endif // +#ifdef 진우 + isDay = true; +#endif // +#ifdef 기무리 + isDay = true; +#endif // +#ifdef 인혁 + isDay = true; +#endif // + if (FAILED(Ready_Lights())) { return E_FAIL; } + if (FAILED(Ready_Volumetric())) { + return E_FAIL; + } + //플레이어 , 맵 보다 먼저 생성해야함 ! if (FAILED(Reday_Layer_EffectPool())) { return E_FAIL; @@ -164,13 +185,54 @@ HRESULT CLevel_GamePlay::Render() HRESULT CLevel_GamePlay::Ready_Lights() { - if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(ENUM_CLASS(LEVEL::STATIC), NEXT_LEVEL, LAYER_LIGHT))) { + + LIGHT_DESC Desc = {}; + if (m_isDay) + { + Desc.vDiffuse = _float4(0.6529f, 0.6157f, 0.7843f, 1.0f); + Desc.vAmbient = _float4(0.6275f, 0.6275f, 0.6275f, 0.0314f); + Desc.vSpecular = _float4(0.05f, 0.05f, 0.05f, 0.05f); + } + else + { + Desc.vDiffuse = _float4(0.0471f, 0.0745f, 0.1294f, 0.2549f); + Desc.vAmbient = _float4(0.1686f, 0.1765f, 0.1373f, 0.0f); + Desc.vSpecular = _float4(0.0f, 0.0f, 0.0f, 0.0f); + } + + + if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(ENUM_CLASS(LEVEL::STATIC), NEXT_LEVEL, LAYER_LIGHT, &Desc))) { return E_FAIL; } return S_OK; } +HRESULT CLevel_GamePlay::Ready_Volumetric() +{ + // Volumetric 설정 + if(m_isDay) + { + m_pGameInstance->Setting_Volumetirc( + 1.251f, // 밀도 + 0.0253f, // 빛 강도 + 0.9f, // 산란 계수 + 1.78f // 깊이 분포 계수 + ); + } + else + { + m_pGameInstance->Setting_Volumetirc( + 0.626f, // 밀도 + 0.01f, // 빛 강도 + 0.11f, // 산란 계수 + 1.0f // 깊이 분포 계수 + ); + } + + return S_OK; +} + HRESULT CLevel_GamePlay::Ready_Background() { CTerrain::TERRAIN_DESC Terrain_Desc = {}; diff --git a/Jusin154_Team3D/Client/Private/Light_Main.cpp b/Jusin154_Team3D/Client/Private/Light_Main.cpp index 07378ca26..b98709d0d 100644 --- a/Jusin154_Team3D/Client/Private/Light_Main.cpp +++ b/Jusin154_Team3D/Client/Private/Light_Main.cpp @@ -23,10 +23,12 @@ HRESULT CLight_Main::Initialize(void* pArg) if (FAILED(__super::Initialize(pArg))){ return E_FAIL; } - if (FAILED(Ready_Components())){ + if (FAILED(Ready_Components(pArg))){ return E_FAIL; } + m_pTransformCom->Set_State(STATE::LOOK, XMVectorSet(-1.716f, 0.121f, 0.211f, 0.f)); + return S_OK; } @@ -91,20 +93,18 @@ HRESULT CLight_Main::Capture_PreShadow() return S_OK; } -HRESULT CLight_Main::Ready_Components() +HRESULT CLight_Main::Ready_Components(void* pArg) { __super::Ready_Components(nullptr); - m_pTransformCom->LookAt(XMVectorSet(1.f, -4.f, 1.f, 1.f)); + LIGHT_DESC* pLightDescArg = static_cast(pArg); + LIGHT_DESC LightDesc{}; LightDesc.eType = LIGHT::DIRECTIONAL; - //LightDesc.vDiffuse = _float4(0.8f, 0.8f, 0.8f, 0.f); - //LightDesc.vAmbient = _float4(0.6f, 0.6f, 0.6f, 0.f); - //LightDesc.vSpecular = _float4(0.f, 0.f, 0.f, 0.f); - LightDesc.vDiffuse = _float4(0.3f, 0.3f, 0.1f, 0.f); - LightDesc.vAmbient = _float4(0.12f, 0.12f, 0.24f, 0.f); - LightDesc.vSpecular = _float4(0.f, 0.f, 0.f, 0.f); + LightDesc.vDiffuse = pLightDescArg->vDiffuse; + LightDesc.vAmbient = pLightDescArg->vAmbient; + LightDesc.vSpecular = pLightDescArg->vSpecular; LightDesc.pDirection = m_pTransformCom->Get_StatePtr(STATE::LOOK); LightDesc.iLevel = NEXT_LEVEL; diff --git a/Jusin154_Team3D/Client/Public/Level_GamePlay.h b/Jusin154_Team3D/Client/Public/Level_GamePlay.h index 42385a209..c5bd6bcd8 100644 --- a/Jusin154_Team3D/Client/Public/Level_GamePlay.h +++ b/Jusin154_Team3D/Client/Public/Level_GamePlay.h @@ -19,10 +19,13 @@ class CLevel_GamePlay final : public CLevel private: class CInfoInstance* m_pInfoInstance = { nullptr }; class CBroomRaceManager* m_pBroomRaceManager = { nullptr }; + + _bool m_isDay = { true }; private: virtual HRESULT Initialize() override; HRESULT Initialize(void* pArg); HRESULT Ready_Lights(); + HRESULT Ready_Volumetric(); HRESULT Ready_Background(); HRESULT Ready_Layer_Hogsmeade(); HRESULT Ready_Layer_Hogwart(); diff --git a/Jusin154_Team3D/Client/Public/Light_Main.h b/Jusin154_Team3D/Client/Public/Light_Main.h index a56ac9081..e030c53cd 100644 --- a/Jusin154_Team3D/Client/Public/Light_Main.h +++ b/Jusin154_Team3D/Client/Public/Light_Main.h @@ -20,13 +20,13 @@ class CLight_Main final : public CGameObject virtual HRESULT Capture_PreShadow(); private: - CLight* m_pLightCom = { nullptr }; + CLight* m_pLightCom = { nullptr }; private: virtual HRESULT Initialize_Prototype() override; virtual HRESULT Initialize(void* pArg) override; - HRESULT Ready_Components(); + HRESULT Ready_Components(void* pArg); HRESULT Bind_ShaderResources(); _matrix Get_OffCenterProjMatrix(_fmatrix ViewMatrix, vector<_float3>& WorldPositions); diff --git a/Jusin154_Team3D/Editor/Private/MainLight.cpp b/Jusin154_Team3D/Editor/Private/MainLight.cpp index ffe8a2598..4c9169cf2 100644 --- a/Jusin154_Team3D/Editor/Private/MainLight.cpp +++ b/Jusin154_Team3D/Editor/Private/MainLight.cpp @@ -29,7 +29,7 @@ HRESULT CMainLight::Initialize(void* pArg) if (FAILED(Ready_Components())) return E_FAIL; - m_pTransformCom->Set_State(STATE::LOOK, XMVectorSet(1.f, -1.f, 1.f, 0.f)); + m_pTransformCom->Set_State(STATE::LOOK, XMVectorSet(-1.716f, 0.121f, 0.211f, 0.f)); m_pGameTime = CGameTime::Create(); @@ -134,17 +134,14 @@ HRESULT CMainLight::Ready_Components() LIGHT_DESC LightDesc{}; LightDesc.eType = LIGHT::DIRECTIONAL; - LightDesc.vDiffuse = _float4(0.3f, 0.3f, 0.1f, 0.f); - LightDesc.vAmbient = _float4(0.3f, 0.3f, 0.5f, 0.f); + LightDesc.vDiffuse = _float4(0.3294f, 0.4824f, 0.4824f, 0.0314f); + LightDesc.vAmbient = _float4(0.1608f, 0.1608f, 0.1608f, 0.0f); LightDesc.vSpecular = _float4(0.05f, 0.05f, 0.05f, 0.f); + m_pTransformCom->Rotation(XMConvertToRadians(-4.f), XMConvertToRadians(271.f), 0.f); LightDesc.pDirection = m_pTransformCom->Get_StatePtr(STATE::LOOK); LightDesc.iLevel = NEXT_LEVEL; -#ifdef gimch - LightDesc.vDiffuse = _float4(0.745f, 0.797f, 0.8f, 0.f); - LightDesc.vAmbient = _float4(0.417f, 0.533f, 0.544f, 0.f); -#endif // gimch - + /* Com_Light*/ if (FAILED(Add_Component(g_iStaticLevel, &m_pLightCom, &LightDesc))) diff --git a/Jusin154_Team3D/Engine/Private/Light.cpp b/Jusin154_Team3D/Engine/Private/Light.cpp index adc31e056..a7991c7b8 100644 --- a/Jusin154_Team3D/Engine/Private/Light.cpp +++ b/Jusin154_Team3D/Engine/Private/Light.cpp @@ -220,7 +220,14 @@ void CLight::Describe_Entity() GUI::Spacing(); + if (m_LightDesc.eType == LIGHT::DIRECTIONAL) + { + GUI::Text("Direction:"); + GUI::InputFloat3("##Direction", (_float*)m_LightDesc.pDirection); + } m_pOwner->Get_Component()->Describe_Entity(); + + GUI::TreePop(); } diff --git a/Jusin154_Team3D/Engine/Private/Volumetric.cpp b/Jusin154_Team3D/Engine/Private/Volumetric.cpp index 353da513a..5ed28b60f 100644 --- a/Jusin154_Team3D/Engine/Private/Volumetric.cpp +++ b/Jusin154_Team3D/Engine/Private/Volumetric.cpp @@ -193,9 +193,9 @@ void CVolumetric::Describe_Entity() _bool open = true; GUI::Begin("SYSTEM", &open, IMGUI_GLOBAL_BEGIN_FLAG); if (GUI::CollapsingHeader("VOLUMETRIC")) { - GUI::SliderFloat("Density", &m_fDensity,0.01f, 5.f); - GUI::SliderFloat("LightIntensity", &m_fLightIntensity, 0.01f, 5.f); - GUI::SliderFloat("AsymmetryParameter", &m_fAsymmetryParameter, 0.01f, 5.f); + GUI::SliderFloat("Density", &m_fDensity,0.001f, 5.f); + GUI::SliderFloat("LightIntensity", &m_fLightIntensity, 0.01f, 0.5f, "%.4f"); + GUI::SliderFloat("AsymmetryParameter", &m_fAsymmetryParameter, -0.9f, 0.9f, "%.4f"); GUI::SliderFloat("DepthPackExponent", &m_fDepthPackExponent, 0.01f, 5.f); } GUI::End(); diff --git a/Jusin154_Team3D/Engine/Public/Volumetric.h b/Jusin154_Team3D/Engine/Public/Volumetric.h index 7bd847a2b..80303f71c 100644 --- a/Jusin154_Team3D/Engine/Public/Volumetric.h +++ b/Jusin154_Team3D/Engine/Public/Volumetric.h @@ -71,10 +71,10 @@ class CVolumetric final : public CBase ID3D11ComputeShader* m_pCSVolumeAccumulate = { nullptr }; ID3DBlob* m_pCSBlobAccumulate = { nullptr }; - _float m_fDensity = { 0.5f }; - _float m_fLightIntensity = { 1.f }; - _float m_fAsymmetryParameter = { 0.2f }; - _float m_fDepthPackExponent = { 2.f }; + _float m_fDensity = { 0.953f }; // 밀도 + _float m_fLightIntensity = { 0.01f }; // 광원 강도 + _float m_fAsymmetryParameter = { 0.5344f }; // 이방성 계수 값이 클 수록 들어오는 방향으로 나가는 빛의 양이 많아짐 + _float m_fDepthPackExponent = { 1.f }; // 깊이 비선형 분포 지수 #ifdef _DEBUG class CRenderEventDebugger m_AnnotationHelper = {};