This commit is contained in:
GiJungSUk
2025-12-05 22:12:44 +09:00
parent 266b2ae6ad
commit cda875dda9
39 changed files with 302 additions and 131 deletions
@@ -450,6 +450,17 @@ float g_fWeights_32[32] =
0.022216, 0.015813, 0.010814, 0.007105, 0.004485, 0.002720, 0.001585, 0.000888
};
float g_fWeights_64[64] =
{
0.0004, 0.0014, 0.0033, 0.0053, 0.0053, 0.0033, 0.0014, 0.0004,
0.0014, 0.0045, 0.0105, 0.0171, 0.0171, 0.0105, 0.0045, 0.0014,
0.0033, 0.0105, 0.0245, 0.0400, 0.0400, 0.0245, 0.0105, 0.0033,
0.0053, 0.0171, 0.0400, 0.0654, 0.0654, 0.0400, 0.0171, 0.0053,
0.0053, 0.0171, 0.0400, 0.0654, 0.0654, 0.0400, 0.0171, 0.0053,
0.0033, 0.0105, 0.0245, 0.0400, 0.0400, 0.0245, 0.0105, 0.0033,
0.0014, 0.0045, 0.0105, 0.0171, 0.0171, 0.0105, 0.0045, 0.0014,
0.0004, 0.0014, 0.0033, 0.0053, 0.0053, 0.0033, 0.0014, 0.0004 };
float g_fWeights_128[128] =
{
0.000209902, 0.000241594, 0.000277451, 0.000317919, 0.000363477, 0.000414637, 0.000471944, 0.000535974,
@@ -637,12 +648,12 @@ PS_OUT_BLUR_X PS_MAIN_BLUR_X(PS_IN In)
float2 vTexcoord;
float4 vColor = 0.f;
for (int i = -63; i < 64; ++i)
for (int i = -31; i < 32; ++i)
{
vTexcoord.x = In.vTexcoord.x + (float) i / g_vResolution.x;
vTexcoord.y = In.vTexcoord.y;
vColor += g_fWeights_128[i + 63] * g_BlurTexture.Sample(ClampSampler, vTexcoord);
vColor += g_fWeights_64[i + 31] * g_BlurTexture.Sample(ClampSampler, vTexcoord);
}
Out.vBlurX = vColor;
@@ -824,12 +835,12 @@ PS_OUT_BLUR_X PS_MAIN_BLUR_Y(PS_IN In)
float2 vTexcoord;
float4 vColor = 0.f;
for (int i = -63; i < 64; ++i)
for (int i = -31; i < 32; ++i)
{
vTexcoord.x = In.vTexcoord.x;
vTexcoord.y = In.vTexcoord.y + (float) i / g_vResolution.y;
vColor += g_fWeights_128[i + 63] * g_BlurTexture.Sample(ClampSampler, vTexcoord);
vColor += g_fWeights_64[i + 31] * g_BlurTexture.Sample(ClampSampler, vTexcoord);
}
Out.vBlurX = vColor;
@@ -510,6 +510,11 @@ void CGameInstance::Add_Light(_uint _iCurrentLevel, CLight* _pLight)
m_pLight_Manager->Add_Light(_iCurrentLevel, _pLight);
}
void CGameInstance::Add_Light_Group(_uint _iCurrentLevel, CLight* _pLight)
{
m_pLight_Manager->Add_Light_Group(_iCurrentLevel, _pLight);
}
void CGameInstance::Delete_Light(_uint _iCurrentLevel, CLight* _pLight)
{
m_pLight_Manager->Delete_Light(_iCurrentLevel, _pLight);
+11 -1
View File
@@ -123,7 +123,15 @@ HRESULT CLight::Render(CShader* pShader, CVIBuffer* pVIBuffer) const
if (FAILED(pShader->Bind_RawValue("g_vLightDiffuse", &m_LightDesc.vDiffuse, sizeof(_float4)))) {
return E_FAIL;
}
if (FAILED(pShader->Bind_RawValue("g_vLightAmbient", &m_LightDesc.vAmbient, sizeof(_float4)))) {
/* 라이트를 서서히 감쇄시키기 위한 감쇄값 */
_float4 vAmbient = _float4(m_LightDesc.vAmbient.x * m_fAmbientRatio,
m_LightDesc.vAmbient.y * m_fAmbientRatio,
m_LightDesc.vAmbient.z * m_fAmbientRatio,
m_LightDesc.vAmbient.w * m_fAmbientRatio);
if (FAILED(pShader->Bind_RawValue("g_vLightAmbient", &vAmbient, sizeof(_float4)))) {
return E_FAIL;
}
if (FAILED(pShader->Bind_RawValue("g_vLightSpecular", &m_LightDesc.vSpecular, sizeof(_float4)))) {
@@ -188,6 +196,8 @@ void CLight::Describe_Entity()
m_LightDesc.eType = static_cast<LIGHT>(iCurrentItem);
}
GUI::DragFloat4("Diffuse", reinterpret_cast<float*>(&m_LightDesc.vDiffuse) , 0.01f , 0.f ,1.f);
GUI::DragFloat4("Ambient", reinterpret_cast<float*>(&m_LightDesc.vAmbient), 0.01f, 0.f, 1.f);
GUI::DragFloat4("Specular", reinterpret_cast<float*>(&m_LightDesc.vSpecular), 0.01f, 0.f, 1.f);
@@ -14,6 +14,7 @@ HRESULT CLight_Manager::Initialize(_uint iNumLevels)
m_iLevelNumber = iNumLevels;
m_Lights = new list<class CLight*>[m_iLevelNumber];
m_FrameLights = new list<class CLight*>[m_iLevelNumber];
return S_OK;
}
@@ -29,6 +30,16 @@ void CLight_Manager::Add_Light(_uint _iCurrentLevel, CLight* _pLight)
}
void CLight_Manager::Add_Light_Group(_uint _iCurrentLevel, CLight* _pLight)
{
if (nullptr == _pLight)
return;
m_FrameLights[_iCurrentLevel].push_back(_pLight);
SAFE_ADDREF(_pLight);
}
void CLight_Manager::Delete_Light(_uint _iCurrentLevel, CLight* _pLight)
{
for (auto iter = m_Lights[_iCurrentLevel].begin(); iter != m_Lights[_iCurrentLevel].end();)
@@ -81,6 +92,17 @@ HRESULT CLight_Manager::Render_Lights(_uint iCurrentLevel, CShader* pShader, CVI
pLight->Render(pShader, pVIBuffer);
}
for (auto& pLight : m_FrameLights[iCurrentLevel])
{
pLight->Render(pShader, pVIBuffer);
SAFE_RELEASE(pLight);
}
m_FrameLights[iCurrentLevel].clear();
return S_OK;
}
@@ -114,5 +136,17 @@ void CLight_Manager::Free()
Safe_Delete_Array(m_Lights);
for (size_t i = 0; i < m_iLevelNumber; i++)
{
for (auto& Light : m_FrameLights[i])
{
SAFE_RELEASE(Light);
}
m_FrameLights[i].clear();
}
Safe_Delete_Array(m_FrameLights);
}
@@ -141,6 +141,7 @@ class ENGINE_DLL CGameInstance final : public CBase
#pragma endregion
#pragma region LIGHT_MANAGER
void Add_Light(_uint _iCurrentLevel, class CLight* _pLight);
void Add_Light_Group(_uint _iCurrentLevel, class CLight* _pLight);
void Delete_Light(_uint _iCurrentLevel, class CLight* _pLight);
const LIGHT_DESC* Get_Light_Info(_uint _iCurrentLevel, _uint _iLightIndex);
HRESULT Render_Lights(_uint _iCurrentLevel, class CShader* pShader, class CVIBuffer* pVIBuffer);
+25 -1
View File
@@ -27,7 +27,27 @@ class ENGINE_DLL CLight final : public CComponent
public:
const LIGHT_DESC* Get_LightDesc() { return &m_LightDesc; }
void Set_Color(_float4& vDiffuse, _float4& vAmbient, _float4& vSpecular);
void Set_Color(_float4& vDiffuse, _float4& vAmbient, _float4& vSpecular);
void Reset_AmbientRatio()
{
m_fAmbientRatio = 1.f;
m_fAccLightTime = 0.f;
}
void Update_AmbientRatio(_float fTimeDelta , _float fTime) {
if (fTime <= 0)
return;
m_fAccLightTime += fTimeDelta;
if (m_fAccLightTime >= fTime)
return;
m_fAmbientRatio = 1 - (m_fAccLightTime / fTime);
}
public:
HRESULT Render(class CShader* pShader, class CVIBuffer* pVIBuffer) const;
@@ -35,6 +55,10 @@ class ENGINE_DLL CLight final : public CComponent
LIGHT_DESC m_LightDesc = {};
_bool m_bUsePowerAttenuation = { true };
_float m_fLightAttenuationPower = { 3.30f };
_float m_fAmbientRatio = { 1.f };
_float m_fAccLightTime = { 0.f };
// 1 -> Linear,
// ( 1 > fPower )-> 뾰족하게 감쇄
// ( 1 < fPower )-> 완만하게 감쇄
@@ -11,6 +11,7 @@ class CLight_Manager final : public CBase
virtual ~CLight_Manager() = default;
public:
void Add_Light(_uint _iCurrentLevel, class CLight* _pLight);
void Add_Light_Group(_uint _iCurrentLevel, class CLight* _pLight);
void Delete_Light(_uint _iCurrentLevel, class CLight* _pLight);
void Light_Clear(_uint _iCurrentLevel);
const LIGHT_DESC* Get_Light_Info(_uint _iCurrentLevel ,_uint _iLightIndex);
@@ -24,6 +25,7 @@ class CLight_Manager final : public CBase
private:
_uint m_iLevelNumber = {};
list<class CLight*>* m_Lights = { nullptr };
list<class CLight*>* m_FrameLights = { nullptr };
public:
static CLight_Manager* Create(_uint iNumLevel);
virtual void Free() override;