diff --git a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl index 70ab08713..db13bce76 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl +++ b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl @@ -46,12 +46,17 @@ Texture2D g_BlurWeightTexture; Texture2D g_BlurWeightXTexture; Texture2D g_SurfaceTexture; +Texture2D g_OriginalTexture; vector g_vLightDiffuse; vector g_vLightAmbient; vector g_vLightSpecular; +float g_fFogDensity; +float g_fFogPow; +vector g_vFogColor; + struct VS_IN { float3 vPosition : POSITION; @@ -776,6 +781,31 @@ PS_OUT_BLUR_X PS_MAIN_BLUR_Y(PS_IN In) return Out; } +PS_OUT_FLT4_SINGLE PS_MAIN_FOG(PS_IN In) +{ + PS_OUT_FLT4_SINGLE Out; + + vector vColor = g_OriginalTexture.Sample(DefaultSampler, In.vTexcoord); + vector vDepthDesc = g_DepthTexture.Sample(DefaultSampler, In.vTexcoord); + + vector vFinalColor; + float fViewZ = vDepthDesc.y * g_fFar; + + float fRatio; + + fRatio = clamp(pow(exp(-(g_fFogDensity * fViewZ)), g_fFogPow), 0.f, 1.f); + + vFinalColor = lerp(g_vFogColor, vColor, max(fRatio, 0.2f)); + vFinalColor.a = 1.f; + + if (1.f == vDepthDesc.y) + vFinalColor = float4(g_vFogColor); + + Out.vSingleTarget = vFinalColor; + + return Out; +} + technique11 DefaultTechnique { @@ -916,4 +946,14 @@ technique11 DefaultTechnique GeometryShader = NULL; PixelShader = compile ps_5_0 PS_MAIN_POSTCOMBINED(); } + + pass FogPass // 14 + { + SetRasterizerState(RS_Default); + SetDepthStencilState(DSS_None, 0); + SetBlendState(BS_AlphaBlend, float4(0.f, 0.f, 0.f, 0.f), 0xffffffff); + VertexShader = compile vs_5_0 VS_MAIN(); + GeometryShader = NULL; + PixelShader = compile ps_5_0 PS_MAIN_FOG(); + } } diff --git a/Jusin154_Team3D/Editor/Default/Editor.vcxproj b/Jusin154_Team3D/Editor/Default/Editor.vcxproj index d1cd51f77..2066d1f43 100644 --- a/Jusin154_Team3D/Editor/Default/Editor.vcxproj +++ b/Jusin154_Team3D/Editor/Default/Editor.vcxproj @@ -208,6 +208,7 @@ + @@ -217,6 +218,7 @@ + @@ -358,6 +360,7 @@ + @@ -368,6 +371,7 @@ + diff --git a/Jusin154_Team3D/Editor/Default/Editor.vcxproj.filters b/Jusin154_Team3D/Editor/Default/Editor.vcxproj.filters index 0f724765c..c6cd1d72c 100644 --- a/Jusin154_Team3D/Editor/Default/Editor.vcxproj.filters +++ b/Jusin154_Team3D/Editor/Default/Editor.vcxproj.filters @@ -351,7 +351,7 @@ {8bb21e5b-933f-4930-8d49-1093e0c3ea77} - + {a54567fa-e528-4c98-a605-289d7d300029} @@ -424,6 +424,12 @@ {9d80f32a-aaca-490e-babf-3a7fe4cc0600} + + {cf446efa-94e5-4fd2-83e1-dba2149eddc8} + + + {99652c97-4011-4d1f-84fb-7e6aa9f6ec1a} + @@ -782,7 +788,7 @@ 02.GameObjects\Layer_Effect\Effect\08.Protego - + 50.UI\GamePlay_Canvas\Mission_Panel\MissionBanner_Border @@ -828,6 +834,12 @@ 50.UI\Spell_Canvas\Spell_Panel\Spell_Vidio_Border + + 03.GameTime + + + 02.GameObjects\Env\03.MapElement\Light + @@ -1185,7 +1197,7 @@ 02.GameObjects\Layer_Effect\Effect\08.Protego - + 50.UI\GamePlay_Canvas\Mission_Panel\MissionBanner_Border @@ -1231,6 +1243,12 @@ 50.UI\Spell_Canvas\Spell_Panel\Spell_Vidio_Border + + 03.GameTime + + + 02.GameObjects\Env\03.MapElement\Light + diff --git a/Jusin154_Team3D/Editor/Private/GameTime.cpp b/Jusin154_Team3D/Editor/Private/GameTime.cpp new file mode 100644 index 000000000..fb874c02b --- /dev/null +++ b/Jusin154_Team3D/Editor/Private/GameTime.cpp @@ -0,0 +1,47 @@ +#include "pch.h" +#include "GameTime.h" +#include "GameInstance.h" + +CGameTime::CGameTime() + : m_pGameInstance(CGameInstance::GetInstance()) +{ + SAFE_ADDREF(m_pGameInstance); +} + +HRESULT CGameTime::Initialize() +{ + return S_OK; +} + +void CGameTime::Update_GameTime(_float fTiemDelta) +{ + m_fGameTime += fTiemDelta; + m_fDayTime += fTiemDelta; + + if (SECONDS_PER_GAME_DAY <= m_fDayTime) + { + m_fDayTime = 0.f; + } + + +} + +CGameTime* CGameTime::Create() +{ + CGameTime* pInstance = new CGameTime(); + + if (FAILED(pInstance->Initialize())) + { + MSG_BOX("Failed to Created : CGameTime"); + SAFE_RELEASE(pInstance); + } + + return pInstance; +} + +void CGameTime::Free() +{ + __super::Free(); + + SAFE_RELEASE(m_pGameInstance); +} diff --git a/Jusin154_Team3D/Editor/Private/Loader.cpp b/Jusin154_Team3D/Editor/Private/Loader.cpp index 6787276d7..2eb0d395a 100644 --- a/Jusin154_Team3D/Editor/Private/Loader.cpp +++ b/Jusin154_Team3D/Editor/Private/Loader.cpp @@ -93,6 +93,7 @@ #include "MapObject_Manager.h" #include "MapElement_Interactable.h" #include "MapElement_Static.h" +#include "MapElement_Light.h" #include "Land.h" #include "Collider.h" #include "VIBuffer_Model_Instance.h" @@ -2060,320 +2061,325 @@ HRESULT CLoader::Loading_For_MapViewer() //if (FAILED(MapFolderLoad("C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_GEN_J\\Collision", // ".bin", false, ModelPrototypeTags, ModelPrototypePath))) // return E_FAIL; + + /* Light */ + if (FAILED(MapFolderLoad("C:\\MeshTable\\Game\\Environment\\Hogsmeade\\Common\\Meshes\\LightPosts", + ".fbx", true, ModelPrototypeTags, ModelPrototypePath))) + return E_FAIL; #pragma endregion #ifdef gimch -vector> jobFutures; +//vector> jobFutures; +// +//_uint iLoadCount = 46; +//vector*> Contents(iLoadCount); -_uint iLoadCount = 46; -vector*> Contents(iLoadCount); - -{ - { /* Terrain */ - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\Common\\Collision\\Terrain", - ".bin", false, - &Contents[jobFutures.size()] - )); - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\Common\\Meshes\\Terrain", - ".bin", false, - &Contents[jobFutures.size()] - )); - } - { /* TScrolls */ - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_TScrolls\\Meshes", - ".bin", false, - &Contents[jobFutures.size()] - )); - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_TScrolls\\Collisions", - ".bin", false, - &Contents[jobFutures.size()] - )); - } - { /* 3BroomStick*/ - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_ThreeBroomsticks\\Meshes", - ".bin", false, - &Contents[jobFutures.size()] - )); - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_ThreeBroomsticks\\Collision", - ".bin", false, - &Contents[jobFutures.size()] - )); - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_ThreeBroomsticks\\Meshes\\3Broom_Kit", - ".bin", false, - &Contents[jobFutures.size()] - )); - } - { /* Ollivanders*/ - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_Ollivanders\\Meshes", - ".bin", false, - &Contents[jobFutures.size()] - )); - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_Ollivanders\\Collision", - ".bin", false, - &Contents[jobFutures.size()] - )); - } - { /* Gatehouse*/ - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_Gatehouse\\Meshes", - ".bin", false, - &Contents[jobFutures.size()] - )); - } - { /* BLDG_QuidditchShop */ - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_QuidditchShop\\Meshes", - ".bin", false, - &Contents[jobFutures.size()] - )); - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_QuidditchShop\\Collision", - ".bin", false, - &Contents[jobFutures.size()] - )); - } - { /* BLDG_HogsheadInn */ - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_HogsheadInn\\Meshes", - ".bin", false, - &Contents[jobFutures.size()] - )); - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_HogsheadInn\\Collision", - ".bin", false, - &Contents[jobFutures.size()] - )); - } - { /* BLDG_Honeydukes */ - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_Honeydukes\\Meshes", - ".bin", false, - &Contents[jobFutures.size()] - )); - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_Honeydukes\\Collision", - ".bin", false, - &Contents[jobFutures.size()] - )); - } - { /* BLDG_OwlPost */ - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_OwlPost\\Meshes", - ".bin", false, - &Contents[jobFutures.size()] - )); - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_OwlPost\\Collision", - ".bin", false, - &Contents[jobFutures.size()] - )); - } - { /* BLDG_TeaShop */ - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_TeaShop\\Meshes", - ".bin", false, - &Contents[jobFutures.size()] - )); - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_TeaShop\\Collision", - ".bin", false, - &Contents[jobFutures.size()] - )); - } - { /* BLDG_Zonkos */ - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_Zonkos\\Meshes", - ".bin", false, - &Contents[jobFutures.size()] - )); - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_Zonkos\\Collision", - ".bin", false, - &Contents[jobFutures.size()] - )); - } - { /* BLDG_DB_GR */ - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_DB_GR\\Meshes", - ".bin", false, - &Contents[jobFutures.size()] - )); - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_DB_GR\\Collision", - ".bin", false, - &Contents[jobFutures.size()] - )); - } - { /* BLDG_Potions */ - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_Potions\\Meshes", - ".bin", false, - &Contents[jobFutures.size()] - )); - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_Potions\\Collisions", - ".bin", false, - &Contents[jobFutures.size()] - )); - } - { /* BLDG_Salon */ - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_Salon\\Meshes", - ".bin", false, - &Contents[jobFutures.size()] - )); - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_Salon\\Collision", - ".bin", false, - &Contents[jobFutures.size()] - )); - } - { /* Hengist_Tree */ - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\Common\\Meshes\\Vegetation\\Hengist_Tree", - ".bin", false, - &Contents[jobFutures.size()] - )); - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\Common\\Collision\\Vegetation", - ".bin", false, - &Contents[jobFutures.size()] - )); - } - { /* GEN A*/ - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_GEN_A\\Meshes", - ".bin", false, - &Contents[jobFutures.size()] - )); - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_GEN_A\\Collision", - ".bin", false, - &Contents[jobFutures.size()] - )); - } - { /* GEN B*/ - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_GEN_B\\Meshes", - ".bin", false, - &Contents[jobFutures.size()] - )); - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_GEN_B\\Collision", - ".bin", false, - &Contents[jobFutures.size()] - )); - } - { /* GEN C*/ - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_GEN_C\\Meshes", - ".bin", false, - &Contents[jobFutures.size()] - )); - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_GEN_C\\Collision", - ".bin", false, - &Contents[jobFutures.size()] - )); - } - { /* GEN E*/ - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_GEN_E\\Meshes", - ".bin", false, - &Contents[jobFutures.size()] - )); - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_GEN_E\\Collision", - ".bin", false, - &Contents[jobFutures.size()] - )); - } - { /* GEN F*/ - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_GEN_F\\Meshes", - ".bin", false, - &Contents[jobFutures.size()] - )); - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_GEN_F\\Collision", - ".bin", false, - &Contents[jobFutures.size()] - )); - } - { /* GEN G*/ - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_GEN_G\\Meshes", - ".bin", false, - &Contents[jobFutures.size()] - )); - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_GEN_G\\Collision", - ".bin", false, - &Contents[jobFutures.size()] - )); - } - { /* GEN H*/ - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_GEN_H\\Meshes", - ".bin", false, - &Contents[jobFutures.size()] - )); - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_GEN_H\\Collision", - ".bin", false, - &Contents[jobFutures.size()] - )); - } - { /* GEN J*/ - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_GEN_J\\Meshes", - ".bin", false, - &Contents[jobFutures.size()] - )); - jobFutures.emplace_back(Deferred_FolderLoad( - "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_GEN_J\\Collision", - ".bin", false, - &Contents[jobFutures.size()] - )); - } -} - - for (auto& jobFuture : jobFutures) - { - jobFuture.get(); - } - - for (_uint i = 0; i < Contents.size(); ++i) { - for (_uint j = 0; j < (Contents[i])->size(); ++j) { - FOLDER_LOAD* pContents = (*Contents[i])[j]; - if (true == pContents->bLoadTags) { - ModelPrototypeTags.push_back(pContents->pModelTag); - ModelPrototypePath.push_back(pContents->pathModel); - } - - if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, pContents->pModelTag, pContents->pLoadedModel))) { - return E_FAIL; - } - - for (_uint k = 0; k < pContents->pRigidBodyTags.size(); ++k) { - if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, pContents->pRigidBodyTags[k], pContents->LoadedRigidBody[k]))) { - return E_FAIL; - } - } - - } - } +//{ +// { /* Terrain */ +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\Common\\Collision\\Terrain", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\Common\\Meshes\\Terrain", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// } +// { /* TScrolls */ +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_TScrolls\\Meshes", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_TScrolls\\Collisions", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// } +// { /* 3BroomStick*/ +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_ThreeBroomsticks\\Meshes", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_ThreeBroomsticks\\Collision", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_ThreeBroomsticks\\Meshes\\3Broom_Kit", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// } +// { /* Ollivanders*/ +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_Ollivanders\\Meshes", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_Ollivanders\\Collision", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// } +// { /* Gatehouse*/ +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_Gatehouse\\Meshes", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// } +// { /* BLDG_QuidditchShop */ +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_QuidditchShop\\Meshes", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_QuidditchShop\\Collision", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// } +// { /* BLDG_HogsheadInn */ +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_HogsheadInn\\Meshes", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_HogsheadInn\\Collision", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// } +// { /* BLDG_Honeydukes */ +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_Honeydukes\\Meshes", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_Honeydukes\\Collision", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// } +// { /* BLDG_OwlPost */ +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_OwlPost\\Meshes", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_OwlPost\\Collision", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// } +// { /* BLDG_TeaShop */ +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_TeaShop\\Meshes", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_TeaShop\\Collision", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// } +// { /* BLDG_Zonkos */ +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_Zonkos\\Meshes", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_Zonkos\\Collision", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// } +// { /* BLDG_DB_GR */ +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_DB_GR\\Meshes", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_DB_GR\\Collision", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// } +// { /* BLDG_Potions */ +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_Potions\\Meshes", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_Potions\\Collisions", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// } +// { /* BLDG_Salon */ +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_Salon\\Meshes", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_Salon\\Collision", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// } +// { /* Hengist_Tree */ +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\Common\\Meshes\\Vegetation\\Hengist_Tree", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\Common\\Collision\\Vegetation", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// } +// { /* GEN A*/ +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_GEN_A\\Meshes", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_GEN_A\\Collision", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// } +// { /* GEN B*/ +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_GEN_B\\Meshes", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_GEN_B\\Collision", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// } +// { /* GEN C*/ +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_GEN_C\\Meshes", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_GEN_C\\Collision", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// } +// { /* GEN E*/ +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_GEN_E\\Meshes", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_GEN_E\\Collision", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// } +// { /* GEN F*/ +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_GEN_F\\Meshes", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_GEN_F\\Collision", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// } +// { /* GEN G*/ +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_GEN_G\\Meshes", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_GEN_G\\Collision", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// } +// { /* GEN H*/ +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_GEN_H\\Meshes", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_GEN_H\\Collision", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// } +// { /* GEN J*/ +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_GEN_J\\Meshes", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// jobFutures.emplace_back(Deferred_FolderLoad( +// "C:\\MeshTable\\Game\\Environment\\Hogsmeade\\BLDG_GEN_J\\Collision", +// ".bin", false, +// &Contents[jobFutures.size()] +// )); +// } +//} +// +// for (auto& jobFuture : jobFutures) +// { +// jobFuture.get(); +// } +// +// for (_uint i = 0; i < Contents.size(); ++i) { +// for (_uint j = 0; j < (Contents[i])->size(); ++j) { +// FOLDER_LOAD* pContents = (*Contents[i])[j]; +// if (true == pContents->bLoadTags) { +// ModelPrototypeTags.push_back(pContents->pModelTag); +// ModelPrototypePath.push_back(pContents->pathModel); +// } +// +// if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, pContents->pModelTag, pContents->pLoadedModel))) { +// return E_FAIL; +// } +// +// for (_uint k = 0; k < pContents->pRigidBodyTags.size(); ++k) { +// if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, pContents->pRigidBodyTags[k], pContents->LoadedRigidBody[k]))) { +// return E_FAIL; +// } +// } +// +// } +// } m_strMessage = TEXT("쉐이더를(을) 로딩 중 입니다."); @@ -2465,6 +2471,10 @@ vector*> Contents(iLoadCount); if (FAILED(m_pGameInstance->Add_Prototype(g_iStaticLevel, CMapElement_Static::Create(m_pDevice, m_pContext)))) return E_FAIL; + /* For.Prototype_GameObject_MapElement_Light */ + if (FAILED(m_pGameInstance->Add_Prototype(g_iStaticLevel, CMapElement_Light::Create(m_pDevice, m_pContext)))) + return E_FAIL; + /* For.Prototype_GameObject_Terrain */ if (FAILED(m_pGameInstance->Add_Prototype(g_iStaticLevel, CTerrain::Create(m_pDevice, m_pContext)))) return E_FAIL; @@ -2484,12 +2494,12 @@ vector*> Contents(iLoadCount); m_isFinished = true; - for (_uint i = 0; i < Contents.size(); ++i) { + /*for (_uint i = 0; i < Contents.size(); ++i) { for (_uint j = 0; j < (Contents[i])->size(); ++j) { Safe_Delete((*Contents[i])[j]); } Safe_Delete(Contents[i]); - } + }*/ #endif return S_OK; } diff --git a/Jusin154_Team3D/Editor/Private/MainLight.cpp b/Jusin154_Team3D/Editor/Private/MainLight.cpp index a950ae69a..6e1ef1be7 100644 --- a/Jusin154_Team3D/Editor/Private/MainLight.cpp +++ b/Jusin154_Team3D/Editor/Private/MainLight.cpp @@ -3,6 +3,7 @@ #include "GameInstance.h" #include "Camera_Debug.h" +#include "GameTime.h" CMainLight::CMainLight(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) : CGameObject(pDevice, pContext) @@ -30,17 +31,84 @@ HRESULT CMainLight::Initialize(void* pArg) m_pTransformCom->Set_State(STATE::LOOK, XMVectorSet(1.f, -1.f, 1.f, 0.f)); + m_pGameTime = CGameTime::Create(); + + // --- m_Diffuse_Colors 초기화 (주요 색상) --- + m_Diffuse_Colors[ENUM_CLASS(DAY_PHASE::DAWN)] = { 0.8f, 0.6f, 0.4f, 1.0f }; // 따뜻한 새벽 햇살 + m_Diffuse_Colors[ENUM_CLASS(DAY_PHASE::DAY)] = { 1.0f, 1.0f, 1.0f, 1.0f }; // 순백색 주광 + m_Diffuse_Colors[ENUM_CLASS(DAY_PHASE::DUSK)] = { 0.9f, 0.4f, 0.2f, 1.0f }; // 붉은 석양 + m_Diffuse_Colors[ENUM_CLASS(DAY_PHASE::NIGHT)] = { 0.2f, 0.2f, 0.4f, 1.0f }; // 푸른 달빛 + + // --- m_Ambient_Colors 초기화 (그림자 및 전체적인 밝기) --- + m_Ambient_Colors[ENUM_CLASS(DAY_PHASE::DAWN)] = { 0.3f, 0.3f, 0.4f, 1.0f }; // 그림자도 약간 푸른빛 + m_Ambient_Colors[ENUM_CLASS(DAY_PHASE::DAY)] = { 0.4f, 0.4f, 0.4f, 1.0f }; // 밝은 환경광 + m_Ambient_Colors[ENUM_CLASS(DAY_PHASE::DUSK)] = { 0.2f, 0.2f, 0.3f, 1.0f }; // 환경광 감소 + m_Ambient_Colors[ENUM_CLASS(DAY_PHASE::NIGHT)] = { 0.1f, 0.1f, 0.2f, 1.0f }; // 최소한의 어두운 환경광 + + // --- m_Specular_Colors 초기화 (반짝이는 하이라이트) --- + m_Specular_Colors[ENUM_CLASS(DAY_PHASE::DAWN)] = { 0.7f, 0.7f, 0.7f, 1.0f }; + m_Specular_Colors[ENUM_CLASS(DAY_PHASE::DAY)] = { 1.0f, 1.0f, 1.0f, 1.0f }; // 가장 선명한 반사 + m_Specular_Colors[ENUM_CLASS(DAY_PHASE::DUSK)] = { 0.8f, 0.6f, 0.4f, 1.0f }; // 석양 색이 입혀진 반사 + m_Specular_Colors[ENUM_CLASS(DAY_PHASE::NIGHT)] = { 0.3f, 0.3f, 0.5f, 1.0f }; + + if (nullptr == m_pGameTime) + return E_FAIL; + return S_OK; } void CMainLight::Priority_Update(_float fTimeDelta) { - + m_pGameTime->Update_GameTime(fTimeDelta); } void CMainLight::Update(_float fTimeDelta) { + _float fProgress = m_pGameTime->Get_DayTime() / SECONDS_PER_GAME_DAY; + _float fStartProgress = {}; + + if (0.25f > fProgress) + { + m_eCurPhase = DAY_PHASE::DAWN; + m_eNextPhase = DAY_PHASE::DAY; + fStartProgress = 0.f; + } + else if (0.25f <= fProgress && 0.5f > fProgress) + { + m_eCurPhase = DAY_PHASE::DAY; + m_eNextPhase = DAY_PHASE::DUSK; + fStartProgress = 0.25f; + } + else if (0.5f <= fProgress && 0.75f > fProgress) + { + m_eCurPhase = DAY_PHASE::DUSK; + m_eNextPhase = DAY_PHASE::NIGHT; + fStartProgress = 0.5f; + } + else if (0.75f <= fProgress) + { + m_eCurPhase = DAY_PHASE::NIGHT; + m_eNextPhase = DAY_PHASE::DAWN; + fStartProgress = 0.75f; + } + _float fRatio = (fProgress - fStartProgress) / 0.25f; + + XMStoreFloat4(&m_vCurDiffuse, XMVectorLerp( + XMLoadFloat4(&m_Diffuse_Colors[ENUM_CLASS(m_eCurPhase)]), + XMLoadFloat4(&m_Diffuse_Colors[ENUM_CLASS(m_eNextPhase)]), fRatio)); + + XMStoreFloat4(&m_vAmbient, XMVectorLerp( + XMLoadFloat4(&m_Ambient_Colors[ENUM_CLASS(m_eCurPhase)]), + XMLoadFloat4(&m_Ambient_Colors[ENUM_CLASS(m_eNextPhase)]), fRatio)); + + XMStoreFloat4(&m_vSpecular, XMVectorLerp( + XMLoadFloat4(&m_Specular_Colors[ENUM_CLASS(m_eCurPhase)]), + XMLoadFloat4(&m_Specular_Colors[ENUM_CLASS(m_eNextPhase)]), fRatio)); + + m_pLightCom->Set_Color(m_vCurDiffuse, m_vAmbient, m_vSpecular); + + //m_pLightCom->Describe_Entity(); } void CMainLight::Late_Update(_float fTimeDelta) @@ -116,7 +184,8 @@ void CMainLight::Free() { __super::Free(); - Safe_Release(m_pLightCom); + SAFE_RELEASE(m_pLightCom); + SAFE_RELEASE(m_pGameTime); } void CMainLight::Describe_Entity() diff --git a/Jusin154_Team3D/Editor/Private/MapElement_Light.cpp b/Jusin154_Team3D/Editor/Private/MapElement_Light.cpp new file mode 100644 index 000000000..504db6bd8 --- /dev/null +++ b/Jusin154_Team3D/Editor/Private/MapElement_Light.cpp @@ -0,0 +1,263 @@ +#include "pch.h" +#include "MapElement_Light.h" + +#include "GameInstance.h" + +#include "Terrain.h" +#include "Layer.h" +#include "VIBuffer_Terrain.h" + +CMapElement_Light::CMapElement_Light(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) + : CMapElement{ pDevice, pContext } +{ +} + +CMapElement_Light::CMapElement_Light(const CMapElement_Light& rhs) + : CMapElement(rhs) +{ +} + +HRESULT CMapElement_Light::Initialize_Prototype() +{ + return S_OK; +} + +HRESULT CMapElement_Light::Initialize(void* pArg) +{ + MAPOBJECT_LOD_DESC* pDesc = static_cast(pArg); + + m_iMaxLodLevel = pDesc->iMaxLodLevel; + + for (_uint i = 0; i < m_iMaxLodLevel + 1; i++) + { + m_ModelPrototypeTags.push_back(pDesc->ModelPrototypeTags[i]); + //m_ModelPathIndices.push_back((*pDesc->pModelPathIndices)[i]); + } + + if (FAILED(__super::Initialize(pArg))) + return E_FAIL; + + if (FAILED(Ready_Components(pArg))) + return E_FAIL; + +#ifdef _DEBUG + m_bSelected = false; + m_vPosition = pDesc->vPosition; + m_vScale = pDesc->vScale; + m_vRotation = pDesc->vRotation; + + m_pTransformCom->Set_State(STATE::POSITION, XMVectorSetW(XMLoadFloat3(&m_vPosition), 1.f)); + m_pTransformCom->Set_Scale(m_vScale); + m_pTransformCom->Rotation(XMConvertToRadians(m_vRotation.x), XMConvertToRadians(m_vRotation.y), XMConvertToRadians(m_vRotation.z)); +#endif // _DEBUG + + return S_OK; +} + +void CMapElement_Light::Priority_Update(_float fTimeDelta) +{ +#ifdef _DEBUG + m_bSelected = false; +#endif +} + +void CMapElement_Light::Update(_float fTimeDelta) +{ + m_pLightCom->Describe_Entity(); +} + +void CMapElement_Light::Late_Update(_float fTimeDelta) +{ +#ifdef _DEBUG + if (m_bSelected) + { + m_pTransformCom->Set_State(STATE::POSITION, XMVectorSetW(XMLoadFloat3(&m_vPosition), 1.f)); + m_pTransformCom->Set_Scale(m_vScale); + m_pTransformCom->Rotation(XMConvertToRadians(m_vRotation.x), XMConvertToRadians(m_vRotation.y), XMConvertToRadians(m_vRotation.z)); + } +#endif + + if (m_pGameInstance->isIn_WorldFrustum(Get_WorldPostion(), m_pTransformCom->Get_Radius())) { + m_pGameInstance->Add_RenderGroup(RENDER::NONBLEND, this); + } +} + +HRESULT CMapElement_Light::Render() +{ + if (FAILED(Bind_ShaderResources())) + return E_FAIL; + + _uint iNumMeshes = m_pModelComs[m_iLodIndex]->Get_NumMeshes(); + + for (_uint i = 0; i < iNumMeshes; i++) + { + if (FAILED(m_pModelComs[0]->Bind_Material(i, m_pShaderCom))) { + return E_FAIL; + } + if (m_bSelected) + { + if (FAILED(m_pShaderCom->Begin(ENUM_CLASS(SHADER_PASS_MESH::MAPTOOL)))) { + return E_FAIL; + } + } + else + { + if (FAILED(m_pShaderCom->Begin(ENUM_CLASS(SHADER_PASS_MESH::DEFAULT)))) { + return E_FAIL; + } + } + + if (FAILED(m_pModelComs[m_iLodIndex]->Render(i))) { + return E_FAIL; + } + } + + return S_OK; +} + +HRESULT CMapElement_Light::Ready_Components(void* pArg) +{ + if (FAILED(__super::Ready_Components(pArg))) { + return E_FAIL; + } + + for (_uint i = 0; i < m_iMaxLodLevel + 1; ++i) + { + CModel* pModel = { nullptr }; + + /* Com_Model */ + if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, m_ModelPrototypeTags[i], + reinterpret_cast(&pModel)))) + return E_FAIL; + + m_pModelComs.push_back(pModel); + } + + /* Com_Shader */ + if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, FX_MESH, + reinterpret_cast(&m_pShaderCom)))) + return E_FAIL; + + LIGHT_DESC LightDesc{}; + + LightDesc.eType = LIGHT::POINT; + LightDesc.vDiffuse = _float4(0.8f, 0.8f, 0.8f, 0.f); + LightDesc.vAmbient = _float4(0.8f, 0.8f, 0.8f, 0.f); + LightDesc.vSpecular = _float4(0.f, 0.f, 0.f, 0.f); + LightDesc.fRange = 5.f; + LightDesc.iLevel = NEXT_LEVEL; + + /* Com_Light*/ + if (FAILED(Add_Component(g_iStaticLevel, &m_pLightCom, &LightDesc))) + { + return E_FAIL; + } + + + + return S_OK; +} + +HRESULT CMapElement_Light::Bind_ShaderResources() +{ + if (FAILED(m_pShaderCom->Bind_Matrix("g_WorldMatrix", m_pTransformCom->Get_WorldMatrixPtr()))) { + return E_FAIL; + } + if (FAILED(m_pShaderCom->Bind_Matrix("g_ViewMatrix", m_pGameInstance->Get_Transform_Float4x4(D3DTS::VIEW)))) { + return E_FAIL; + } + if (FAILED(m_pShaderCom->Bind_Matrix("g_ProjMatrix", m_pGameInstance->Get_Transform_Float4x4(D3DTS::PROJ)))) { + return E_FAIL; + } + + if (FAILED(m_pShaderCom->Bind_RawValue("g_fFar", m_pGameInstance->Get_CurrentCameraFar(), sizeof(_float)))) { + return E_FAIL; + } + + return S_OK; +} + +CMapElement_Light* CMapElement_Light::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) +{ + CMapElement_Light* pInstance = new CMapElement_Light(pDevice, pContext); + + if (FAILED(pInstance->Initialize_Prototype())) + { + MSG_BOX("Failed to Created : CMapElement_Light"); + SAFE_RELEASE(pInstance); + } + + return pInstance; +} + +CGameObject* CMapElement_Light::Clone(void* pArg, CGameObject* pOwner) +{ + CMapElement_Light* pInstance = new CMapElement_Light(*this); + pInstance->m_pOwner = pOwner; + if (FAILED(pInstance->Initialize(pArg))) + { + MSG_BOX("Failed to Cloned : CMapElement_Light"); + SAFE_RELEASE(pInstance); + } + + return pInstance; +} + +void CMapElement_Light::Free() +{ + __super::Free(); + + SAFE_RELEASE(m_pLightCom); + + SAFE_RELEASE(m_pShaderCom); + for (auto& pModel : m_pModelComs) + SAFE_RELEASE(pModel); +} + +void CMapElement_Light::Describe_Entity() +{ + if (m_bDead) + return; + if (nullptr == m_pGameInstance) + return; + + GUI::Text(CMyTools::ToString(m_ModelPrototypeTags[m_iLodIndex]).c_str()); + GUI::InputInt("Lod Level", (_int*)(&m_iLodIndex)); + m_iLodIndex = max(0, m_iLodIndex); + m_iLodIndex = min(m_iMaxLodLevel, m_iLodIndex); + GUI::Text("----- Transfrom ----"); + GUI::InputFloat("X##Position", &m_vPosition.x, 0.1f, 1.f); + GUI::InputFloat("Y##Position", &m_vPosition.y, 0.1f, 1.f); + GUI::InputFloat("Z##Position", &m_vPosition.z, 0.1f, 1.f); + + if (m_pGameInstance->Mouse_Down(DIM_LBUTTON) && m_pGameInstance->Key_Pressing(DIK_LSHIFT)) + { + CTerrain* pTerrain = m_pGameInstance->Get_Layer(ENUM_CLASS(LEVEL::MAP), TEXT("Layer_Terrain"))->Get_Object(); + if (nullptr != pTerrain) + { + pTerrain->Get_Component()->Picking(pTerrain->Get_Component()->Get_XMWorldMatrix(), &m_vPosition); + } + + } + + GUI::Text("----- Rotation ----"); + GUI::InputFloat("X##Rotation", &m_vRotation.x, 10.f, 45.f); + GUI::InputFloat("Y##Rotation", &m_vRotation.y, 10.f, 45.f); + GUI::InputFloat("Z##Rotation", &m_vRotation.z, 10.f, 45.f); + + GUI::Text("----- Scale ----"); + GUI::InputFloat("X##Scale", &m_vScale.x, 0.1f, 1.f); + GUI::InputFloat("Y##Scale", &m_vScale.y, 0.1f, 1.f); + GUI::InputFloat("Z##Scale", &m_vScale.z, 0.1f, 1.f); + + m_vScale.x = max(0.01f, m_vScale.x); + m_vScale.y = max(0.01f, m_vScale.y); + m_vScale.z = max(0.01f, m_vScale.z); + + if (GUI::Button("Delete")) + m_bDead = true; + + + + m_bSelected = true; +} diff --git a/Jusin154_Team3D/Editor/Private/MapObject_Manager.cpp b/Jusin154_Team3D/Editor/Private/MapObject_Manager.cpp index 9b53b0049..476220b99 100644 --- a/Jusin154_Team3D/Editor/Private/MapObject_Manager.cpp +++ b/Jusin154_Team3D/Editor/Private/MapObject_Manager.cpp @@ -10,6 +10,7 @@ #include "BuildingContainer.h" #include "MapElement_Static.h" #include "MapElement_Interactable.h" +#include "MapElement_Light.h" CMapObject_Manager::CMapObject_Manager(ID3D11Device * pDevice, ID3D11DeviceContext * pContext) @@ -28,7 +29,7 @@ CMapObject_Manager::CMapObject_Manager(const CMapObject_Manager& rhs) HRESULT CMapObject_Manager::Initialize_Prototype(vector<_wstring>& ModelPrototypeTags, vector& ModelPrototypePaths) { - /*for (_uint i = 0 ; i < ModelPrototypeTags.size(); ++i) + for (_uint i = 0 ; i < ModelPrototypeTags.size(); ++i) { if (_wstring::npos != ModelPrototypeTags[i].find(L"Lod")) { @@ -41,7 +42,7 @@ HRESULT CMapObject_Manager::Initialize_Prototype(vector<_wstring>& ModelPrototyp m_ModelPrototypeTags.push_back(ModelPrototypeTags[i]); m_ModelPrototypePaths.push_back(ModelPrototypePaths[i]); - }*/ + } return S_OK; } @@ -75,11 +76,12 @@ void CMapObject_Manager::Priority_Update(_float fTimeDelta) void CMapObject_Manager::Update(_float fTimeDelta) { GUI::Begin("File"); - const char* ModeNames[3] = + const char* ModeNames[4] = { "CONTAINER", "ELEMENT_STATIC", - "ELEMENT_INTERACT" + "ELEMENT_INTERACT", + "ELEMENT_LIGHT" }; GUI::Combo("MODE", (_int*)(&m_eType), ModeNames, IM_ARRAYSIZE(ModeNames)); GUI::Checkbox("Model View", &m_bModelVisable); @@ -1156,23 +1158,10 @@ void CMapObject_Manager::Update_PrototypeList() if (ImGui::Button(CMyTools::ToString(Tag).c_str())) { - switch (m_eType) - { - case Editor::CMapObject_Manager::ADD_TYPE::CONTAINER: + if (ADD_TYPE::CONTAINER == m_eType) Create_PartObject(Tag); - break; - - case Editor::CMapObject_Manager::ADD_TYPE::ELEMENT_STATIC: - Create_Elemnt_Static(Tag); - break; - - case Editor::CMapObject_Manager::ADD_TYPE::ELEMENT_INTERACT: - Create_Elemnt_Interact(Tag); - break; - default: - break; - } - + else + Create_Elemnt(Tag); } } GUI::End(); @@ -1291,6 +1280,8 @@ void CMapObject_Manager::Update_ObjectList() pLayer = m_pGameInstance->Get_Layer(ENUM_CLASS(LEVEL::MAP), TEXT("Layer_Element_Static")); else if (ADD_TYPE::ELEMENT_INTERACT == m_eType) pLayer = m_pGameInstance->Get_Layer(ENUM_CLASS(LEVEL::MAP), TEXT("Layer_Element_Interact")); + else if (ADD_TYPE::ELEMENT_LIGHT == m_eType) + pLayer = m_pGameInstance->Get_Layer(ENUM_CLASS(LEVEL::MAP), TEXT("Layer_Element_Light")); if (nullptr == pLayer) { @@ -1440,13 +1431,12 @@ void CMapObject_Manager::Create_PartObject(_wstring& strPrototypeTag) m_MapObjects.push_back(pMapObject); } -void CMapObject_Manager::Create_Elemnt_Static(_wstring& strPrototypeTag) +void CMapObject_Manager::Create_Elemnt(_wstring& strPrototypeTag) { - vector<_uint> LodModelIndices; - MAPOBJECT_LOD_DESC Desc = {}; vector<_wstring> PrototypeTags; + vector<_uint> LodModelIndices; Find_Lod_Prototype(strPrototypeTag, LodModelIndices); @@ -1466,42 +1456,19 @@ void CMapObject_Manager::Create_Elemnt_Static(_wstring& strPrototypeTag) Desc.vScale = _float3(1.f, 1.f, 1.f); Desc.pModelPathIndices = &LodModelIndices; - CMapElement_Static* pMapObject = { nullptr }; - const string strKey = CMyTools::ToString(strPrototypeTag); - - m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, TEXT("Layer_Element_Static"), &Desc); -} - -void CMapObject_Manager::Create_Elemnt_Interact(_wstring& strPrototypeTag) -{ - vector<_uint> LodModelIndices; - - MAPOBJECT_LOD_DESC Desc = {}; - - vector<_wstring> PrototypeTags; - - Find_Lod_Prototype(strPrototypeTag, LodModelIndices); - - PrototypeTags.push_back(strPrototypeTag); - - for (_uint i = 0; i < LodModelIndices.size(); ++i) + if (ADD_TYPE::ELEMENT_STATIC == m_eType) { - _wstring strLodTag = strPrototypeTag + L"_Lod" + to_wstring(i + 1); - PrototypeTags.push_back(strLodTag); + m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, TEXT("Layer_Element_Static"), &Desc); } - - Desc.iMaxLodLevel = (_uint)LodModelIndices.size() - 1; - Desc.ModelPrototypeTags = PrototypeTags; - Desc.pParentTransform = m_pTransformCom; - Desc.vPosition = _float3(0.f, 0.f, 0.f); - Desc.vRotation = _float3(0.f, 0.f, 0.f); - Desc.vScale = _float3(1.f, 1.f, 1.f); - Desc.pModelPathIndices = &LodModelIndices; - - CMapElement_Interactable* pMapObject = { nullptr }; - const string strKey = CMyTools::ToString(strPrototypeTag); - - m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, TEXT("Layer_Element_Interact"), &Desc); + else if (ADD_TYPE::ELEMENT_INTERACT == m_eType) + { + m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, TEXT("Layer_Element_Interact"), &Desc); + } + else if (ADD_TYPE::ELEMENT_LIGHT == m_eType) + { + m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, TEXT("Layer_Element_Light"), &Desc); + } + } _bool CMapObject_Manager::Find_Lod_Prototype(_wstring strPrototypeTag, vector<_uint>& LodModelIndices) @@ -1566,6 +1533,11 @@ void CMapObject_Manager::Free() { __super::Free(); + m_ModelPrototypeTags.clear(); + m_PartObjectKeyCount.clear(); + m_LODModelPrototypeTags.clear(); + m_ModelPrototypePaths.clear(); + for (auto& pObject : m_MapObjects) { SAFE_RELEASE(pObject); diff --git a/Jusin154_Team3D/Editor/Private/Terrain.cpp b/Jusin154_Team3D/Editor/Private/Terrain.cpp index bba59e573..9cb5a4222 100644 --- a/Jusin154_Team3D/Editor/Private/Terrain.cpp +++ b/Jusin154_Team3D/Editor/Private/Terrain.cpp @@ -138,7 +138,7 @@ HRESULT CTerrain::Render() } else { - if (FAILED(m_pShaderCom->Begin(ENUM_CLASS(SHADER_PASS_NORTEX::DEFAULT)))) { + if (FAILED(m_pShaderCom->Begin(ENUM_CLASS(SHADER_PASS_NORTEX::ENV_TERRAIN_ANISO)))) { return E_FAIL; } } @@ -191,6 +191,15 @@ HRESULT CTerrain::Ready_Components() HRESULT CTerrain::Bind_ShaderResources() { + if (FAILED(m_pShaderCom->Bind_RawValue("g_fDiffuseMultiplier", &m_vDRN.x, sizeof(_float)))) { + return E_FAIL; + } + if (FAILED(m_pShaderCom->Bind_RawValue("g_fSurfaceMultiplier", &m_vDRN.y, sizeof(_float)))) { + return E_FAIL; + } + if (FAILED(m_pShaderCom->Bind_RawValue("g_fNormalMultiplier", &m_vDRN.z, sizeof(_float)))) { + return E_FAIL; + } if (FAILED(m_pTransformCom->Bind_ShaderResource(m_pShaderCom, "g_WorldMatrix"))) { return E_FAIL; } diff --git a/Jusin154_Team3D/Editor/Public/Editor_Macro.h b/Jusin154_Team3D/Editor/Public/Editor_Macro.h index 7d99927b5..4f18a9b2d 100644 --- a/Jusin154_Team3D/Editor/Public/Editor_Macro.h +++ b/Jusin154_Team3D/Editor/Public/Editor_Macro.h @@ -58,6 +58,11 @@ namespace Editor { #define LAYER_MAPOBJECTMANAGER TEXT("Layer_MapObjectManager") +#pragma region TIME +#define SECONDS_PER_GAME_DAY 30.f +#pragma endregion + + #pragma endregion #pragma region MACRO_TEXTURE diff --git a/Jusin154_Team3D/Editor/Public/GameTime.h b/Jusin154_Team3D/Editor/Public/GameTime.h new file mode 100644 index 000000000..c152d526f --- /dev/null +++ b/Jusin154_Team3D/Editor/Public/GameTime.h @@ -0,0 +1,39 @@ +#pragma once + +#include "Editor_Define.h" +#include "Base.h" + +NS_BEGIN(Engine) +class CGameInstance; +NS_END + +NS_BEGIN(Editor) + +class CGameTime : public CBase +{ +private: + CGameTime(); + virtual ~CGameTime() = default; + +public: + _float Get_DayTime() const { return m_fDayTime; } + +public: + void Update_GameTime(_float fTiemDelta); + +private: + CGameInstance* m_pGameInstance = { nullptr }; + + _float m_PerDayTime = { 24.f }; + _float m_fGameTime = { 0.f }; + _float m_fDayTime = { 0.f }; + +private: + HRESULT Initialize(); + +public: + static CGameTime* Create(); + virtual void Free() override; +}; + +NS_END diff --git a/Jusin154_Team3D/Editor/Public/MainLight.h b/Jusin154_Team3D/Editor/Public/MainLight.h index 87a3e8dad..111f7be96 100644 --- a/Jusin154_Team3D/Editor/Public/MainLight.h +++ b/Jusin154_Team3D/Editor/Public/MainLight.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "Editor_Define.h" #include "GameObject.h" @@ -11,6 +11,8 @@ NS_BEGIN(Editor) class CMainLight final : public CGameObject { +public: + enum class DAY_PHASE { DAWN, DAY, DUSK, NIGHT, END }; private: CMainLight(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); @@ -26,7 +28,19 @@ class CMainLight final : public CGameObject virtual HRESULT Render() override; private: - CLight* m_pLightCom = { nullptr }; + CLight* m_pLightCom = { nullptr }; + class CGameTime* m_pGameTime = { nullptr }; + _float4 m_vCurDiffuse = {}; + _float4 m_vAmbient = {}; + _float4 m_vSpecular = {}; + + DAY_PHASE m_eCurPhase = { DAY_PHASE::END}; + DAY_PHASE m_eNextPhase = { DAY_PHASE::END }; + + _float4 m_Diffuse_Colors[ENUM_CLASS(DAY_PHASE::END)] = {}; + _float4 m_Ambient_Colors[ENUM_CLASS(DAY_PHASE::END)] = {}; + _float4 m_Specular_Colors[ENUM_CLASS(DAY_PHASE::END)] = {}; + private: HRESULT Ready_Components(); @@ -39,4 +53,4 @@ class CMainLight final : public CGameObject virtual void Describe_Entity() override; }; -NS_END \ No newline at end of file +NS_END diff --git a/Jusin154_Team3D/Editor/Public/MapElement.h b/Jusin154_Team3D/Editor/Public/MapElement.h index d88aa7df9..c903efc46 100644 --- a/Jusin154_Team3D/Editor/Public/MapElement.h +++ b/Jusin154_Team3D/Editor/Public/MapElement.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "Editor_Define.h" #include "GameObject.h" @@ -43,7 +43,6 @@ class CMapElement abstract : public CGameObject _float3 m_vScale = {}; #endif // _DEBUG - protected: virtual HRESULT Initialize_Prototype() override; virtual HRESULT Initialize(void* pArg) override; @@ -56,4 +55,4 @@ class CMapElement abstract : public CGameObject void Describe_Entity() override; }; -NS_END \ No newline at end of file +NS_END diff --git a/Jusin154_Team3D/Editor/Public/MapElement_Light.h b/Jusin154_Team3D/Editor/Public/MapElement_Light.h new file mode 100644 index 000000000..89be70ebe --- /dev/null +++ b/Jusin154_Team3D/Editor/Public/MapElement_Light.h @@ -0,0 +1,41 @@ +#pragma once + +#include "Editor_Define.h" +#include "MapElement.h" + +NS_BEGIN(Engine) +class CLight; +NS_END + +NS_BEGIN(Editor) + +class CMapElement_Light : public CMapElement +{ +private: + CMapElement_Light(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); + CMapElement_Light(const CMapElement_Light& rhs); + virtual ~CMapElement_Light() = default; + +public: + virtual void Priority_Update(_float fTimeDelta) override; + virtual void Update(_float fTimeDelta) override; + virtual void Late_Update(_float fTimeDelta) override; + virtual HRESULT Render() override; + +private: + CLight* m_pLightCom = { nullptr }; + +private: + virtual HRESULT Initialize_Prototype() override; + virtual HRESULT Initialize(void* pArg) override; + virtual HRESULT Ready_Components(void* pArg) override; + virtual HRESULT Bind_ShaderResources() override; + +public: + static CMapElement_Light* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); + virtual CGameObject* Clone(void* pArg, class CGameObject* pOwner) override; + virtual void Free() override; + void Describe_Entity() override; +}; + +NS_END diff --git a/Jusin154_Team3D/Editor/Public/MapObject_Manager.h b/Jusin154_Team3D/Editor/Public/MapObject_Manager.h index 05a238d2e..571f456d3 100644 --- a/Jusin154_Team3D/Editor/Public/MapObject_Manager.h +++ b/Jusin154_Team3D/Editor/Public/MapObject_Manager.h @@ -12,7 +12,7 @@ NS_BEGIN(Editor) class CMapObject_Manager final : public CGameObject { - enum class ADD_TYPE {CONTAINER, ELEMENT_STATIC, ELEMENT_INTERACT}; + enum class ADD_TYPE {CONTAINER, ELEMENT_STATIC, ELEMENT_INTERACT, ELEMENT_LIGHT }; private: CMapObject_Manager(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); @@ -68,8 +68,7 @@ class CMapObject_Manager final : public CGameObject void Update_ContainerObject(); void Create_PartObject(_wstring& strPrototypeTag); - void Create_Elemnt_Static(_wstring& strPrototypeTag); - void Create_Elemnt_Interact(_wstring& strPrototypeTag); + void Create_Elemnt(_wstring& strPrototypeTag); _bool Find_Lod_Prototype(_wstring strPrototypeTag, vector<_uint>& LodModelIndices); _uint Get_KeyCount(_wstring strPrototypeTag); diff --git a/Jusin154_Team3D/Editor/Public/Terrain.h b/Jusin154_Team3D/Editor/Public/Terrain.h index b1ca26178..bf82379b1 100644 --- a/Jusin154_Team3D/Editor/Public/Terrain.h +++ b/Jusin154_Team3D/Editor/Public/Terrain.h @@ -43,6 +43,9 @@ class CTerrain final : public CGameObject _uint m_iTextureIndex = {}; + _float3 m_vDRN = { (1.f / 16.f), (1.f / 16.f), (1.f / 16.f) }; + + class CAlphaMap* m_pAlphaMap = { nullptr }; _uint m_iMaskRange = {1}; _int m_iColorIndex = {0}; diff --git a/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl b/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl index 70ab08713..db13bce76 100644 --- a/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl +++ b/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl @@ -46,12 +46,17 @@ Texture2D g_BlurWeightTexture; Texture2D g_BlurWeightXTexture; Texture2D g_SurfaceTexture; +Texture2D g_OriginalTexture; vector g_vLightDiffuse; vector g_vLightAmbient; vector g_vLightSpecular; +float g_fFogDensity; +float g_fFogPow; +vector g_vFogColor; + struct VS_IN { float3 vPosition : POSITION; @@ -776,6 +781,31 @@ PS_OUT_BLUR_X PS_MAIN_BLUR_Y(PS_IN In) return Out; } +PS_OUT_FLT4_SINGLE PS_MAIN_FOG(PS_IN In) +{ + PS_OUT_FLT4_SINGLE Out; + + vector vColor = g_OriginalTexture.Sample(DefaultSampler, In.vTexcoord); + vector vDepthDesc = g_DepthTexture.Sample(DefaultSampler, In.vTexcoord); + + vector vFinalColor; + float fViewZ = vDepthDesc.y * g_fFar; + + float fRatio; + + fRatio = clamp(pow(exp(-(g_fFogDensity * fViewZ)), g_fFogPow), 0.f, 1.f); + + vFinalColor = lerp(g_vFogColor, vColor, max(fRatio, 0.2f)); + vFinalColor.a = 1.f; + + if (1.f == vDepthDesc.y) + vFinalColor = float4(g_vFogColor); + + Out.vSingleTarget = vFinalColor; + + return Out; +} + technique11 DefaultTechnique { @@ -916,4 +946,14 @@ technique11 DefaultTechnique GeometryShader = NULL; PixelShader = compile ps_5_0 PS_MAIN_POSTCOMBINED(); } + + pass FogPass // 14 + { + SetRasterizerState(RS_Default); + SetDepthStencilState(DSS_None, 0); + SetBlendState(BS_AlphaBlend, float4(0.f, 0.f, 0.f, 0.f), 0xffffffff); + VertexShader = compile vs_5_0 VS_MAIN(); + GeometryShader = NULL; + PixelShader = compile ps_5_0 PS_MAIN_FOG(); + } } diff --git a/Jusin154_Team3D/Engine/Default/Engine.vcxproj b/Jusin154_Team3D/Engine/Default/Engine.vcxproj index f92ffb8d6..a884dc4a7 100644 --- a/Jusin154_Team3D/Engine/Default/Engine.vcxproj +++ b/Jusin154_Team3D/Engine/Default/Engine.vcxproj @@ -207,6 +207,7 @@ call Update_Lib.bat + @@ -423,6 +424,7 @@ call Update_Lib.bat + diff --git a/Jusin154_Team3D/Engine/Default/Engine.vcxproj.filters b/Jusin154_Team3D/Engine/Default/Engine.vcxproj.filters index bf933498c..1240a0667 100644 --- a/Jusin154_Team3D/Engine/Default/Engine.vcxproj.filters +++ b/Jusin154_Team3D/Engine/Default/Engine.vcxproj.filters @@ -295,6 +295,9 @@ {432b36d5-fdf6-456a-bc71-8bf793a42314} + + {d566d9e6-6183-48dc-a196-25fd47a10c48} + @@ -558,6 +561,9 @@ 02.Element\02.Component\02.VIBuffer\Box + + 01.Utility\07. Fog + @@ -1190,6 +1196,9 @@ 02.Element\02.Component\02.VIBuffer\Box + + 01.Utility\07. Fog + diff --git a/Jusin154_Team3D/Engine/Private/Fog.cpp b/Jusin154_Team3D/Engine/Private/Fog.cpp new file mode 100644 index 000000000..39fefeaa3 --- /dev/null +++ b/Jusin154_Team3D/Engine/Private/Fog.cpp @@ -0,0 +1,64 @@ +#include "pch.h" +#include "Fog.h" +#include "Shader.h" + +CFog::CFog() + : m_bVisible{ true } +{ +} + +void CFog::Set_FogDensity(_float fFogDensity) +{ + m_fFogDensity = fFogDensity; +} + +void CFog::Set_FogColor(_float4& vFogColor) +{ + memcpy(&m_vFogColor, &vFogColor, sizeof(_float4)); +} + +HRESULT CFog::Bind_FogValue(CShader* pShader) +{ +#ifdef _DEBUG + if (m_bVisible) { + pShader->Bind_RawValue("g_fFogDensity", &m_fFogDensity, sizeof(_float)); + pShader->Bind_RawValue("g_fFogPow", &m_fFogPow, sizeof(_float)); + pShader->Bind_RawValue("g_vFogColor", &m_vFogColor, sizeof(_float4)); + } + else + { + _float fValue = 0.f; + _float4 vColor = { 0.f, 0.f,0.f,0.f }; + pShader->Bind_RawValue("g_fFogDensity", &fValue, sizeof(_float)); + pShader->Bind_RawValue("g_fFogDensity", &fValue, sizeof(_float)); + pShader->Bind_RawValue("g_vFogColor", &vColor, sizeof(_float4)); + } +#else + pShader->Bind_RawValue("g_fFogDensity", &m_fFogDensity, sizeof(_float)); + pShader->Bind_RawValue("g_vFogColor", &m_vFogColor, sizeof(_float4)); +#endif // _DEBUG + + return S_OK; +} + +#ifdef _DEBUG +void CFog::Update_Fog() +{ + GUI::Begin("Fog Edit"); + GUI::Checkbox("Fog ON / OFF", &m_bVisible); + GUI::InputFloat("g_fFogDensity", &m_fFogDensity, 0.001f); + GUI::InputFloat("g_fFogPow", &m_fFogPow, 0.1f); + GUI::ColorEdit4("Fog Color", (_float*)(&m_vFogColor), ImGuiColorEditFlags_NoInputs); + GUI::End(); +} +#endif // _DEBUG + +CFog* CFog::Create() +{ + return new CFog(); +} + +void CFog::Free() +{ + __super::Free(); +} diff --git a/Jusin154_Team3D/Engine/Private/GameInstance.cpp b/Jusin154_Team3D/Engine/Private/GameInstance.cpp index 97fdcc968..7539f7c80 100644 --- a/Jusin154_Team3D/Engine/Private/GameInstance.cpp +++ b/Jusin154_Team3D/Engine/Private/GameInstance.cpp @@ -17,6 +17,7 @@ #include "Picking.h" #include "PhysX_Manager.h" #include "ThreadHolder.h" +#include "Fog.h" IMPLEMENT_SINGLETON(CGameInstance) @@ -100,6 +101,11 @@ HRESULT CGameInstance::Initialize_Engine(const ENGINE_DESC& EngineDesc, ID3D11De return E_FAIL; } + m_pFog = CFog::Create(); + if (nullptr == m_pFog) { + return E_FAIL; + } + return S_OK; } @@ -108,7 +114,9 @@ void CGameInstance::Update_Engine(_float fTimeDelta) m_pKey_Manager->Update(); m_pMouse_Manager->Update(); //m_pSound_Manager->Update(); - +#ifdef _DEBUG + m_pFog->Update_Fog(); +#endif // _DEBUG m_pPicking->Update(); m_pObject_Manager->Priority_Update(fTimeDelta); @@ -514,6 +522,11 @@ HRESULT CGameInstance::Begin_MRT(const _wstring& strMRTTag, ID3D11DepthStencilVi return m_pRenderTarget_Manager->Begin_MRT(strMRTTag, pDSV); } +HRESULT CGameInstance::Begin_MRT_NonClear(const _wstring& strMRTTag, ID3D11DepthStencilView* pDSV) +{ + return m_pRenderTarget_Manager->Begin_MRT_NonClear(strMRTTag, pDSV); +} + HRESULT CGameInstance::Begin_MRT_Include_BackBuffer(const _wstring& strMRTTag, ID3D11DepthStencilView* pDSV) { return m_pRenderTarget_Manager->Begin_MRT_Include_BackBuffer(strMRTTag, pDSV); @@ -623,6 +636,7 @@ _bool CGameInstance::SaveAssimpModel(const _char* filename) auto iter = m_ModelMap.find(filename); return iter->second->SaveAssimpModel(filename); } + void CGameInstance::Add_ModelToMap(const _char* filePath, CModel* pModel) { m_ModelMap[filePath] = pModel; @@ -715,6 +729,22 @@ HRESULT CGameInstance::LoadTriMeshes(const _char* pPath, vectorSet_FogDensity(fFogDensity); +} +void CGameInstance::Set_FogColor(_float4& vFogColor) +{ + m_pFog->Set_FogColor(vFogColor); +} + +HRESULT CGameInstance::Bind_FogValue(class CShader* pShader) +{ + return m_pFog->Bind_FogValue(pShader); +} +#pragma endregion // FOG + bool CGameInstance::Key_Pressing(int _iKey) { //if (false == (GUI::IsWindowFocused(ImGuiFocusedFlags_AnyWindow))) { @@ -824,6 +854,7 @@ void CGameInstance::Release_Engine() DestroyInstance(); + SAFE_RELEASE(m_pFog); SAFE_RELEASE(m_pPicking); SAFE_RELEASE(m_pCollider_Manager); SAFE_RELEASE(m_pShadow); diff --git a/Jusin154_Team3D/Engine/Private/Light.cpp b/Jusin154_Team3D/Engine/Private/Light.cpp index 4a77afd55..b18672ef2 100644 --- a/Jusin154_Team3D/Engine/Private/Light.cpp +++ b/Jusin154_Team3D/Engine/Private/Light.cpp @@ -57,6 +57,13 @@ HRESULT CLight::Initialize(void* pArg) return S_OK; } +void CLight::Set_Color(_float4& vDiffuse, _float4& vAmbient, _float4& vSpecular) +{ + memcpy(&m_LightDesc.vDiffuse, &vDiffuse, sizeof(_float4)); + memcpy(&m_LightDesc.vAmbient, &vAmbient, sizeof(_float4)); + memcpy(&m_LightDesc.vSpecular, &vSpecular, sizeof(_float4)); +} + HRESULT CLight::Render(CShader* pShader, CVIBuffer* pVIBuffer) const { _uint iPassIndex = { 0 }; diff --git a/Jusin154_Team3D/Engine/Private/RenderTarget_Manager.cpp b/Jusin154_Team3D/Engine/Private/RenderTarget_Manager.cpp index bd05b1b2a..fb0294ef9 100644 --- a/Jusin154_Team3D/Engine/Private/RenderTarget_Manager.cpp +++ b/Jusin154_Team3D/Engine/Private/RenderTarget_Manager.cpp @@ -84,6 +84,37 @@ HRESULT CRenderTarget_Manager::Begin_MRT(const _wstring& strMultiRenderTargetKey return S_OK; } +HRESULT CRenderTarget_Manager::Begin_MRT_NonClear(const _wstring& strMultiRenderTargetKey, ID3D11DepthStencilView* pDSV) +{ + m_pContext->OMGetRenderTargets(1, &m_pBackBufferRTV, &m_pOriginalDSV); + + list* pMRTList = Find_MRT(strMultiRenderTargetKey); + + if (nullptr == pMRTList) { + return E_FAIL; + } + + _uint iNumRenderTargets = { 0 }; + ID3D11RenderTargetView* pRenderTargetViews[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT] = {}; + + m_pContext->OMSetRenderTargets(0, nullptr, nullptr); + + if (nullptr != pDSV) { + m_pContext->ClearDepthStencilView(pDSV, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.f, 0); + } + + for (auto& pRenderTarget : *pMRTList) + { + pRenderTargetViews[iNumRenderTargets++] = pRenderTarget->Get_RTV(); + } + if (0 == iNumRenderTargets) { + return E_FAIL; + } + + m_pContext->OMSetRenderTargets(iNumRenderTargets, pRenderTargetViews, (nullptr == pDSV) ? m_pOriginalDSV : pDSV); + + return S_OK; +} HRESULT CRenderTarget_Manager::Begin_MRT_Include_BackBuffer(const _wstring& strMRTTag, ID3D11DepthStencilView* pDSV) { m_pContext->OMGetRenderTargets(1, &m_pBackBufferRTV, &m_pOriginalDSV); diff --git a/Jusin154_Team3D/Engine/Private/Renderer.cpp b/Jusin154_Team3D/Engine/Private/Renderer.cpp index 8d79136a4..0d47c79da 100644 --- a/Jusin154_Team3D/Engine/Private/Renderer.cpp +++ b/Jusin154_Team3D/Engine/Private/Renderer.cpp @@ -65,6 +65,7 @@ void CRenderer::Render() Render_Combined(); Render_Occlusion(); Render_EnvironmentPostProcess(); + Render_Fog(); Render_Effect(); Render_NonLight(); Render_Blend(); @@ -117,6 +118,7 @@ void CRenderer::Render_Priority() } m_RenderObjects[ENUM_CLASS(RENDER::PRIORITY)].clear(); + } void CRenderer::Render_Shadow() @@ -227,7 +229,7 @@ void CRenderer::Render_LightAcc() void CRenderer::Render_Combined() { - if (FAILED(m_pGameInstance->Begin_MRT_Include_BackBuffer(TEXT("MRT_Combined")))) { + if (FAILED(m_pGameInstance->Begin_MRT(TEXT("MRT_Combined")))) { return; } { @@ -319,7 +321,7 @@ void CRenderer::Render_EnvironmentPostProcess() } m_pShader->Bind_Matrix("g_WorldMatrix", &m_WorldMatrix); - m_pShader->Bind_Matrix("g_ViewMatrix", &m_ViewMatrix); + m_pShader->Bind_Matrix("g_ViewMatrix", &m_ViewMatrix); m_pShader->Bind_Matrix("g_ProjMatrix", &m_ProjMatrix); m_pShader->Bind_Matrix("g_invMatView", m_pGameInstance->Get_Transform_Float4x4(D3DTS::VIEW_INV)); m_pShader->Bind_Matrix("g_invmatProj", m_pGameInstance->Get_Transform_Float4x4(D3DTS::PROJ_INV)); @@ -345,6 +347,10 @@ void CRenderer::Render_EnvironmentPostProcess() return; } + if (FAILED(m_pGameInstance->Begin_MRT_NonClear(TEXT("MRT_Fog")))) { + return; + } + m_pShader->Bind_Matrix("g_WorldMatrix", &m_WorldMatrix); m_pShader->Bind_Matrix("g_ViewMatrix", &m_ViewMatrix); m_pShader->Bind_Matrix("g_ProjMatrix", &m_ProjMatrix); @@ -356,6 +362,7 @@ void CRenderer::Render_EnvironmentPostProcess() m_pShader->Bind_RawValue("g_fFarBlurStart", &m_fDOF_ENV_StartDistance, sizeof(_float)); m_pShader->Bind_RawValue("g_fFarBlurEnd", &m_fDOF_ENV_MaxEnd, sizeof(_float)); m_pShader->Bind_RawValue("g_fDOFBlurMultiplier", &m_fDOF_ENV_AmountRadius, sizeof(_float)); + if (FAILED(m_pGameInstance->Bind_RenderTarget(TEXT("Target_Depth"), m_pShader, "g_DepthTexture"))) { return; } @@ -369,6 +376,31 @@ void CRenderer::Render_EnvironmentPostProcess() m_pVIBuffer->Bind_Resources(); m_pVIBuffer->Render(); + + if (FAILED(m_pGameInstance->End_MRT())) { + return; + } +} + +void CRenderer::Render_Fog() +{ + m_pShader->Bind_RawValue("g_fFar", m_pGameInstance->Get_CurrentCameraFar(), sizeof(_float)); + + m_pGameInstance->Bind_FogValue(m_pShader); + + if (FAILED(m_pGameInstance->Bind_RenderTarget(TEXT("Target_Fog"), m_pShader, "g_OriginalTexture"))) { + return; + } + + if (FAILED(m_pGameInstance->Bind_RenderTarget(TEXT("Target_Depth"), m_pShader, "g_DepthTexture"))) { + return; + } + + m_pShader->Begin(ENUM_CLASS(SHADER_PASS_DEFERRED::FOG)); + + m_pVIBuffer->Bind_Resources(); + m_pVIBuffer->Render(); + } void CRenderer::Render_Effect() @@ -824,6 +856,11 @@ HRESULT CRenderer::Initialize() return E_FAIL; } + /* Target_Diffuse */ + if (FAILED(m_pGameInstance->Add_RenderTarget(TEXT("Target_Fog"), (_uint)Viewport.Width, (_uint)Viewport.Height, + DXGI_FORMAT_R8G8B8A8_UNORM, _float4(0.0f, 0.f, 0.f, 0.f)))) { + return E_FAIL; + } if (FAILED(Ready_ShadowDepthStencilView(g_iMaxShadowWidth, g_iMaxShadowHeight))) { @@ -850,6 +887,9 @@ HRESULT CRenderer::Initialize() } /* MRT_Combined */ + if (FAILED(m_pGameInstance->Add_MRT(TEXT("MRT_Combined"), TEXT("Target_Fog")))) { + return E_FAIL; + } if (FAILED(m_pGameInstance->Add_MRT(TEXT("MRT_Combined"), TEXT("Target_AfterCombined")))) { return E_FAIL; } @@ -909,6 +949,11 @@ HRESULT CRenderer::Initialize() if (FAILED(m_pGameInstance->Add_MRT(TEXT("MRT_WB"), TEXT("Target_Color")))) { return E_FAIL; } + + /* MRT_Fog */ + if (FAILED(m_pGameInstance->Add_MRT(TEXT("MRT_Fog"), TEXT("Target_Fog")))) { + return E_FAIL; + } } m_pShader = (CShader*)m_pGameInstance->Clone_Asset_Prototype(g_iStaticLevel, FX_DEFERRED, nullptr, nullptr); diff --git a/Jusin154_Team3D/Engine/Public/Engine_Enum.h b/Jusin154_Team3D/Engine/Public/Engine_Enum.h index fd55e6016..bac13c485 100644 --- a/Jusin154_Team3D/Engine/Public/Engine_Enum.h +++ b/Jusin154_Team3D/Engine/Public/Engine_Enum.h @@ -34,7 +34,7 @@ enum class NAVI_POINT { A, B, C, END }; enum class NAVI_LINE { AB, BC, CA, END }; enum class SHADER_PASS_CELL { DEBUG, END }; -enum class SHADER_PASS_DEFERRED { DEBUG, DIRECTIONAL, POINT, COMBINED, BLUR, SPOT, REFIT, EMBOSSING, BLOOM_BLURX, BLOOM_BLURY, BLOOM_ACCUM, BLOOM_FINISH, BLURX_ENVIRONMENT, POSTCOMBINED, END }; +enum class SHADER_PASS_DEFERRED { DEBUG, DIRECTIONAL, POINT, COMBINED, BLUR, SPOT, REFIT, EMBOSSING, BLOOM_BLURX, BLOOM_BLURY, BLOOM_ACCUM, BLOOM_FINISH, BLURX_ENVIRONMENT, POSTCOMBINED, FOG, END }; enum class QUESTYPE {MAIN, SUB, END}; enum class TEXTURE_MOUNT_SLOT0 { NOT_DEFINED, METALLIC, SPECULAR, HEIGHT, END }; diff --git a/Jusin154_Team3D/Engine/Public/Fog.h b/Jusin154_Team3D/Engine/Public/Fog.h new file mode 100644 index 000000000..4548b9122 --- /dev/null +++ b/Jusin154_Team3D/Engine/Public/Fog.h @@ -0,0 +1,35 @@ +#pragma once + +#include "Base.h" + +NS_BEGIN(Engine) + +class CFog final : public CBase +{ +private: + CFog(); + virtual ~CFog() = default; + +public: + void Set_FogDensity(_float fFogDensity); + void Set_FogColor(_float4& vFogColor); + + HRESULT Bind_FogValue(class CShader* pShader); + +#ifdef _DEBUG + void Update_Fog(); +#endif // _DEBUG + + +private: + _bool m_bVisible = {}; + _float m_fFogDensity = { 0.04f }; + _float m_fFogPow = { 0.1f }; + _float4 m_vFogColor = { 0.906f, 0.812f, 0.745f, 0.5f }; + +public: + static CFog* Create(); + virtual void Free() override; +}; + +NS_END diff --git a/Jusin154_Team3D/Engine/Public/GameInstance.h b/Jusin154_Team3D/Engine/Public/GameInstance.h index 0449f0134..c6a45d9a4 100644 --- a/Jusin154_Team3D/Engine/Public/GameInstance.h +++ b/Jusin154_Team3D/Engine/Public/GameInstance.h @@ -153,6 +153,7 @@ class ENGINE_DLL CGameInstance final : public CBase HRESULT Add_RenderTarget(const _wstring& strRenderTargetKey, _uint iSizeX, _uint iSizeY, DXGI_FORMAT ePixelFormat, const _float4& vClearColor); HRESULT Add_MRT(const _wstring& strMultiRenderTargetKey, const _wstring& strRenderTargetKey); HRESULT Begin_MRT(const _wstring& strMRTTag, ID3D11DepthStencilView* pDSV = nullptr); + HRESULT Begin_MRT_NonClear(const _wstring& strMRTTag, ID3D11DepthStencilView* pDSV = nullptr); HRESULT Begin_MRT_Include_BackBuffer(const _wstring& strMRTTag, ID3D11DepthStencilView* pDSV = nullptr); HRESULT Begin_MRT_NO_DepthStencil(const _wstring& strMRTTag); HRESULT End_MRT(); @@ -222,6 +223,14 @@ class ENGINE_DLL CGameInstance final : public CBase } #pragma endregion +#pragma region FOG + void Set_FogDensity(_float fFogDensity); + void Set_FogColor(_float4& vFogColor); + + HRESULT Bind_FogValue(class CShader* pShader); +#pragma endregion + + public: void Add_ModelToMap(const _char* filePath, CModel* pModel); @@ -255,7 +264,8 @@ class ENGINE_DLL CGameInstance final : public CBase class CPhysX_Manager* m_pPhysX_Manager = { nullptr }; class CPicking* m_pPicking = { nullptr }; class CThreadHolder* m_pThreadHolder = { nullptr }; - class COcclusionQuery* m_pOcclusionQuery = { nullptr }; + class CFog* m_pFog = { nullptr }; + #ifdef _DEBUG private: diff --git a/Jusin154_Team3D/Engine/Public/Light.h b/Jusin154_Team3D/Engine/Public/Light.h index ac5562130..ad0f232c2 100644 --- a/Jusin154_Team3D/Engine/Public/Light.h +++ b/Jusin154_Team3D/Engine/Public/Light.h @@ -20,6 +20,7 @@ class ENGINE_DLL CLight final : public CComponent virtual HRESULT Initialize(void* pArg) override; public: const LIGHT_DESC* Get_LightDesc() { return &m_LightDesc; } + void Set_Color(_float4& vDiffuse, _float4& vAmbient, _float4& vSpecular); public: HRESULT Render(class CShader* pShader, class CVIBuffer* pVIBuffer) const; diff --git a/Jusin154_Team3D/Engine/Public/RenderTarget_Manager.h b/Jusin154_Team3D/Engine/Public/RenderTarget_Manager.h index 72de0e6d5..4a90b57e5 100644 --- a/Jusin154_Team3D/Engine/Public/RenderTarget_Manager.h +++ b/Jusin154_Team3D/Engine/Public/RenderTarget_Manager.h @@ -13,6 +13,7 @@ class CRenderTarget_Manager final : public CBase HRESULT Add_RenderTarget(const _wstring& strRenderTargetKey, _uint iSizeX, _uint iSizeY, DXGI_FORMAT ePixelFormat, const _float4& vClearColor); HRESULT Add_MRT(const _wstring& strMultiRenderTargetKey, const _wstring& strRenderTargetKey); HRESULT Begin_MRT(const _wstring& strMRTTag, ID3D11DepthStencilView* pDSV); + HRESULT Begin_MRT_NonClear(const _wstring& strMRTTag, ID3D11DepthStencilView* pDSV); HRESULT Begin_MRT_Include_BackBuffer(const _wstring& strMRTTag, ID3D11DepthStencilView* pDSV); HRESULT Begin_MRT_NO_DepthStencil(const _wstring& strMRTTag); HRESULT End_MRT(); diff --git a/Jusin154_Team3D/Engine/Public/Renderer.h b/Jusin154_Team3D/Engine/Public/Renderer.h index 8426a3e6d..4d07aa396 100644 --- a/Jusin154_Team3D/Engine/Public/Renderer.h +++ b/Jusin154_Team3D/Engine/Public/Renderer.h @@ -40,7 +40,6 @@ class CRenderer final : public CBase _float4x4 m_ProjMatrix = {}; ID3D11DepthStencilView* m_pShadowDSV = { nullptr }; - ID3D11DepthStencilView* m_pOcclusionDSV = { nullptr }; SHADOW_LIGHT_DESC m_PreShadowDesc = {}; _float4x4 m_PreShadowMatrices[ENUM_CLASS(D3DTS::END)] = {}; @@ -55,7 +54,6 @@ class CRenderer final : public CBase _float m_fDOF_ENV_MaxEnd = { 360.f }; _float m_fDOF_ENV_AmountRadius = { 1.f }; - private: void Render_Occlusion(); void Render_Priority(); @@ -65,6 +63,7 @@ class CRenderer final : public CBase void Render_Blur(); void Render_Combined(); void Render_EnvironmentPostProcess(); + void Render_Fog(); void Render_Effect(); void Render_WeightBlend(); void Render_NonLight(); @@ -81,7 +80,6 @@ class CRenderer final : public CBase private: HRESULT Ready_ShadowDepthStencilView(_uint iSizeX, _uint iSizeY); - HRESULT Ready_OcclusionDepthStencilView(_uint iSizeX, _uint iSizeY); private: HRESULT Initialize();