From a2ded247cb7bde8be4e2dbf35317cc4e848e4742 Mon Sep 17 00:00:00 2001 From: Chanbin Kim <127280695+JinhoBa@users.noreply.github.com> Date: Sat, 3 Jan 2026 17:57:58 +0900 Subject: [PATCH] =?UTF-8?q?[add]=20Hogwart=20AlphaMap=20=EC=B6=94=EA=B0=80?= =?UTF-8?q?=20[add]=20Hogwart=20HeightMap=20=EC=B6=94=EA=B0=80=20[fix]=20L?= =?UTF-8?q?ake=20Data=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Client/Private/Level_GamePlay.cpp | 12 +-- .../Client/Private/MapElement_Lake.cpp | 3 + .../Data/Map/Terrain/Hogsmeade_AlphaMap.bin | 2 +- .../Data/Map/Terrain/Hogsmeade_HeightMap.bin | 2 +- .../Data/Map/Terrain/Hogsmeade_HeightMap2.bin | 3 - .../Data/Map/Terrain/Hogwart_AlphaMap.bin | 2 +- .../Data/Map/Terrain/Hogwart_HeightMap.bin | 2 +- .../Map/Terrain/Hogwart_HeightMap1211.bin | 3 + .../Data/Map/Water/Element_Water_Info.xml | 10 +- .../Resources/ShaderFiles/Shader_VtxMesh.hlsl | 2 +- .../Editor/Private/Level_MapViewer.cpp | 52 +++++----- Jusin154_Team3D/Editor/Private/Loader.cpp | 16 +-- .../Editor/Private/MapElement_Lake.cpp | 17 +++- .../Editor/Private/MapObject_LOD.cpp | 2 +- .../Editor/Private/MapObject_Manager.cpp | 4 +- Jusin154_Team3D/Editor/Private/Terrain.cpp | 40 ++++---- .../Engine/Private/VIBuffer_Terrain.cpp | 99 ++++++++++++++++--- .../Engine/Public/VIBuffer_Terrain.h | 5 +- 18 files changed, 179 insertions(+), 97 deletions(-) delete mode 100644 Jusin154_Team3D/Editor/Bin/Resources/Data/Map/Terrain/Hogsmeade_HeightMap2.bin create mode 100644 Jusin154_Team3D/Editor/Bin/Resources/Data/Map/Terrain/Hogwart_HeightMap1211.bin diff --git a/Jusin154_Team3D/Client/Private/Level_GamePlay.cpp b/Jusin154_Team3D/Client/Private/Level_GamePlay.cpp index f7e74c29a..a029d75bb 100644 --- a/Jusin154_Team3D/Client/Private/Level_GamePlay.cpp +++ b/Jusin154_Team3D/Client/Private/Level_GamePlay.cpp @@ -201,7 +201,6 @@ HRESULT CLevel_GamePlay::Ready_Lights() Desc.vSpecular = _float4(0.0f, 0.0f, 0.0f, 0.0f); } - if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(ENUM_CLASS(LEVEL::STATIC), NEXT_LEVEL, LAYER_LIGHT, &Desc))) { return E_FAIL; } @@ -306,7 +305,11 @@ HRESULT CLevel_GamePlay::Ready_Background() if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, LAYER_BACKGROUND, &Land_Desc))) return E_FAIL; - + /* 물 오브젝트 */ + if (FAILED(CInfoInstance::GetInstance()->Load_WaterElemet("Element_Water_Info"))) { + return E_FAIL; + } + // --------------------------------- // >> M A P Configuration << // 맵 로드할지 안할지 bool 설정 @@ -367,11 +370,6 @@ HRESULT CLevel_GamePlay::Ready_Background() if (FAILED(Ready_Layer_Hogwart())) return E_FAIL; } - - /* 물 오브젝트 */ - if (FAILED(CInfoInstance::GetInstance()->Load_WaterElemet("Element_Water_Info"))) { - return E_FAIL; - } #endif if (FAILED(Ready_IntstanceProp())) diff --git a/Jusin154_Team3D/Client/Private/MapElement_Lake.cpp b/Jusin154_Team3D/Client/Private/MapElement_Lake.cpp index e473bf5a8..123e89c9b 100644 --- a/Jusin154_Team3D/Client/Private/MapElement_Lake.cpp +++ b/Jusin154_Team3D/Client/Private/MapElement_Lake.cpp @@ -94,6 +94,9 @@ HRESULT CMapElement_Lake::Render() if (FAILED(m_pModelComs[0]->Render(0))) { return E_FAIL; } + if (FAILED(m_pShallowModels[0]->Render(0))) { + return E_FAIL; + } return S_OK; } diff --git a/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/Terrain/Hogsmeade_AlphaMap.bin b/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/Terrain/Hogsmeade_AlphaMap.bin index c8dd09079..a1a1073ca 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/Terrain/Hogsmeade_AlphaMap.bin +++ b/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/Terrain/Hogsmeade_AlphaMap.bin @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2a425f685254b0d133c6350fd0f020e4f526efac9cdccfed91c6944313da3b34 +oid sha256:1db07c9f76accbd123a54079fada22e054faeb39de5d139a0e118a217c473256 size 67108864 diff --git a/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/Terrain/Hogsmeade_HeightMap.bin b/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/Terrain/Hogsmeade_HeightMap.bin index 624d8db9d..c83e18247 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/Terrain/Hogsmeade_HeightMap.bin +++ b/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/Terrain/Hogsmeade_HeightMap.bin @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:70a00e80f048ff149ec44044d738d5bbbbbc7e3d6adf4877de62ab209bc4dea2 +oid sha256:5d1403c26882c44252bc1a63ed0528c901904c7233bae4d4628f98bf4b2bfee2 size 1052676 diff --git a/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/Terrain/Hogsmeade_HeightMap2.bin b/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/Terrain/Hogsmeade_HeightMap2.bin deleted file mode 100644 index 624d8db9d..000000000 --- a/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/Terrain/Hogsmeade_HeightMap2.bin +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:70a00e80f048ff149ec44044d738d5bbbbbc7e3d6adf4877de62ab209bc4dea2 -size 1052676 diff --git a/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/Terrain/Hogwart_AlphaMap.bin b/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/Terrain/Hogwart_AlphaMap.bin index 12b3c5bdb..c450837ca 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/Terrain/Hogwart_AlphaMap.bin +++ b/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/Terrain/Hogwart_AlphaMap.bin @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1ede88dfe51b7df9ba8c5b31cdac05271b4563a0706b9c61a8dc8910cc26c991 +oid sha256:a20876a27b9c0d56d8821ca63e6c35a30b13d84d94c681c44501faeb7c44291a size 83886080 diff --git a/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/Terrain/Hogwart_HeightMap.bin b/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/Terrain/Hogwart_HeightMap.bin index 52a4d9956..cb940bcd3 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/Terrain/Hogwart_HeightMap.bin +++ b/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/Terrain/Hogwart_HeightMap.bin @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:96f348613e941630ef113e523868c7e9fe043b3c24c1d0a66b428fddbb3663ad +oid sha256:d9c73a5d48022ff413f70ceb6c1dfca636b2515898175121c1057b9d66a0d0b9 size 1315332 diff --git a/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/Terrain/Hogwart_HeightMap1211.bin b/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/Terrain/Hogwart_HeightMap1211.bin new file mode 100644 index 000000000..52a4d9956 --- /dev/null +++ b/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/Terrain/Hogwart_HeightMap1211.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:96f348613e941630ef113e523868c7e9fe043b3c24c1d0a66b428fddbb3663ad +size 1315332 diff --git a/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/Water/Element_Water_Info.xml b/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/Water/Element_Water_Info.xml index 61081ef62..34c1f1e0e 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/Water/Element_Water_Info.xml +++ b/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/Water/Element_Water_Info.xml @@ -22,12 +22,12 @@ Prototype_Component_Hogwart_Lake Prototype_Component_Hogwart_LakeSurFace - - + + - + @@ -35,7 +35,7 @@ - - + + diff --git a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_VtxMesh.hlsl b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_VtxMesh.hlsl index 1bb9ad1ec..124415419 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_VtxMesh.hlsl +++ b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_VtxMesh.hlsl @@ -737,7 +737,7 @@ PS_OUT PS_LAKE(PS_IN In) float4 vMtrlDiffuse = g_DiffuseTexture.Sample(AnisoTropy_BLUR_Sampler, In.vTexcoord * 30.f); float3 vNoise = (g_NoiseTexture.Sample(AnisoTropy_BLUR_Sampler, In.vTexcoord + g_fTime * 0.1f).rgb - 0.5f) * 0.3f; - float4 vCaustics = g_CausticsTexture.Sample(AnisoTropy_BLUR_Sampler, In.vTexcoord * 30.f + vNoise.g); + float4 vCaustics = g_CausticsTexture.Sample(AnisoTropy_BLUR_Sampler, In.vTexcoord * 10.f + vNoise.g); float3 vNormalDecoded = DecodeNormalFromRG(g_NormalTexture, AnisoTropy_BLUR_Sampler, vUV + vNoise.g); float3 vNormalLarge = DecodeNormalFromRG(g_NormalLargeTexture, AnisoTropy_BLUR_Sampler, vUVLarge + vNoise.r); diff --git a/Jusin154_Team3D/Editor/Private/Level_MapViewer.cpp b/Jusin154_Team3D/Editor/Private/Level_MapViewer.cpp index 33d66d872..9e7c0d4b3 100644 --- a/Jusin154_Team3D/Editor/Private/Level_MapViewer.cpp +++ b/Jusin154_Team3D/Editor/Private/Level_MapViewer.cpp @@ -51,7 +51,7 @@ HRESULT CLevel_MapViewer::Initialize() return E_FAIL; } - if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, TEXT("Layer_EffectPool")))) //플레이어보다 먼저 생성해야함! + if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, TEXT("Z_Layer_EffectPool")))) //플레이어보다 먼저 생성해야함! { return E_FAIL; } @@ -189,31 +189,31 @@ HRESULT CLevel_MapViewer::Ready_Layer_Terrain(const _wstring& strLayerTag) CMapElement_Lake::MAPOBJECT_LAKE_DESC Lake_Desc = {}; - //vector<_wstring> ModelPrototypeTags; - //vector<_wstring> ShallowModelPrototypeTags; - //ModelPrototypeTags.push_back(TEXT("Prototype_Component_Hogwart_Lake")); - //ShallowModelPrototypeTags.push_back(TEXT("Prototype_Component_Hogwart_LakeSurFace")); - //Lake_Desc.bEdit = false; - //Lake_Desc.iMaxLodLevel = 0; - //Lake_Desc.iRenderType = 4; - //Lake_Desc.vPosition = _float3(-144.f, -61.9f, -115.f); - //Lake_Desc.vRotation = _float3(0.f, 0.f, 0.f); - //Lake_Desc.vScale = _float3(1.f, 1.f, 1.f); - //Lake_Desc.fTimeSpeed = _float(0.02f); - //Lake_Desc.fRefractionStrength = _float(); - //Lake_Desc.fRefractionPow = _float(); - //Lake_Desc.fUVValue1 = _float(); - //Lake_Desc.fUVValue2 = _float(); - //Lake_Desc.fUVValue3 = _float(); - //Lake_Desc.vUVSpeed = _float2(); - //Lake_Desc.vLargeUVSpeed = _float2(); - //Lake_Desc.vSubUVSpeed3 = _float2(); - //Lake_Desc.vRefractionColor = _float4(); - //Lake_Desc.vSurfaceColor = _float4(); - //Lake_Desc.ModelPrototypeTags = ModelPrototypeTags; - //Lake_Desc.ShallowModelPrototypeTags = ShallowModelPrototypeTags; - //if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, strLayerTag, &Lake_Desc))) - // return E_FAIL; + vector<_wstring> ModelPrototypeTags; + vector<_wstring> ShallowModelPrototypeTags; + ModelPrototypeTags.push_back(TEXT("Prototype_Component_Hogwart_Lake")); + ShallowModelPrototypeTags.push_back(TEXT("Prototype_Component_Hogwart_LakeSurFace")); + Lake_Desc.bEdit = false; + Lake_Desc.iMaxLodLevel = 0; + Lake_Desc.iRenderType = 4; + Lake_Desc.vPosition = _float3(-89.2f, -61.6f, -657.8f); + Lake_Desc.vRotation = _float3(0.f, 0.f, 0.f); + Lake_Desc.vScale = _float3(1.3f, 1.f, 1.3f); + Lake_Desc.fTimeSpeed = _float(0.02f); + Lake_Desc.fRefractionStrength = 0.08f; + Lake_Desc.fRefractionPow = 1.5f; + Lake_Desc.fUVValue1 = 10.f; + Lake_Desc.fUVValue2 = 20.f; + Lake_Desc.fUVValue3 = 20.f; + Lake_Desc.vUVSpeed = _float2(0.1f, 0.f); + Lake_Desc.vLargeUVSpeed = _float2(0.3f, 0.1f); + Lake_Desc.vSubUVSpeed3 = _float2(10.f, 0.f); + Lake_Desc.vRefractionColor = _float4(0.35f, 0.35f, 0.35f, 1.f); + Lake_Desc.vSurfaceColor = _float4(0.25f, 0.f, 1.f, 1.f); + Lake_Desc.ModelPrototypeTags = ModelPrototypeTags; + Lake_Desc.ShallowModelPrototypeTags = ShallowModelPrototypeTags; + if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, strLayerTag, &Lake_Desc))) + return E_FAIL; return S_OK; diff --git a/Jusin154_Team3D/Editor/Private/Loader.cpp b/Jusin154_Team3D/Editor/Private/Loader.cpp index bda56e76a..daedf2f67 100644 --- a/Jusin154_Team3D/Editor/Private/Loader.cpp +++ b/Jusin154_Team3D/Editor/Private/Loader.cpp @@ -2948,7 +2948,7 @@ HRESULT CLoader::Loading_For_MapViewer() #pragma endregion -_bool bLoadHogsmeade = false; +_bool bLoadHogsmeade = true; if (bLoadHogsmeade) { #pragma region HOGSMEADE_OBJECT @@ -3335,10 +3335,10 @@ if (FAILED(MapFolderLoad("C:\\MeshTable\\Game\\Environment\\Sanctum_Dungeon\\Mes vector> jobFutures; -_uint iLoadCount = 46; +_uint iLoadCount = 44; vector*> Contents(iLoadCount); -_bool isLoad_Map = { false }; +_bool isLoad_Map = { true }; if(isLoad_Map) { { /* Terrain */ @@ -3417,11 +3417,6 @@ if(isLoad_Map) )); } { /* BLDG_HogsheadInn */ - jobFutures.emplace_back(Deferred_FolderLoad( - "../Bin/Resources/Models/MapMesh/Game/Environment/Hogsmeade/BLDG_HogsheadInn/Meshes", - ".bin", false, - &Contents[jobFutures.size()] - )); jobFutures.emplace_back(Deferred_FolderLoad( "../Bin/Resources/Models/MapMesh/Game/Environment/Hogsmeade/BLDG_HogsheadInn/Collision", ".bin", false, @@ -3489,11 +3484,6 @@ if(isLoad_Map) )); } { /* BLDG_Potions */ - jobFutures.emplace_back(Deferred_FolderLoad( - "../Bin/Resources/Models/MapMesh/Game/Environment/Hogsmeade/BLDG_Potions/Meshes", - ".bin", false, - &Contents[jobFutures.size()] - )); jobFutures.emplace_back(Deferred_FolderLoad( "../Bin/Resources/Models/MapMesh/Game/Environment/Hogsmeade/BLDG_Potions/Collisions", ".bin", false, diff --git a/Jusin154_Team3D/Editor/Private/MapElement_Lake.cpp b/Jusin154_Team3D/Editor/Private/MapElement_Lake.cpp index 2f30f1ed7..4fa233b29 100644 --- a/Jusin154_Team3D/Editor/Private/MapElement_Lake.cpp +++ b/Jusin154_Team3D/Editor/Private/MapElement_Lake.cpp @@ -51,8 +51,21 @@ HRESULT CMapElement_Lake::Initialize(void* pArg) m_pTransformCom->Rotation(XMConvertToRadians(m_vRotation.x), XMConvertToRadians(m_vRotation.y), XMConvertToRadians(m_vRotation.z)); #endif // _DEBUG - m_vRefractionColor = _float4(1.f, 1.f, 1.f, 1.f); - m_vSurfaceColor = _float4(1.f, 1.f, 1.f, 1.f); + m_fTimeSpeed = pDesc->fTimeSpeed; + + m_fRefractionStrength = pDesc->fRefractionStrength; + m_fRefractionPow = pDesc->fRefractionPow; + + m_fUVValue1 = pDesc->fUVValue1; + m_fUVValue2 = pDesc->fUVValue2; + m_fUVValue3 = pDesc->fUVValue3; + + m_vUVSpeed = pDesc->vUVSpeed; + m_vLargeUVSpeed = pDesc->vLargeUVSpeed; + m_vSubUVSpeed3 = pDesc->vSubUVSpeed3; + + memcpy(&m_vRefractionColor, &pDesc->vRefractionColor, sizeof(_float4)); + memcpy(&m_vSurfaceColor, &pDesc->vSurfaceColor, sizeof(_float4)); return S_OK; } diff --git a/Jusin154_Team3D/Editor/Private/MapObject_LOD.cpp b/Jusin154_Team3D/Editor/Private/MapObject_LOD.cpp index e22ff2076..103ece47a 100644 --- a/Jusin154_Team3D/Editor/Private/MapObject_LOD.cpp +++ b/Jusin154_Team3D/Editor/Private/MapObject_LOD.cpp @@ -120,7 +120,7 @@ void CMapObject_LOD::Late_Update(_float fTimeDelta) m_fCamDepth = XMVectorGetX(XMVector3LengthSq(vCamPosition - XMLoadFloat4(&m_vExtentPosition))); - m_iLodIndex = min(m_iMaxLodLevel, (_uint)(m_fCamDepth / (fRaius * fRaius + 40000.f))); + m_iLodIndex = min(m_iMaxLodLevel, (_uint)(m_fCamDepth / (fRaius * fRaius + 10000.f))); if (m_pGameInstance->Key_Pressing(DIK_Z)) m_iLodIndex = 0; diff --git a/Jusin154_Team3D/Editor/Private/MapObject_Manager.cpp b/Jusin154_Team3D/Editor/Private/MapObject_Manager.cpp index e543244bb..0bf64b28c 100644 --- a/Jusin154_Team3D/Editor/Private/MapObject_Manager.cpp +++ b/Jusin154_Team3D/Editor/Private/MapObject_Manager.cpp @@ -65,8 +65,8 @@ HRESULT CMapObject_Manager::Initialize(void* pArg) m_iContainerObjectIndex = 99; - //if (FAILED(Load_MapData("Hogsmeade_MapContainer_Data", LAYER_HOGSMEADE))) - // return E_FAIL; + if (FAILED(Load_MapData("Hogsmeade_MapContainer_Data", LAYER_HOGSMEADE))) + return E_FAIL; //m_pContainer = m_pGameInstance->Get_Layer(ENUM_CLASS(LEVEL::MAP), TEXT("Layer_Building"))->Get_Object(); diff --git a/Jusin154_Team3D/Editor/Private/Terrain.cpp b/Jusin154_Team3D/Editor/Private/Terrain.cpp index e0fc616a2..c6ba187c0 100644 --- a/Jusin154_Team3D/Editor/Private/Terrain.cpp +++ b/Jusin154_Team3D/Editor/Private/Terrain.cpp @@ -83,7 +83,7 @@ void CTerrain::Update(_float fTimeDelta) { if (m_isEdit) Describe_Entity(); - + //m_pVIBufferCom->Culling(m_pTransformCom->Get_XMWorldMatrix()); if(m_pGameInstance->Key_Down(DIK_LCONTROL) && m_pGameInstance->Key_Down(DIK_W)) @@ -182,23 +182,25 @@ HRESULT CTerrain::Bind_ShaderResources() return E_FAIL; } - if (FAILED(m_pShaderCom->Bind_RawValue("g_fFar", m_pGameInstance->Get_CurrentCameraFar(), sizeof(_float)))) { + if (FAILED(m_pDiffuseTextureCom->Bind_ShaderResources(m_pShaderCom, "g_DiffuseTextures", 0, m_pDiffuseTextureCom->Get_Size()))) { return E_FAIL; } - - if (FAILED(m_pDiffuseTextureCom->Bind_ShaderResources(m_pShaderCom, "g_DiffuseTextures", 0, m_pDiffuseTextureCom->Get_Size()))){ + if (FAILED(m_pNormalTextureCom->Bind_ShaderResources(m_pShaderCom, "g_NormalTextures", 0, m_pNormalTextureCom->Get_Size()))) { return E_FAIL; } - if (FAILED(m_pNormalTextureCom->Bind_ShaderResources(m_pShaderCom, "g_NormalTextures", 0, m_pNormalTextureCom->Get_Size()))){ - return E_FAIL; - } - if (FAILED(m_pMROTextureCom->Bind_ShaderResources(m_pShaderCom, "g_SurfaceParamsTextures", 0, m_pMROTextureCom->Get_Size()))){ + if (FAILED(m_pMROTextureCom->Bind_ShaderResources(m_pShaderCom, "g_SurfaceParamsTextures", 0, m_pMROTextureCom->Get_Size()))) { return E_FAIL; } if (FAILED(m_pShaderCom->Bind_SRV("g_MaskTexture", m_pAlphaMap->Get_SRV()))) { return E_FAIL; } + if (FAILED(m_pShaderCom->Bind_RawValue("g_fFar", m_pGameInstance->Get_CurrentCameraFar(), sizeof(_float)))) { + return E_FAIL; + } + + + if (FAILED(m_pShaderCom->Bind_RawValue("g_fUsingSurfaceParams", &m_fUsingSurfaceParams, sizeof(_float)))) return E_FAIL; @@ -315,24 +317,24 @@ void CTerrain::Describe_Entity() if (GUI::Button("Load", ImVec2(100.f, 30.f))) { m_pAlphaMap->Load_ToFile("Hogwart_AlphaMap.bin"); - } + } - - //GUI::DragFloat("Up", &m_fUpValue, 0.01f, -1.0f, 1.f); + m_iMaskRange = max(1, m_iMaskRange); + GUI::DragFloat("Up", &m_fUpValue, 0.01f, -1.0f, 1.f); if (m_pGameInstance->Mouse_Pressing(DIM_LBUTTON)) { if (m_pGameInstance->isPicking(&m_vPickingPosition)) { - if (m_pGameInstance->Key_Pressing(DIK_PERIOD)) - m_pVIBufferCom->FitY(m_pTransformCom->Get_XMWorldMatrix(), m_fUpValue); - if (m_pGameInstance->Key_Pressing(DIK_COMMA)) - m_pVIBufferCom->FitY(m_pTransformCom->Get_XMWorldMatrix(), m_fUpValue * -1.f); + //if (m_pGameInstance->Key_Pressing(DIK_PERIOD)) + // m_pVIBufferCom->FitY(m_pTransformCom->Get_XMWorldMatrix(), m_fUpValue, m_vPickingPosition, m_iMaskRange); + //if (m_pGameInstance->Key_Pressing(DIK_COMMA)) + // m_pVIBufferCom->FitY(m_pTransformCom->Get_XMWorldMatrix(), m_fUpValue * -1.f, m_vPickingPosition, m_iMaskRange); XMStoreFloat3(&m_vPickingPosition, XMVector3TransformCoord(XMLoadFloat3(&m_vPickingPosition), m_pTransformCom->Get_WorldMatrixInv())); - - m_pAlphaMap->Update(m_vPickingPosition, m_iColorIndex, m_fMaskValue, m_iMaskRange); + if(m_pGameInstance->Key_Pressing(DIK_M)) + m_pAlphaMap->Update(m_vPickingPosition, m_iColorIndex, m_fMaskValue, m_iMaskRange); } } @@ -341,9 +343,9 @@ void CTerrain::Describe_Entity() #pragma region HEIGHT MAP HRESULT hr = {}; if(GUI::Button("Save HeightMap")) - hr = m_pVIBufferCom->Save_HeightMap("Hogwart_Height.bin"); + hr = m_pVIBufferCom->Save_HeightMap("Hogwart_HeightMap.bin"); if(GUI::Button("Load HeightMap")) - hr = m_pVIBufferCom->Load_HeightMap("Hogwart_Height.bin"); + hr = m_pVIBufferCom->Load_HeightMap("Hogwart_HeightMap.bin"); #pragma endregion _float4 vPos = {}; diff --git a/Jusin154_Team3D/Engine/Private/VIBuffer_Terrain.cpp b/Jusin154_Team3D/Engine/Private/VIBuffer_Terrain.cpp index a4624b6ac..0c3f1443f 100644 --- a/Jusin154_Team3D/Engine/Private/VIBuffer_Terrain.cpp +++ b/Jusin154_Team3D/Engine/Private/VIBuffer_Terrain.cpp @@ -1,4 +1,4 @@ -#include "pch.h" + #include "pch.h" #include "VIBuffer_Terrain.h" #include "GameInstance.h" #include "QuadTree.h" @@ -455,31 +455,106 @@ void CVIBuffer_Terrain::Culling(_fmatrix WorldMatrix) m_iNumIndices = iNumIndices; } -void CVIBuffer_Terrain::FitY(_fmatrix WorldMatrix, _float fY) +void CVIBuffer_Terrain::FitY(_fmatrix WorldMatrix, _float fY, _float3 vPickingPos, _uint iRange) { m_pGameInstance->Transform_Frustum_ToLocalSpace(XMMatrixInverse(nullptr, WorldMatrix)); - D3D11_MAPPED_SUBRESOURCE SubResource{}; + //D3D11_MAPPED_SUBRESOURCE SubResource{}; - m_pContext->Map(m_pVB, 0, D3D11_MAP_READ_WRITE, 0, &SubResource); + //m_pContext->Map(m_pVB, 0, D3D11_MAP_READ_WRITE, 0, &SubResource); - VTXNORTEX* pVertices = static_cast(SubResource.pData); + //VTXNORTEX* pVertices = static_cast(SubResource.pData); + //_matrix WorldInv = XMMatrixInverse(nullptr, WorldMatrix); + + + + //m_pQuadTree->Set_Y(m_pGameInstance, m_pVertexPositions, pVertices, WorldMatrix, fY); + + //for (_uint i = 0; i < m_iNumVertices; ++i) + //{ + // memcpy(&m_pVertexPositions[i], &pVertices[i].vPosition, sizeof(_float3)); + //} + _float3 Out{}; + _float3 vLocalPosition = {}; _matrix WorldInv = XMMatrixInverse(nullptr, WorldMatrix); - m_pGameInstance->Ray_WorldToLocal(&WorldInv); + XMStoreFloat3(&vLocalPosition, XMVector3TransformCoord(XMVectorSetW(XMLoadFloat3(&vPickingPos), 1.f), WorldInv)); + _uint iIndex = static_cast<_uint>(vLocalPosition.x) + static_cast<_uint>(vLocalPosition.z) * m_iNumVerticesX; - m_pQuadTree->Set_Y(m_pGameInstance, m_pVertexPositions, pVertices, WorldMatrix, fY); - - for (_uint i = 0; i < m_iNumVertices; ++i) - { - memcpy(&m_pVertexPositions[i], &pVertices[i].vPosition, sizeof(_float3)); - } + _uint iIndices[4] = { + iIndex + m_iNumVerticesX, + iIndex + m_iNumVerticesX + 1, + iIndex + 1, + iIndex + }; + D3D11_MAPPED_SUBRESOURCE SubResource{}; + m_pContext->Map(m_pVB, 0, D3D11_MAP_READ_WRITE, 0, &SubResource); + VTXNORTEX* pVertices = static_cast(SubResource.pData); + Add_Y(pVertices, iIndex, fY); + Add_NeighborY(pVertices, static_cast<_uint>(vLocalPosition.x), static_cast<_uint>(vLocalPosition.z), fY, iRange); m_pContext->Unmap(m_pVB, 0); } +void CVIBuffer_Terrain::Add_NeighborY(VTXNORTEX* pVertices, _uint iX, _uint iZ, _float fY, _uint iRange) +{ + _int Range = iRange; // 이웃 범위 설정 + + for (_int dz = -Range; dz <= Range; ++dz) + { + for (_int dx = -Range; dx <= Range; ++dx) + { + _int nx = iX + dx; + _int nz = iZ + dz; + + // 범위 체크 (0 ~ m_iNumVerticesX/Z-1) + if (nx < 0 || nz < 0 || + nx >= (_int)m_iNumVerticesX || + nz >= (_int)m_iNumVerticesZ) + continue; + + _uint iNeighborIndex = + static_cast<_uint>(nx) + + static_cast<_uint>(nz) * m_iNumVerticesX; + + Add_Y(pVertices, iNeighborIndex, fY); + } + } + +} + +void CVIBuffer_Terrain::Add_Y(VTXNORTEX* pVertices, _uint iIndex, _float fY) +{ + _uint iIndices[4] = { + iIndex + m_iNumVerticesX, + iIndex + m_iNumVerticesX + 1, + iIndex + 1, + iIndex + }; + + for (_uint i = 0; i < 4; i++) + { + if (0 > iIndices[i] || m_iNumVertices <= iIndices[i]) + return; + } + _float fHieght = { }; + _float fAvgHieght = { }; + for (_uint i = 0; i < 4; i++) + { + fHieght += pVertices[iIndices[i]].vPosition.y; + } + + fAvgHieght = fHieght / 4.f; + + for (_uint i = 0; i < 4; i++) + { + pVertices[iIndices[i]].vPosition.y = fAvgHieght + fY; + memcpy(&m_pVertexPositions[iIndices[i]], &pVertices[iIndices[i]].vPosition, sizeof(_float3)); + } +} + HRESULT CVIBuffer_Terrain::Load_HeightMap(const _char* pFilePath) { diff --git a/Jusin154_Team3D/Engine/Public/VIBuffer_Terrain.h b/Jusin154_Team3D/Engine/Public/VIBuffer_Terrain.h index 6c02deb16..a31f25905 100644 --- a/Jusin154_Team3D/Engine/Public/VIBuffer_Terrain.h +++ b/Jusin154_Team3D/Engine/Public/VIBuffer_Terrain.h @@ -28,8 +28,9 @@ class ENGINE_DLL CVIBuffer_Terrain final : public CVIBuffer _bool Picking(_fmatrix WorldMatrix, _float3* pOut); void Culling(_fmatrix WorldMatrix); - void FitY(_fmatrix WorldMatrix, _float fY); - + void FitY(_fmatrix WorldMatrix, _float fY, _float3 vPickingPos, _uint iRange); + void Add_NeighborY(VTXNORTEX* pVertices, _uint iX, _uint iZ, _float fY, _uint iRange); + void Add_Y(VTXNORTEX* pVertices, _uint iIndex, _float fY); HRESULT Load_HeightMap(const _char* pFilePath); #ifdef EDITOR_PROJECT