From 5ee577e7945300d836dcb1da638f584fc9e710f2 Mon Sep 17 00:00:00 2001 From: kimnuri Date: Mon, 29 Dec 2025 15:04:35 +0900 Subject: [PATCH 1/3] [fix] Render bugs --- .../Client/Private/Level_GamePlay.cpp | 105 ++++-- Jusin154_Team3D/Client/Private/Loader.cpp | 306 +++++++++--------- Jusin154_Team3D/Client/Private/Player.cpp | 92 +++--- Jusin154_Team3D/Client/Private/PlayerRobe.cpp | 75 ++++- Jusin154_Team3D/Client/Public/PlayerRobe.h | 6 + Jusin154_Team3D/Client/Public/Player_ENUM.h | 19 +- .../Shader_BoneCombinedInsertion_Compute.hlsl | 40 +++ .../Shader_BoneCombinedInsertion_Compute.hlsl | 40 +++ Jusin154_Team3D/Engine/Default/Engine.vcxproj | 4 + .../Engine/Default/Engine.vcxproj.filters | 3 + Jusin154_Team3D/Engine/Private/Model.cpp | 113 ++++++- .../Engine/Private/Prototype_Manager.cpp | 6 +- Jusin154_Team3D/Engine/Public/Engine_Macro.h | 1 + Jusin154_Team3D/Engine/Public/Model.h | 27 +- 14 files changed, 569 insertions(+), 268 deletions(-) create mode 100644 Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_BoneCombinedInsertion_Compute.hlsl create mode 100644 Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_BoneCombinedInsertion_Compute.hlsl diff --git a/Jusin154_Team3D/Client/Private/Level_GamePlay.cpp b/Jusin154_Team3D/Client/Private/Level_GamePlay.cpp index 4e42cbdf8..89a848704 100644 --- a/Jusin154_Team3D/Client/Private/Level_GamePlay.cpp +++ b/Jusin154_Team3D/Client/Private/Level_GamePlay.cpp @@ -329,8 +329,8 @@ HRESULT CLevel_GamePlay::Ready_Background() #endif // #ifdef 기무리 isReady_Background = true; - isReady_Hogsmeade = true; - isReady_Hogwart = true; + isReady_Hogsmeade = false; + isReady_Hogwart = false; #endif // #ifdef 인혁 isReady_Background = false; @@ -644,20 +644,43 @@ HRESULT CLevel_GamePlay::Ready_Layer_Player(const _wstring& strLayerTag) return E_FAIL; } + + _bool isLoad_NPC = { true }; +#ifdef _DEBUG +#ifdef gimch + +#endif // gimch +#ifdef 진우 + +#endif // +#ifdef 기무리 + isLoad_NPC = false; +#endif // +#ifdef 인혁 + +#endif // +#ifdef Bin + +#endif // Bin +#endif // _DEBUG + + if(true == isLoad_NPC) { - CNPC_Ollivander::NPCDESC NPCDesc{}; - NPCDesc.vPos = _float4(40.f, 4.f, 68.9f, 1.f); - NPCDesc.vRotQ = _float4(0.f, 0.f, 0.f, 1.f); - if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, strLayerTag, &NPCDesc))) { - return E_FAIL; + { + CNPC_Ollivander::NPCDESC NPCDesc{}; + NPCDesc.vPos = _float4(40.f, 4.f, 68.9f, 1.f); + NPCDesc.vRotQ = _float4(0.f, 0.f, 0.f, 1.f); + if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, strLayerTag, &NPCDesc))) { + return E_FAIL; + } } - } - { - CNPC_EleazarFig::NPCDESC NPCDesc{}; - NPCDesc.vPos = _float4(101.f, 14.f, 100.f, 1.f); - NPCDesc.vRotQ = _float4(0.f, 0.f, 0.f, 1.f); - if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, strLayerTag, &NPCDesc))) { - return E_FAIL; + { + CNPC_EleazarFig::NPCDESC NPCDesc{}; + NPCDesc.vPos = _float4(101.f, 14.f, 100.f, 1.f); + NPCDesc.vRotQ = _float4(0.f, 0.f, 0.f, 1.f); + if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, strLayerTag, &NPCDesc))) { + return E_FAIL; + } } } return S_OK; @@ -715,29 +738,49 @@ HRESULT CLevel_GamePlay::Ready_Layer_SkyBox(const _wstring& strLayerTag) HRESULT CLevel_GamePlay::Ready_Layer_Monster() { - for (_uint i = 0; i <1; ++i) - { - if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, LAYER_MONSTER))) { + _bool isLoad_Monster = { true }; +#ifdef _DEBUG +#ifdef gimch + +#endif // gimch +#ifdef 진우 + +#endif // +#ifdef 기무리 + isLoad_Monster = false; +#endif // +#ifdef 인혁 + +#endif // +#ifdef Bin + +#endif // Bin +#endif // _DEBUG + if (true == isLoad_Monster) { + for (_uint i = 0; i < 1; ++i) + { + if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, LAYER_MONSTER))) { + return E_FAIL; + } + } + + for (_uint i = 0; i < 1; ++i) + { + if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, LAYER_MONSTER))) { + return E_FAIL; + } + } + + + if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, LAYER_MONSTER))) { return E_FAIL; } - } - for (_uint i = 0; i <1; ++i) - { - if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, LAYER_MONSTER))) { + if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, LAYER_MONSTER))) { return E_FAIL; } + } - - - if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, LAYER_MONSTER))) { - return E_FAIL; - } - - if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, LAYER_MONSTER))) { - return E_FAIL; - } - #if 진우 #else diff --git a/Jusin154_Team3D/Client/Private/Loader.cpp b/Jusin154_Team3D/Client/Private/Loader.cpp index 2afc59636..fc9134555 100644 --- a/Jusin154_Team3D/Client/Private/Loader.cpp +++ b/Jusin154_Team3D/Client/Private/Loader.cpp @@ -355,27 +355,39 @@ HRESULT CLoader::Loading_For_GamePlay() _bool isLoad_Background = { true }; _bool isLoad_Hogwart = { false }; + _bool isLoad_UI_SEQUANTIAL = { true }; + _bool isLoad_NPC = { true }; + _bool isLoad_Monster = { true }; +#ifdef _DEBUG #ifdef gimch isLoad_Background = true; isLoad_Hogwart = false; + isLoad_UI_SEQUANTIAL = false; #endif // gimch -#ifdef Bin - isLoad_Background = false; - isLoad_Hogwart = false; -#endif // #ifdef 진우 isLoad_Background = false; isLoad_Hogwart = false; + isLoad_UI_SEQUANTIAL = false; #endif // #ifdef 기무리 isLoad_Background = true; - isLoad_Hogwart = true; + isLoad_Hogwart = false; + isLoad_UI_SEQUANTIAL = false; + isLoad_NPC = false; + isLoad_Monster = false; #endif // #ifdef 인혁 isLoad_Background = false; isLoad_Hogwart = false; + isLoad_UI_SEQUANTIAL = false; #endif // +#ifdef Bin + isLoad_Background = false; + isLoad_Hogwart = false; + isLoad_UI_SEQUANTIAL = false; +#endif // Bin +#endif // _DEBUG #pragma region MAP_MODELS vector*>> jobMapModels; @@ -945,8 +957,6 @@ HRESULT CLoader::Loading_For_GamePlay() } #pragma endregion - - #pragma region UI Asset_FileLoad("../Bin/Resources/Textures/Keyboard", L"Prototype_Texture_", [&](_wstring wstrFileName, const _char* pFilePath) @@ -1225,106 +1235,103 @@ HRESULT CLoader::Loading_For_GamePlay() { return E_FAIL; } +#pragma region UI_ANI + if (true == isLoad_UI_SEQUANTIAL) { + + if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Ancient_Magic"), + CTexture::Create(m_pDevice, m_pContext, TEXTURE_LOAD_TYPE::INCREMENTAL, TEXT("C:\\MeshTable\\SpellAnim\\Ancient_Magic\\Ancient_Magic%d.png"), 152)))) + { + return E_FAIL; + } + + if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Ancient_Magic_Throw"), + CTexture::Create(m_pDevice, m_pContext, TEXTURE_LOAD_TYPE::INCREMENTAL, TEXT("C:\\MeshTable\\SpellAnim\\Ancient_Magic_Throw\\Ancient_Magic_Throw%d.png"), 89)))) + { + return E_FAIL; + } + + if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Arresto_Momentum"), + CTexture::Create(m_pDevice, m_pContext, TEXTURE_LOAD_TYPE::INCREMENTAL, TEXT("C:\\MeshTable\\SpellAnim\\Arresto_Momentum\\Arresto_Momentum%d.png"), 120)))) + { + return E_FAIL; + } + + if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Avada_Kedavra"), + CTexture::Create(m_pDevice, m_pContext, TEXTURE_LOAD_TYPE::INCREMENTAL, TEXT("C:\\MeshTable\\SpellAnim\\Avada_Kedavra\\Avada_Kedavra%d.png"), 208)))) + { + return E_FAIL; + } + + if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Basic_Cast"), + CTexture::Create(m_pDevice, m_pContext, TEXTURE_LOAD_TYPE::INCREMENTAL, TEXT("C:\\MeshTable\\SpellAnim\\Basic_Cast\\Basic_Cast%d.png"), 308)))) + { + return E_FAIL; + } + + if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Bombarda"), + CTexture::Create(m_pDevice, m_pContext, TEXTURE_LOAD_TYPE::INCREMENTAL, TEXT("C:\\MeshTable\\SpellAnim\\Bombarda\\Bombarda%d.png"), 262)))) + { + return E_FAIL; + } + + if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Descendo"), + CTexture::Create(m_pDevice, m_pContext, TEXTURE_LOAD_TYPE::INCREMENTAL, TEXT("C:\\MeshTable\\SpellAnim\\Descendo\\Descendo%d.png"), 155)))) + { + return E_FAIL; + } + + if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Levioso"), + CTexture::Create(m_pDevice, m_pContext, TEXTURE_LOAD_TYPE::INCREMENTAL, TEXT("C:\\MeshTable\\SpellAnim\\Levioso\\Levioso%d.png"), 180)))) + { + return E_FAIL; + } + + if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Lumos"), + CTexture::Create(m_pDevice, m_pContext, TEXTURE_LOAD_TYPE::INCREMENTAL, TEXT("C:\\MeshTable\\SpellAnim\\Lumos\\Lumos%d.png"), 365)))) + { + return E_FAIL; + } + + if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Petrificus_Totalus"), + CTexture::Create(m_pDevice, m_pContext, TEXTURE_LOAD_TYPE::INCREMENTAL, TEXT("C:\\MeshTable\\SpellAnim\\Petrificus_Totalus\\Petrificus_Totalus%d.png"), 275)))) + { + return E_FAIL; + } + + if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Protego"), + CTexture::Create(m_pDevice, m_pContext, TEXTURE_LOAD_TYPE::INCREMENTAL, TEXT("C:\\MeshTable\\SpellAnim\\Protego\\Protego%d.png"), 285)))) + { + return E_FAIL; + } + + if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Revelio"), + CTexture::Create(m_pDevice, m_pContext, TEXTURE_LOAD_TYPE::INCREMENTAL, TEXT("C:\\MeshTable\\SpellAnim\\Revelio\\Revelio%d.png"), 227)))) + { + return E_FAIL; + } + + if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Stupefy"), + CTexture::Create(m_pDevice, m_pContext, TEXTURE_LOAD_TYPE::INCREMENTAL, TEXT("C:\\MeshTable\\SpellAnim\\Stupefy\\Stupefy%d.png"), 222)))) + { + return E_FAIL; + } + + if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Transformation"), + CTexture::Create(m_pDevice, m_pContext, TEXTURE_LOAD_TYPE::INCREMENTAL, TEXT("C:\\MeshTable\\SpellAnim\\Transformation\\Transformation%d.png"), 146)))) + { + return E_FAIL; + } + + } +#pragma endregion + +#pragma endregion #pragma region Global_SRV { m_pGameInstance->Load_GlobalSRV(TEXT("GLOBAL_DISOLVE_NOISE_05"), "../Bin/Resources/Textures/Effect/Noises/VFX_T_Noise05_D.png"); m_pGameInstance->Load_GlobalSRV(TEXT("GLOBAL_DISOLVE_BURN_VERTICAL"), "../Bin/Resources/Textures/Effect/Diffuse/drp_fire_Line_Vertical.png"); } #pragma endregion -#if 진우 -#elif 기무리 -#elif 인혁 -#elif Bin -#elif gimch -#else -#pragma region UI_ANI - if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Ancient_Magic"), - CTexture::Create(m_pDevice, m_pContext, TEXTURE_LOAD_TYPE::INCREMENTAL, TEXT("C:\\MeshTable\\SpellAnim\\Ancient_Magic\\Ancient_Magic%d.png"), 152)))) - { - return E_FAIL; - } - - if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Ancient_Magic_Throw"), - CTexture::Create(m_pDevice, m_pContext, TEXTURE_LOAD_TYPE::INCREMENTAL, TEXT("C:\\MeshTable\\SpellAnim\\Ancient_Magic_Throw\\Ancient_Magic_Throw%d.png"), 89)))) - { - return E_FAIL; - } - - if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Arresto_Momentum"), - CTexture::Create(m_pDevice, m_pContext, TEXTURE_LOAD_TYPE::INCREMENTAL, TEXT("C:\\MeshTable\\SpellAnim\\Arresto_Momentum\\Arresto_Momentum%d.png"), 120)))) - { - return E_FAIL; - } - - if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Avada_Kedavra"), - CTexture::Create(m_pDevice, m_pContext, TEXTURE_LOAD_TYPE::INCREMENTAL, TEXT("C:\\MeshTable\\SpellAnim\\Avada_Kedavra\\Avada_Kedavra%d.png"), 208)))) - { - return E_FAIL; - } - - if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Basic_Cast"), - CTexture::Create(m_pDevice, m_pContext, TEXTURE_LOAD_TYPE::INCREMENTAL, TEXT("C:\\MeshTable\\SpellAnim\\Basic_Cast\\Basic_Cast%d.png"), 308)))) - { - return E_FAIL; - } - - if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Bombarda"), - CTexture::Create(m_pDevice, m_pContext, TEXTURE_LOAD_TYPE::INCREMENTAL, TEXT("C:\\MeshTable\\SpellAnim\\Bombarda\\Bombarda%d.png"), 262)))) - { - return E_FAIL; - } - - if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Descendo"), - CTexture::Create(m_pDevice, m_pContext, TEXTURE_LOAD_TYPE::INCREMENTAL, TEXT("C:\\MeshTable\\SpellAnim\\Descendo\\Descendo%d.png"), 155)))) - { - return E_FAIL; - } - - if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Levioso"), - CTexture::Create(m_pDevice, m_pContext, TEXTURE_LOAD_TYPE::INCREMENTAL, TEXT("C:\\MeshTable\\SpellAnim\\Levioso\\Levioso%d.png"), 180)))) - { - return E_FAIL; - } - - if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Lumos"), - CTexture::Create(m_pDevice, m_pContext, TEXTURE_LOAD_TYPE::INCREMENTAL, TEXT("C:\\MeshTable\\SpellAnim\\Lumos\\Lumos%d.png"), 365)))) - { - return E_FAIL; - } - - if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Petrificus_Totalus"), - CTexture::Create(m_pDevice, m_pContext, TEXTURE_LOAD_TYPE::INCREMENTAL, TEXT("C:\\MeshTable\\SpellAnim\\Petrificus_Totalus\\Petrificus_Totalus%d.png"), 275)))) - { - return E_FAIL; - } - - if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Protego"), - CTexture::Create(m_pDevice, m_pContext, TEXTURE_LOAD_TYPE::INCREMENTAL, TEXT("C:\\MeshTable\\SpellAnim\\Protego\\Protego%d.png"), 285)))) - { - return E_FAIL; - } - - if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Revelio"), - CTexture::Create(m_pDevice, m_pContext, TEXTURE_LOAD_TYPE::INCREMENTAL, TEXT("C:\\MeshTable\\SpellAnim\\Revelio\\Revelio%d.png"), 227)))) - { - return E_FAIL; - } - - if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Stupefy"), - CTexture::Create(m_pDevice, m_pContext, TEXTURE_LOAD_TYPE::INCREMENTAL, TEXT("C:\\MeshTable\\SpellAnim\\Stupefy\\Stupefy%d.png"), 222)))) - { - return E_FAIL; - } - - if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Transformation"), - CTexture::Create(m_pDevice, m_pContext, TEXTURE_LOAD_TYPE::INCREMENTAL, TEXT("C:\\MeshTable\\SpellAnim\\Transformation\\Transformation%d.png"), 146)))) - { - return E_FAIL; - } - -#pragma endregion -#endif -#pragma endregion #pragma region TERRAIN_TEXTURE /* Terrain_Diffuse */ if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Terrain_Diffuse"), @@ -1373,7 +1380,6 @@ HRESULT CLoader::Loading_For_GamePlay() return E_FAIL; } #pragma endregion - #pragma region LAKE_TEXTURE /* For.Prototype_Component_Water_Noise_D */ if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("T_Noises_D"), @@ -1510,6 +1516,7 @@ HRESULT CLoader::Loading_For_GamePlay() #pragma endregion +#pragma region SHADER m_strMessage = TEXT("셰이더를(을) 로딩 중 입니다."); @@ -1531,7 +1538,7 @@ HRESULT CLoader::Loading_For_GamePlay() return E_FAIL; } - if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, FX_INSTANCE_PROP_MODEL, + if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, FX_INSTANCE_PROP_MODEL, CShader::Create(m_pDevice, m_pContext, TEXT("../Bin/Resources/ShaderFiles/Shader_VtxWorldModelInstance.hlsl"), VTX_MODEL_INSTANCE_MODEL::Elements, VTX_MODEL_INSTANCE_MODEL::iNumElements)))) { return E_FAIL; @@ -1572,6 +1579,7 @@ HRESULT CLoader::Loading_For_GamePlay() return E_FAIL; } +#pragma endregion m_strMessage = TEXT("모델를(을) 로딩 중 입니다."); CVIBuffer_UI_Instance::UI_INSTANCE_DESC SpellSlotUIDesc{}; @@ -1820,55 +1828,57 @@ HRESULT CLoader::Loading_For_GamePlay() CModel::Create(m_pDevice, m_pContext, MODEL::PBR_ANIM, "../Bin/Resources/Models/Human/PlayableCharacter/Playable.bin", XMMatrixRotationZ(XMConvertToRadians(180.f)) * XMMatrixIdentity())))){ return E_FAIL; } + if (true == isLoad_NPC) { + if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Npc_Model"), + CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/Models/Human/Npc/Npc.bin", XMMatrixRotationY(XMConvertToRadians(180.f)) * XMMatrixIdentity())))) { + return E_FAIL; + } + if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_GerboldOlivander_Model"), + CModel::Create(m_pDevice, m_pContext, MODEL::PBR_ANIM, "../Bin/Resources/Models/Human/Npc/GerboldOllivander/GerboldOlivander.bin", XMMatrixScaling(0.01f, 0.01f, 0.01f) * XMMatrixRotationY(XMConvertToRadians(180.f)) * XMMatrixRotationZ(XMConvertToRadians(180.f)) * XMMatrixIdentity())))) { + return E_FAIL; + } - if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Npc_Model"), - CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/Models/Human/Npc/Npc.bin",XMMatrixRotationY(XMConvertToRadians(180.f)) * XMMatrixIdentity())))) { - return E_FAIL; + if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Professor_EleazarFig_Model"), + CModel::Create(m_pDevice, m_pContext, MODEL::PBR_ANIM, "../Bin/Resources/Models/Human/Npc/EleazarFig/Professor_EleazarFig.bin", XMMatrixScaling(0.01f, 0.01f, 0.01f) * XMMatrixRotationY(XMConvertToRadians(180.f)) * XMMatrixRotationZ(XMConvertToRadians(180.f)) * XMMatrixIdentity())))) { + return E_FAIL; + } + + if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_VictorRookWood_Model"), + CModel::Create(m_pDevice, m_pContext, MODEL::PBR_ANIM, "../Bin/Resources/Models/Human/Npc/VictorRookWood/VictorRookWood.bin", XMMatrixRotationY(XMConvertToRadians(180.f)) * XMMatrixIdentity())))) { + return E_FAIL; + } } + if (true == isLoad_Monster) { - if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Goblin_Model"), - CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/Models/Monster/Goblin/Goblin.bin", XMMatrixRotationY(XMConvertToRadians(180.f)) * XMMatrixIdentity())))) { - return E_FAIL; + if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Goblin_Model"), + CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/Models/Monster/Goblin/Goblin.bin", XMMatrixRotationY(XMConvertToRadians(180.f)) * XMMatrixIdentity())))) { + return E_FAIL; + } + + if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Goblin_Mage_Model"), + CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/Models/Monster/Goblin_Mage/GoblinMage.bin", XMMatrixRotationY(XMConvertToRadians(180.f)) * XMMatrixIdentity())))) + return E_FAIL; + + if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Goblin_Spector_Model"), + CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/Models/Monster/GoblinSpector/GoblinSpector.bin", XMMatrixRotationY(XMConvertToRadians(180.f)) * XMMatrixIdentity())))) + return E_FAIL; + + + if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Ghost_Peeves_Model"), + CModel::Create(m_pDevice, m_pContext, MODEL::PBR_ANIM, "../Bin/Resources/Models/Human/Npc/Ghost_Peeves/Ghost_Peeves.bin", XMMatrixScaling(0.1f, 0.1f, 0.1f) * XMMatrixRotationY(XMConvertToRadians(180.f)) * XMMatrixIdentity())))) { + return E_FAIL; + } + + if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Troll_Model"), + CModel::Create(m_pDevice, m_pContext, MODEL::PBR_ANIM, "../Bin/Resources/Models/Monster/SubTroll/troll.bin", XMMatrixRotationY(XMConvertToRadians(180.f)) * XMMatrixIdentity())))) { + return E_FAIL; + } + + if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Ranrok_Model"), + CModel::Create(m_pDevice, m_pContext, MODEL::PBR_ANIM, "../Bin/Resources/Models/Monster/ConjuredDragon/ConjuredDragon.bin", XMMatrixScaling(0.01f, 0.01f, 0.01f) * XMMatrixRotationZ(XMConvertToRadians(180.f)) * XMMatrixIdentity())))) { + return E_FAIL; + } } - - if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Goblin_Mage_Model"), - CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/Models/Monster/Goblin_Mage/GoblinMage.bin", XMMatrixRotationY(XMConvertToRadians(180.f)) * XMMatrixIdentity())))) - return E_FAIL; - - if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Goblin_Spector_Model"), - CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/Models/Monster/GoblinSpector/GoblinSpector.bin", XMMatrixRotationY(XMConvertToRadians(180.f)) * XMMatrixIdentity())))) - return E_FAIL; - - if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_GerboldOlivander_Model"), - CModel::Create(m_pDevice, m_pContext, MODEL::PBR_ANIM, "../Bin/Resources/Models/Human/Npc/GerboldOllivander/GerboldOlivander.bin", XMMatrixScaling(0.01f, 0.01f, 0.01f) * XMMatrixRotationY(XMConvertToRadians(180.f)) * XMMatrixRotationZ(XMConvertToRadians(180.f)) * XMMatrixIdentity())))) { - return E_FAIL; - } - - if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Professor_EleazarFig_Model"), - CModel::Create(m_pDevice, m_pContext, MODEL::PBR_ANIM, "../Bin/Resources/Models/Human/Npc/EleazarFig/Professor_EleazarFig.bin", XMMatrixScaling(0.01f, 0.01f, 0.01f) * XMMatrixRotationY(XMConvertToRadians(180.f)) * XMMatrixRotationZ(XMConvertToRadians(180.f)) * XMMatrixIdentity())))) { - return E_FAIL; - } - - if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_VictorRookWood_Model"), - CModel::Create(m_pDevice, m_pContext, MODEL::PBR_ANIM, "../Bin/Resources/Models/Human/Npc/VictorRookWood/VictorRookWood.bin", XMMatrixRotationY(XMConvertToRadians(180.f)) * XMMatrixIdentity())))) { - return E_FAIL; - } - - if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Ghost_Peeves_Model"), - CModel::Create(m_pDevice, m_pContext, MODEL::PBR_ANIM, "../Bin/Resources/Models/Human/Npc/Ghost_Peeves/Ghost_Peeves.bin", XMMatrixScaling(0.1f, 0.1f, 0.1f) * XMMatrixRotationY(XMConvertToRadians(180.f)) * XMMatrixIdentity())))) { - return E_FAIL; - } - - if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Troll_Model"), - CModel::Create(m_pDevice, m_pContext, MODEL::PBR_ANIM, "../Bin/Resources/Models/Monster/SubTroll/troll.bin", XMMatrixRotationY(XMConvertToRadians(180.f)) * XMMatrixIdentity())))) { - return E_FAIL; - } - - if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Ranrok_Model"), - CModel::Create(m_pDevice, m_pContext, MODEL::PBR_ANIM, "../Bin/Resources/Models/Monster/ConjuredDragon/ConjuredDragon.bin", XMMatrixScaling(0.01f, 0.01f, 0.01f) * XMMatrixRotationZ(XMConvertToRadians(180.f)) * XMMatrixIdentity())))) { - return E_FAIL; - } - #pragma endregion #pragma region ITEM diff --git a/Jusin154_Team3D/Client/Private/Player.cpp b/Jusin154_Team3D/Client/Private/Player.cpp index d293cc6fb..c5190a036 100644 --- a/Jusin154_Team3D/Client/Private/Player.cpp +++ b/Jusin154_Team3D/Client/Private/Player.cpp @@ -189,37 +189,6 @@ __super::Update(fTimeDelta); } } -void CPlayer::UpdateGrapInteractive(_float fTimeDelta) -{ - if (nullptr != m_pGrapInteractive) { - m_vGrapInteratableLerp.x += fTimeDelta; - m_pGrapInteractive->GrapToPlayer(m_pTransformCom->Get_State(STATE::POSITION) + m_pCamPosition_ShoulderPart->Get_ShoulderGlobalPos(), m_vGrapInteratableLerp.x); - if (m_vGrapInteratableLerp.x > m_vGrapInteratableLerp.y) { - m_vGrapInteratableLerp.x -= m_vGrapInteratableLerp.y; - } - } -} - -void CPlayer::Update_CameraShake(_float fTimeDelta) -{ - if (true == m_bCameraShake) { - m_vCameraShakeTimer.x += fTimeDelta; - if (m_vCameraShakeTimer.x > m_vCameraShakeTimer.y) { - m_vCameraShakeTimer.x = 0.f; - m_pCamPosition_ShoulderPart->Set_CameraShake(0.f, 0.f); - m_bCameraShake = false; - } - else { - _float fIntense = { 1.f - m_vCameraShakeTimer.x / m_vCameraShakeTimer.y }; - fIntense *= fIntense; - m_pCamPosition_ShoulderPart->Set_CameraShake( - fIntense * m_pGameInstance->Real_Random_Float(-m_fCameraShakeIntense, m_fCameraShakeIntense), - fIntense * m_pGameInstance->Real_Random_Float(-m_fCameraShakeIntense, m_fCameraShakeIntense) - ); - } - } -} - void CPlayer::Late_Update(_float fTimeDelta) { m_pTransformCom->Set_State(STATE::POSITION, m_pCharacter_Controller->Get_FootPosition()); @@ -262,21 +231,22 @@ void CPlayer::Late_Update(_float fTimeDelta) m_pTransformCom->Set_State(STATE::LOOK, look); //////////////////////////////////////////////////////////////////////////// -#ifdef 기무리 - if (nullptr == m_pRobePart) { - { - CPlayerRobe::PlayerRobe_DESC Desc{}; - Desc.pModel = m_pModelCom; - Desc.pParentTransform = m_pTransformCom; - Desc.pSocketMatrix = m_pModelCom->Get_BoneMatrixPtr("Hips_Cloth"); - if (FAILED(Add_PartObject("RobePart", g_iStaticLevel, &m_pRobePart, &Desc))) { - assert(false); - } - } - } -#endif // 기무리 +//#ifdef 기무리 +// if (nullptr == m_pRobePart) { +// { +// CPlayerRobe::PlayerRobe_DESC Desc{}; +// Desc.pModel = m_pModelCom; +// Desc.pParentTransform = m_pTransformCom; +// Desc.pSocketMatrix = m_pModelCom->Get_BoneMatrixPtr("Hips_Cloth"); +// if (FAILED(Add_PartObject("RobePart", g_iStaticLevel, &m_pRobePart, &Desc))) { +// assert(false); +// } +// } +// } +//#endif // 기무리 } + HRESULT CPlayer::Render() { if (!m_bVisible){ @@ -318,17 +288,47 @@ HRESULT CPlayer::Render() return E_FAIL; } } + Render_CameraCoordinateSystem(); + //m_pCharacter_Controller->Render(); } #ifdef _DEBUG if (RENDER::NONLIGHT == eType) { - //m_pCharacter_Controller->Render(); //m_pRigidBody->Render(); - Render_CameraCoordinateSystem(); } #endif return S_OK; } +void CPlayer::UpdateGrapInteractive(_float fTimeDelta) +{ + if (nullptr != m_pGrapInteractive) { + m_vGrapInteratableLerp.x += fTimeDelta; + m_pGrapInteractive->GrapToPlayer(m_pTransformCom->Get_State(STATE::POSITION) + m_pCamPosition_ShoulderPart->Get_ShoulderGlobalPos(), m_vGrapInteratableLerp.x); + if (m_vGrapInteratableLerp.x > m_vGrapInteratableLerp.y) { + m_vGrapInteratableLerp.x -= m_vGrapInteratableLerp.y; + } + } +} + +void CPlayer::Update_CameraShake(_float fTimeDelta) +{ + if (true == m_bCameraShake) { + m_vCameraShakeTimer.x += fTimeDelta; + if (m_vCameraShakeTimer.x > m_vCameraShakeTimer.y) { + m_vCameraShakeTimer.x = 0.f; + m_pCamPosition_ShoulderPart->Set_CameraShake(0.f, 0.f); + m_bCameraShake = false; + } + else { + _float fIntense = { 1.f - m_vCameraShakeTimer.x / m_vCameraShakeTimer.y }; + fIntense *= fIntense; + m_pCamPosition_ShoulderPart->Set_CameraShake( + fIntense * m_pGameInstance->Real_Random_Float(-m_fCameraShakeIntense, m_fCameraShakeIntense), + fIntense * m_pGameInstance->Real_Random_Float(-m_fCameraShakeIntense, m_fCameraShakeIntense) + ); + } + } +} HRESULT CPlayer::Render_Shadow(SHADOW eType) { if (FAILED(m_pShaderCom->Bind_Matrix("g_WorldMatrix", m_pTransformCom->Get_WorldMatrixPtr()))) { diff --git a/Jusin154_Team3D/Client/Private/PlayerRobe.cpp b/Jusin154_Team3D/Client/Private/PlayerRobe.cpp index c29fa7370..45f614a02 100644 --- a/Jusin154_Team3D/Client/Private/PlayerRobe.cpp +++ b/Jusin154_Team3D/Client/Private/PlayerRobe.cpp @@ -47,13 +47,25 @@ HRESULT CPlayerRobe::Render() HRESULT CPlayerRobe::Update_RobeSocketPosition() { - PSX::PxTransform pxTransform = {}; - _matrix WorldMatrix = {}; - for (_uint i = 0; i < ENUM_CLASS(PLAYER_JOINT_BONE_ORDER::END); ++i) { - pxTransform = m_pRobeJointAnchor[i]->Get_GlobalPosition(); - WorldMatrix = XMMatrixAffineTransformation(XMVectorSet(1.f, 1.f, 1.f, 0.f), XMVectorZero(), XMLoadFloat4((_float4*)&pxTransform.q), XMVectorSetW(XMLoadFloat3((_float3*)&pxTransform.p), 1.f)); - m_pModelCom->Set_BoneCombinedTransformation(PLAYER_JOINT_BONE_NAMES[i], WorldMatrix); + { + PSX::PxTransform pxTransform = {}; + _matrix WorldMatrix = {}; + _matrix OwnerInvWorldMatrix = m_pParentTransformCom->Get_WorldMatrixInv(); + for (_uint i = 0; i < ENUM_CLASS(PLAYER_JOINT_BONE_ORDER::END); ++i) { + pxTransform = m_pRobeJointAnchor[i]->Get_GlobalPosition(); + WorldMatrix = XMMatrixAffineTransformation(XMVectorSet(1.f, 1.f, 1.f, 0.f), XMVectorZero(), XMLoadFloat4((_float4*)&pxTransform.q), XMVectorSetW(XMLoadFloat3((_float3*)&pxTransform.p), 1.f)); + XMStoreFloat4x4(&m_ReconstructedJointAnchorMatirces[i], WorldMatrix * OwnerInvWorldMatrix); + } } + { + D3D11_MAPPED_SUBRESOURCE SubResource{}; + if (FAILED(m_pContext->Map(m_pBoneCombinedMatrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &SubResource))) { + return E_FAIL; + } + memcpy_s(SubResource.pData, sizeof(_float4x4) * ENUM_CLASS(PLAYER_JOINT_BONE_ORDER::END), m_ReconstructedJointAnchorMatirces, sizeof(_float4x4) * ENUM_CLASS(PLAYER_JOINT_BONE_ORDER::END)); + m_pContext->Unmap(m_pBoneCombinedMatrixBuffer, 0); + } + m_pModelCom->ComputeInsertionBoneBuffer(m_BoneInsertionDesc, m_pBoneCombinedMatrixSRV); return S_OK; } @@ -80,6 +92,34 @@ HRESULT CPlayerRobe::Helper_RouteJointGenerater(CRigidBody_Dynamic::RIGIDBODY_DY return S_OK; } +HRESULT CPlayerRobe::Create_BoneCombinedMatrixSRV() +{ + D3D11_BUFFER_DESC desc{}; + desc.Usage = D3D11_USAGE_DYNAMIC; + desc.ByteWidth = sizeof(_float4x4) * ENUM_CLASS(PLAYER_JOINT_BONE_ORDER::END); + desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; + desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + desc.StructureByteStride = sizeof(_float4x4); + desc.MiscFlags = D3D11_RESOURCE_MISC_BUFFER_STRUCTURED; + + if (FAILED(m_pDevice->CreateBuffer(&desc, nullptr, &m_pBoneCombinedMatrixBuffer))) { + return E_FAIL; + } + + D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc = {}; + srvDesc.ViewDimension = D3D11_SRV_DIMENSION_BUFFER; + srvDesc.Format = DXGI_FORMAT_UNKNOWN; + srvDesc.Buffer.FirstElement = 0; + srvDesc.Buffer.NumElements = ENUM_CLASS(PLAYER_JOINT_BONE_ORDER::END); + + + if (FAILED(m_pDevice->CreateShaderResourceView(m_pBoneCombinedMatrixBuffer, &srvDesc, &m_pBoneCombinedMatrixSRV))){ + return E_FAIL; + } + + return S_OK; +} + HRESULT CPlayerRobe::Update_LegsPosition() { @@ -200,13 +240,13 @@ HRESULT CPlayerRobe::Render_BonePhysX() }); Render_Legs(); _vector vRouteColor = CMyTools::ColorRGB_A_HEXtoVECTOR(0x0000ff, 1.f); - for (_uint i = 0; i < ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::END); ++i) { - if (nullptr != m_pRobeJointRoute[i]) { - m_pRobeJointRoute[i]->Render([this]() { - m_pContext->OMSetDepthStencilState(m_pDepthStencilStateNone, 0); - }); - } - } + //for (_uint i = 0; i < ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::END); ++i) { + // if (nullptr != m_pRobeJointRoute[i]) { + // m_pRobeJointRoute[i]->Render([this]() { + // m_pContext->OMSetDepthStencilState(m_pDepthStencilStateNone, 0); + // }); + // } + //} for (_uint i = 0; i < ENUM_CLASS(PLAYER_JOINT_BONE_ORDER::END); ++i) { m_pRobeJointAnchor[i]->Render([this]() { m_pContext->OMSetDepthStencilState(m_pDepthStencilStateNone, 0); @@ -455,6 +495,13 @@ HRESULT CPlayerRobe::Initialize(void* pArg) m_pLeftLegLocalMatrix = m_pModelCom->Get_BoneMatrixPtr("LeftLeg"); m_pRightFootLocalMatrix = m_pModelCom->Get_BoneMatrixPtr("RightFoot"); m_pRightLegLocalMatrix = m_pModelCom->Get_BoneMatrixPtr("RightLeg"); + + { + ZeroMemory(&m_BoneInsertionDesc, sizeof(m_BoneInsertionDesc)); + m_BoneInsertionDesc.iMatrixCount = ENUM_CLASS(PLAYER_JOINT_BONE_ORDER::END); + m_BoneInsertionDesc.iStartOffset = m_pModelCom->Get_BoneIndex(PLAYER_JOINT_BONE_NAMES[ENUM_CLASS(PLAYER_JOINT_BONE_ORDER::RIGHTUP)]); + } + Create_BoneCombinedMatrixSRV(); XMStoreFloat4x4(&m_PreTransformMatrix, XMLoadFloat4x4(m_pModelCom->Get_PreTransformMatrixPtr())); @@ -570,6 +617,8 @@ void CPlayerRobe::Free() #ifdef _DEBUG SAFE_RELEASE(m_pDepthStencilStateNone); #endif // _DEBUG + SAFE_RELEASE(m_pBoneCombinedMatrixSRV); + SAFE_RELEASE(m_pBoneCombinedMatrixBuffer); SAFE_RELEASE(m_pRightLeg); SAFE_RELEASE(m_pLeftLeg); SAFE_RELEASE(m_pRobeMainAnchor); diff --git a/Jusin154_Team3D/Client/Public/PlayerRobe.h b/Jusin154_Team3D/Client/Public/PlayerRobe.h index eafc1b58a..b5ab2c13a 100644 --- a/Jusin154_Team3D/Client/Public/PlayerRobe.h +++ b/Jusin154_Team3D/Client/Public/PlayerRobe.h @@ -49,6 +49,11 @@ class CPlayerRobe final : public CPartObject CRigidBody_Dynamic* m_pRobeJointRoute[ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::END)] = { nullptr }; CRigidBody_Dynamic* m_pRobeJointAnchor[ENUM_CLASS(PLAYER_JOINT_BONE_ORDER::END)] = { nullptr }; PSX::PxD6Joint* m_pDynamicJoints[ENUM_CLASS(PLAYER_JOINT_ORDER::END)] = { nullptr }; + + ID3D11Buffer* m_pBoneCombinedMatrixBuffer = { nullptr }; + ID3D11ShaderResourceView* m_pBoneCombinedMatrixSRV = { nullptr }; + + CModel::BONEINSERTION_DESC m_BoneInsertionDesc = {}; #ifdef _DEBUG unique_ptr m_pMainShape = { nullptr }; unique_ptr m_pSubShape = { nullptr }; @@ -65,6 +70,7 @@ class CPlayerRobe final : public CPartObject HRESULT Update_LegsPosition(); HRESULT Update_RobeSocketPosition(); HRESULT Helper_RouteJointGenerater(CRigidBody_Dynamic::RIGIDBODY_DYNAMIC_DESC& Desc_Body, ROUTE_DESC& Desc_Route, _matrix* xmAnchorMatricesWorld); + HRESULT Create_BoneCombinedMatrixSRV(); #ifdef _DEBUG HRESULT Render_BonePhysX(); HRESULT Render_Legs(); diff --git a/Jusin154_Team3D/Client/Public/Player_ENUM.h b/Jusin154_Team3D/Client/Public/Player_ENUM.h index 96d76f479..41b9bfd7f 100644 --- a/Jusin154_Team3D/Client/Public/Player_ENUM.h +++ b/Jusin154_Team3D/Client/Public/Player_ENUM.h @@ -43,21 +43,20 @@ static const _char* PLAYER_JOINT_BONE_NAMES[12] = { enum class PLAYER_JOINT_BONE_ORDER { RIGHTUP - , TAILUP - , LEFTUP - , RIGHT - , TAIL - , LEFT - - , RIGHTDOWNRIGHT , RIGHTDOWN + , RIGHTDOWNRIGHT - , TAILRIGHTDOWN - , TAILLEFTDOWN - + , LEFTUP + , LEFT , LEFTDOWN , LEFTDOWNLEFT + + , TAILUP + , TAIL + , TAILLEFTDOWN + , TAILRIGHTDOWN + , END }; diff --git a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_BoneCombinedInsertion_Compute.hlsl b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_BoneCombinedInsertion_Compute.hlsl new file mode 100644 index 000000000..ee1d7a957 --- /dev/null +++ b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_BoneCombinedInsertion_Compute.hlsl @@ -0,0 +1,40 @@ +struct LocalPos +{ + row_major float4x4 Combined; + row_major float4x4 Local; + row_major float4x4 LocalCombined; +}; + +struct BoneCombined +{ + row_major float4x4 BoneCombinedTransformation; +}; + +StructuredBuffer g_CombinedMatIn : register(t0); + +RWStructuredBuffer g_LocalPosOutput : register(u0); + +cbuffer BoneInsertionCB : register(b0) +{ + uint iStartOffset; + uint iMatrixCount; + uint iPad0; + uint iPad1; +}; + +[numthreads(256, 1, 1)] +void CS_MAIN(uint3 DTid : SV_DispatchThreadID) +{ + uint iBoneIndex = DTid.x; + + if (iBoneIndex >= iMatrixCount) + { + return; + } + + float4x4 CombinedMatrix = g_CombinedMatIn[iBoneIndex].BoneCombinedTransformation; + + g_LocalPosOutput[iBoneIndex+iStartOffset].LocalCombined = CombinedMatrix; + g_LocalPosOutput[iBoneIndex+iStartOffset].Combined = CombinedMatrix; + +} diff --git a/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_BoneCombinedInsertion_Compute.hlsl b/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_BoneCombinedInsertion_Compute.hlsl new file mode 100644 index 000000000..ee1d7a957 --- /dev/null +++ b/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_BoneCombinedInsertion_Compute.hlsl @@ -0,0 +1,40 @@ +struct LocalPos +{ + row_major float4x4 Combined; + row_major float4x4 Local; + row_major float4x4 LocalCombined; +}; + +struct BoneCombined +{ + row_major float4x4 BoneCombinedTransformation; +}; + +StructuredBuffer g_CombinedMatIn : register(t0); + +RWStructuredBuffer g_LocalPosOutput : register(u0); + +cbuffer BoneInsertionCB : register(b0) +{ + uint iStartOffset; + uint iMatrixCount; + uint iPad0; + uint iPad1; +}; + +[numthreads(256, 1, 1)] +void CS_MAIN(uint3 DTid : SV_DispatchThreadID) +{ + uint iBoneIndex = DTid.x; + + if (iBoneIndex >= iMatrixCount) + { + return; + } + + float4x4 CombinedMatrix = g_CombinedMatIn[iBoneIndex].BoneCombinedTransformation; + + g_LocalPosOutput[iBoneIndex+iStartOffset].LocalCombined = CombinedMatrix; + g_LocalPosOutput[iBoneIndex+iStartOffset].Combined = CombinedMatrix; + +} diff --git a/Jusin154_Team3D/Engine/Default/Engine.vcxproj b/Jusin154_Team3D/Engine/Default/Engine.vcxproj index 7f862f739..474a61c1c 100644 --- a/Jusin154_Team3D/Engine/Default/Engine.vcxproj +++ b/Jusin154_Team3D/Engine/Default/Engine.vcxproj @@ -627,6 +627,10 @@ call Update_Lib.bat + + Effect + 5.0 + Effect 5.0 diff --git a/Jusin154_Team3D/Engine/Default/Engine.vcxproj.filters b/Jusin154_Team3D/Engine/Default/Engine.vcxproj.filters index fd08bd1c2..324a02417 100644 --- a/Jusin154_Team3D/Engine/Default/Engine.vcxproj.filters +++ b/Jusin154_Team3D/Engine/Default/Engine.vcxproj.filters @@ -1356,5 +1356,8 @@ 99.Define\01.SHADER + + 99.Define\01.SHADER + \ No newline at end of file diff --git a/Jusin154_Team3D/Engine/Private/Model.cpp b/Jusin154_Team3D/Engine/Private/Model.cpp index 8669113bf..7a1e27f61 100644 --- a/Jusin154_Team3D/Engine/Private/Model.cpp +++ b/Jusin154_Team3D/Engine/Private/Model.cpp @@ -1507,6 +1507,34 @@ HRESULT CModel::Create_ComputeShaderLocal() return S_OK; } +HRESULT CModel::Create_ComputeShaderBoneInsertion() +{ + _uint CS_InputStrides[] = { + sizeof(_float4x4) + }; + + _uint CS_OutputStrides[] = { + sizeof(BONE_DESC), + }; + + CComputeShader::CS_INFO CS_Desc = {}; + + CS_Desc.iNumElement = (_uint)m_Bones.size(); + CS_Desc.iNumInputBuffer = 1; + CS_Desc.iNumOutputBuffer = 1; + + CS_Desc.iInputStructStride = CS_InputStrides; + CS_Desc.iOutputStructStride = CS_OutputStrides; + + m_pCS_BoneInsertion = (CComputeShader*)m_pGameInstance->Clone_Asset_Prototype(g_iStaticLevel, CS_BONEINSERT, &CS_Desc, nullptr); + + if (nullptr == m_pCS_BoneInsertion) { + return E_FAIL; + } + + return S_OK; +} + HRESULT CModel::Create_Temp() { for (auto& anim : m_Animations) @@ -1632,18 +1660,28 @@ HRESULT CModel::Create_BoneMatrixVB() HRESULT CModel::Create_Const() { + { + D3D11_BUFFER_DESC cbDesc = {}; + cbDesc.Usage = D3D11_USAGE_DYNAMIC; + cbDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; + cbDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + cbDesc.ByteWidth = sizeof(ANIMSTATE_DESC); - D3D11_BUFFER_DESC cbDesc = {}; - cbDesc.Usage = D3D11_USAGE_DYNAMIC; - cbDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; - cbDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - cbDesc.ByteWidth = sizeof(ANIMSTATE_DESC); - - D3D11_SUBRESOURCE_DATA CBInitialDesc = {}; - - if (FAILED(m_pDevice->CreateBuffer(&cbDesc, nullptr, &m_pConstantBuffer))) - return E_FAIL; + if (FAILED(m_pDevice->CreateBuffer(&cbDesc, nullptr, &m_pConstantBuffer))){ + return E_FAIL; + } + } + { + D3D11_BUFFER_DESC cbDesc = {}; + cbDesc.Usage = D3D11_USAGE_DYNAMIC; + cbDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; + cbDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + cbDesc.ByteWidth = sizeof(BONEINSERTION_DESC); + if (FAILED(m_pDevice->CreateBuffer(&cbDesc, nullptr, &m_pInsertionCB))) { + return E_FAIL; + } + } return S_OK; } @@ -1879,6 +1917,55 @@ void CModel::ComputeLocal(_uint AnimIndex, _uint MeshIndex) } +void CModel::ComputeInsertionBoneBuffer(BONEINSERTION_DESC& CBDesc, ID3D11ShaderResourceView* pSRV) +{ + if (m_pComputeShader == nullptr){ + return; + } + + D3D11_MAPPED_SUBRESOURCE ConstantSubResource = {}; + + if (SUCCEEDED(m_pContext->Map(m_pInsertionCB, 0, D3D11_MAP_WRITE_DISCARD, 0, &ConstantSubResource))) + { + BONEINSERTION_DESC* pDesc = static_cast(ConstantSubResource.pData); + memcpy_s(pDesc, sizeof(BONEINSERTION_DESC), &CBDesc, sizeof(BONEINSERTION_DESC)); + m_pContext->Unmap(m_pInsertionCB, 0); + } + + ID3D11ShaderResourceView* srvs[] = + { + pSRV, + }; + + ID3D11UnorderedAccessView* uavs[] = + { + m_pBoneMatrixUAV + }; + _uint iThreadPerX = 256; + _uint iGroupCountX = (CBDesc.iMatrixCount + iThreadPerX - 1) / iThreadPerX; + if (iGroupCountX == 0) { + iGroupCountX = 1; + } + + m_pCS_BoneInsertion->Dispatch_ExternalSRV_UAV( + 0, + 0, + _float3((_float)iGroupCountX, 1.f, 1.f), + srvs, + 1, + uavs, + 1, + m_pInsertionCB + ); + + ID3D11UnorderedAccessView* nullUAV[1] = { nullptr }; + UINT counts[1] = { 0 }; + m_pContext->CSSetUnorderedAccessViews(0, 1, nullUAV, counts); + + ID3D11ShaderResourceView* nullSRV[1] = { nullptr }; + m_pContext->CSSetShaderResources(0, 1, nullSRV); +} + void CModel::Bind_OutPut_SRV_VS(_uint iIndex, _uint iBufferIndex) { @@ -2360,6 +2447,10 @@ HRESULT CModel::Initialize(void* pArg) return E_FAIL; } + if (FAILED(Create_ComputeShaderBoneInsertion())){ + return E_FAIL; + } + for (int i = 0; i < m_Meshes.size(); i++) { if (1 < m_Meshes[i]->Get_NumBone()) { @@ -2480,6 +2571,7 @@ void CModel::Free() SAFE_RELEASE(m_pComputeShader); SAFE_RELEASE(m_pCS_AnimLocal); + SAFE_RELEASE(m_pCS_BoneInsertion); SAFE_RELEASE(m_pConstantBuffer); SAFE_RELEASE(m_pParentBuffer); SAFE_RELEASE(m_pBoneLocalBuffer); @@ -2487,6 +2579,7 @@ void CModel::Free() SAFE_RELEASE(m_pPrevBoneMatrixBuffer); SAFE_RELEASE(m_pSkipBoneBuffer); SAFE_RELEASE(m_pLocalMatrixBuffer); + SAFE_RELEASE(m_pInsertionCB); SAFE_RELEASE(m_pParentSRV); SAFE_RELEASE(m_pBoneLocalSRV); SAFE_RELEASE(m_pBoneMatrixSRV); diff --git a/Jusin154_Team3D/Engine/Private/Prototype_Manager.cpp b/Jusin154_Team3D/Engine/Private/Prototype_Manager.cpp index 9c22da455..6039d2a5f 100644 --- a/Jusin154_Team3D/Engine/Private/Prototype_Manager.cpp +++ b/Jusin154_Team3D/Engine/Private/Prototype_Manager.cpp @@ -147,7 +147,6 @@ HRESULT CPrototype_Manager::Ready_EngineAssets() CComputeShader::Create(m_pDevice, m_pContext, L"../Bin/Resources/ShaderFiles/Shader_Instance_Compute.hlsl", "CS_MAIN")))) { return E_FAIL; - } if (FAILED(Add_Asset_Prototype(g_iStaticLevel, CS_MODEL, @@ -161,7 +160,12 @@ HRESULT CPrototype_Manager::Ready_EngineAssets() CComputeShader::Create(m_pDevice, m_pContext, L"../Bin/Resources/ShaderFiles/Shader_Local_Compute.hlsl", "CS_LOCAL")))) { return E_FAIL; + } + if (FAILED(Add_Asset_Prototype(g_iStaticLevel, CS_BONEINSERT, + CComputeShader::Create(m_pDevice, m_pContext, + L"../Bin/Resources/ShaderFiles/Shader_BoneCombinedInsertion_Compute.hlsl", "CS_MAIN")))) { + return E_FAIL; } #pragma endregion diff --git a/Jusin154_Team3D/Engine/Public/Engine_Macro.h b/Jusin154_Team3D/Engine/Public/Engine_Macro.h index b4c869e2e..0b13bccea 100644 --- a/Jusin154_Team3D/Engine/Public/Engine_Macro.h +++ b/Jusin154_Team3D/Engine/Public/Engine_Macro.h @@ -98,6 +98,7 @@ #define CS_INSTANCE_MODEL TEXT("CS_INSTANCE_MODEL") #define CS_MODEL TEXT("CS_MODEL") #define CS_LOCAL TEXT("CS_LOCAL") +#define CS_BONEINSERT TEXT("CS_BONEINSERT") #define SAFE_ADDREF(pInstance) Safe_AddRef(pInstance) diff --git a/Jusin154_Team3D/Engine/Public/Model.h b/Jusin154_Team3D/Engine/Public/Model.h index 29b5c508f..ee2050e3d 100644 --- a/Jusin154_Team3D/Engine/Public/Model.h +++ b/Jusin154_Team3D/Engine/Public/Model.h @@ -36,6 +36,12 @@ class ENGINE_DLL CModel final : public CComponent _float4 RootInitRot; }ANIMSTATE_DESC; + typedef struct tagBoneInsertionDesc { + _uint iStartOffset; + _uint iMatrixCount; + _uint iPad0; + _uint iPad1; + }BONEINSERTION_DESC; private: @@ -116,14 +122,15 @@ class ENGINE_DLL CModel final : public CComponent HRESULT Begin(_uint iMeshIndex, class CShader* pShader, _bool OutLine = false); #pragma endregion - void ComputeAnimation(_uint AnimIndex, _uint MeshIndex); - void ComputeLocal(_uint AnimIndex, _uint MeshIndex); - void Bind_OutPut_SRV_VS(_uint iIndex, _uint iBufferIndex); - void Bind_OutPut_SRV_VS_Prev(_uint iIndex, _uint iBufferIndex); - void ComputeAnimation_Second(_uint AnimIndex); - void InItialize_BoneIndex(); + void ComputeAnimation(_uint AnimIndex, _uint MeshIndex); + void ComputeLocal(_uint AnimIndex, _uint MeshIndex); + void ComputeInsertionBoneBuffer(BONEINSERTION_DESC& CBDesc, ID3D11ShaderResourceView* pSRV); + void Bind_OutPut_SRV_VS(_uint iIndex, _uint iBufferIndex); + void Bind_OutPut_SRV_VS_Prev(_uint iIndex, _uint iBufferIndex); + void ComputeAnimation_Second(_uint AnimIndex); + void InItialize_BoneIndex(); - void Initialize_BoneMasks(); + void Initialize_BoneMasks(); public: HRESULT Ready_PhysXMeshes(_fmatrix& PreTransformMatrix, _uint iLevel); @@ -234,6 +241,7 @@ class ENGINE_DLL CModel final : public CComponent private: HRESULT Create_ComputeShader(); HRESULT Create_ComputeShaderLocal(); + HRESULT Create_ComputeShaderBoneInsertion(); HRESULT Create_ParentVB(); HRESULT Create_BoneLocalVB(); HRESULT Create_SkipBoneVB(); @@ -245,7 +253,7 @@ class ENGINE_DLL CModel final : public CComponent HRESULT Create_Local(); - _uint m_iNumBuffer = {}; + _uint m_iNumBuffer = {}; vector<_int> m_Parent = {}; vector<_float4x4> m_BoneLocal = {}; @@ -255,6 +263,7 @@ class ENGINE_DLL CModel final : public CComponent class CComputeShader* m_pComputeShader = nullptr; class CComputeShader* m_pCS_AnimLocal = nullptr; + class CComputeShader* m_pCS_BoneInsertion = nullptr; ID3D11Buffer* m_pConstantBuffer = { nullptr }; ID3D11Buffer* m_pParentBuffer = { nullptr }; @@ -263,7 +272,7 @@ class ENGINE_DLL CModel final : public CComponent ID3D11Buffer* m_pBoneLocalBuffer = { nullptr }; ID3D11Buffer* m_pSkipBoneBuffer = { nullptr }; ID3D11Buffer* m_pLocalMatrixBuffer = { nullptr }; - + ID3D11Buffer* m_pInsertionCB = { nullptr }; ID3D11ShaderResourceView* m_pParentSRV = { nullptr }; ID3D11ShaderResourceView* m_pBoneLocalSRV = { nullptr }; From 53934ad2218f54c6fb449b65cf732aa1359770a2 Mon Sep 17 00:00:00 2001 From: kimnuri Date: Mon, 29 Dec 2025 17:30:02 +0900 Subject: [PATCH 2/3] [add] OutLine_DSS [fix] XMLPass --- .../Client/Private/BroomRacerAI.cpp | 2 +- .../Client/Private/Goblin_Assassin.cpp | 22 ++- Jusin154_Team3D/Client/Private/Monster.cpp | 10 +- Jusin154_Team3D/Client/Private/Player.cpp | 2 +- Jusin154_Team3D/Client/Private/Ranrok.cpp | 84 +++++++++++- Jusin154_Team3D/Client/Private/Troll.cpp | 19 ++- Jusin154_Team3D/Client/Public/Client_Enum.h | 2 +- Jusin154_Team3D/Client/Public/Ranrok.h | 1 + .../Npc/EleazarFig/Professor_EleazarFig.xml | 2 +- .../EleazarFig/Professor_EleazarFig_Anim.xml | 2 +- .../Monster/ConjuredDragon/ConjuredDragon.xml | 16 +-- .../ShaderFiles/Shader_NPC_PBR_Anim.hlsl | 128 ++---------------- .../Editor/Private/DummyObject.cpp | 2 +- Jusin154_Team3D/Editor/Private/Ranrok.cpp | 18 ++- Jusin154_Team3D/Editor/Public/Editor_Define.h | 2 +- .../Engine/Private/GameInstance.cpp | 12 +- Jusin154_Team3D/Engine/Private/Model.cpp | 9 +- Jusin154_Team3D/Engine/Private/PipeLine.cpp | 54 +++++++- Jusin154_Team3D/Engine/Public/GameInstance.h | 2 + Jusin154_Team3D/Engine/Public/Model.h | 2 +- Jusin154_Team3D/Engine/Public/PipeLine.h | 13 +- 21 files changed, 240 insertions(+), 164 deletions(-) diff --git a/Jusin154_Team3D/Client/Private/BroomRacerAI.cpp b/Jusin154_Team3D/Client/Private/BroomRacerAI.cpp index d2f1f3c84..68bcb4d7e 100644 --- a/Jusin154_Team3D/Client/Private/BroomRacerAI.cpp +++ b/Jusin154_Team3D/Client/Private/BroomRacerAI.cpp @@ -174,7 +174,7 @@ HRESULT CBroomRacerAI::Render() } if (m_pModelCom->Get_Type() == MODEL::PBR_ANIM) { - if (FAILED(m_pModelCom->Begin(i, m_pShaderCom, false))) { + if (FAILED(m_pModelCom->Begin(i, m_pShaderCom))) { return E_FAIL; } diff --git a/Jusin154_Team3D/Client/Private/Goblin_Assassin.cpp b/Jusin154_Team3D/Client/Private/Goblin_Assassin.cpp index 9f2534bdf..59b0b8394 100644 --- a/Jusin154_Team3D/Client/Private/Goblin_Assassin.cpp +++ b/Jusin154_Team3D/Client/Private/Goblin_Assassin.cpp @@ -175,16 +175,23 @@ HRESULT CGoblin_Assassin::Render() return E_FAIL; } - if (FAILED(m_pModelCom->Begin(i, m_pShaderCom, m_bDrawOutLine))) { + if (FAILED(m_pModelCom->Begin(i, m_pShaderCom))) { return E_FAIL; } m_pModelCom->Bind_OutPut_SRV_VS(26, 0); m_pModelCom->Bind_OutPut_SRV_VS_Prev(27, 0); + if (true == m_bDrawOutLine) { + m_pGameInstance->Begin_OutLine_Write(2); + } if (FAILED(m_pModelCom->Render(i))) { return E_FAIL; } + + if (true == m_bDrawOutLine) { + m_pGameInstance->End_OutLine_Write(); + } } if (true == m_bDrawOutLine) { @@ -222,13 +229,16 @@ HRESULT CGoblin_Assassin::Render_OutLine() } Compute_Depth(); - _float fRatio = (m_fCamDepth / *m_pGameInstance->Get_CurrentCameraFar()); + _float fRatio = CMyTools::Saturate((m_fCamDepth / *m_pGameInstance->Get_CurrentCameraFar())); m_fOutLineThickness = CMyTools::Lerp_f1D(0.01f, 0.1f, fRatio); - if (m_fOutLineThickness > 0.1f) { - m_fOutLineThickness = 0.1f; + if (FAILED(m_pShaderCom->Bind_Matrix("g_PrevWorldMatrix", m_pTransformCom->Get_PrevWorldMatrixPtr()))) { + return E_FAIL; } - else if (m_fOutLineThickness < 0.01f) { - m_fOutLineThickness = 0.01f; + if (FAILED(m_pGameInstance->Bind_PrevMatrix(m_pShaderCom, "g_PrevViewMatrix", D3DTS::VIEW))) { + return E_FAIL; + } + if (FAILED(m_pGameInstance->Bind_PrevMatrix(m_pShaderCom, "g_PrevProjMatrix", D3DTS::PROJ))) { + return E_FAIL; } if (FAILED(m_pShaderCom->Bind_RawValue("g_vOutLineColor", &m_vOutLineColor, sizeof(_float3)))) { return E_FAIL; diff --git a/Jusin154_Team3D/Client/Private/Monster.cpp b/Jusin154_Team3D/Client/Private/Monster.cpp index 965bc70d3..953e311b3 100644 --- a/Jusin154_Team3D/Client/Private/Monster.cpp +++ b/Jusin154_Team3D/Client/Private/Monster.cpp @@ -28,7 +28,7 @@ HRESULT CMonster::Initialize(void* pArg) } m_pInfoInstance->Regist_ActiveMonster(this); - + return S_OK; } @@ -115,14 +115,8 @@ HRESULT CMonster::Render_OutLine() return E_FAIL; } Compute_Depth(); - _float fRatio = (m_fCamDepth / *m_pGameInstance->Get_CurrentCameraFar()); + _float fRatio = CMyTools::Saturate((m_fCamDepth / *m_pGameInstance->Get_CurrentCameraFar())); m_fOutLineThickness = CMyTools::Lerp_f1D(2.f, 6.f, fRatio); - if (m_fOutLineThickness > 6.f) { - m_fOutLineThickness = 6.f; - } - else if (m_fOutLineThickness < 2.f) { - m_fOutLineThickness = 2.f; - } if (FAILED(m_pShaderCom->Bind_RawValue("g_vOutLineColor", &m_vOutLineColor, sizeof(_float3)))) { return E_FAIL; } diff --git a/Jusin154_Team3D/Client/Private/Player.cpp b/Jusin154_Team3D/Client/Private/Player.cpp index 70979be40..9a2eaae22 100644 --- a/Jusin154_Team3D/Client/Private/Player.cpp +++ b/Jusin154_Team3D/Client/Private/Player.cpp @@ -273,7 +273,7 @@ HRESULT CPlayer::Render() { return E_FAIL; } - if (FAILED(m_pModelCom->Begin(i, m_pShaderCom, false))) { + if (FAILED(m_pModelCom->Begin(i, m_pShaderCom))) { return E_FAIL; } diff --git a/Jusin154_Team3D/Client/Private/Ranrok.cpp b/Jusin154_Team3D/Client/Private/Ranrok.cpp index 14f0c98b0..fafcd5096 100644 --- a/Jusin154_Team3D/Client/Private/Ranrok.cpp +++ b/Jusin154_Team3D/Client/Private/Ranrok.cpp @@ -436,16 +436,23 @@ HRESULT CRanrok::Render_Nonblend() if (FAILED(m_pModelCom->Bind_Material(i, m_pShaderCom))) { return E_FAIL; } - if (FAILED(m_pModelCom->Begin(i, m_pShaderCom, m_bDrawOutLine))) { + if (FAILED(m_pModelCom->Begin(i, m_pShaderCom))) { return E_FAIL; } m_pModelCom->Bind_OutPut_SRV_VS(26, 0); m_pModelCom->Bind_OutPut_SRV_VS_Prev(27, 0); + if (true == m_bDrawOutLine) { + m_pGameInstance->Begin_OutLine_Write(2); + } if (FAILED(m_pModelCom->Render(i))) { return E_FAIL; } + + if (true == m_bDrawOutLine) { + m_pGameInstance->End_OutLine_Write(); + } } if (m_bDrawOutLine) { @@ -498,7 +505,79 @@ HRESULT CRanrok::Render_Blend() if (FAILED(m_pModelCom->Bind_Material(i, m_pShaderCom))) { return E_FAIL; } - if (FAILED(m_pModelCom->Begin(i, m_pShaderCom, m_bDrawOutLine))) { + if (FAILED(m_pModelCom->Begin(i, m_pShaderCom))) { + return E_FAIL; + } + + m_pModelCom->Bind_OutPut_SRV_VS(26, 0); + m_pModelCom->Bind_OutPut_SRV_VS_Prev(27, 0); + + if (true == m_bDrawOutLine) { + m_pGameInstance->Begin_OutLine_Write(2); + } + if (FAILED(m_pModelCom->Render(i))) { + return E_FAIL; + } + + if (true == m_bDrawOutLine) { + m_pGameInstance->End_OutLine_Write(); + } + } + + return S_OK; +} +HRESULT CRanrok::Render_OutLine() +{ + m_bDrawOutLine = false; + if (FAILED(Bind_ShaderResources())) { + return E_FAIL; + } + + Compute_Depth(); + _float fRatio = CMyTools::Saturate((m_fCamDepth / *m_pGameInstance->Get_CurrentCameraFar())); + m_fOutLineThickness = CMyTools::Lerp_f1D(2.f, 6.f, fRatio); + if (FAILED(m_pShaderCom->Bind_Matrix("g_PrevWorldMatrix", m_pTransformCom->Get_PrevWorldMatrixPtr()))) { + return E_FAIL; + } + if (FAILED(m_pGameInstance->Bind_PrevMatrix(m_pShaderCom, "g_PrevViewMatrix", D3DTS::VIEW))) { + return E_FAIL; + } + if (FAILED(m_pGameInstance->Bind_PrevMatrix(m_pShaderCom, "g_PrevProjMatrix", D3DTS::PROJ))) { + return E_FAIL; + } + if (FAILED(m_pShaderCom->Bind_RawValue("g_vOutLineColor", &m_vOutLineColor, sizeof(_float3)))) { + return E_FAIL; + } + if (FAILED(m_pShaderCom->Bind_RawValue("g_fOutLineThickness", &m_fOutLineThickness, sizeof(_float)))) { + return E_FAIL; + } + if (FAILED(m_pShaderCom->Bind_RawValue("g_fOutLineScale", &m_fOutLineScale, sizeof(_float)))) { + return E_FAIL; + } + if (FAILED(m_pShaderCom->Bind_RawValue("g_fOutLinePower", &m_fOutLinePower, sizeof(_float)))) { + return E_FAIL; + } + if (FAILED(m_pShaderCom->Bind_RawValue("g_vCamPosition", m_pGameInstance->Get_CamPosition(), sizeof(_float4)))) { + return E_FAIL; + } + _uint iNumMeshes = m_pModelCom->Get_NumMeshes(); + + for (_uint i = 0; i < iNumMeshes; i++) + { + if (FAILED(m_pShaderCom->Bind_Matrices( + "g_OffsetMatrix", + m_pModelCom->Get_OffsetMatrix(i).data(), + (_int)m_pModelCom->Get_OffsetMatrix(i).size() + ))) + { + return E_FAIL; + } + + if (FAILED(m_pModelCom->Bind_Material(i, m_pShaderCom))) { + return E_FAIL; + } + + if (FAILED(m_pShaderCom->Begin(ENUM_CLASS(SHADER_PASS_NPC_PBR_ANIM::OUTLINE_READ)))) { return E_FAIL; } @@ -509,7 +588,6 @@ HRESULT CRanrok::Render_Blend() return E_FAIL; } } - return S_OK; } diff --git a/Jusin154_Team3D/Client/Private/Troll.cpp b/Jusin154_Team3D/Client/Private/Troll.cpp index 68ba708b4..2b2a8d415 100644 --- a/Jusin154_Team3D/Client/Private/Troll.cpp +++ b/Jusin154_Team3D/Client/Private/Troll.cpp @@ -197,16 +197,24 @@ HRESULT CTroll::Render() return E_FAIL; } - if (FAILED(m_pModelCom->Begin(i, m_pShaderCom, m_bDrawOutLine))) { + if (FAILED(m_pModelCom->Begin(i, m_pShaderCom))) { return E_FAIL; } m_pModelCom->Bind_OutPut_SRV_VS(26, 0); m_pModelCom->Bind_OutPut_SRV_VS_Prev(27, 0); + + if (true == m_bDrawOutLine) { + m_pGameInstance->Begin_OutLine_Write(2); + } if (FAILED(m_pModelCom->Render(i))) { return E_FAIL; } + + if (true == m_bDrawOutLine) { + m_pGameInstance->End_OutLine_Write(); + } } if (true == m_bDrawOutLine) { @@ -252,6 +260,15 @@ HRESULT CTroll::Render_OutLine() else if (m_fOutLineThickness < 2.f) { m_fOutLineThickness = 2.f; } + if (FAILED(m_pShaderCom->Bind_Matrix("g_PrevWorldMatrix", m_pTransformCom->Get_PrevWorldMatrixPtr()))) { + return E_FAIL; + } + if (FAILED(m_pGameInstance->Bind_PrevMatrix(m_pShaderCom, "g_PrevViewMatrix", D3DTS::VIEW))) { + return E_FAIL; + } + if (FAILED(m_pGameInstance->Bind_PrevMatrix(m_pShaderCom, "g_PrevProjMatrix", D3DTS::PROJ))) { + return E_FAIL; + } if (FAILED(m_pShaderCom->Bind_RawValue("g_vOutLineColor", &m_vOutLineColor, sizeof(_float3)))) { return E_FAIL; } diff --git a/Jusin154_Team3D/Client/Public/Client_Enum.h b/Jusin154_Team3D/Client/Public/Client_Enum.h index 4c825a93d..8a40d9c90 100644 --- a/Jusin154_Team3D/Client/Public/Client_Enum.h +++ b/Jusin154_Team3D/Client/Public/Client_Enum.h @@ -25,7 +25,7 @@ namespace Client enum class SHADER_PASS_NPC_PBR_ANIM { EYELASH_DAOTHV_ToSRO, TEETH_SRXO_ToSRO, EYE_DN_ToSRO, EYE_OCC, FACIAL_HAIR_DAOTHV_ToSRO, HEAD_HAIR_DAOTHV_ToSRO, HEADwtHAND_DSRXON_ToSRO, LOWER_DSRON_ToSRO, UPPER_DMRON_ToMRO, GLASSES_DMRON_ToMRO, EmissiveMetalness_DENMRO_ToMRO, MI_ClothSim_DSEN_ToSRO, MI_Troll_Club_DAENMROSRXO_To - , OUTLINE_READ, TEETH_SRXO_ToSRO__OUTLINE_WRITE, EYE_DN_ToSRO__OUTLINE_WRITE, HEADwtHAND_DSRXON_ToSRO__OUTLINE_WRITE, UPPER_DMRON_ToMRO__OUTLINE_WRITE, EmissiveMetalness_DENMRO_ToMRO__OUTLINE_WRITE, MI_ClothSim_DSEN_ToSRO__OUTLINE_WRITE + , OUTLINE_READ , END }; enum class UI_STATE { GAMEPLAYER, SPELL, QUEST, INVENTORY, SPELLLNEARN, END }; diff --git a/Jusin154_Team3D/Client/Public/Ranrok.h b/Jusin154_Team3D/Client/Public/Ranrok.h index 464ed9958..b2f6cf838 100644 --- a/Jusin154_Team3D/Client/Public/Ranrok.h +++ b/Jusin154_Team3D/Client/Public/Ranrok.h @@ -48,6 +48,7 @@ class CRanrok final : public CMonster virtual void Update(_float fTimeDelta) override; virtual void Late_Update(_float fTimeDelta) override; virtual HRESULT Render() override; + virtual HRESULT Render_OutLine() override; virtual HRESULT Render_Shadow(SHADOW eType) override; virtual _vector Get_LockOnPos() override; virtual void OnCollision(CGameObject* pOther = nullptr, void* pDesc = nullptr)override; diff --git a/Jusin154_Team3D/Editor/Bin/Resources/Models/Human/Npc/EleazarFig/Professor_EleazarFig.xml b/Jusin154_Team3D/Editor/Bin/Resources/Models/Human/Npc/EleazarFig/Professor_EleazarFig.xml index 63a17c1c2..c41c58940 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/Models/Human/Npc/EleazarFig/Professor_EleazarFig.xml +++ b/Jusin154_Team3D/Editor/Bin/Resources/Models/Human/Npc/EleazarFig/Professor_EleazarFig.xml @@ -173,7 +173,7 @@ - + diff --git a/Jusin154_Team3D/Editor/Bin/Resources/Models/Human/Npc/EleazarFig/Professor_EleazarFig_Anim.xml b/Jusin154_Team3D/Editor/Bin/Resources/Models/Human/Npc/EleazarFig/Professor_EleazarFig_Anim.xml index 63a17c1c2..ca2a1c2a6 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/Models/Human/Npc/EleazarFig/Professor_EleazarFig_Anim.xml +++ b/Jusin154_Team3D/Editor/Bin/Resources/Models/Human/Npc/EleazarFig/Professor_EleazarFig_Anim.xml @@ -173,7 +173,7 @@ - + diff --git a/Jusin154_Team3D/Editor/Bin/Resources/Models/Monster/ConjuredDragon/ConjuredDragon.xml b/Jusin154_Team3D/Editor/Bin/Resources/Models/Monster/ConjuredDragon/ConjuredDragon.xml index b82a6a608..52cde6bca 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/Models/Monster/ConjuredDragon/ConjuredDragon.xml +++ b/Jusin154_Team3D/Editor/Bin/Resources/Models/Monster/ConjuredDragon/ConjuredDragon.xml @@ -1,5 +1,5 @@ - + @@ -28,7 +28,7 @@ - + @@ -57,7 +57,7 @@ - + @@ -86,7 +86,7 @@ - + @@ -115,7 +115,7 @@ - + @@ -144,7 +144,7 @@ - + @@ -173,7 +173,7 @@ - + @@ -202,7 +202,7 @@ - + diff --git a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_NPC_PBR_Anim.hlsl b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_NPC_PBR_Anim.hlsl index 5ad2199ac..0786c3caa 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_NPC_PBR_Anim.hlsl +++ b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_NPC_PBR_Anim.hlsl @@ -1334,62 +1334,7 @@ technique11 DefaultTechnique GeometryShader = NULL; PixelShader = compile ps_5_0 PS_MAIN_OUTLINE_READ(); } - pass TEETH_SRXO_ToSRO__OUTLINE_WRITE // 14 - { - SetRasterizerState(RS_Default); - SetDepthStencilState(DSS_Default_OutLine_SWrite, 2); - SetBlendState(BS_None, 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_TEETH_SRXO_ToSRO(); - } - pass EYE_DN_ToSRO__OUTLINE_WRITE // 15 - { - SetRasterizerState(RS_Default); - SetDepthStencilState(DSS_Default_OutLine_SWrite, 2); - SetBlendState(BS_None, 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_EYE_DN_SRO(); - } - pass HEADwtHAND_DSRXON_ToSRO__OUTLINE_WRITE // 16 - { - SetRasterizerState(RS_Default); - SetDepthStencilState(DSS_Default_OutLine_SWrite, 2); - SetBlendState(BS_None, 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_HEADwtHAND_DSRXON_ToSRO(); - } - pass UPPER_DMRON_ToMRO__OUTLINE_WRITE // 17 - { - SetRasterizerState(RS_Default); - SetDepthStencilState(DSS_Default_OutLine_SWrite, 2); - SetBlendState(BS_None, 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_UPPER_DMRON_ToMRO(); - } - pass EmissiveMetalness_DENMRO_ToMRO__OUTLINE_WRITE // 18 - { - SetRasterizerState(RS_Default); - SetDepthStencilState(DSS_Default_OutLine_SWrite, 2); - SetBlendState(BS_None, 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_EmissiveMetalness_DENMRO_ToMRO(); - } - pass MI_ClothSim_DSEN_ToSRO__OUTLINE_WRITE // 19 - { - SetRasterizerState(RS_Default); - SetDepthStencilState(DSS_Default_OutLine_SWrite, 2); - SetBlendState(BS_None, 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_MI_ClothSim_DSEN_ToSRO(); - } -/////// - pass MI_DANSROMRO_ToSRO // 20 + pass MI_DANSROMRO_ToSRO // 14 { SetRasterizerState(RS_Default); SetDepthStencilState(DSS_Default, 0); @@ -1398,26 +1343,8 @@ technique11 DefaultTechnique GeometryShader = NULL; PixelShader = compile ps_5_0 PS_MI_DANSROMRO_ToSRO(); } - pass MI_DANSROMRO_ToSRO_OUTLINE_WRITE // 21 - { - SetRasterizerState(RS_Default); - SetDepthStencilState(DSS_Default_OutLine_SWrite, 2); - SetBlendState(BS_None, 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_MI_DANSROMRO_ToSRO(); - } - pass DNMRO_ToMRO__OUTLINE_WRITE // 22 - { - SetRasterizerState(RS_Default); - SetDepthStencilState(DSS_Default_OutLine_SWrite, 2); - SetBlendState(BS_None, 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_DNMRO_ToMRO(); - } //// DRAGON - pass DragonAuraPass // 23 + pass DragonAuraPass // 15 { SetRasterizerState(RS_Default); SetDepthStencilState(DSS_Default, 0); @@ -1426,7 +1353,7 @@ technique11 DefaultTechnique GeometryShader = NULL; PixelShader = compile ps_5_0 PS_Dragon_Aura(); } - pass DragonEtherealEyesPass // 24 + pass DragonEtherealEyesPass // 16 { SetRasterizerState(RS_Default); SetDepthStencilState(DSS_Default, 0); @@ -1435,16 +1362,7 @@ technique11 DefaultTechnique GeometryShader = NULL; PixelShader = compile ps_5_0 PS_Dragon_EtherealEyes(); } - pass DragonEtherealEyes_OUTLINE_WRITEPass // 25 - { - SetRasterizerState(RS_Default); - SetDepthStencilState(DSS_Default_OutLine_SWrite, 2); - 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_Dragon_EtherealEyes(); - } - pass DragonEtherealWingsPass // 26 + pass DragonEtherealWingsPass // 17 { SetRasterizerState(RS_Default); SetDepthStencilState(DSS_Default, 0); @@ -1453,7 +1371,7 @@ technique11 DefaultTechnique GeometryShader = NULL; PixelShader = compile ps_5_0 PS_Dragon_EtherealWings(); } - pass DragonWingsPass // 27 + pass DragonWingsPass // 18 { SetRasterizerState(RS_Default); SetDepthStencilState(DSS_Default, 0); @@ -1462,16 +1380,7 @@ technique11 DefaultTechnique GeometryShader = NULL; PixelShader = compile ps_5_0 PS_Dragon_Wings(); } - pass DragonWings_OUTLINE_WRITEPass // 28 - { - SetRasterizerState(RS_Default); - SetDepthStencilState(DSS_Default_OutLine_SWrite, 2); - SetBlendState(BS_None, 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_Dragon_Wings(); - } - pass DragonBodyPass // 29 + pass DragonBodyPass // 19 { SetRasterizerState(RS_Default); SetDepthStencilState(DSS_Default, 0); @@ -1480,16 +1389,7 @@ technique11 DefaultTechnique GeometryShader = NULL; PixelShader = compile ps_5_0 PS_Dragon_Body(); } - pass DragonBody_OUTLINE_WRITEPass // 30 - { - SetRasterizerState(RS_Default); - SetDepthStencilState(DSS_Default_OutLine_SWrite, 2); - SetBlendState(BS_None, 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_Dragon_Body(); - } - pass DragonRedHotPass // 31 + pass DragonRedHotPass // 20 { SetRasterizerState(RS_Default); SetDepthStencilState(DSS_Default, 0); @@ -1498,7 +1398,7 @@ technique11 DefaultTechnique GeometryShader = NULL; PixelShader = compile ps_5_0 PS_Dragon_RedHot(); } - pass DragonPinkHotPass // 32 + pass DragonPinkHotPass // 21 { SetRasterizerState(RS_Default); SetDepthStencilState(DSS_Default, 0); @@ -1507,7 +1407,7 @@ technique11 DefaultTechnique GeometryShader = NULL; PixelShader = compile ps_5_0 PS_Dragon_PinkHot(); } - pass DragonYellowHotPass // 33 + pass DragonYellowHotPass // 22 { SetRasterizerState(RS_Default); SetDepthStencilState(DSS_Default, 0); @@ -1517,7 +1417,7 @@ technique11 DefaultTechnique PixelShader = compile ps_5_0 PS_Dragon_YellowHot(); } //// PLAYER_ - pass PLAYER_HAIR_DAOTHV_ToSRO // 34 + pass PLAYER_HAIR_DAOTHV_ToSRO // 23 { SetRasterizerState(RS_Default); SetDepthStencilState(DSS_Default, 0); @@ -1526,7 +1426,7 @@ technique11 DefaultTechnique GeometryShader = NULL; PixelShader = compile ps_5_0 PS_Player_HairDAOTHV_ToSRO(); } - pass PLAYER_Suit_DSRON_ToSRO // 35 + pass PLAYER_Suit_DSRON_ToSRO // 24 { SetRasterizerState(RS_Default); SetDepthStencilState(DSS_Default, 0); @@ -1535,7 +1435,7 @@ technique11 DefaultTechnique GeometryShader = NULL; PixelShader = compile ps_5_0 PS_Player_Suit_DSRON_ToSRO(); } - pass PLAYER_EyeLash_DAOTHV_ToSRO // 36 + pass PLAYER_EyeLash_DAOTHV_ToSRO // 25 { SetRasterizerState(RS_Default); SetDepthStencilState(DSS_Default, 0); @@ -1544,7 +1444,7 @@ technique11 DefaultTechnique GeometryShader = NULL; PixelShader = compile ps_5_0 PS_Player_EyeLash_DAOTHV_ToSRO(); } - pass PLAYER_Eye_ToSRO // 37 + pass PLAYER_Eye_ToSRO // 26 { SetRasterizerState(RS_Default); SetDepthStencilState(DSS_Default, 0); @@ -1553,7 +1453,7 @@ technique11 DefaultTechnique GeometryShader = NULL; PixelShader = compile ps_5_0 PS_Player_Eye_ToMRO(); } - pass PLAYER_Robe_ToMRO // 38 + pass PLAYER_Robe_ToMRO // 27 { SetRasterizerState(RS_Default); SetDepthStencilState(DSS_Default, 0); diff --git a/Jusin154_Team3D/Editor/Private/DummyObject.cpp b/Jusin154_Team3D/Editor/Private/DummyObject.cpp index 41616f309..5924e3c82 100644 --- a/Jusin154_Team3D/Editor/Private/DummyObject.cpp +++ b/Jusin154_Team3D/Editor/Private/DummyObject.cpp @@ -84,7 +84,7 @@ HRESULT CDummyObject::Render() if (m_pModelCom->Get_Type() == MODEL::PBR_ANIM) { - if (FAILED(m_pModelCom->Begin(i, m_pShaderCom, false))) { + if (FAILED(m_pModelCom->Begin(i, m_pShaderCom))) { return E_FAIL; } diff --git a/Jusin154_Team3D/Editor/Private/Ranrok.cpp b/Jusin154_Team3D/Editor/Private/Ranrok.cpp index ae6d38f6f..8ad10ca23 100644 --- a/Jusin154_Team3D/Editor/Private/Ranrok.cpp +++ b/Jusin154_Team3D/Editor/Private/Ranrok.cpp @@ -418,16 +418,23 @@ HRESULT CRanrok::Render_Nonblend() if (FAILED(m_pModelCom->Bind_Material(i, m_pShaderCom))) { return E_FAIL; } - if (FAILED(m_pModelCom->Begin(i, m_pShaderCom, m_bDrawOutLine))) { + if (FAILED(m_pModelCom->Begin(i, m_pShaderCom))) { return E_FAIL; } m_pModelCom->Bind_OutPut_SRV_VS(26, 0); m_pModelCom->Bind_OutPut_SRV_VS_Prev(27, 0); + if (true == m_bDrawOutLine) { + m_pGameInstance->Begin_OutLine_Write(2); + } if (FAILED(m_pModelCom->Render(i))) { return E_FAIL; } + + if (true == m_bDrawOutLine) { + m_pGameInstance->End_OutLine_Write(); + } } if (m_bDrawOutLine) { @@ -480,16 +487,23 @@ HRESULT CRanrok::Render_Blend() if (FAILED(m_pModelCom->Bind_Material(i, m_pShaderCom))) { return E_FAIL; } - if (FAILED(m_pModelCom->Begin(i, m_pShaderCom, m_bDrawOutLine))) { + if (FAILED(m_pModelCom->Begin(i, m_pShaderCom))) { return E_FAIL; } m_pModelCom->Bind_OutPut_SRV_VS(26, 0); m_pModelCom->Bind_OutPut_SRV_VS_Prev(27, 0); + if (true == m_bDrawOutLine) { + m_pGameInstance->Begin_OutLine_Write(2); + } if (FAILED(m_pModelCom->Render(i))) { return E_FAIL; } + + if (true == m_bDrawOutLine) { + m_pGameInstance->End_OutLine_Write(); + } } return S_OK; diff --git a/Jusin154_Team3D/Editor/Public/Editor_Define.h b/Jusin154_Team3D/Editor/Public/Editor_Define.h index 0c933939a..9d74c1d76 100644 --- a/Jusin154_Team3D/Editor/Public/Editor_Define.h +++ b/Jusin154_Team3D/Editor/Public/Editor_Define.h @@ -20,7 +20,7 @@ namespace Editor enum class SHADER_PASS_ANIM { DEFAULT, SHADOW, CAPTURE, BLUR, HAIR, EYELASH, OUTLINE_WRITE, OUTLINE_READ, SPECTOR, END }; enum class SHADER_PASS_NPC_PBR_ANIM { EYELASH_DAOTHV_ToSRO, TEETH_SRXO_ToSRO, EYE_DN_ToSRO, EYE_OCC, FACIAL_HAIR_DAOTHV_ToSRO, HEAD_HAIR_DAOTHV_ToSRO, HEADwtHAND_DSRXON_ToSRO, LOWER_DSRON_ToSRO, UPPER_DMRON_ToMRO, GLASSES_DMRON_ToMRO, EmissiveMetalness_DENMRO_ToMRO, MI_ClothSim_DSEN_ToSRO, MI_Troll_Club_DAENMROSRXO_To - , OUTLINE_READ, TEETH_SRXO_ToSRO__OUTLINE_WRITE, EYE_DN_ToSRO__OUTLINE_WRITE, HEADwtHAND_DSRXON_ToSRO__OUTLINE_WRITE, UPPER_DMRON_ToMRO__OUTLINE_WRITE, EmissiveMetalness_DENMRO_ToMRO__OUTLINE_WRITE, MI_ClothSim_DSEN_ToSRO__OUTLINE_WRITE + , OUTLINE_READ , END}; enum class SHADER_PASS_MESH { DEFAULT, SHADOW, SKYBOX, ALPHABLEND, EFFECT_ALPHABLEND, EFFECT_BLEND, EFFECT_ALPHABLEND_CULL, EFFECT_BLEND_CULL, CAPTURE, BLUR, EFFECT_ALPHABLEND_UVMOVE, MAPTOOL, GLASS, OUTLINE_WRITE, OUTLINE_READ, BLOOM, LAKE, END }; enum class SHADER_PASS_NORTEX { DEFAULT, TERRAIN, ENV_TERRAIN_ANISO, SHADOW, END }; diff --git a/Jusin154_Team3D/Engine/Private/GameInstance.cpp b/Jusin154_Team3D/Engine/Private/GameInstance.cpp index d6d82f0ac..92764d4e5 100644 --- a/Jusin154_Team3D/Engine/Private/GameInstance.cpp +++ b/Jusin154_Team3D/Engine/Private/GameInstance.cpp @@ -82,7 +82,7 @@ HRESULT CGameInstance::Initialize_Engine(const ENGINE_DESC& EngineDesc, ID3D11De if (nullptr == m_pKey_Manager) { return E_FAIL; } - m_pPipeLine = CPipeLine::Create(); + m_pPipeLine = CPipeLine::Create(*ppDevice, *ppContext); if (nullptr == m_pPipeLine) { return E_FAIL; } @@ -794,6 +794,16 @@ _float CGameInstance::Get_ShadowBoxFar(_uint iShadowBoxIndex) return m_pPipeLine->Get_ShadowBoxFar(iShadowBoxIndex); } +HRESULT CGameInstance::Begin_OutLine_Write(_uint iDSSRef) +{ + return m_pPipeLine->Begin_OutLine_Write(iDSSRef); +} + +HRESULT CGameInstance::End_OutLine_Write() +{ + return m_pPipeLine->End_OutLine_Write(); +} + void CGameInstance::Add_Light(_uint _iCurrentLevel, CLight* _pLight) { m_pLight_Manager->Add_Light(_iCurrentLevel, _pLight); diff --git a/Jusin154_Team3D/Engine/Private/Model.cpp b/Jusin154_Team3D/Engine/Private/Model.cpp index 748494f1d..a9784e5a2 100644 --- a/Jusin154_Team3D/Engine/Private/Model.cpp +++ b/Jusin154_Team3D/Engine/Private/Model.cpp @@ -95,7 +95,7 @@ HRESULT CModel::Bind_Material(_uint iMeshIndex, CShader* pShader) return m_Materials[iMaterialIndex]->Bind_SRV(pShader, m_eType); } -HRESULT CModel::Begin(_uint iMeshIndex, CShader* pShader, _bool OutLine) +HRESULT CModel::Begin(_uint iMeshIndex, CShader* pShader) { if (iMeshIndex >= m_iNumMeshes) { return E_FAIL; @@ -107,12 +107,7 @@ HRESULT CModel::Begin(_uint iMeshIndex, CShader* pShader, _bool OutLine) return E_FAIL; } HRESULT hr = { E_FAIL }; - if (false == OutLine) { - hr = pShader->Begin(m_Materials[iMaterialIndex]->Get_UsingPass()); - } - else { - hr = pShader->Begin(m_Materials[iMaterialIndex]->Get_OutLinePass()); - } + hr = pShader->Begin(m_Materials[iMaterialIndex]->Get_UsingPass()); return hr; } diff --git a/Jusin154_Team3D/Engine/Private/PipeLine.cpp b/Jusin154_Team3D/Engine/Private/PipeLine.cpp index 9647912da..cbbf27b7c 100644 --- a/Jusin154_Team3D/Engine/Private/PipeLine.cpp +++ b/Jusin154_Team3D/Engine/Private/PipeLine.cpp @@ -3,9 +3,13 @@ #include "Shader.h" #include "GameInstance.h" -CPipeLine::CPipeLine() - :m_pGameInstance(CGameInstance::GetInstance()) +CPipeLine::CPipeLine(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) + : m_pDevice{ pDevice } + , m_pContext{ pContext } + , m_pGameInstance{ CGameInstance::GetInstance() } { + SAFE_ADDREF(m_pDevice); + SAFE_ADDREF(m_pContext); SAFE_ADDREF(m_pGameInstance); } @@ -150,6 +154,20 @@ HRESULT CPipeLine::Load_GlobalSRV(const _tchar* wszKeyGlobalSRV, filesystem::pat return S_OK; } +HRESULT CPipeLine::Begin_OutLine_Write(_uint iDSSRef) +{ + m_pContext->OMGetDepthStencilState(&m_pPrevDSS, &m_iPrevDSSRef); + m_pContext->OMSetDepthStencilState(m_pDSS_OutLineWrite, iDSSRef); + return S_OK; +} + +HRESULT CPipeLine::End_OutLine_Write() +{ + m_pContext->OMSetDepthStencilState(m_pPrevDSS, m_iPrevDSSRef); + SAFE_RELEASE(m_pPrevDSS); + return S_OK; +} + HRESULT CPipeLine::Ready_Shadow_Light(const _float4& vShadowDirRPYQuat) { _vector vShadowQuat = XMQuaternionNormalize(XMLoadFloat4(&vShadowDirRPYQuat)); @@ -256,6 +274,30 @@ HRESULT CPipeLine::Initialize() XMStoreFloat4x4(&m_TransformStateMatrices[i], XMMatrixIdentity()); } + if (nullptr == m_pDSS_OutLineWrite) { + D3D11_DEPTH_STENCIL_DESC depthStencilDescription{}; + depthStencilDescription.DepthEnable = TRUE; + depthStencilDescription.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL; // true에 해당 + depthStencilDescription.DepthFunc = D3D11_COMPARISON_LESS_EQUAL; // less_equal + + depthStencilDescription.StencilEnable = TRUE; + depthStencilDescription.StencilReadMask = 0xFF; + depthStencilDescription.StencilWriteMask = 0xFF; + + // FrontFace + depthStencilDescription.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP; + depthStencilDescription.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP; + depthStencilDescription.FrontFace.StencilPassOp = D3D11_STENCIL_OP_REPLACE; // Replace + depthStencilDescription.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS; // Always + + // BackFace + depthStencilDescription.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP; + depthStencilDescription.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP; + depthStencilDescription.BackFace.StencilPassOp = D3D11_STENCIL_OP_REPLACE; + depthStencilDescription.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS; + m_pDevice->CreateDepthStencilState(&depthStencilDescription, &m_pDSS_OutLineWrite); + } + return S_OK; } @@ -440,9 +482,9 @@ ID3D11ShaderResourceView* CPipeLine::Find_GlobalShaderResourceView(const _tchar* return (*iter).second; } -CPipeLine* CPipeLine::Create() +CPipeLine* CPipeLine::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) { - CPipeLine* pInstance = new CPipeLine(); + CPipeLine* pInstance = new CPipeLine(pDevice, pContext); if (FAILED(pInstance->Initialize())) { @@ -455,6 +497,10 @@ CPipeLine* CPipeLine::Create() void CPipeLine::Free() { __super::Free(); + SAFE_RELEASE(m_pDevice); + SAFE_RELEASE(m_pContext); + SAFE_RELEASE(m_pDSS_OutLineWrite); + SAFE_RELEASE(m_pGameInstance); for (auto& pairSRV : m_mapGlobalSRV) { SAFE_RELEASE(pairSRV.second); } diff --git a/Jusin154_Team3D/Engine/Public/GameInstance.h b/Jusin154_Team3D/Engine/Public/GameInstance.h index 18535b8c0..bcc4eb697 100644 --- a/Jusin154_Team3D/Engine/Public/GameInstance.h +++ b/Jusin154_Team3D/Engine/Public/GameInstance.h @@ -151,6 +151,8 @@ class ENGINE_DLL CGameInstance final : public CBase HRESULT Bind_Shadow_Resource(class CShader* pShader, const _char* pConstantName, D3DTS eType, SHADOW eShadowType) const; const _float4x4* Get_ShadowMatricesPtr(_uint iShadowBoxIndex); _float Get_ShadowBoxFar(_uint iShadowBoxIndex); + HRESULT Begin_OutLine_Write(_uint iDSSMask); + HRESULT End_OutLine_Write(); #pragma endregion #pragma region LIGHT_MANAGER void Add_Light(_uint _iCurrentLevel, class CLight* _pLight); diff --git a/Jusin154_Team3D/Engine/Public/Model.h b/Jusin154_Team3D/Engine/Public/Model.h index a633231c9..d1d36466f 100644 --- a/Jusin154_Team3D/Engine/Public/Model.h +++ b/Jusin154_Team3D/Engine/Public/Model.h @@ -121,7 +121,7 @@ class ENGINE_DLL CModel final : public CComponent #pragma endregion #pragma region Material HRESULT Bind_Material(_uint iMeshIndex, class CShader* pShader); - HRESULT Begin(_uint iMeshIndex, class CShader* pShader, _bool OutLine = false); + HRESULT Begin(_uint iMeshIndex, class CShader* pShader); #pragma endregion void ComputeAnimation(_uint AnimIndex, _uint MeshIndex); diff --git a/Jusin154_Team3D/Engine/Public/PipeLine.h b/Jusin154_Team3D/Engine/Public/PipeLine.h index 5a3557e6d..d03bc8752 100644 --- a/Jusin154_Team3D/Engine/Public/PipeLine.h +++ b/Jusin154_Team3D/Engine/Public/PipeLine.h @@ -21,7 +21,7 @@ cascade class CPipeLine final : public CBase { private: - CPipeLine(); + CPipeLine(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); virtual ~CPipeLine() = default; public: void Set_Transform(D3DTS eState, _fmatrix TransformStateMatrix); @@ -43,6 +43,9 @@ class CPipeLine final : public CBase HRESULT Bind_GlobalSRV(class CShader* pShader, const _tchar* wszKeyGlobalSRV, const _char* pConstantName); HRESULT Load_GlobalSRV(const _tchar* wszKeyGlobalSRV, filesystem::path pathSRVFolder); + HRESULT Begin_OutLine_Write(_uint iDSSRef); + HRESULT End_OutLine_Write(); + HRESULT Ready_Shadow_Light(const _float4& vShadowDirRPYQuat); HRESULT Bind_Shadow_Resource(class CShader* pShader, const _char* pConstantName, D3DTS eType, SHADOW eShadowType) const; const _float4x4* Get_ShadowMatricesPtr(_uint iShadowBoxIndex); @@ -51,6 +54,8 @@ class CPipeLine final : public CBase void Update(); // Objects의 Priority, Update사이에서 불려야만 함 private: + ID3D11Device* m_pDevice = { nullptr }; + ID3D11DeviceContext* m_pContext = { nullptr }; class CGameInstance* m_pGameInstance = { nullptr }; _float4x4 m_TransformStateMatrices[ENUM_CLASS(D3DTS::END)] = {}; _float4x4 m_ShadowTransformStateMatrices[3][ENUM_CLASS(D3DTS::END)] = {}; @@ -83,6 +88,10 @@ class CPipeLine final : public CBase _float4 m_vShadowInvDirectionalRPYQuat = { 0.f, 0.f, 0.f, 1.f }; unordered_map<_wstring, ID3D11ShaderResourceView*> m_mapGlobalSRV = {}; + ID3D11DepthStencilState* m_pDSS_OutLineWrite = { nullptr }; + ID3D11DepthStencilState* m_pPrevDSS = { nullptr }; + _uint m_iPrevDSSRef = { }; + private: HRESULT Initialize(); void Make_Planes(const _float4* pPoints, _float4* pPlanes); @@ -93,7 +102,7 @@ class CPipeLine final : public CBase ID3D11ShaderResourceView* Find_GlobalShaderResourceView(const _tchar* wszKeyGlobalSRV); public: - static CPipeLine* Create(); + static CPipeLine* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); virtual void Free() override; #ifdef _DEBUG virtual void Describe_Entity(); From 203f908ca584ae95df11c76154b7b55ab6eb3109 Mon Sep 17 00:00:00 2001 From: Chanbin Kim <127280695+JinhoBa@users.noreply.github.com> Date: Mon, 29 Dec 2025 17:34:13 +0900 Subject: [PATCH 3/3] =?UTF-8?q?[add]=20Volumetic=20PointLight=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20[add]=20Volumetic=20Fog=20=EB=86=92=EC=9D=B4=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Jusin154_Team3D/Client/Private/Light_Main.cpp | 2 + .../ShaderFiles/Engine_Shader_Functions.hlsli | 18 +-- .../Shader_Volumetric_Accumulate.hlsl | 11 +- .../Shader_Volumetric_Compute.hlsl | 92 +++++++++--- .../ShaderFiles/Shader_VtxAnimMesh.hlsl | 4 - Jusin154_Team3D/Editor/Private/MainLight.cpp | 1 + .../ShaderFiles/Engine_Shader_Functions.hlsli | 18 +-- .../Shader_Volumetric_Accumulate.hlsl | 11 +- .../Shader_Volumetric_Compute.hlsl | 92 +++++++++--- .../Engine/Private/GameInstance.cpp | 24 +++ .../Engine/Private/Light_Manager.cpp | 8 + Jusin154_Team3D/Engine/Private/PipeLine.cpp | 17 +++ .../Engine/Private/RenderTarget_Manager.cpp | 10 ++ Jusin154_Team3D/Engine/Private/Volumetric.cpp | 141 ++++++++++++++++-- Jusin154_Team3D/Engine/Public/GameInstance.h | 7 +- Jusin154_Team3D/Engine/Public/Light_Manager.h | 3 +- Jusin154_Team3D/Engine/Public/PipeLine.h | 1 + .../Engine/Public/RenderTarget_Manager.h | 2 +- Jusin154_Team3D/Engine/Public/Volumetric.h | 35 ++++- 19 files changed, 407 insertions(+), 90 deletions(-) diff --git a/Jusin154_Team3D/Client/Private/Light_Main.cpp b/Jusin154_Team3D/Client/Private/Light_Main.cpp index b98709d0d..4a6a16f7a 100644 --- a/Jusin154_Team3D/Client/Private/Light_Main.cpp +++ b/Jusin154_Team3D/Client/Private/Light_Main.cpp @@ -90,6 +90,8 @@ HRESULT CLight_Main::Capture_PreShadow() _float4x4 ProjMatrix = {}; XMStoreFloat4x4(&ProjMatrix, Get_OffCenterProjMatrix(xmViewMatrix, vNeededPos)); m_pGameInstance->Render_PreShadow(ViewMatrix, ProjMatrix); + + m_pGameInstance->Update_Volumetric(); return S_OK; } diff --git a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Engine_Shader_Functions.hlsli b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Engine_Shader_Functions.hlsli index 7eb0dd87f..18416faf2 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Engine_Shader_Functions.hlsli +++ b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Engine_Shader_Functions.hlsli @@ -557,23 +557,23 @@ float2 CalcVelocityUV(float4 vCurrentProjPos, float4 vPreviousProjPos, float fIn float3 DownSampleFast(Texture2D SrcTexture2D, float2 vCenterTexcoord, float2 vSrcTexelSize, float2 vResolution) { float2 uv = float2(0.f, 0.f); - float3 vCenterColor = SrcTexture2D.SampleLevel(BorderZeroSampler, vCenterTexcoord, 0); + float3 vCenterColor = SrcTexture2D.SampleLevel(BorderZeroSampler, vCenterTexcoord, 0).rgb; uv = vCenterTexcoord + vSrcTexelSize * float2(-1.0, -1.0); - float3 fLTColor = BilinearFetches(vResolution, SrcTexture2D, uv, BorderZeroSampler); + float3 fLTColor = BilinearFetches(vResolution, SrcTexture2D, uv, BorderZeroSampler).rgb; uv = vCenterTexcoord + vSrcTexelSize * float2(0.0, -1.0); - float3 fTColor = SrcTexture2D.SampleLevel(BorderZeroSampler, uv, 0); + float3 fTColor = SrcTexture2D.SampleLevel(BorderZeroSampler, uv, 0).rgb; uv = vCenterTexcoord + vSrcTexelSize * float2(+1.0, -1.0); - float3 fRTColor = BilinearFetches(vResolution, SrcTexture2D, uv, BorderZeroSampler); + float3 fRTColor = BilinearFetches(vResolution, SrcTexture2D, uv, BorderZeroSampler).rgb; uv = vCenterTexcoord + vSrcTexelSize * float2(-1.0, 0.0); - float3 fLColor = SrcTexture2D.SampleLevel(BorderZeroSampler, uv, 0); + float3 fLColor = SrcTexture2D.SampleLevel(BorderZeroSampler, uv, 0).rgb; uv = vCenterTexcoord + vSrcTexelSize * float2(1.0, 0.0); - float3 fRColor = SrcTexture2D.SampleLevel(BorderZeroSampler, uv, 0); + float3 fRColor = SrcTexture2D.SampleLevel(BorderZeroSampler, uv, 0).rgb; uv = vCenterTexcoord + vSrcTexelSize * float2(-1.0, +1.0); - float3 fLBColor = BilinearFetches(vResolution, SrcTexture2D, uv, BorderZeroSampler); + float3 fLBColor = BilinearFetches(vResolution, SrcTexture2D, uv, BorderZeroSampler).rgb; uv = vCenterTexcoord + vSrcTexelSize * float2(0.0, 1.0); - float3 fBColor = SrcTexture2D.SampleLevel(BorderZeroSampler, uv, 0); + float3 fBColor = SrcTexture2D.SampleLevel(BorderZeroSampler, uv, 0).rgb; uv = vCenterTexcoord + vSrcTexelSize * float2(+1.0, +1.0); - float3 fRBColor = BilinearFetches(vResolution, SrcTexture2D, uv, BorderZeroSampler); + float3 fRBColor = BilinearFetches(vResolution, SrcTexture2D, uv, BorderZeroSampler).rgb; return vCenterColor * 0.25f + (fLTColor + fRTColor + fLBColor + fRBColor) * 0.0625f + (fTColor + fLColor + fRColor + fBColor) * 0.125f; } diff --git a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_Volumetric_Accumulate.hlsl b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_Volumetric_Accumulate.hlsl index aa5694dfa..37f3b0529 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_Volumetric_Accumulate.hlsl +++ b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_Volumetric_Accumulate.hlsl @@ -28,11 +28,14 @@ cbuffer g_ConstantBuffer : register(b0) // b0 << 이 숫자와 컨스턴트 쉐 row_major matrix InvProjMatrix; row_major matrix InvViewMatrix; + row_major matrix ShadowViewMatrix; + row_major matrix ShadowViewProjMatrix; + float fAsymmetryParameter; - float padding0; - float padding1; - float padding2; -} + uint iNumLight; + float fHeightOffset; + float fBaseHeight; +}; float ConvertNdcZToDepth(float ndcZ); float SliceTickness(float ndcZ, uint dimZ); diff --git a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_Volumetric_Compute.hlsl b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_Volumetric_Compute.hlsl index b602fc1e4..b732abfe0 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_Volumetric_Compute.hlsl +++ b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_Volumetric_Compute.hlsl @@ -5,16 +5,17 @@ static const float EPSILON = 1e-6f; struct LightData { - uint itype; - float3 vDirection; - - float3 vPosition; - float fRange; - - float4 vColor; + float3 vDirection; + float fRange; + float4 vPosition; + float4 vDiffuse; }; -//StructuredBuffer g_LightBuffer : register(t1); +StructuredBuffer g_LightBuffer : register(t0); +Texture2D g_ShadowMap : register(t1); +Texture2D NoiseTexture : register(t2); + +SamplerState g_Sampler : register(s0); RWTexture3D g_VolumeUAV : register(u0); @@ -39,18 +40,22 @@ cbuffer g_ConstantBuffer : register(b0) // b0 << 이 숫자와 컨스턴트 쉐 row_major matrix InvProjMatrix; row_major matrix InvViewMatrix; + row_major matrix ShadowViewMatrix; + row_major matrix ShadowViewProjMatrix; + float fAsymmetryParameter; - float padding0; - float padding1; - float padding2; -} + uint iNumLight; + float fHeightOffset; + float fBaseHeight; +}; float3 ConvertThreadIdToNdc(uint3 id, uint3 dims); float ConvertNdcZToDepth(float ndcZ); float3 ConvertToWorldPosition(float3 ndc, float depth); float3 ConvertThreadIdToWorldPosition(uint3 id, uint3 dims); float HenyeyGreensteinPhaseFunction(float3 vInputDir, float3 vOutputDir, float fAnisotropy); - +float ComputePointLightVisible(float3 vLightDir, float fRange); +float ComputeShadowVisibility(float3 vWorldPosition); // 볼륨 텍스쳐 밀도, 산란 계산 [numthreads(8, 8, 4)] void CS_MAIN( uint3 DispatchThreadID : SV_DispatchThreadID) @@ -60,18 +65,40 @@ void CS_MAIN( uint3 DispatchThreadID : SV_DispatchThreadID) if (!all(DispatchThreadID < dims)) return; - float3 worldPosition = ConvertThreadIdToWorldPosition(DispatchThreadID, dims); - float3 toCamera = normalize(vCameraPosition - worldPosition); + float3 vWorldPosition = ConvertThreadIdToWorldPosition(DispatchThreadID, dims); + float3 toCamera = normalize(vCameraPosition - vWorldPosition); - float3 lighting = vLightColor.rgb * vLightColor.a; - float3 lightDir = normalize(vLightDirection); - float3 toLight = -lightDir; + float3 lighting = float3(0.1f, 0.1f, 0.1f); //vLightColor.rgb * vLightColor.a; - float phase = HenyeyGreensteinPhaseFunction(lightDir, toCamera, fAsymmetryParameter); + float3 lightDir = float3(0.f, 0.f, 0.f); - lighting += vLightColor.rgb * vLightColor.rgb * phase; + [loop] + for (uint i = 0; i < iNumLight; ++i) + { + float visibility = 1.f; + + if (0.f < length(g_LightBuffer[i].vDirection)) + { + lightDir = normalize(g_LightBuffer[i].vDirection); + visibility = ComputeShadowVisibility(vWorldPosition); - g_VolumeUAV[DispatchThreadID] = float4(lighting * fLightIntensity * fDensity, fDensity); + } + else + { + lightDir = vWorldPosition - g_LightBuffer[i].vPosition.xyz; + visibility = ComputePointLightVisible(lightDir, g_LightBuffer[i].fRange); + lightDir = normalize(lightDir); + } + + float3 toLight = -lightDir; + float phase = HenyeyGreensteinPhaseFunction(lightDir, toCamera, fAsymmetryParameter); + + lighting += g_LightBuffer[i].vDiffuse.rgb * g_LightBuffer[i].vDiffuse.a * phase * visibility; + } + + float fHeightDensity = max(0.1f, exp(-(vWorldPosition.y - fBaseHeight) * fHeightOffset)) * fDensity; + + g_VolumeUAV[DispatchThreadID] = float4(lighting * fLightIntensity * fHeightDensity, fHeightDensity); } float3 ConvertThreadIdToNdc(uint3 id, uint3 dims) @@ -109,3 +136,26 @@ float HenyeyGreensteinPhaseFunction(float3 vInputDir, float3 vOutputDir, float f float denom = pow(1.f + (fAsymmetryParameter * fAsymmetryParameter) - 2.f * fAsymmetryParameter * cosTheta, 3.f / 2.f); return (1.f / (4.f * PI)) * ((1.f - (fAsymmetryParameter * fAsymmetryParameter)) / max(denom, EPSILON)); } + +float ComputePointLightVisible(float3 vLightDir, float fRange) +{ + float fDistance = length(vLightDir); + + if (fDistance < fRange) + return 1.f; + else + return 0.f; +} + +float ComputeShadowVisibility(float3 vWorldPosition) +{ + float4 vShadowCoord = mul(float4(vWorldPosition, 1.f), ShadowViewProjMatrix); + float3 DepthUV = vShadowCoord.xyz / vShadowCoord.w; + + DepthUV.x = DepthUV.x * 0.5f + 0.5f; + DepthUV.y = DepthUV.y * -0.5f + 0.5f; + + //float fNoise = NoiseTexture.SampleLevel(g_Sampler, DepthUV.xy, 4).r; + + return 1.f; +} diff --git a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_VtxAnimMesh.hlsl b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_VtxAnimMesh.hlsl index d52149768..7dd932afd 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_VtxAnimMesh.hlsl +++ b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_VtxAnimMesh.hlsl @@ -88,10 +88,6 @@ float g_fUsingSurfaceParams; matrix g_BoneMatrices[512]; - - - - struct VS_IN { float3 vPosition : POSITION; diff --git a/Jusin154_Team3D/Editor/Private/MainLight.cpp b/Jusin154_Team3D/Editor/Private/MainLight.cpp index 4c9169cf2..18e0ffc3a 100644 --- a/Jusin154_Team3D/Editor/Private/MainLight.cpp +++ b/Jusin154_Team3D/Editor/Private/MainLight.cpp @@ -118,6 +118,7 @@ void CMainLight::Update(_float fTimeDelta) void CMainLight::Late_Update(_float fTimeDelta) { + } HRESULT CMainLight::Render() diff --git a/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Engine_Shader_Functions.hlsli b/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Engine_Shader_Functions.hlsli index 7eb0dd87f..18416faf2 100644 --- a/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Engine_Shader_Functions.hlsli +++ b/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Engine_Shader_Functions.hlsli @@ -557,23 +557,23 @@ float2 CalcVelocityUV(float4 vCurrentProjPos, float4 vPreviousProjPos, float fIn float3 DownSampleFast(Texture2D SrcTexture2D, float2 vCenterTexcoord, float2 vSrcTexelSize, float2 vResolution) { float2 uv = float2(0.f, 0.f); - float3 vCenterColor = SrcTexture2D.SampleLevel(BorderZeroSampler, vCenterTexcoord, 0); + float3 vCenterColor = SrcTexture2D.SampleLevel(BorderZeroSampler, vCenterTexcoord, 0).rgb; uv = vCenterTexcoord + vSrcTexelSize * float2(-1.0, -1.0); - float3 fLTColor = BilinearFetches(vResolution, SrcTexture2D, uv, BorderZeroSampler); + float3 fLTColor = BilinearFetches(vResolution, SrcTexture2D, uv, BorderZeroSampler).rgb; uv = vCenterTexcoord + vSrcTexelSize * float2(0.0, -1.0); - float3 fTColor = SrcTexture2D.SampleLevel(BorderZeroSampler, uv, 0); + float3 fTColor = SrcTexture2D.SampleLevel(BorderZeroSampler, uv, 0).rgb; uv = vCenterTexcoord + vSrcTexelSize * float2(+1.0, -1.0); - float3 fRTColor = BilinearFetches(vResolution, SrcTexture2D, uv, BorderZeroSampler); + float3 fRTColor = BilinearFetches(vResolution, SrcTexture2D, uv, BorderZeroSampler).rgb; uv = vCenterTexcoord + vSrcTexelSize * float2(-1.0, 0.0); - float3 fLColor = SrcTexture2D.SampleLevel(BorderZeroSampler, uv, 0); + float3 fLColor = SrcTexture2D.SampleLevel(BorderZeroSampler, uv, 0).rgb; uv = vCenterTexcoord + vSrcTexelSize * float2(1.0, 0.0); - float3 fRColor = SrcTexture2D.SampleLevel(BorderZeroSampler, uv, 0); + float3 fRColor = SrcTexture2D.SampleLevel(BorderZeroSampler, uv, 0).rgb; uv = vCenterTexcoord + vSrcTexelSize * float2(-1.0, +1.0); - float3 fLBColor = BilinearFetches(vResolution, SrcTexture2D, uv, BorderZeroSampler); + float3 fLBColor = BilinearFetches(vResolution, SrcTexture2D, uv, BorderZeroSampler).rgb; uv = vCenterTexcoord + vSrcTexelSize * float2(0.0, 1.0); - float3 fBColor = SrcTexture2D.SampleLevel(BorderZeroSampler, uv, 0); + float3 fBColor = SrcTexture2D.SampleLevel(BorderZeroSampler, uv, 0).rgb; uv = vCenterTexcoord + vSrcTexelSize * float2(+1.0, +1.0); - float3 fRBColor = BilinearFetches(vResolution, SrcTexture2D, uv, BorderZeroSampler); + float3 fRBColor = BilinearFetches(vResolution, SrcTexture2D, uv, BorderZeroSampler).rgb; return vCenterColor * 0.25f + (fLTColor + fRTColor + fLBColor + fRBColor) * 0.0625f + (fTColor + fLColor + fRColor + fBColor) * 0.125f; } diff --git a/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_Volumetric_Accumulate.hlsl b/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_Volumetric_Accumulate.hlsl index aa5694dfa..37f3b0529 100644 --- a/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_Volumetric_Accumulate.hlsl +++ b/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_Volumetric_Accumulate.hlsl @@ -28,11 +28,14 @@ cbuffer g_ConstantBuffer : register(b0) // b0 << 이 숫자와 컨스턴트 쉐 row_major matrix InvProjMatrix; row_major matrix InvViewMatrix; + row_major matrix ShadowViewMatrix; + row_major matrix ShadowViewProjMatrix; + float fAsymmetryParameter; - float padding0; - float padding1; - float padding2; -} + uint iNumLight; + float fHeightOffset; + float fBaseHeight; +}; float ConvertNdcZToDepth(float ndcZ); float SliceTickness(float ndcZ, uint dimZ); diff --git a/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_Volumetric_Compute.hlsl b/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_Volumetric_Compute.hlsl index b602fc1e4..b732abfe0 100644 --- a/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_Volumetric_Compute.hlsl +++ b/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_Volumetric_Compute.hlsl @@ -5,16 +5,17 @@ static const float EPSILON = 1e-6f; struct LightData { - uint itype; - float3 vDirection; - - float3 vPosition; - float fRange; - - float4 vColor; + float3 vDirection; + float fRange; + float4 vPosition; + float4 vDiffuse; }; -//StructuredBuffer g_LightBuffer : register(t1); +StructuredBuffer g_LightBuffer : register(t0); +Texture2D g_ShadowMap : register(t1); +Texture2D NoiseTexture : register(t2); + +SamplerState g_Sampler : register(s0); RWTexture3D g_VolumeUAV : register(u0); @@ -39,18 +40,22 @@ cbuffer g_ConstantBuffer : register(b0) // b0 << 이 숫자와 컨스턴트 쉐 row_major matrix InvProjMatrix; row_major matrix InvViewMatrix; + row_major matrix ShadowViewMatrix; + row_major matrix ShadowViewProjMatrix; + float fAsymmetryParameter; - float padding0; - float padding1; - float padding2; -} + uint iNumLight; + float fHeightOffset; + float fBaseHeight; +}; float3 ConvertThreadIdToNdc(uint3 id, uint3 dims); float ConvertNdcZToDepth(float ndcZ); float3 ConvertToWorldPosition(float3 ndc, float depth); float3 ConvertThreadIdToWorldPosition(uint3 id, uint3 dims); float HenyeyGreensteinPhaseFunction(float3 vInputDir, float3 vOutputDir, float fAnisotropy); - +float ComputePointLightVisible(float3 vLightDir, float fRange); +float ComputeShadowVisibility(float3 vWorldPosition); // 볼륨 텍스쳐 밀도, 산란 계산 [numthreads(8, 8, 4)] void CS_MAIN( uint3 DispatchThreadID : SV_DispatchThreadID) @@ -60,18 +65,40 @@ void CS_MAIN( uint3 DispatchThreadID : SV_DispatchThreadID) if (!all(DispatchThreadID < dims)) return; - float3 worldPosition = ConvertThreadIdToWorldPosition(DispatchThreadID, dims); - float3 toCamera = normalize(vCameraPosition - worldPosition); + float3 vWorldPosition = ConvertThreadIdToWorldPosition(DispatchThreadID, dims); + float3 toCamera = normalize(vCameraPosition - vWorldPosition); - float3 lighting = vLightColor.rgb * vLightColor.a; - float3 lightDir = normalize(vLightDirection); - float3 toLight = -lightDir; + float3 lighting = float3(0.1f, 0.1f, 0.1f); //vLightColor.rgb * vLightColor.a; - float phase = HenyeyGreensteinPhaseFunction(lightDir, toCamera, fAsymmetryParameter); + float3 lightDir = float3(0.f, 0.f, 0.f); - lighting += vLightColor.rgb * vLightColor.rgb * phase; + [loop] + for (uint i = 0; i < iNumLight; ++i) + { + float visibility = 1.f; + + if (0.f < length(g_LightBuffer[i].vDirection)) + { + lightDir = normalize(g_LightBuffer[i].vDirection); + visibility = ComputeShadowVisibility(vWorldPosition); - g_VolumeUAV[DispatchThreadID] = float4(lighting * fLightIntensity * fDensity, fDensity); + } + else + { + lightDir = vWorldPosition - g_LightBuffer[i].vPosition.xyz; + visibility = ComputePointLightVisible(lightDir, g_LightBuffer[i].fRange); + lightDir = normalize(lightDir); + } + + float3 toLight = -lightDir; + float phase = HenyeyGreensteinPhaseFunction(lightDir, toCamera, fAsymmetryParameter); + + lighting += g_LightBuffer[i].vDiffuse.rgb * g_LightBuffer[i].vDiffuse.a * phase * visibility; + } + + float fHeightDensity = max(0.1f, exp(-(vWorldPosition.y - fBaseHeight) * fHeightOffset)) * fDensity; + + g_VolumeUAV[DispatchThreadID] = float4(lighting * fLightIntensity * fHeightDensity, fHeightDensity); } float3 ConvertThreadIdToNdc(uint3 id, uint3 dims) @@ -109,3 +136,26 @@ float HenyeyGreensteinPhaseFunction(float3 vInputDir, float3 vOutputDir, float f float denom = pow(1.f + (fAsymmetryParameter * fAsymmetryParameter) - 2.f * fAsymmetryParameter * cosTheta, 3.f / 2.f); return (1.f / (4.f * PI)) * ((1.f - (fAsymmetryParameter * fAsymmetryParameter)) / max(denom, EPSILON)); } + +float ComputePointLightVisible(float3 vLightDir, float fRange) +{ + float fDistance = length(vLightDir); + + if (fDistance < fRange) + return 1.f; + else + return 0.f; +} + +float ComputeShadowVisibility(float3 vWorldPosition) +{ + float4 vShadowCoord = mul(float4(vWorldPosition, 1.f), ShadowViewProjMatrix); + float3 DepthUV = vShadowCoord.xyz / vShadowCoord.w; + + DepthUV.x = DepthUV.x * 0.5f + 0.5f; + DepthUV.y = DepthUV.y * -0.5f + 0.5f; + + //float fNoise = NoiseTexture.SampleLevel(g_Sampler, DepthUV.xy, 4).r; + + return 1.f; +} diff --git a/Jusin154_Team3D/Engine/Private/GameInstance.cpp b/Jusin154_Team3D/Engine/Private/GameInstance.cpp index d6d82f0ac..62b597e1f 100644 --- a/Jusin154_Team3D/Engine/Private/GameInstance.cpp +++ b/Jusin154_Team3D/Engine/Private/GameInstance.cpp @@ -724,6 +724,11 @@ _matrix CGameInstance::Get_Transform_Matrix(D3DTS eState) return m_pPipeLine->Get_Transform_Matrix(eState); } +_matrix CGameInstance::Get_ShadowTransform_Matrix(D3DTS eState, SHADOW eShadowType) +{ + return m_pPipeLine->Get_ShadowTransform_Matrix(eState, eShadowType); +} + const _float4* CGameInstance::Get_CamPosition() { return m_pPipeLine->Get_CamPosition(); @@ -819,6 +824,15 @@ HRESULT CGameInstance::Render_Lights(_uint _iCurrentLevel, CShader* pShader, CVI return m_pLight_Manager->Render_Lights(_iCurrentLevel, pShader, pVIBuffer); } +list* CGameInstance::Get_LightList(_uint _iCurrentLevel) +{ + return m_pLight_Manager->Get_LightList(_iCurrentLevel); +} + +_uint CGameInstance::Get_NumLight(_uint _iCurrentLevel) +{ + return m_pLight_Manager->Get_NumLight(_iCurrentLevel); +} HRESULT CGameInstance::Add_ColliderGroup(_uint iColliderGroup, class CCollider* pBounding) { @@ -908,6 +922,11 @@ HRESULT CGameInstance::Clear_RenderTarget(const _wstring& strRenderTargetKey) return m_pRenderTarget_Manager->Clear_RenderTarget(strRenderTargetKey); } +ID3D11ShaderResourceView* CGameInstance::Get_RenderTarget_SRV(const _wstring& strRenderTargetKey) +{ + return m_pRenderTarget_Manager->Get_RenderTarget_SRV(strRenderTargetKey); +} + #ifdef _DEBUG void CGameInstance::RenderTarget_Debuger() { @@ -1324,6 +1343,11 @@ void CGameInstance::Setting_Volumetirc(_float fDensity, _float fLightIntensity, m_pVolumetric->Setting_Volumetirc(fDensity , fLightIntensity , fAsymmetryParameter, fDepthPackExponent); } +void CGameInstance::Update_Volumetric() +{ + m_pVolumetric->Update(); +} + #pragma endregion void CGameInstance::Release_Engine() { diff --git a/Jusin154_Team3D/Engine/Private/Light_Manager.cpp b/Jusin154_Team3D/Engine/Private/Light_Manager.cpp index 7103da91e..73bfb8e12 100644 --- a/Jusin154_Team3D/Engine/Private/Light_Manager.cpp +++ b/Jusin154_Team3D/Engine/Private/Light_Manager.cpp @@ -84,6 +84,14 @@ const LIGHT_DESC* CLight_Manager::Get_Light_Info(_uint _iCurrentLevel, _uint _iL return (*iter)->Get_LightDesc(); } +_uint CLight_Manager::Get_NumLight(_uint _iCurrentLevel) +{ + if(true == m_Lights[_iCurrentLevel].empty()) + return 0; + + return static_cast<_uint>(m_Lights[_iCurrentLevel].size()); +} + HRESULT CLight_Manager::Render_Lights(_uint iCurrentLevel, CShader* pShader, CVIBuffer* pVIBuffer) { diff --git a/Jusin154_Team3D/Engine/Private/PipeLine.cpp b/Jusin154_Team3D/Engine/Private/PipeLine.cpp index 9647912da..af52db175 100644 --- a/Jusin154_Team3D/Engine/Private/PipeLine.cpp +++ b/Jusin154_Team3D/Engine/Private/PipeLine.cpp @@ -24,6 +24,23 @@ _matrix CPipeLine::Get_Transform_Matrix(D3DTS eState) return XMLoadFloat4x4(&m_TransformStateMatrices[ENUM_CLASS(eState)]); } +_matrix CPipeLine::Get_ShadowTransform_Matrix(D3DTS eState, SHADOW eShadowType) +{ + _uint iPass = UINT_MAX; + if (0 < ((_ubyte)eShadowType & (_ubyte)SHADOW::SHADOW_NEAR)) { + iPass = 0; + } + else if (0 < ((_ubyte)eShadowType & (_ubyte)SHADOW::SHADOW_MIDDLE)) { + iPass = 1; + } + else if (0 < ((_ubyte)eShadowType & (_ubyte)SHADOW::SHADOW_FAR)) { + iPass = 2; + } + assert(iPass != UINT_MAX); + + return XMLoadFloat4x4(&m_ShadowTransformStateMatrices[iPass][ENUM_CLASS(eState)]); +} + const _float4* CPipeLine::Get_CamPosition() { return &m_vCamPosition; diff --git a/Jusin154_Team3D/Engine/Private/RenderTarget_Manager.cpp b/Jusin154_Team3D/Engine/Private/RenderTarget_Manager.cpp index dd9ed2d22..ed23bf69d 100644 --- a/Jusin154_Team3D/Engine/Private/RenderTarget_Manager.cpp +++ b/Jusin154_Team3D/Engine/Private/RenderTarget_Manager.cpp @@ -252,6 +252,16 @@ HRESULT CRenderTarget_Manager::Clear_RenderTarget(const _wstring& strRenderTarge return S_OK; } +ID3D11ShaderResourceView* CRenderTarget_Manager::Get_RenderTarget_SRV(const _wstring& strRenderTargetKey) +{ + CRenderTarget* pRenderTarget = Find_RenderTarget(strRenderTargetKey); + + if(nullptr == pRenderTarget) + return nullptr; + + return pRenderTarget->Get_SRV(); +} + HRESULT CRenderTarget_Manager::Accumulate_RenderTarget(CVIBuffer_Rect* pVIBuffer, CShader* pShader, const _wstring& wstrRenderTarget_SrcA, const _wstring& wstrRenderTarget_SrcB, diff --git a/Jusin154_Team3D/Engine/Private/Volumetric.cpp b/Jusin154_Team3D/Engine/Private/Volumetric.cpp index 5ed28b60f..5c8fd5aed 100644 --- a/Jusin154_Team3D/Engine/Private/Volumetric.cpp +++ b/Jusin154_Team3D/Engine/Private/Volumetric.cpp @@ -27,18 +27,71 @@ HRESULT CVolumetric::Initialize() if(FAILED(CreateResourceViews())) return E_FAIL; + if(FAILED(Create_SamplerState())) + return E_FAIL; + return S_OK; } void CVolumetric::Update() { - + } void CVolumetric::Cumpute_Volume() { EVENTSCOPE_("Render_Cumpute_Volume"); + XMStoreFloat4x4(&m_ShadowViewMatrix, + m_pGameInstance->Get_ShadowTransform_Matrix(D3DTS::VIEW, SHADOW::SHADOW_MIDDLE)); + XMStoreFloat4x4(&m_ShadowViewProjMatrix, + m_pGameInstance->Get_ShadowTransform_Matrix(D3DTS::VIEW, SHADOW::SHADOW_MIDDLE) * + m_pGameInstance->Get_ShadowTransform_Matrix(D3DTS::PROJ, SHADOW::SHADOW_MIDDLE) + ); + + /* Light Buffer Update */ + D3D11_MAPPED_SUBRESOURCE LightSubResource = {}; + if (FAILED(m_pContext->Map(m_pLightInfoBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &LightSubResource))) + { + MSG_BOX("Failed to Map : CVolumetric"); + } + else + { + _uint iCurentLevel = m_pGameInstance->Get_CurrentLevelID(); + + m_iNumLights = min(m_iMaxNumLights, m_pGameInstance->Get_NumLight(iCurentLevel)); + + if (0 != m_iNumLights) + { + + CS_LIGHT_DESC* pDesc = static_cast(LightSubResource.pData); + list* Lights = m_pGameInstance->Get_LightList(iCurentLevel); + + _uint iIndex = 0; + for (auto& Light : *Lights) + { + const LIGHT_DESC* pLihgtDesc = Light->Get_LightDesc(); + memcpy(&pDesc[iIndex].vDiffuse, &pLihgtDesc->vDiffuse, sizeof(_float4)); + if(LIGHT::DIRECTIONAL != pLihgtDesc->eType) + { + memcpy(&pDesc[iIndex].vPosition, pLihgtDesc->pPosition, sizeof(_float3)); + ZeroMemory(&pDesc[iIndex].vDirection, sizeof(_float3)); + } + else + memcpy(&pDesc[iIndex].vDirection , pLihgtDesc->pDirection, sizeof(_float4)); + + pDesc[iIndex].fRange = pLihgtDesc->fRange; + ++iIndex; + if (m_iMaxNumLights <= iIndex) + break; + } + } + + m_pContext->Unmap(m_pLightInfoBuffer, 0); + } + + + /* Constannt Buffer Update */ D3D11_MAPPED_SUBRESOURCE ConstantSubResource = {}; if (FAILED(m_pContext->Map(m_pConstantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &ConstantSubResource))) @@ -74,10 +127,13 @@ void CVolumetric::Cumpute_Volume() XMStoreFloat4x4(&pDesc->InvProjMatrix, m_pGameInstance->Get_Transform_Matrix(D3DTS::PROJ_INV)); XMStoreFloat4x4(&pDesc->InvViewMatrix, m_pGameInstance->Get_Transform_Matrix(D3DTS::VIEW_INV)); + XMStoreFloat4x4(&pDesc->ShadowViewMatrix, XMLoadFloat4x4(&m_ShadowViewMatrix)); + XMStoreFloat4x4(&pDesc->ShadowViewProjMatrix, XMLoadFloat4x4(&m_ShadowViewProjMatrix)); + pDesc->fAsymmetryParameter = m_fAsymmetryParameter; - pDesc->padding0 = 0.f; - pDesc->padding1 = 0.f; - pDesc->padding2 = 0.f; + pDesc->iNumLight = m_iNumLights; + pDesc->fHeightOffset = m_fHieghtOffset; + pDesc->fBaseHeight = m_fBaseHeight; m_pContext->Unmap(m_pConstantBuffer, 0); } @@ -88,6 +144,15 @@ void CVolumetric::Cumpute_Volume() //SRV, UAV 바인딩 m_pContext->CSSetUnorderedAccessViews(0, 1, &m_pVolumeUAV, nullptr); + m_pContext->CSSetShaderResources(0, 1, &m_pLightInfoSRV); + + // Sampler 바인딩 + m_pContext->CSSetSamplers(0, 1, &m_pSamplerState); + + // 쉐도우 맵 바인딩 + ID3D11ShaderResourceView* ShadowSRV[1] = { m_pGameInstance->Get_RenderTarget_SRV(TEXT("Target_Shadow_Middle")) }; + m_pContext->CSSetShaderResources(1, 1, ShadowSRV); + m_pContext->CSSetShaderResources(2, 1, &m_pNoiseTexture); //컴퓨트 쉐이더 실행 XMUINT3 vGroupCount = { (160 + 7) / 8, (90 + 7) / 8, (128 + 3) / 4 }; @@ -169,6 +234,9 @@ void CVolumetric::Free() SAFE_RELEASE(m_pConstantBuffer); SAFE_RELEASE(m_pLightInfoBuffer); + SAFE_RELEASE(m_pLightInfoSRV); + SAFE_RELEASE(m_pSamplerState); + SAFE_RELEASE(m_pNoiseTexture); SAFE_RELEASE(m_pAccVolumeUAV); SAFE_RELEASE(m_pAccVolumeSRV); @@ -197,6 +265,8 @@ void CVolumetric::Describe_Entity() 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::SliderFloat("HieghtOffset", &m_fHieghtOffset, 0.f, 1.f, "%.5f"); + GUI::InputFloat("BaseHeight", &m_fBaseHeight, 0.1f, 1.f); } GUI::End(); @@ -268,8 +338,6 @@ HRESULT CVolumetric::CreateBuffers() cbDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; cbDesc.ByteWidth = sizeof(CS_VOLUME_CONSTANT_DESC); - D3D11_SUBRESOURCE_DATA CBInitialDesc = {}; - if (FAILED(m_pDevice->CreateBuffer(&cbDesc, nullptr, &m_pConstantBuffer))) return E_FAIL; @@ -304,13 +372,26 @@ HRESULT CVolumetric::CreateBuffers() XMStoreFloat4x4(&pDesc->InvViewMatrix, m_pGameInstance->Get_Transform_Matrix(D3DTS::VIEW_INV)); pDesc->fAsymmetryParameter = 0.0f; - pDesc->padding0 = 0.f; - pDesc->padding1 = 0.f; - pDesc->padding2 = 0.f; + pDesc->iNumLight = 0; + pDesc->fHeightOffset = 0.f; + pDesc->fBaseHeight = 0.f; m_pContext->Unmap(m_pConstantBuffer, 0); } + + // 라이트 정보 버퍼 생성 + D3D11_BUFFER_DESC cbLIghtDesc = {}; + cbLIghtDesc.Usage = D3D11_USAGE_DYNAMIC; + cbLIghtDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE; + cbLIghtDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + cbLIghtDesc.ByteWidth = sizeof(CS_LIGHT_DESC) * m_iMaxNumLights; + cbLIghtDesc.MiscFlags = D3D11_RESOURCE_MISC_BUFFER_STRUCTURED; + cbLIghtDesc.StructureByteStride = sizeof(CS_LIGHT_DESC); + + if (FAILED(m_pDevice->CreateBuffer(&cbLIghtDesc, nullptr, &m_pLightInfoBuffer))) + return E_FAIL; + return S_OK; } @@ -358,6 +439,48 @@ HRESULT CVolumetric::CreateResourceViews() if (FAILED(m_pDevice->CreateUnorderedAccessView(m_pAccumulateTexture3D, &UAV_Decs, &m_pAccVolumeUAV))) return E_FAIL; + // Light Info SRV + D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc = {}; + srvDesc.Format = DXGI_FORMAT_UNKNOWN; + srvDesc.ViewDimension = D3D_SRV_DIMENSION_BUFFER; + srvDesc.Buffer.FirstElement = 0; + srvDesc.Buffer.NumElements = m_iMaxNumLights; + + if (FAILED(m_pDevice->CreateShaderResourceView(m_pLightInfoBuffer, &srvDesc, &m_pLightInfoSRV))) + return E_FAIL; + + + // Noise Texture SRV + + if(FAILED(CreateDDSTextureFromFile(m_pDevice, + TEXT("C:/MeshTable/Game/Environment/MasterMaterials/BaseTextures/Noise/T_PerlinNoise.dds"), + nullptr, + &m_pNoiseTexture + ))) + { + assert(false); + return E_FAIL; + } + + return S_OK; +} + +HRESULT CVolumetric::Create_SamplerState() +{ + D3D11_SAMPLER_DESC desc = {}; + desc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR; + + desc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP; + desc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP; + desc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP; + desc.MinLOD = 0.0f; + desc.MaxLOD = D3D11_FLOAT32_MAX; + if (FAILED(m_pDevice->CreateSamplerState(&desc, &m_pSamplerState))) + { + assert(false); + return E_FAIL; + } + return S_OK; } diff --git a/Jusin154_Team3D/Engine/Public/GameInstance.h b/Jusin154_Team3D/Engine/Public/GameInstance.h index 18535b8c0..b3213ce98 100644 --- a/Jusin154_Team3D/Engine/Public/GameInstance.h +++ b/Jusin154_Team3D/Engine/Public/GameInstance.h @@ -94,7 +94,7 @@ class ENGINE_DLL CGameInstance final : public CBase } return hr; } - void Set_LayerEnabled(_bool isEnable); + class CLayer* Get_Layer(_uint iLayerLevelIndex, const _wstring& strLayerTag); void Clear_Objects_With_Layers(_uint iLevelIndex); @@ -136,6 +136,7 @@ class ENGINE_DLL CGameInstance final : public CBase void Set_Transform(D3DTS eState, _fmatrix TransformStateMatrix); const _float4x4* Get_Transform_Float4x4(D3DTS eState); _matrix Get_Transform_Matrix(D3DTS eState); + _matrix Get_ShadowTransform_Matrix(D3DTS eState, SHADOW eShadowType); const _float4* Get_CamPosition(); const _vector Get_CamXMPosition(); void Transform_Frustum_ToLocalSpace(_fmatrix WorldMatrixInverse); @@ -158,6 +159,8 @@ class ENGINE_DLL CGameInstance final : public CBase 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); + list* Get_LightList(_uint _iCurrentLevel); + _uint Get_NumLight(_uint _iCurrentLevel); #pragma endregion #pragma region COLLIDER_MANAGER HRESULT Add_ColliderGroup(_uint iColliderGroup, class CCollider* pBounding); @@ -183,6 +186,7 @@ class ENGINE_DLL CGameInstance final : public CBase HRESULT Finish_RenderTarget(class CVIBuffer_Rect* pVIBuffer, class CShader* pShader, const _wstring& wstrRenderTargetOriginal, const _wstring& wstrRenderTargetBloomed, SHADER_PASS_DEFERRED ePass); HRESULT Bind_CS_RenderTarget(_uint iIndex, const _wstring& strTargetTag); HRESULT Clear_RenderTarget(const _wstring& strRenderTargetKey); + ID3D11ShaderResourceView* Get_RenderTarget_SRV(const _wstring& strRenderTargetKey); #ifdef _DEBUG void RenderTarget_Debuger(); HRESULT Render_RenderTarget_Debug(class CShader* pShader, class CVIBuffer_Rect* pVIBuffer); @@ -272,6 +276,7 @@ class ENGINE_DLL CGameInstance final : public CBase ID3D11ShaderResourceView* Get_VolumeSRV(); _float* Get_DepthPackExponentPtr(); void Setting_Volumetirc(_float fDensity, _float fLightIntensity, _float fAsymmetryParameter, _float fDepthPackExponent); + void Update_Volumetric(); #pragma endregion diff --git a/Jusin154_Team3D/Engine/Public/Light_Manager.h b/Jusin154_Team3D/Engine/Public/Light_Manager.h index 05fcaade6..c9636a915 100644 --- a/Jusin154_Team3D/Engine/Public/Light_Manager.h +++ b/Jusin154_Team3D/Engine/Public/Light_Manager.h @@ -15,7 +15,8 @@ class CLight_Manager final : public CBase void Delete_Light(_uint _iCurrentLevel, class CLight* _pLight); void Light_Clear(_uint _iCurrentLevel); const LIGHT_DESC* Get_Light_Info(_uint _iCurrentLevel ,_uint _iLightIndex); - + list* Get_LightList(_uint _iCurrentLevel) { return &m_Lights[_iCurrentLevel]; } + _uint Get_NumLight(_uint _iCurrentLevel); public: HRESULT Render_Lights(_uint iCurrentLevel, class CShader* pShader, class CVIBuffer* pVIBuffer); diff --git a/Jusin154_Team3D/Engine/Public/PipeLine.h b/Jusin154_Team3D/Engine/Public/PipeLine.h index 5a3557e6d..d85abb645 100644 --- a/Jusin154_Team3D/Engine/Public/PipeLine.h +++ b/Jusin154_Team3D/Engine/Public/PipeLine.h @@ -27,6 +27,7 @@ class CPipeLine final : public CBase void Set_Transform(D3DTS eState, _fmatrix TransformStateMatrix); const _float4x4* Get_Transform_Float4x4(D3DTS eState); _matrix Get_Transform_Matrix(D3DTS eState); + _matrix Get_ShadowTransform_Matrix(D3DTS eState, SHADOW eShadowType); const _float4* Get_CamPosition(); const _vector Get_CamXMPosition(); diff --git a/Jusin154_Team3D/Engine/Public/RenderTarget_Manager.h b/Jusin154_Team3D/Engine/Public/RenderTarget_Manager.h index 55923d76f..65ad0f832 100644 --- a/Jusin154_Team3D/Engine/Public/RenderTarget_Manager.h +++ b/Jusin154_Team3D/Engine/Public/RenderTarget_Manager.h @@ -23,7 +23,7 @@ class CRenderTarget_Manager final : public CBase HRESULT Copy_RenderTargetAToB(const _wstring& strATag, const _wstring& strBTag); HRESULT Bind_CS_RenderTarget(_uint iIndex, const _wstring& strTargetTag); HRESULT Clear_RenderTarget(const _wstring& strRenderTargetKey); - + ID3D11ShaderResourceView* Get_RenderTarget_SRV(const _wstring& strRenderTargetKey); // 두 랜더타겟을 하나로 모음 HRESULT Accumulate_RenderTarget(class CVIBuffer_Rect* pVIBuffer, class CShader* pShader, const _wstring& wstrRenderTarget_SrcA, const _wstring& wstrRenderTarget_SrcB, const _wstring& wstrRenderTarget_Target, SHADER_PASS_DEFERRED ePass); // 랜더 타겟의 크기를 dest로 다시 맞춤 diff --git a/Jusin154_Team3D/Engine/Public/Volumetric.h b/Jusin154_Team3D/Engine/Public/Volumetric.h index 80303f71c..e368327fd 100644 --- a/Jusin154_Team3D/Engine/Public/Volumetric.h +++ b/Jusin154_Team3D/Engine/Public/Volumetric.h @@ -27,12 +27,22 @@ class CVolumetric final : public CBase _float4x4 InvProjMatrix; _float4x4 InvViewMatrix; + _float4x4 ShadowViewMatrix; + _float4x4 ShadowViewProjMatrix; + _float fAsymmetryParameter; - _float padding0; - _float padding1; - _float padding2; + _uint iNumLight; + _float fHeightOffset; + _float fBaseHeight; }CS_VOLUME_CONSTANT_DESC; + typedef struct tagCSLightDesc + { + _float3 vDirection; + _float fRange; + _float4 vPosition; + _float4 vDiffuse; + }CS_LIGHT_DESC; private: CVolumetric(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); @@ -46,7 +56,7 @@ class CVolumetric final : public CBase HRESULT Dispatch(); ID3D11ShaderResourceView* Get_VolumeSRV() { return m_pAccVolumeSRV; } - _float* Get_DepthPackExponentPtr() { return &m_fDepthPackExponent; } + _float* Get_DepthPackExponentPtr() { return &m_fDepthPackExponent; } void Setting_Volumetirc(_float fDensity , _float fLightIntensity, _float fAsymmetryParameter , _float fDepthPackExponent); private: @@ -56,6 +66,8 @@ class CVolumetric final : public CBase ID3D11Texture3D* m_pTexture3D = { nullptr }; ID3D11Texture3D* m_pAccumulateTexture3D = { nullptr }; + ID3D11ShaderResourceView* m_pNoiseTexture = { nullptr }; + ID3D11ShaderResourceView* m_pVolumeSRV = {nullptr}; ID3D11UnorderedAccessView* m_pVolumeUAV = { nullptr }; @@ -64,6 +76,7 @@ class CVolumetric final : public CBase ID3D11Buffer* m_pConstantBuffer = { nullptr }; ID3D11Buffer* m_pLightInfoBuffer = { nullptr }; + ID3D11ShaderResourceView* m_pLightInfoSRV = { nullptr }; ID3D11ComputeShader* m_pCSVolumeCalculate = { nullptr }; ID3DBlob* m_pCSBlobCalculate = { nullptr }; @@ -71,10 +84,19 @@ class CVolumetric final : public CBase ID3D11ComputeShader* m_pCSVolumeAccumulate = { nullptr }; ID3DBlob* m_pCSBlobAccumulate = { nullptr }; + ID3D11SamplerState* m_pSamplerState = { nullptr }; + _float m_fDensity = { 0.953f }; // 밀도 - _float m_fLightIntensity = { 0.01f }; // 광원 강도 + _float m_fLightIntensity = { 0.01f }; // 광원 강도 _float m_fAsymmetryParameter = { 0.5344f }; // 이방성 계수 값이 클 수록 들어오는 방향으로 나가는 빛의 양이 많아짐 - _float m_fDepthPackExponent = { 1.f }; // 깊이 비선형 분포 지수 + _float m_fDepthPackExponent = { 1.f }; // 깊이 비선형 분포 지수 + _float m_fHieghtOffset = { 0.f }; + _float m_fBaseHeight = { 0.f }; + _uint m_iNumLights = { 1 }; + _uint m_iMaxNumLights = { 20 }; + + _float4x4 m_ShadowViewMatrix = {}; + _float4x4 m_ShadowViewProjMatrix = {}; #ifdef _DEBUG class CRenderEventDebugger m_AnnotationHelper = {}; @@ -87,6 +109,7 @@ class CVolumetric final : public CBase HRESULT CreateBlob(); HRESULT CreateBuffers(); HRESULT CreateResourceViews(); + HRESULT Create_SamplerState(); public: static CVolumetric* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);