diff --git a/Jusin154_Team3D/Client/Private/Goblin.cpp b/Jusin154_Team3D/Client/Private/Goblin.cpp index f7cbf1e00..a4f45ca5b 100644 --- a/Jusin154_Team3D/Client/Private/Goblin.cpp +++ b/Jusin154_Team3D/Client/Private/Goblin.cpp @@ -223,7 +223,10 @@ void CGoblin::Free() Safe_Delete(m_pCallBack_Behavior); Safe_Delete(m_pCallBack_HitReport); } +#ifdef _DEBUG void CGoblin::Describe_Entity() { } + +#endif // _DEBUG diff --git a/Jusin154_Team3D/Client/Private/Loader.cpp b/Jusin154_Team3D/Client/Private/Loader.cpp index dd1c74ebe..6e289de81 100644 --- a/Jusin154_Team3D/Client/Private/Loader.cpp +++ b/Jusin154_Team3D/Client/Private/Loader.cpp @@ -53,6 +53,7 @@ unsigned int APIENTRY LoadingMain(void* pArg) if (FAILED(pLoader->Loading())) { assert(false); + int a = 0; return 1; } @@ -271,7 +272,7 @@ HRESULT CLoader::Loading_For_GamePlay() } if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Box"), - CModel::Create(m_pDevice, m_pContext, MODEL::NONANIM, "../Bin/Resources/Models/Box/Box.fbx", XMMatrixScaling(0.01f, 0.01f, 0.01f) * XMMatrixIdentity())))) { + CModel::Create(m_pDevice, m_pContext, MODEL::NONANIM, "../Bin/Resources/Models/Box/Box.bin", XMMatrixScaling(0.01f, 0.01f, 0.01f) * XMMatrixIdentity())))) { return E_FAIL; } @@ -321,7 +322,7 @@ HRESULT CLoader::Loading_For_GamePlay() if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Prototype_Component_SkyboxModel"), - CModel::Create(m_pDevice, m_pContext, MODEL::NONANIM, "../Bin/Resources/Models/SkyBox/SkyBox.fbx", XMMatrixIdentity())))) + CModel::Create(m_pDevice, m_pContext, MODEL::NONANIM, "../Bin/Resources/Models/SkyBox/SkyBox.bin", XMMatrixIdentity())))) return E_FAIL; Asset_FileLoad("../Bin/Resources/Models/Effect/ParticleMesh", L"Prototype_Instance_Model_", [&](_wstring wstrFileName, const _char* pFilePath) { @@ -483,8 +484,9 @@ HRESULT CLoader::Asset_FileLoad(const _char* pDirectoryPath, const _tchar* pPreN string ext = file.path().extension().string(); - if (!strcmp(ext.c_str(), ".txt")) + if (!strcmp(ext.c_str(), ".txt") || !strcmp(ext.c_str(), ".fbx")){ continue; + } _char szFilePath[MAX_PATH] = {}; diff --git a/Jusin154_Team3D/Client/Private/Monster.cpp b/Jusin154_Team3D/Client/Private/Monster.cpp index 704992d98..2600aecab 100644 --- a/Jusin154_Team3D/Client/Private/Monster.cpp +++ b/Jusin154_Team3D/Client/Private/Monster.cpp @@ -73,7 +73,10 @@ void CMonster::Free() SAFE_RELEASE(m_pPlayerTransform); } +#ifdef _DEBUG void CMonster::Describe_Entity() { } + +#endif // _DEBUG diff --git a/Jusin154_Team3D/Client/Private/Wand.cpp b/Jusin154_Team3D/Client/Private/Wand.cpp index 73b51f396..f7bf9b126 100644 --- a/Jusin154_Team3D/Client/Private/Wand.cpp +++ b/Jusin154_Team3D/Client/Private/Wand.cpp @@ -50,6 +50,8 @@ HRESULT CWand::Initialize(void* pArg) assert(false); return E_FAIL; } + SAFE_ADDREF(m_pTrail); + SAFE_ADDREF(m_pEffectParts); m_pEffectParts->Load("../Bin/Resources/Data/Effect/Lumos/Lumos", static_cast(NEXT_LEVEL)); @@ -70,9 +72,10 @@ void CWand::Priority_Update(_float fTimeDelta) m_pTransformCom->Set_WorldMatrix(socketMatrix * XMLoadFloat4x4(m_pParentTransformCom->Get_WorldMatrixPtr())); +#ifdef _DEBUG Describe_Entity(); - +#endif // _DEBUG } void CWand::Update(_float fTimeDelta) diff --git a/Jusin154_Team3D/Client/Public/Goblin.h b/Jusin154_Team3D/Client/Public/Goblin.h index 355b1c540..0665ba634 100644 --- a/Jusin154_Team3D/Client/Public/Goblin.h +++ b/Jusin154_Team3D/Client/Public/Goblin.h @@ -37,8 +37,11 @@ class CGoblin final : public CMonster static CGoblin* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); virtual CGameObject* Clone(void* pArg, CGameObject* pOwner = nullptr) override; virtual void Free() override; +#ifdef _DEBUG virtual void Describe_Entity() override; +#endif // _DEBUG + private: virtual void Add_FSM(); virtual void Set_Anim(); diff --git a/Jusin154_Team3D/Client/Public/Monster.h b/Jusin154_Team3D/Client/Public/Monster.h index 3545423b4..dfca98381 100644 --- a/Jusin154_Team3D/Client/Public/Monster.h +++ b/Jusin154_Team3D/Client/Public/Monster.h @@ -31,7 +31,11 @@ class CMonster abstract : public CUnit public: virtual CGameObject* Clone(void* pArg, CGameObject* pOwner = nullptr)PURE; virtual void Free() override; +#ifdef _DEBUG virtual void Describe_Entity() override; + +#endif // _DEBUG + }; NS_END diff --git a/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/Instance/OakTree_MedA.bin b/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/Instance/OakTree_MedA.bin index b9177b704..4601cf586 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/Instance/OakTree_MedA.bin +++ b/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/Instance/OakTree_MedA.bin @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6740af55f03d155ccb6f9a878a58fba8f50e217bc8944823bd953278d7ad291f -size 2180 +oid sha256:d6b01f115b996fba0b935a1d32d7e7c2e2fbdeaedf09f3dc95d52c27eb8dc5a2 +size 20804 diff --git a/Jusin154_Team3D/Editor/Bin/Resources/Models/InstanceProp/SM_OakTree_MedA.bin b/Jusin154_Team3D/Editor/Bin/Resources/Models/InstanceProp/SM_OakTree_MedA.bin new file mode 100644 index 000000000..cd2f53b0c --- /dev/null +++ b/Jusin154_Team3D/Editor/Bin/Resources/Models/InstanceProp/SM_OakTree_MedA.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ed60b97d375624913d511db6d165643e842748d3cd72e9ac39c74203514439b0 +size 1131818 diff --git a/Jusin154_Team3D/Editor/Bin/Resources/Models/InstanceProp/Tree/SM_OakTree_MedA.fbx b/Jusin154_Team3D/Editor/Bin/Resources/Models/InstanceProp/SM_OakTree_MedA.fbx similarity index 100% rename from Jusin154_Team3D/Editor/Bin/Resources/Models/InstanceProp/Tree/SM_OakTree_MedA.fbx rename to Jusin154_Team3D/Editor/Bin/Resources/Models/InstanceProp/SM_OakTree_MedA.fbx 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 b02455a1e..7037ecd28 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Engine_Shader_Functions.hlsli +++ b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Engine_Shader_Functions.hlsli @@ -168,7 +168,20 @@ PBR_LIGHT_OUT PBR_Lighting( return Out; } +float GetBloomCurve(float x) +{ + float fResult = x; + float fThreshold = 0.68f * 2.f; + x *= 2.f; + + fResult = x * 0.05f // 최소 기본값 보장 + + max(0, x - fThreshold) // 밝기값 68 이하는 기본값으로하고 초과하면 그 값만큼 더해줌 + * 0.5f; // 0~2로 정규화 되어있기 때문에 강조 값 보정해줌 + + return fResult * 0.5f; +} +// RG 노말맵에서 Z 벡터 복원 float3 DecodeNormalFromRG(Texture2D NormalMap, SamplerState Samp, float2 uv) { float2 vSampledRG = (NormalMap.Sample(Samp, uv).rg * 2.f - 1.f); diff --git a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl index f0e085866..eef8ea86c 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl +++ b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl @@ -69,6 +69,17 @@ VS_OUT VS_MAIN(VS_IN In) return Out; } +VS_OUT VS_CAPTURE(VS_IN In) +{ + VS_OUT Out; + + float2 vClipPos = In.vPosition.xy * 2.0f; // → -1.0 ~ +1.0 + + Out.vPosition = float4(vClipPos, 0.0f, 1.0f); + Out.vTexcoord = In.vTexcoord; + + return Out; +} struct PS_IN { @@ -362,8 +373,8 @@ PS_OUT_BACKBUFFER PS_MAIN_COMBINED(PS_IN In) Out.vBackBuffer = vDiffuse * vShade + vSpecular; - vector vDepthDesc = g_DepthTexture.Sample(DefaultSampler, In.vTexcoord); + vector vDepthDesc = g_DepthTexture.Sample(DefaultSampler, In.vTexcoord); float fViewZ = vDepthDesc.y * g_fFar; @@ -444,12 +455,70 @@ PS_OUT_BACKBUFFER PS_MAIN_COMBINED(PS_IN In) return Out; } +PS_OUT_BACKBUFFER PS_MAIN_REFIT(PS_IN In) +{ + PS_OUT_BACKBUFFER Out; + + Out.vBackBuffer = g_DiffuseTexture.Sample(PointSampler, In.vTexcoord); + + return Out; +} + +PS_OUT_BACKBUFFER PS_MAIN_EMBOSS(PS_IN In) +{ + PS_OUT_BACKBUFFER Out; + + float3 vColor = g_DiffuseTexture.Sample(PointSampler, In.vTexcoord).xyz; + + // temp 이거 키면 겁나 빤짞빤짞 빛남 ㄷㄷ + //vColor *= 3.f; + // temp + + //float fIntensity = dot(vColor, float3(0.3333f, 0.3333f, 0.3333f)); // 대략적인 밝기 + float fIntensity = dot(vColor, float3(0.2126f, 0.7152f, 0.0722f)); // 대략적인 밝기 ( 인간적인 ) + if (fIntensity <= 1e-4f) + { + Out.vBackBuffer = 0; + return Out; + } + float fBloomIntensity = GetBloomCurve(fIntensity); + + float3 bloomColor = (vColor * fBloomIntensity) / fIntensity; + Out.vBackBuffer = float4(bloomColor, 1.f); + + return Out; +} + struct PS_OUT_BLUR_X { float4 vBlurX : SV_TARGET0; float4 vBlurWeight : SV_TARGET1; }; +PS_OUT_BACKBUFFER PS_MAIN_BLOOM_ACCUM(PS_IN In) +{ + PS_OUT_BACKBUFFER Out; + + float3 vColorSrcA = g_DiffuseTexture.Sample(PointSampler, In.vTexcoord).xyz; + float3 vColorSrcB = g_BlurTexture.Sample(PointSampler, In.vTexcoord).xyz; + + Out.vBackBuffer = float4(saturate(vColorSrcA + vColorSrcB), 1.f); + + return Out; +} + +PS_OUT_BACKBUFFER PS_MAIN_BLOOM_FINISH(PS_IN In) +{ + PS_OUT_BACKBUFFER Out; + + vector vColor = g_DiffuseTexture.Sample(PointSampler, In.vTexcoord); + float3 vBloom = g_BlurTexture.Sample(PointSampler, In.vTexcoord).xyz; + Out.vBackBuffer = vColor; + Out.vBackBuffer += float4(vBloom, 1.f); + + return Out; +} + PS_OUT_BLUR_X PS_MAIN_BLUR_X(PS_IN In) { @@ -458,28 +527,6 @@ PS_OUT_BLUR_X PS_MAIN_BLUR_X(PS_IN In) float2 vTexcoord; float4 vColor = 0.f; - float fBlurWeight = g_BlurWeightTexture.Sample(ClampSampler, In.vTexcoord).r; - int iBlurWeight = (int) (round(fBlurWeight) * 128.f); - - - - int iBlurMin; - int iBlurMax; - - iBlurMin = -1 * (iBlurWeight / 2) + 1; - iBlurMax = iBlurWeight / 2; - - //for (int i = -15; i < 16; ++i) - //{ - // vTexcoord.x = In.vTexcoord.x; - // vTexcoord.y = In.vTexcoord.y + (float) i / g_vResolution.y; - - // vColor += g_fWeights[i + 15] * g_BlurXTexture.Sample(ClampSampler, vTexcoord); - //} - - //Out.vBackBuffer += vColor; - - for (int i = -63; i < 64; ++i) { vTexcoord.x = In.vTexcoord.x + (float) i / g_vResolution.x; @@ -489,7 +536,28 @@ PS_OUT_BLUR_X PS_MAIN_BLUR_X(PS_IN In) } Out.vBlurX = vColor; - Out.vBlurWeight = fBlurWeight; + Out.vBlurWeight = 0.f; + + return Out; +} + +PS_OUT_BLUR_X PS_MAIN_BLUR_Y(PS_IN In) +{ + PS_OUT_BLUR_X Out; + + float2 vTexcoord; + float4 vColor = 0.f; + + for (int i = -63; i < 64; ++i) + { + vTexcoord.x = In.vTexcoord.x; + vTexcoord.y = In.vTexcoord.y + (float) i / g_vResolution.y; + + vColor += g_fWeights[i + 63] * g_BlurTexture.Sample(ClampSampler, vTexcoord); + } + + Out.vBlurX = vColor; + Out.vBlurWeight = 0.f; return Out; } @@ -562,8 +630,58 @@ technique11 DefaultTechnique SetRasterizerState(RS_Default); SetDepthStencilState(DSS_None, 0); SetBlendState(BS_Blend, float4(0.f, 0.f, 0.f, 0.f), 0xffffffff); - VertexShader = compile vs_5_0 VS_MAIN(); + VertexShader = compile vs_5_0 VS_CAPTURE(); GeometryShader = NULL; - PixelShader = compile ps_5_0 PS_MAIN_SPOT(); + PixelShader = compile ps_5_0 PS_MAIN_REFIT(); + } + + pass EmbossingPass // 7 + { + SetRasterizerState(RS_Default); + SetDepthStencilState(DSS_None, 0); + SetBlendState(BS_Blend, float4(0.f, 0.f, 0.f, 0.f), 0xffffffff); + VertexShader = compile vs_5_0 VS_CAPTURE(); + GeometryShader = NULL; + PixelShader = compile ps_5_0 PS_MAIN_EMBOSS(); + } + + pass Bloom_BlurXPass // 8 + { + SetRasterizerState(RS_Default); + SetDepthStencilState(DSS_None, 0); + SetBlendState(BS_Blend, float4(0.f, 0.f, 0.f, 0.f), 0xffffffff); + VertexShader = compile vs_5_0 VS_CAPTURE(); + GeometryShader = NULL; + PixelShader = compile ps_5_0 PS_MAIN_BLUR_X(); + } + + pass Bloom_BlurYPass // 9 + { + SetRasterizerState(RS_Default); + SetDepthStencilState(DSS_None, 0); + SetBlendState(BS_Blend, float4(0.f, 0.f, 0.f, 0.f), 0xffffffff); + VertexShader = compile vs_5_0 VS_CAPTURE(); + GeometryShader = NULL; + PixelShader = compile ps_5_0 PS_MAIN_BLUR_Y(); + } + + pass Bloom_AccumPass // 10 + { + SetRasterizerState(RS_Default); + SetDepthStencilState(DSS_None, 0); + SetBlendState(BS_Blend, float4(0.f, 0.f, 0.f, 0.f), 0xffffffff); + VertexShader = compile vs_5_0 VS_CAPTURE(); + GeometryShader = NULL; + PixelShader = compile ps_5_0 PS_MAIN_BLOOM_ACCUM(); + } + + pass Bloom_FinishPass // 11 + { + SetRasterizerState(RS_Default); + SetDepthStencilState(DSS_None, 0); + SetBlendState(BS_Blend, float4(0.f, 0.f, 0.f, 0.f), 0xffffffff); + VertexShader = compile vs_5_0 VS_CAPTURE(); + GeometryShader = NULL; + PixelShader = compile ps_5_0 PS_MAIN_BLOOM_FINISH(); } } diff --git a/Jusin154_Team3D/Editor/Private/InstancedProp.cpp b/Jusin154_Team3D/Editor/Private/InstancedProp.cpp index 23bf43af6..978ad9d2c 100644 --- a/Jusin154_Team3D/Editor/Private/InstancedProp.cpp +++ b/Jusin154_Team3D/Editor/Private/InstancedProp.cpp @@ -18,23 +18,27 @@ void CInstancedProp::Priority_Update(_float fTimeDelta) void CInstancedProp::Update(_float fTimeDelta) { - if (m_pGameInstance->Mouse_Down(DIM_MBUTTON)) + if(m_bEditMode) { - m_pVIBufferInstanceCom->Add_Instance(m_pTransformCom->Get_XMWorldMatrix()); - _float4x4 WorldMatrix = {}; - XMStoreFloat4x4(&WorldMatrix, m_pTransformCom->Get_XMWorldMatrix()); - m_WorldMatrices.push_back(WorldMatrix); - m_pVIBufferInstanceCom->Update_Instance(); - m_vRotation.y = m_pGameInstance->Random_Float(0.f, 360.f); - - _float3 vPosition = {}; - if (m_pGameInstance->isPicking(&vPosition)) + if (m_pGameInstance->Mouse_Down(DIM_MBUTTON)) { - memcpy(&m_vPosition, &vPosition, sizeof(_float3)); - } - } + m_pVIBufferInstanceCom->Add_Instance(m_pTransformCom->Get_XMWorldMatrix()); + _float4x4 WorldMatrix = {}; + XMStoreFloat4x4(&WorldMatrix, m_pTransformCom->Get_XMWorldMatrix()); + m_WorldMatrices.push_back(WorldMatrix); + m_pVIBufferInstanceCom->Update_Instance(); + m_vRotation.y = m_pGameInstance->Random_Float(0.f, 360.f); - Describe_Entity(); + _float3 vPosition = {}; + if (m_pGameInstance->isPicking(&vPosition)) + { + memcpy(&m_vPosition, &vPosition, sizeof(_float3)); + } + } +#ifdef _DEBUG + Describe_Entity(); +#endif + } } void CInstancedProp::Late_Update(_float fTimeDelta) @@ -59,7 +63,6 @@ HRESULT CInstancedProp::Render() m_pVIBufferInstanceCom->Render(i); } - return S_OK; } @@ -71,9 +74,14 @@ HRESULT CInstancedProp::Initialize_Prototype() HRESULT CInstancedProp::Initialize(void* pArg) { + INSTANCE_PROP_DESC* pDesc = static_cast(pArg); + if (FAILED(__super::Initialize(pArg))) return E_FAIL; + m_bEditMode = pDesc->bEditMode; + m_strPrototypeTag = pDesc->strPrototypeTag; + if (FAILED(Ready_Components(pArg))) return E_FAIL; @@ -83,6 +91,9 @@ HRESULT CInstancedProp::Initialize(void* pArg) XMStoreFloat4x4(&m_WorldMatrixIdentity, XMMatrixIdentity()); + if(!m_bEditMode) + Load_InstancedProp(pDesc->strInstanceDataPath.c_str()); + return S_OK; } @@ -92,7 +103,7 @@ HRESULT CInstancedProp::Ready_Components(void* pArg) return E_FAIL; /* Com_VIBuffer_Instance_Model */ - if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, TEXT("Prototype_Component_VIBuffer_Model_Instancel"), + if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, m_strPrototypeTag, reinterpret_cast(&m_pVIBufferInstanceCom)))) return E_FAIL; @@ -101,26 +112,6 @@ HRESULT CInstancedProp::Ready_Components(void* pArg) reinterpret_cast(&m_pShaderCom)))) return E_FAIL; - CTexture* pTexture = { nullptr }; - - /* Com_Texture */ - if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("Terrain_Diffuse"), reinterpret_cast(&pTexture), nullptr))) { - return E_FAIL; - } - m_pTextures.push_back(pTexture); - - /* Com_Texture */ - if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("Terrain_Normal"), reinterpret_cast(&pTexture), nullptr))) { - return E_FAIL; - } - m_pTextures.push_back(pTexture); - - /* Com_Texture */ - if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("Terrain_MRO"), reinterpret_cast(&pTexture), nullptr))) { - return E_FAIL; - } - m_pTextures.push_back(pTexture); - return S_OK; } @@ -246,18 +237,14 @@ void CInstancedProp::Free() SAFE_RELEASE(m_pShaderCom); SAFE_RELEASE(m_pVIBufferInstanceCom); - - for (auto& pTexture : m_pTextures) - SAFE_RELEASE(pTexture); - m_pTextures.clear(); } - void CInstancedProp::Describe_Entity() { GUI::Begin("Instanced Prop"); +#ifdef _DEBUG m_pVIBufferInstanceCom->Describe_Entity(); - +#endif // _DEBUG GUI::Text("----- Transfrom ----"); GUI::InputFloat("X##Position", &m_vPosition.x, 0.1f, 1.f); GUI::InputFloat("Y##Position", &m_vPosition.y, 0.1f, 1.f); @@ -307,6 +294,7 @@ void CInstancedProp::Describe_Entity() { Load_InstancedProp(("../Bin/Resources/Data/Map/Instance/" + string(m_szFileName) + ".bin").c_str()); } - + GUI::End(); } + diff --git a/Jusin154_Team3D/Editor/Private/Level_MapViewer.cpp b/Jusin154_Team3D/Editor/Private/Level_MapViewer.cpp index a56561a33..884095fd0 100644 --- a/Jusin154_Team3D/Editor/Private/Level_MapViewer.cpp +++ b/Jusin154_Team3D/Editor/Private/Level_MapViewer.cpp @@ -47,6 +47,10 @@ HRESULT CLevel_MapViewer::Initialize() return E_FAIL; } + if (FAILED(Ready_Layer_InstanceProp(TEXT("Layer_InstanceProp")))) { + return E_FAIL; + } + if (FAILED(Ready_Layer_BuildingContainer(TEXT("Layer_Building")))) { return E_FAIL; } @@ -113,6 +117,20 @@ HRESULT CLevel_MapViewer::Ready_Layer_Terrain(const _wstring& strLayerTag) return S_OK; } +HRESULT CLevel_MapViewer::Ready_Layer_InstanceProp(const _wstring& strLayerTag) +{ + CInstancedProp::INSTANCE_PROP_DESC Desc = {}; + Desc.bEditMode = false; + Desc.strPrototypeTag = L"Prototype_Component_VIBuffer_Model_Instancel_SM_OakTree_MedA"; + Desc.strInstanceDataPath = "../Bin/Resources/Data/Map/Instance/OakTree_MedA.bin"; + + /* Oak_Tree */ + if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, strLayerTag, &Desc))) + return E_FAIL; + + return S_OK; +} + HRESULT CLevel_MapViewer::Ready_Layer_BuildingContainer(const _wstring& strLayerTag) { //if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, strLayerTag))) @@ -126,8 +144,7 @@ HRESULT CLevel_MapViewer::Ready_Layer_MapObjectManager(const _wstring& strLayerT if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, strLayerTag))) return E_FAIL; - if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, strLayerTag))) - return E_FAIL; + return S_OK; } diff --git a/Jusin154_Team3D/Editor/Private/Loader.cpp b/Jusin154_Team3D/Editor/Private/Loader.cpp index ca05c80e9..e27215c09 100644 --- a/Jusin154_Team3D/Editor/Private/Loader.cpp +++ b/Jusin154_Team3D/Editor/Private/Loader.cpp @@ -1631,20 +1631,11 @@ HRESULT CLoader::Loading_For_MapViewer() { m_strMessage = TEXT("텍스쳐를(을) 로딩 중 입니다."); - //if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("TerrainTest"), - // CTexture::Create(m_pDevice, m_pContext, TEXTURE_LOAD_TYPE::SINGLE, TEXT("../Bin/Resources/Textures/T_C_Dun_Moss_D.png"), 0)))) { - // return E_FAIL; - //} if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("TerrainTest"), CTexture::Create(m_pDevice, m_pContext, TEXTURE_LOAD_TYPE::SINGLE, TEXT("../Bin/Resources/Textures//T_LandscapeStreamingProxy_0_LOD1_Summer_D.png"), 0)))) { return E_FAIL; } - - - - - /* Terrain_Mask */ if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Terrain_Mask"), CTexture::Create(m_pDevice, m_pContext, TEXTURE_LOAD_TYPE::SINGLE, TEXT("../Bin/Resources/Data/Map/T_OL_GrassBlend_Mask_D.dds"), 0)))) { @@ -2214,10 +2205,16 @@ vector*> Contents(iLoadCount); InstanceDesc.iNum = 500; - /* For.Prototype_Component_VIBuffer_Model_Instancel */ - if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Prototype_Component_VIBuffer_Model_Instancel"), - CVIBuffer_Model_Instance::Create(m_pDevice, m_pContext, &InstanceDesc, - "../Bin/Resources/Models/InstanceProp/Tree/SM_OakTree_MedA.fbx", "../Bin/Resources/Data/Map/Instance/InstanceMaterial.xml")))) + ///* For.Prototype_Component_VIBuffer_Model_Instancel */ + //if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Prototype_Component_VIBuffer_Model_Instancel"), + // CVIBuffer_Model_Instance::Create(m_pDevice, m_pContext, &InstanceDesc, + // "../Bin/Resources/Models/InstanceProp/SM_OakTree_MedA.fbx", "../Bin/Resources/Data/Map/Instance/InstanceMaterial.xml")))) + // return E_FAIL; + + /* For.Prototype_Component_VIBuffer_Model_Instancel_SM_OakTree_MedA */ + if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Prototype_Component_VIBuffer_Model_Instancel_SM_OakTree_MedA"), + CVIBuffer_Model_Instance::Create(m_pDevice, m_pContext, + "../Bin/Resources/Models/InstanceProp/SM_OakTree_MedA.bin", "../Bin/Resources/Data/Map/Instance/InstanceMaterial.xml")))) return E_FAIL; /* For.Prototype_GameObject_SkyBox */ diff --git a/Jusin154_Team3D/Editor/Public/InstancedProp.h b/Jusin154_Team3D/Editor/Public/InstancedProp.h index f08eeba9d..16248e852 100644 --- a/Jusin154_Team3D/Editor/Public/InstancedProp.h +++ b/Jusin154_Team3D/Editor/Public/InstancedProp.h @@ -16,8 +16,9 @@ class CInstancedProp final : public CGameObject public: typedef struct tagInstancedPropDesc { - string strModelFilePath; - string strTextureFilePath; + _bool bEditMode{}; + _wstring strPrototypeTag; + string strInstanceDataPath; }INSTANCE_PROP_DESC; private: CInstancedProp(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); @@ -31,17 +32,20 @@ class CInstancedProp final : public CGameObject virtual HRESULT Render() override; private: + _bool m_bEditMode = {}; CVIBuffer_Model_Instance* m_pVIBufferInstanceCom = { nullptr }; CShader* m_pShaderCom = { nullptr }; - vector m_pTextures = {}; vector<_float4x4> m_WorldMatrices = {}; _float4x4 m_WorldMatrixIdentity = {}; + _wstring m_strPrototypeTag; + + _float4 m_vPosition = {}; + _float3 m_vRotation = {}; + _float3 m_vScale = {}; #ifdef _DEBUG _char m_szFileName[MAX_PATH] = {}; - _float4 m_vPosition = {}; - _float3 m_vRotation = {}; - _float3 m_vScale = {}; + #endif // _DEBUG @@ -63,6 +67,7 @@ class CInstancedProp final : public CGameObject virtual CGameObject* Clone(void* pArg, class CGameObject* pOwner) override; virtual void Free() override; void Describe_Entity() override; + }; NS_END diff --git a/Jusin154_Team3D/Editor/Public/Level_MapViewer.h b/Jusin154_Team3D/Editor/Public/Level_MapViewer.h index 3891c2585..941fca2e3 100644 --- a/Jusin154_Team3D/Editor/Public/Level_MapViewer.h +++ b/Jusin154_Team3D/Editor/Public/Level_MapViewer.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "Editor_Define.h" #include "Level.h" @@ -21,6 +21,7 @@ class CLevel_MapViewer final : public CLevel HRESULT Ready_Layer_Camera(const _wstring& strLayerTag); HRESULT Ready_Layer_Background(const _wstring& strLayerTag); HRESULT Ready_Layer_Terrain(const _wstring& strLayerTag); + HRESULT Ready_Layer_InstanceProp(const _wstring& strLayerTag); HRESULT Ready_Layer_BuildingContainer(const _wstring& strLayerTag); HRESULT Ready_Layer_MapObjectManager(const _wstring& strLayerTag); @@ -31,4 +32,4 @@ class CLevel_MapViewer final : public CLevel virtual void Free() override; }; -NS_END \ No newline at end of file +NS_END 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 b02455a1e..7037ecd28 100644 --- a/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Engine_Shader_Functions.hlsli +++ b/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Engine_Shader_Functions.hlsli @@ -168,7 +168,20 @@ PBR_LIGHT_OUT PBR_Lighting( return Out; } +float GetBloomCurve(float x) +{ + float fResult = x; + float fThreshold = 0.68f * 2.f; + x *= 2.f; + + fResult = x * 0.05f // 최소 기본값 보장 + + max(0, x - fThreshold) // 밝기값 68 이하는 기본값으로하고 초과하면 그 값만큼 더해줌 + * 0.5f; // 0~2로 정규화 되어있기 때문에 강조 값 보정해줌 + + return fResult * 0.5f; +} +// RG 노말맵에서 Z 벡터 복원 float3 DecodeNormalFromRG(Texture2D NormalMap, SamplerState Samp, float2 uv) { float2 vSampledRG = (NormalMap.Sample(Samp, uv).rg * 2.f - 1.f); diff --git a/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl b/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl index f0e085866..eef8ea86c 100644 --- a/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl +++ b/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl @@ -69,6 +69,17 @@ VS_OUT VS_MAIN(VS_IN In) return Out; } +VS_OUT VS_CAPTURE(VS_IN In) +{ + VS_OUT Out; + + float2 vClipPos = In.vPosition.xy * 2.0f; // → -1.0 ~ +1.0 + + Out.vPosition = float4(vClipPos, 0.0f, 1.0f); + Out.vTexcoord = In.vTexcoord; + + return Out; +} struct PS_IN { @@ -362,8 +373,8 @@ PS_OUT_BACKBUFFER PS_MAIN_COMBINED(PS_IN In) Out.vBackBuffer = vDiffuse * vShade + vSpecular; - vector vDepthDesc = g_DepthTexture.Sample(DefaultSampler, In.vTexcoord); + vector vDepthDesc = g_DepthTexture.Sample(DefaultSampler, In.vTexcoord); float fViewZ = vDepthDesc.y * g_fFar; @@ -444,12 +455,70 @@ PS_OUT_BACKBUFFER PS_MAIN_COMBINED(PS_IN In) return Out; } +PS_OUT_BACKBUFFER PS_MAIN_REFIT(PS_IN In) +{ + PS_OUT_BACKBUFFER Out; + + Out.vBackBuffer = g_DiffuseTexture.Sample(PointSampler, In.vTexcoord); + + return Out; +} + +PS_OUT_BACKBUFFER PS_MAIN_EMBOSS(PS_IN In) +{ + PS_OUT_BACKBUFFER Out; + + float3 vColor = g_DiffuseTexture.Sample(PointSampler, In.vTexcoord).xyz; + + // temp 이거 키면 겁나 빤짞빤짞 빛남 ㄷㄷ + //vColor *= 3.f; + // temp + + //float fIntensity = dot(vColor, float3(0.3333f, 0.3333f, 0.3333f)); // 대략적인 밝기 + float fIntensity = dot(vColor, float3(0.2126f, 0.7152f, 0.0722f)); // 대략적인 밝기 ( 인간적인 ) + if (fIntensity <= 1e-4f) + { + Out.vBackBuffer = 0; + return Out; + } + float fBloomIntensity = GetBloomCurve(fIntensity); + + float3 bloomColor = (vColor * fBloomIntensity) / fIntensity; + Out.vBackBuffer = float4(bloomColor, 1.f); + + return Out; +} + struct PS_OUT_BLUR_X { float4 vBlurX : SV_TARGET0; float4 vBlurWeight : SV_TARGET1; }; +PS_OUT_BACKBUFFER PS_MAIN_BLOOM_ACCUM(PS_IN In) +{ + PS_OUT_BACKBUFFER Out; + + float3 vColorSrcA = g_DiffuseTexture.Sample(PointSampler, In.vTexcoord).xyz; + float3 vColorSrcB = g_BlurTexture.Sample(PointSampler, In.vTexcoord).xyz; + + Out.vBackBuffer = float4(saturate(vColorSrcA + vColorSrcB), 1.f); + + return Out; +} + +PS_OUT_BACKBUFFER PS_MAIN_BLOOM_FINISH(PS_IN In) +{ + PS_OUT_BACKBUFFER Out; + + vector vColor = g_DiffuseTexture.Sample(PointSampler, In.vTexcoord); + float3 vBloom = g_BlurTexture.Sample(PointSampler, In.vTexcoord).xyz; + Out.vBackBuffer = vColor; + Out.vBackBuffer += float4(vBloom, 1.f); + + return Out; +} + PS_OUT_BLUR_X PS_MAIN_BLUR_X(PS_IN In) { @@ -458,28 +527,6 @@ PS_OUT_BLUR_X PS_MAIN_BLUR_X(PS_IN In) float2 vTexcoord; float4 vColor = 0.f; - float fBlurWeight = g_BlurWeightTexture.Sample(ClampSampler, In.vTexcoord).r; - int iBlurWeight = (int) (round(fBlurWeight) * 128.f); - - - - int iBlurMin; - int iBlurMax; - - iBlurMin = -1 * (iBlurWeight / 2) + 1; - iBlurMax = iBlurWeight / 2; - - //for (int i = -15; i < 16; ++i) - //{ - // vTexcoord.x = In.vTexcoord.x; - // vTexcoord.y = In.vTexcoord.y + (float) i / g_vResolution.y; - - // vColor += g_fWeights[i + 15] * g_BlurXTexture.Sample(ClampSampler, vTexcoord); - //} - - //Out.vBackBuffer += vColor; - - for (int i = -63; i < 64; ++i) { vTexcoord.x = In.vTexcoord.x + (float) i / g_vResolution.x; @@ -489,7 +536,28 @@ PS_OUT_BLUR_X PS_MAIN_BLUR_X(PS_IN In) } Out.vBlurX = vColor; - Out.vBlurWeight = fBlurWeight; + Out.vBlurWeight = 0.f; + + return Out; +} + +PS_OUT_BLUR_X PS_MAIN_BLUR_Y(PS_IN In) +{ + PS_OUT_BLUR_X Out; + + float2 vTexcoord; + float4 vColor = 0.f; + + for (int i = -63; i < 64; ++i) + { + vTexcoord.x = In.vTexcoord.x; + vTexcoord.y = In.vTexcoord.y + (float) i / g_vResolution.y; + + vColor += g_fWeights[i + 63] * g_BlurTexture.Sample(ClampSampler, vTexcoord); + } + + Out.vBlurX = vColor; + Out.vBlurWeight = 0.f; return Out; } @@ -562,8 +630,58 @@ technique11 DefaultTechnique SetRasterizerState(RS_Default); SetDepthStencilState(DSS_None, 0); SetBlendState(BS_Blend, float4(0.f, 0.f, 0.f, 0.f), 0xffffffff); - VertexShader = compile vs_5_0 VS_MAIN(); + VertexShader = compile vs_5_0 VS_CAPTURE(); GeometryShader = NULL; - PixelShader = compile ps_5_0 PS_MAIN_SPOT(); + PixelShader = compile ps_5_0 PS_MAIN_REFIT(); + } + + pass EmbossingPass // 7 + { + SetRasterizerState(RS_Default); + SetDepthStencilState(DSS_None, 0); + SetBlendState(BS_Blend, float4(0.f, 0.f, 0.f, 0.f), 0xffffffff); + VertexShader = compile vs_5_0 VS_CAPTURE(); + GeometryShader = NULL; + PixelShader = compile ps_5_0 PS_MAIN_EMBOSS(); + } + + pass Bloom_BlurXPass // 8 + { + SetRasterizerState(RS_Default); + SetDepthStencilState(DSS_None, 0); + SetBlendState(BS_Blend, float4(0.f, 0.f, 0.f, 0.f), 0xffffffff); + VertexShader = compile vs_5_0 VS_CAPTURE(); + GeometryShader = NULL; + PixelShader = compile ps_5_0 PS_MAIN_BLUR_X(); + } + + pass Bloom_BlurYPass // 9 + { + SetRasterizerState(RS_Default); + SetDepthStencilState(DSS_None, 0); + SetBlendState(BS_Blend, float4(0.f, 0.f, 0.f, 0.f), 0xffffffff); + VertexShader = compile vs_5_0 VS_CAPTURE(); + GeometryShader = NULL; + PixelShader = compile ps_5_0 PS_MAIN_BLUR_Y(); + } + + pass Bloom_AccumPass // 10 + { + SetRasterizerState(RS_Default); + SetDepthStencilState(DSS_None, 0); + SetBlendState(BS_Blend, float4(0.f, 0.f, 0.f, 0.f), 0xffffffff); + VertexShader = compile vs_5_0 VS_CAPTURE(); + GeometryShader = NULL; + PixelShader = compile ps_5_0 PS_MAIN_BLOOM_ACCUM(); + } + + pass Bloom_FinishPass // 11 + { + SetRasterizerState(RS_Default); + SetDepthStencilState(DSS_None, 0); + SetBlendState(BS_Blend, float4(0.f, 0.f, 0.f, 0.f), 0xffffffff); + VertexShader = compile vs_5_0 VS_CAPTURE(); + GeometryShader = NULL; + PixelShader = compile ps_5_0 PS_MAIN_BLOOM_FINISH(); } } diff --git a/Jusin154_Team3D/Engine/Private/GameInstance.cpp b/Jusin154_Team3D/Engine/Private/GameInstance.cpp index 6bd5690c0..07f79843a 100644 --- a/Jusin154_Team3D/Engine/Private/GameInstance.cpp +++ b/Jusin154_Team3D/Engine/Private/GameInstance.cpp @@ -109,6 +109,9 @@ void CGameInstance::Update_Engine(_float fTimeDelta) m_pMouse_Manager->Update(); //m_pSound_Manager->Update(); +#ifdef _DEBUG + + #ifdef 기무리 static _bool bPicking = false; GUI::Checkbox("Picking Enable", &bPicking); @@ -116,6 +119,7 @@ void CGameInstance::Update_Engine(_float fTimeDelta) m_pPicking->Update(); } #endif // 기무리 +#endif // _DEBUG #ifndef 기무리 m_pPicking->Update(); #endif // !기무리 @@ -253,6 +257,11 @@ HRESULT CGameInstance::Bind_DepthStencil(CShader* pShader, const _char* pContant return m_pGraphic_Device->Bind_DepthStencil(pShader , pContantName); } +void CGameInstance::Get_BackBufferPTR(ID3D11Texture2D** pTexture2D) +{ + m_pGraphic_Device->Get_BackBufferPTR(pTexture2D); +} + _float CGameInstance::Get_TimeDelta(const _wstring& strTimerTag) { return m_pTimer_Manager->Get_TimeDelta(strTimerTag); @@ -541,9 +550,21 @@ HRESULT CGameInstance::Copy_RenderTarget(const _wstring& strTargetTag, ID3D11Tex { return m_pRenderTarget_Manager->Copy_RenderTarget(strTargetTag, pTexture2D); } -HRESULT CGameInstance::Refit_RenderTarget(CVIBuffer_Rect* pVIBuffer, CShader* pShader, const _wstring& wstrRenderTargetInput, const _wstring& wstrRenderTargetOutput) +HRESULT CGameInstance::Paste_RenderTarget(const _wstring& strTargetTag, ID3D11Texture2D* pTexture2D) { - return m_pRenderTarget_Manager->Refit_RenderTarget(pVIBuffer, pShader, wstrRenderTargetInput, wstrRenderTargetOutput); + return m_pRenderTarget_Manager->Paste_RenderTarget(strTargetTag, pTexture2D); +} +HRESULT CGameInstance::Accumulate_RenderTarget(CVIBuffer_Rect* pVIBuffer, CShader* pShader, const _wstring& wstrRenderTarget_SrcA, const _wstring& wstrRenderTarget_SrcB, const _wstring& wstrRenderTarget_Target, SHADER_PASS_DEFERRED ePass) +{ + return m_pRenderTarget_Manager->Accumulate_RenderTarget(pVIBuffer, pShader, wstrRenderTarget_SrcA, wstrRenderTarget_SrcB, wstrRenderTarget_Target, ePass); +} +HRESULT CGameInstance::Refit_RenderTarget(CVIBuffer_Rect* pVIBuffer, CShader* pShader, const _wstring& wstrRenderTargetInput, const _wstring& wstrRenderTargetOutput, SHADER_PASS_DEFERRED ePass) +{ + return m_pRenderTarget_Manager->Refit_RenderTarget(pVIBuffer, pShader, wstrRenderTargetInput, wstrRenderTargetOutput, ePass); +} +HRESULT CGameInstance::Finish_RenderTarget(CVIBuffer_Rect* pVIBuffer, CShader* pShader, const _wstring& wstrRenderTargetOriginal, const _wstring& wstrRenderTargetBloomed, SHADER_PASS_DEFERRED ePass) +{ + return m_pRenderTarget_Manager->Finish_RenderTarget(pVIBuffer, pShader, wstrRenderTargetOriginal, wstrRenderTargetBloomed, ePass); } #ifdef _DEBUG void CGameInstance::RenderTarget_Debuger() diff --git a/Jusin154_Team3D/Engine/Private/Graphic_Device.cpp b/Jusin154_Team3D/Engine/Private/Graphic_Device.cpp index 6364a0419..7bca5fe38 100644 --- a/Jusin154_Team3D/Engine/Private/Graphic_Device.cpp +++ b/Jusin154_Team3D/Engine/Private/Graphic_Device.cpp @@ -84,6 +84,11 @@ HRESULT CGraphic_Device::Present() return m_pSwapChain->Present(0, 0); } +void CGraphic_Device::Get_BackBufferPTR(ID3D11Texture2D** pTexture2D) +{ + m_pSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (void**)pTexture2D); +} + HRESULT CGraphic_Device::Bind_DepthStencil(CShader* pShader, const _char* pContantName) { if (FAILED(pShader->Bind_SRV(pContantName, m_pDepthStencilSRV))) diff --git a/Jusin154_Team3D/Engine/Private/Instance_Model.cpp b/Jusin154_Team3D/Engine/Private/Instance_Model.cpp index e4657a899..003917002 100644 --- a/Jusin154_Team3D/Engine/Private/Instance_Model.cpp +++ b/Jusin154_Team3D/Engine/Private/Instance_Model.cpp @@ -28,6 +28,8 @@ CInstance_Model::CInstance_Model(const CInstance_Model& rhs) SAFE_ADDREF(m_pVBInstance); } +#ifdef EDITOR_PROJECT + HRESULT CInstance_Model::Initialize_Prototype(const _char* pModelFilePath, MODEL eType, _fmatrix& PreTransformMatrix, _uint iRootBoneIndex) { if (FAILED(__super::Initialize_Prototype())) @@ -64,7 +66,6 @@ HRESULT CInstance_Model::Initialize_Prototype(const _char* pModelFilePath, MODEL SaveAssimpModel(Temp , m_pAIScene); return S_OK; } - #pragma region Mesh if (FAILED(Ready_Meshes())) { return E_FAIL; @@ -74,7 +75,49 @@ HRESULT CInstance_Model::Initialize_Prototype(const _char* pModelFilePath, MODEL return S_OK; } +#endif + +#ifndef EDITOR_PROJECT + +HRESULT CInstance_Model::Initialize_Prototype(const _char* pModelFilePath, MODEL eType, _fmatrix& PreTransformMatrix, _uint iRootBoneIndex) +{ + if (FAILED(__super::Initialize_Prototype())) + return E_FAIL; + + m_iNumBuffer = 2; + + XMStoreFloat4x4(&m_PreTransformMatrix, PreTransformMatrix); + + m_eType = eType; + _char szTextureFileName[MAX_PATH] = {}; + _char szDir[MAX_PATH] = {}; + _char szName[MAX_PATH] = {}; + _char szEXT[MAX_PATH] = {}; + + _splitpath_s(pModelFilePath, nullptr, 0, szDir, MAX_PATH, szName, MAX_PATH, szEXT, MAX_PATH); + + + if (strcmp(".bin", szEXT) == 0) + { + LoadData(pModelFilePath); + } + else { + return E_FAIL; + } +#pragma region Mesh + if (FAILED(Ready_Meshes())) { + return E_FAIL; + } + +#pragma endregion + + return S_OK; +} + +#endif + #ifdef EDITOR_PROJECT + HRESULT CInstance_Model::Assimp_Model_Load(const _char* pModelFilePath, MODEL eType, _fmatrix& PreTransformMatrix, _uint iRootBoneIndex) { _uint iFlag = {}; @@ -103,9 +146,10 @@ HRESULT CInstance_Model::Assimp_Model_Load(const _char* pModelFilePath, MODEL eT return S_OK; #pragma endregion } + #endif -#ifdef EDITOR_PROJECT + HRESULT CInstance_Model::Ready_Meshes(MODEL eType, const aiScene* pAIScene, _fmatrix& PreTransformMatrix) { XMStoreFloat4x4(&m_PreTransformMatrix, PreTransformMatrix); @@ -694,9 +738,7 @@ HRESULT CInstance_Model::Bind_CS_Output(_uint Index, _uint iBufferIndex) return S_OK; } - -#ifdef EDITOR_PROJECT - + CInstance_Model* CInstance_Model::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _char* pModelFilePath, MODEL eType, _fmatrix& PreTransformMatrix, _uint iRootBoneIndex) { CInstance_Model* pInstance = new CInstance_Model(pDevice, pContext); @@ -709,7 +751,6 @@ CInstance_Model* CInstance_Model::Create(ID3D11Device* pDevice, ID3D11DeviceCont return pInstance; } -#endif CComponent* CInstance_Model::Clone(void* pArg, CGameObject* pOwner) { diff --git a/Jusin154_Team3D/Engine/Private/Mouse_Manager.cpp b/Jusin154_Team3D/Engine/Private/Mouse_Manager.cpp index 1cff6dc5f..d48b710c4 100644 --- a/Jusin154_Team3D/Engine/Private/Mouse_Manager.cpp +++ b/Jusin154_Team3D/Engine/Private/Mouse_Manager.cpp @@ -59,7 +59,7 @@ void CMouse_Manager::Update() } m_ptOldMouseCur = m_ptCurrentMouseCur; - +#ifdef _DEBUG GUI::Begin("Mouse_Manager"); GUI::Text("AccumulateMomentum %f, %f", m_vMove.x, m_vMove.y); GUI::Text("CurPos %d, %d", m_ptCurrentMouseCur.x, m_ptCurrentMouseCur.y); @@ -79,7 +79,7 @@ void CMouse_Manager::Update() GUI::Text("INV_VPPOS: %f, %f", pt.x - (viewPort.Width * 0.5f), pt.y - (viewPort.Height * 0.5f)); GUI::End(); - +#endif Picking(); } else { diff --git a/Jusin154_Team3D/Engine/Private/PhysX_Manager.cpp b/Jusin154_Team3D/Engine/Private/PhysX_Manager.cpp index e95b268d4..f25a156d7 100644 --- a/Jusin154_Team3D/Engine/Private/PhysX_Manager.cpp +++ b/Jusin154_Team3D/Engine/Private/PhysX_Manager.cpp @@ -47,11 +47,12 @@ PSX::PxRigidDynamic* CPhysX_Manager::Add_DynamicActor(CRigidBody_Dynamic& RigidB } assert(nullptr != pShape); + // createExclusiveShape를 하면 쉐이프가 actor에 attach 된 상태로 나오기 때문에 + // 쉐이프 속성만 건드려서 액터의 쉐이프를 수정함 pShape->setFlags(RigidBody.Get_ShapeFlags()); pShape->setContactOffset(RigidBody.Get_ContactOffset()); pShape->setRestOffset(0.f); - pActorDynamic->attachShape(*pShape); PSX::PxRigidBodyFlags pxRigidFlags = RigidBody.Get_RigidBodyFlags(); pActorDynamic->setRigidBodyFlags(pxRigidFlags); @@ -101,7 +102,7 @@ PSX::PxRigidStatic* CPhysX_Manager::Add_StaticActor(CRigidBody_Static& RigidBody // GeoFlag 중 더블사이드는 이제 지원 안함, 할거면 노말 뒤집어서 하라고 함 // pPxMeshGeometry->meshFlags |= PSX::PxMeshGeometryFlag::eDOUBLE_SIDED; // 유효성 체크 - PX_ASSERT(pPxMeshGeometry.isValid()); + PX_ASSERT(pPxMeshGeometry->isValid()); m_TriangleMeshGeometry.emplace(RigidBody.Get_PxMeshKey(), pPxMeshGeometry); } break; @@ -331,10 +332,19 @@ unordered_set::iterator CPhysX_Manager::Detach_Actor(PSX::PxActor if (m_pActiveBodys.end() != iter) { m_pActiveBodys.erase(iter); // 액터를 활성화 맵에서 분리 해주고 iterOut = m_pRestBodies.insert(&Actor).first; // 액터를 다시 쓸 수 있기 때문에 따로 보관해줌 - if (m_pScene != nullptr) { - m_pScene->removeActor(Actor); - } } + + PSX::PxScene* pOwnerScene = Actor.getScene(); + + if (pOwnerScene == nullptr) { // 액터가 씬에 없는 경우 nullptr이 나옴 + return iterOut; + } + + if (pOwnerScene != m_pScene) { // 액터가 속한 씬이 아닌경우 빼면 안됨 + return iterOut; + } + m_pScene->removeActor(Actor); + return iterOut; } @@ -475,6 +485,19 @@ HRESULT CPhysX_Manager::Initialize() pPvdClient->setScenePvdFlag(PSX::PxPvdSceneFlag::eTRANSMIT_SCENEQUERIES, true); } + m_pMaterials.reserve(ENUM_CLASS(PXMATERIAL::END)); + m_pMaterials.push_back(m_pPhysics->createMaterial(0.5f, 0.5f, 0.6f)); + + PlaneData.eKind = PHYSX_KIND::BODY_STATIC; + PlaneData.iSubKind = UINT_MAX; + PlaneData.pOwner = nullptr; + PlaneData.pBody = nullptr; + + PSX::PxRigidStatic* pGroundPlane = PxCreatePlane(*m_pPhysics, physx::PxPlane(0, 1, 0, 0), *m_pMaterials[ENUM_CLASS(PXMATERIAL::DEFAULT)]); + pGroundPlane->userData = &PlaneData; + pGroundPlane->setName("PHYSX_MANAGER_PLANE"); + m_pScene->addActor(*pGroundPlane);; + // m_pScene->overlap();?????? #ifdef EDITOR_PROJECT #ifdef 기무리 @@ -483,8 +506,6 @@ HRESULT CPhysX_Manager::Initialize() PlaneData.pOwner = nullptr; PlaneData.pBody = nullptr; - m_pMaterials.reserve(ENUM_CLASS(PXMATERIAL::END)); - m_pMaterials.push_back(m_pPhysics->createMaterial(0.5f, 0.5f, 0.6f)); PSX::PxRigidStatic* pGroundPlane = PxCreatePlane(*m_pPhysics, physx::PxPlane(0, 1, 0, 0), *m_pMaterials[ENUM_CLASS(PXMATERIAL::DEFAULT)]); pGroundPlane->userData = &PlaneData; pGroundPlane->setName("PHYSX_MANAGER_PLANE"); @@ -515,8 +536,6 @@ HRESULT CPhysX_Manager::Initialize() PlaneData.pOwner = nullptr; PlaneData.pBody = nullptr; - m_pMaterials.reserve(ENUM_CLASS(PXMATERIAL::END)); - m_pMaterials.push_back(m_pPhysics->createMaterial(0.5f, 0.5f, 0.6f)); PSX::PxRigidStatic* pGroundPlane = PxCreatePlane(*m_pPhysics, physx::PxPlane(0, 1, 0, 0), *m_pMaterials[ENUM_CLASS(PXMATERIAL::DEFAULT)]); pGroundPlane->userData = &PlaneData; pGroundPlane->setName("PHYSX_MANAGER_PLANE"); @@ -547,8 +566,6 @@ HRESULT CPhysX_Manager::Initialize() PlaneData.pOwner = nullptr; PlaneData.pBody = nullptr; - m_pMaterials.reserve(ENUM_CLASS(PXMATERIAL::END)); - m_pMaterials.push_back(m_pPhysics->createMaterial(0.5f, 0.5f, 0.6f)); PSX::PxRigidStatic* pGroundPlane = PxCreatePlane(*m_pPhysics, physx::PxPlane(0, 1, 0, 0), *m_pMaterials[ENUM_CLASS(PXMATERIAL::DEFAULT)]); pGroundPlane->userData = &PlaneData; pGroundPlane->setName("PHYSX_MANAGER_PLANE"); diff --git a/Jusin154_Team3D/Engine/Private/Picking.cpp b/Jusin154_Team3D/Engine/Private/Picking.cpp index efa57a8fd..21dd71c4e 100644 --- a/Jusin154_Team3D/Engine/Private/Picking.cpp +++ b/Jusin154_Team3D/Engine/Private/Picking.cpp @@ -33,8 +33,9 @@ HRESULT CPicking::Initialize(HWND hWnd, _uint iSizeX, _uint iSizeY) TextureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE; TextureDesc.MiscFlags = 0; - if (FAILED(m_pDevice->CreateTexture2D(&TextureDesc, nullptr, &m_pTexture2D))) + if (FAILED(m_pDevice->CreateTexture2D(&TextureDesc, nullptr, &m_pTexture2D))){ return E_FAIL; + } m_iNumPixels = iSizeX * iSizeY; m_pPixels = new _float4[m_iNumPixels]; @@ -49,8 +50,9 @@ void CPicking::Update() m_pGameInstance->Copy_RenderTarget(TEXT("Target_Depth"), m_pTexture2D); D3D11_MAPPED_SUBRESOURCE SubResource{}; - if (FAILED(m_pContext->Map(m_pTexture2D, 0, D3D11_MAP_READ_WRITE, 0, &SubResource))) + if (FAILED(m_pContext->Map(m_pTexture2D, 0, D3D11_MAP_READ_WRITE, 0, &SubResource))){ return; + } memcpy(m_pPixels, SubResource.pData, sizeof(_float4) * m_iNumPixels); diff --git a/Jusin154_Team3D/Engine/Private/RenderTarget.cpp b/Jusin154_Team3D/Engine/Private/RenderTarget.cpp index 440872956..524104c85 100644 --- a/Jusin154_Team3D/Engine/Private/RenderTarget.cpp +++ b/Jusin154_Team3D/Engine/Private/RenderTarget.cpp @@ -73,6 +73,10 @@ void CRenderTarget::Copy_Resource(ID3D11Texture2D* pTexture2D) { m_pContext->CopyResource(pTexture2D, m_pTexture2D); } +void CRenderTarget::Paste_Resource(ID3D11Texture2D* pTexture2D) +{ + m_pContext->CopyResource(m_pTexture2D, pTexture2D); +} void CRenderTarget::Get_TextureDesc(D3D11_TEXTURE2D_DESC& Desc) { m_pTexture2D->GetDesc(&Desc); @@ -114,7 +118,6 @@ _bool CRenderTarget::Render_Debug(CShader* pShader, CVIBuffer_Rect* pVIBuffer ,_ m_WorldMatrix._41 = fX - m_ptWindowSize.x * 0.5f; m_WorldMatrix._42 = -fY + m_ptWindowSize.y * 0.5f; - if (FAILED(pShader->Bind_Matrix("g_WorldMatrix", &m_WorldMatrix))) return false; diff --git a/Jusin154_Team3D/Engine/Private/RenderTarget_Manager.cpp b/Jusin154_Team3D/Engine/Private/RenderTarget_Manager.cpp index f73d69afb..abbe9bb8c 100644 --- a/Jusin154_Team3D/Engine/Private/RenderTarget_Manager.cpp +++ b/Jusin154_Team3D/Engine/Private/RenderTarget_Manager.cpp @@ -155,59 +155,254 @@ HRESULT CRenderTarget_Manager::Copy_RenderTarget(const _wstring& strTargetTag, I return S_OK; } -HRESULT CRenderTarget_Manager::Refit_RenderTarget(CVIBuffer_Rect* pVIBuffer, CShader* pShader, const _wstring& wstrRenderTargetInput, const _wstring& wstrRenderTargetOutput) +HRESULT CRenderTarget_Manager::Paste_RenderTarget(const _wstring& strTargetTag, ID3D11Texture2D* pTexture2D) { + CRenderTarget* pRenderTarget = Find_RenderTarget(strTargetTag); + if (nullptr == pRenderTarget) { + return E_FAIL; + } + + pRenderTarget->Paste_Resource(pTexture2D); + + return S_OK; +} + +HRESULT CRenderTarget_Manager::Accumulate_RenderTarget(CVIBuffer_Rect* pVIBuffer, CShader* pShader, + const _wstring& wstrRenderTarget_SrcA, const _wstring& wstrRenderTarget_SrcB, + const _wstring& wstrRenderTarget_Target, SHADER_PASS_DEFERRED ePass) +{ + if (nullptr == pVIBuffer || nullptr == pShader) { + return E_FAIL; + } + CRenderTarget* pSrcA = Find_RenderTarget(wstrRenderTarget_SrcA); + CRenderTarget* pSrcB = Find_RenderTarget(wstrRenderTarget_SrcB); + CRenderTarget* pOutput = Find_RenderTarget(wstrRenderTarget_Target); + if (nullptr == pSrcA || nullptr == pSrcB || nullptr == pOutput) { return E_FAIL; } + + HRESULT hResult = S_OK; + + m_pContext->OMGetRenderTargets(1, &m_pBackBufferRTV, &m_pOriginalDSV); + + _uint iNumViewPorts = 1; + D3D11_VIEWPORT OriginalViewport = {}; + m_pContext->RSGetViewports(&iNumViewPorts, &OriginalViewport); + + _uint iNumViewPort = 1; + D3D11_VIEWPORT vp = {}; + m_pContext->RSGetViewports(&iNumViewPort, &vp); + + D3D11_TEXTURE2D_DESC OutputDesc = {}; + pOutput->Get_TextureDesc(OutputDesc); + + D3D11_VIEWPORT NewViewport = vp; + NewViewport.TopLeftX = 0.f; + NewViewport.TopLeftY = 0.f; + NewViewport.Width = static_cast<_float>(OutputDesc.Width); + NewViewport.Height = static_cast<_float>(OutputDesc.Height); + NewViewport.MinDepth = 0.f; + NewViewport.MaxDepth = 1.f; + + pOutput->Clear(); + + { // Bind RTVs + _uint iNumRenderTargets = { 1 }; + ID3D11RenderTargetView* pRenderTargetViews[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT] = { pOutput->Get_RTV(), }; + m_pContext->OMSetRenderTargets(0, nullptr, nullptr); + m_pContext->OMSetRenderTargets(iNumRenderTargets, pRenderTargetViews, nullptr); + } + + m_pContext->RSSetViewports(iNumViewPort, &NewViewport); + + { // Bind const + _float4x4 matIdentity = {}; + XMStoreFloat4x4(&matIdentity, XMMatrixIdentity()); + + if (FAILED(pShader->Bind_Matrix("g_WorldMatrix", &matIdentity))) { + hResult = E_FAIL; + } + else if (FAILED(pShader->Bind_Matrix("g_ViewMatrix", &matIdentity))) { + hResult = E_FAIL; + } + else if (FAILED(pShader->Bind_Matrix("g_ProjMatrix", &matIdentity))) { + hResult = E_FAIL; + } + else if (FAILED(pSrcA->Bind_ShaderResource(pShader, "g_DiffuseTexture"))) { + hResult = E_FAIL; + } + else if (FAILED(pSrcB->Bind_ShaderResource(pShader, "g_BlurTexture"))) { + hResult = E_FAIL; + } + } + + if (SUCCEEDED(hResult)) { + if (FAILED(pShader->Begin(ENUM_CLASS(ePass)))) { + hResult = E_FAIL; + } + else { + pVIBuffer->Bind_Resources(); + pVIBuffer->Render(); + } + } + + ID3D11ShaderResourceView* const pNullSRV[1] = { nullptr }; + m_pContext->PSSetShaderResources(0, 1, pNullSRV); + + m_pContext->OMSetRenderTargets(1, &m_pBackBufferRTV, m_pOriginalDSV); + m_pContext->RSSetViewports(iNumViewPorts, &OriginalViewport); + + SAFE_RELEASE(m_pBackBufferRTV); + SAFE_RELEASE(m_pOriginalDSV); + + return S_OK; +} + +HRESULT CRenderTarget_Manager::Refit_RenderTarget(CVIBuffer_Rect* pVIBuffer, CShader* pShader, + const _wstring& wstrRenderTargetInput, const _wstring& wstrRenderTargetOutput, SHADER_PASS_DEFERRED ePass) +{ + if (nullptr == pVIBuffer || nullptr == pShader) { + return E_FAIL; + } CRenderTarget* pInput = Find_RenderTarget(wstrRenderTargetInput); CRenderTarget* pOutput = Find_RenderTarget(wstrRenderTargetOutput); if (nullptr == pInput || nullptr == pOutput) { return E_FAIL; } + HRESULT hResult = S_OK; + + m_pContext->OMGetRenderTargets(1, &m_pBackBufferRTV, &m_pOriginalDSV); + + _uint iNumViewPorts = 1; + D3D11_VIEWPORT OriginalViewport = {}; + m_pContext->RSGetViewports(&iNumViewPorts, &OriginalViewport); + _uint iNumViewPort = 1; D3D11_VIEWPORT vp = {}; m_pContext->RSGetViewports(&iNumViewPort, &vp); D3D11_TEXTURE2D_DESC OutputDesc = {}; pOutput->Get_TextureDesc(OutputDesc); - vp.Width = (_float)OutputDesc.Width; - vp.Height = (_float)OutputDesc.Height; + + D3D11_VIEWPORT NewViewport = vp; + NewViewport.TopLeftX = 0.f; + NewViewport.TopLeftY = 0.f; + NewViewport.Width = static_cast<_float>(OutputDesc.Width); + NewViewport.Height = static_cast<_float>(OutputDesc.Height); + NewViewport.MinDepth = 0.f; + NewViewport.MaxDepth = 1.f; pOutput->Clear(); - { // Bind RTVs _uint iNumRenderTargets = { 1 }; ID3D11RenderTargetView* pRenderTargetViews[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT] = { pOutput->Get_RTV(), }; m_pContext->OMSetRenderTargets(0, nullptr, nullptr); - m_pContext->OMSetRenderTargets(1, pRenderTargetViews, nullptr); + m_pContext->OMSetRenderTargets(iNumRenderTargets, pRenderTargetViews, nullptr); } - m_pContext->RSSetViewports(iNumViewPort, &vp); + m_pContext->RSSetViewports(iNumViewPort, &NewViewport); + + const _char* pConstantName = { nullptr }; + switch (ePass) + { + case Engine::SHADER_PASS_DEFERRED::BLOOM_BLURX: + pConstantName = "g_BlurTexture"; + break; + case Engine::SHADER_PASS_DEFERRED::REFIT: + pConstantName = "g_DiffuseTexture"; + break; + case Engine::SHADER_PASS_DEFERRED::EMBOSSING: + pConstantName = "g_DiffuseTexture"; + break; + case Engine::SHADER_PASS_DEFERRED::BLOOM_BLURY: + pConstantName = "g_BlurTexture"; + break; + default: + hResult = E_FAIL; + break; + } { // Bind const _float4x4 matIdentity = {}; XMStoreFloat4x4(&matIdentity, XMMatrixIdentity()); + if (FAILED(pShader->Bind_Matrix("g_WorldMatrix", &matIdentity))) { - return E_FAIL; + hResult = E_FAIL; } - if (FAILED(pShader->Bind_Matrix("g_ViewMatrix", &matIdentity))) { - return E_FAIL; + else if (FAILED(pShader->Bind_Matrix("g_ViewMatrix", &matIdentity))) { + hResult = E_FAIL; } - if (FAILED(pShader->Bind_Matrix("g_ProjMatrix", &matIdentity))) { - return E_FAIL; + else if (FAILED(pShader->Bind_Matrix("g_ProjMatrix", &matIdentity))) { + hResult = E_FAIL; } - if (FAILED(pInput->Bind_ShaderResource(pShader, "g_DiffuseTexture"))) { - return E_FAIL; + else if (FAILED(pInput->Bind_ShaderResource(pShader, pConstantName))) { + hResult = E_FAIL; } } - if (FAILED(pShader->Begin(ENUM_CLASS(SHADER_PASS_DEFERRED::REFIT)))) { - return E_FAIL; + if (SUCCEEDED(hResult)) { + if (FAILED(pShader->Begin(ENUM_CLASS(ePass)))) { + hResult = E_FAIL; + } + else { + pVIBuffer->Bind_Resources(); + pVIBuffer->Render(); + } } - pVIBuffer->Bind_Resources(); - pVIBuffer->Render(); ID3D11ShaderResourceView* const pNullSRV[1] = { nullptr }; m_pContext->PSSetShaderResources(0, 1, pNullSRV); + m_pContext->OMSetRenderTargets(1, &m_pBackBufferRTV, m_pOriginalDSV); + m_pContext->RSSetViewports(iNumViewPorts, &OriginalViewport); + + SAFE_RELEASE(m_pBackBufferRTV); + SAFE_RELEASE(m_pOriginalDSV); + + return S_OK; +} + +HRESULT CRenderTarget_Manager::Finish_RenderTarget(CVIBuffer_Rect* pVIBuffer, CShader* pShader, const _wstring& wstrRenderTargetOriginal, const _wstring& wstrRenderTargetBloomed, SHADER_PASS_DEFERRED ePass) +{ + if (nullptr == pVIBuffer || nullptr == pShader) { + return E_FAIL; + } + CRenderTarget* pInput = Find_RenderTarget(wstrRenderTargetOriginal); + CRenderTarget* pBloomed = Find_RenderTarget(wstrRenderTargetBloomed); + if (nullptr == pInput || nullptr == pBloomed) { + return E_FAIL; + } + + HRESULT hResult = S_OK; + + { // Bind const + _float4x4 matIdentity = {}; + XMStoreFloat4x4(&matIdentity, XMMatrixIdentity()); + + if (FAILED(pShader->Bind_Matrix("g_WorldMatrix", &matIdentity))) { + hResult = E_FAIL; + } + else if (FAILED(pShader->Bind_Matrix("g_ViewMatrix", &matIdentity))) { + hResult = E_FAIL; + } + else if (FAILED(pShader->Bind_Matrix("g_ProjMatrix", &matIdentity))) { + hResult = E_FAIL; + } + else if (FAILED(pInput->Bind_ShaderResource(pShader, "g_DiffuseTexture"))) { + hResult = E_FAIL; + } + else if (FAILED(pBloomed->Bind_ShaderResource(pShader, "g_BlurTexture"))) { + hResult = E_FAIL; + } + } + + if (SUCCEEDED(hResult)) { + if (FAILED(pShader->Begin(ENUM_CLASS(ePass)))) { + hResult = E_FAIL; + } + else { + pVIBuffer->Bind_Resources(); + pVIBuffer->Render(); + } + } return S_OK; } diff --git a/Jusin154_Team3D/Engine/Private/Renderer.cpp b/Jusin154_Team3D/Engine/Private/Renderer.cpp index 00540d297..494e8f381 100644 --- a/Jusin154_Team3D/Engine/Private/Renderer.cpp +++ b/Jusin154_Team3D/Engine/Private/Renderer.cpp @@ -68,14 +68,16 @@ void CRenderer::Render() Render_NonLight(); Render_Blend(); Render_WeightBlend(); + Render_Bloom(); Render_LastColor(); Render_UI(); #ifdef _DEBUG m_pGameInstance->RenderTarget_Debuger(); - if(m_pGameInstance->Key_Pressing(DIK_F10)) + if(m_pGameInstance->Key_Pressing(DIK_F10)){ Render_Debug(); + } #endif } @@ -409,7 +411,47 @@ void CRenderer::Render_Blend() void CRenderer::Render_Bloom() { + if (m_pGameInstance->Key_Up(DIK_HOME)) { + m_bPostProcessing_BLOOM = !m_bPostProcessing_BLOOM; + } + if(true == m_bPostProcessing_BLOOM) { + { // BackBuffer + ID3D11Texture2D* pBackBuffer = nullptr; + m_pGameInstance->Get_BackBufferPTR(&pBackBuffer); + //m_pGameInstance->Copy_RenderTarget(TEXT("Target_Diffuse"), pBackBuffer); + m_pGameInstance->Paste_RenderTarget(TEXT("Target_Bloom_Input"), pBackBuffer); + SAFE_RELEASE(pBackBuffer); + } + // "Target_Bloom_Input" + // "Target_Bloom" + // "Target_Bloom_4x4" + // "Target_Bloom_8x8" + // "Target_Bloom_16x16" + // "Target_Bloom_16x16_X" + // "Target_Bloom_8x8_2" + // "Target_Bloom_4x4_2" + + m_pGameInstance->Refit_RenderTarget(m_pVIBuffer, m_pShader, TEXT("Target_Bloom_Input"), TEXT("Target_Bloom_4x4"), SHADER_PASS_DEFERRED::EMBOSSING); // 2 + m_pGameInstance->Refit_RenderTarget(m_pVIBuffer, m_pShader, TEXT("Target_Bloom_4x4"), TEXT("Target_Bloom_8x8"), SHADER_PASS_DEFERRED::REFIT); // 3 + m_pGameInstance->Refit_RenderTarget(m_pVIBuffer, m_pShader, TEXT("Target_Bloom_8x8"), TEXT("Target_Bloom_16x16"), SHADER_PASS_DEFERRED::REFIT); // 4 + + m_pGameInstance->Refit_RenderTarget(m_pVIBuffer, m_pShader, TEXT("Target_Bloom_16x16"), TEXT("Target_Bloom_16x16_X"), SHADER_PASS_DEFERRED::BLOOM_BLURX); + m_pGameInstance->Refit_RenderTarget(m_pVIBuffer, m_pShader, TEXT("Target_Bloom_16x16_X"), TEXT("Target_Bloom_16x16"), SHADER_PASS_DEFERRED::BLOOM_BLURY); // 5 + m_pGameInstance->Refit_RenderTarget(m_pVIBuffer, m_pShader, TEXT("Target_Bloom_16x16"), TEXT("Target_Bloom_8x8"), SHADER_PASS_DEFERRED::REFIT); // 6 + + m_pGameInstance->Accumulate_RenderTarget(m_pVIBuffer, m_pShader, TEXT("Target_Bloom_8x8"), TEXT("Target_Bloom_16x16"), TEXT("Target_Bloom_8x8_2"), SHADER_PASS_DEFERRED::BLOOM_ACCUM); + m_pGameInstance->Refit_RenderTarget(m_pVIBuffer, m_pShader, TEXT("Target_Bloom_8x8_2"), TEXT("Target_Bloom_8x8"), SHADER_PASS_DEFERRED::BLOOM_BLURX); + m_pGameInstance->Refit_RenderTarget(m_pVIBuffer, m_pShader, TEXT("Target_Bloom_8x8"), TEXT("Target_Bloom_8x8_2"), SHADER_PASS_DEFERRED::BLOOM_BLURY); // 7 + + m_pGameInstance->Refit_RenderTarget(m_pVIBuffer, m_pShader, TEXT("Target_Bloom_8x8_2"), TEXT("Target_Bloom_4x4"), SHADER_PASS_DEFERRED::REFIT); + m_pGameInstance->Accumulate_RenderTarget(m_pVIBuffer, m_pShader, TEXT("Target_Bloom_4x4"), TEXT("Target_Bloom_8x8_2"), TEXT("Target_Bloom_4x4_2"), SHADER_PASS_DEFERRED::BLOOM_ACCUM); + m_pGameInstance->Refit_RenderTarget(m_pVIBuffer, m_pShader, TEXT("Target_Bloom_4x4_2"), TEXT("Target_Bloom_4x4"), SHADER_PASS_DEFERRED::BLOOM_BLURX); + m_pGameInstance->Refit_RenderTarget(m_pVIBuffer, m_pShader, TEXT("Target_Bloom_4x4"), TEXT("Target_Bloom_4x4_2"), SHADER_PASS_DEFERRED::BLOOM_BLURY); // 8 + + m_pGameInstance->Refit_RenderTarget(m_pVIBuffer, m_pShader, TEXT("Target_Bloom_4x4_2"), TEXT("Target_Bloom"), SHADER_PASS_DEFERRED::REFIT); + m_pGameInstance->Finish_RenderTarget(m_pVIBuffer, m_pShader, TEXT("Target_Bloom_Input"), TEXT("Target_Bloom"), SHADER_PASS_DEFERRED::BLOOM_FINISH); // 9 + } } void CRenderer::Render_UI() @@ -602,28 +644,36 @@ HRESULT CRenderer::Initialize() } /* Target_Bloom */ + if (FAILED(m_pGameInstance->Add_RenderTarget(TEXT("Target_Bloom_Input"), (_uint)(Viewport.Width), (_uint)(Viewport.Height), + DXGI_FORMAT_R8G8B8A8_UNORM, _float4(0.0f, 0.0f, 0.0f, 0.0f)))) { + return E_FAIL; + } if (FAILED(m_pGameInstance->Add_RenderTarget(TEXT("Target_Bloom"), (_uint)(Viewport.Width), (_uint)(Viewport.Height), - DXGI_FORMAT_R32G32B32A32_FLOAT, _float4(0.0f, 0.0f, 0.0f, 0.0f)))) { + DXGI_FORMAT_R8G8B8A8_UNORM, _float4(0.0f, 0.0f, 0.0f, 0.0f)))) { return E_FAIL; } if (FAILED(m_pGameInstance->Add_RenderTarget(TEXT("Target_Bloom_4x4"), (_uint)(Viewport.Width * 0.25f), (_uint)(Viewport.Height * 0.25f), - DXGI_FORMAT_R32G32B32A32_FLOAT, _float4(0.0f, 0.0f, 0.0f, 0.0f)))) { + DXGI_FORMAT_R8G8B8A8_UNORM, _float4(0.0f, 0.0f, 0.0f, 0.0f)))) { return E_FAIL; } if (FAILED(m_pGameInstance->Add_RenderTarget(TEXT("Target_Bloom_8x8"), (_uint)(Viewport.Width * 0.125f), (_uint)(Viewport.Height * 0.125f), - DXGI_FORMAT_R32G32B32A32_FLOAT, _float4(0.0f, 0.0f, 0.0f, 0.0f)))) { + DXGI_FORMAT_R8G8B8A8_UNORM, _float4(0.0f, 0.0f, 0.0f, 0.0f)))) { return E_FAIL; } if (FAILED(m_pGameInstance->Add_RenderTarget(TEXT("Target_Bloom_16x16"), (_uint)(Viewport.Width * 0.0625f), (_uint)(Viewport.Height * 0.0625f), - DXGI_FORMAT_R32G32B32A32_FLOAT, _float4(0.0f, 0.0f, 0.0f, 0.0f)))) { + DXGI_FORMAT_R8G8B8A8_UNORM, _float4(0.0f, 0.0f, 0.0f, 0.0f)))) { + return E_FAIL; + } + if (FAILED(m_pGameInstance->Add_RenderTarget(TEXT("Target_Bloom_16x16_X"), (_uint)(Viewport.Width * 0.0625f), (_uint)(Viewport.Height * 0.0625f), + DXGI_FORMAT_R8G8B8A8_UNORM, _float4(0.0f, 0.0f, 0.0f, 0.0f)))) { return E_FAIL; } if (FAILED(m_pGameInstance->Add_RenderTarget(TEXT("Target_Bloom_8x8_2"), (_uint)(Viewport.Width * 0.125f), (_uint)(Viewport.Height * 0.125f), - DXGI_FORMAT_R32G32B32A32_FLOAT, _float4(0.0f, 0.0f, 0.0f, 0.0f)))) { + DXGI_FORMAT_R8G8B8A8_UNORM, _float4(0.0f, 0.0f, 0.0f, 0.0f)))) { return E_FAIL; } if (FAILED(m_pGameInstance->Add_RenderTarget(TEXT("Target_Bloom_4x4_2"), (_uint)(Viewport.Width * 0.25f), (_uint)(Viewport.Height * 0.25f), - DXGI_FORMAT_R32G32B32A32_FLOAT, _float4(0.0f, 0.0f, 0.0f, 0.0f)))) { + DXGI_FORMAT_R8G8B8A8_UNORM, _float4(0.0f, 0.0f, 0.0f, 0.0f)))) { return E_FAIL; } @@ -681,6 +731,7 @@ HRESULT CRenderer::Initialize() if (FAILED(m_pGameInstance->Add_MRT(TEXT("MRT_LightAcc"), TEXT("Target_Specular")))) { return E_FAIL; } + /* MRT_Shadow */ if (FAILED(m_pGameInstance->Add_MRT(TEXT("MRT_Shadow"), TEXT("Target_Shadow")))) { return E_FAIL; @@ -702,31 +753,10 @@ HRESULT CRenderer::Initialize() if (FAILED(m_pGameInstance->Add_MRT(TEXT("MRT_Blur_X"), TEXT("Target_Blur_X")))) { return E_FAIL; } - if (FAILED(m_pGameInstance->Add_MRT(TEXT("MRT_Blur_X"), TEXT("Target_Blur_X_Weight")))) { return E_FAIL; } - /* MRT_Bloom */ - if (FAILED(m_pGameInstance->Add_MRT(TEXT("MRT_Bloom"), TEXT("Target_Bloom")))) { - return E_FAIL; - } - if (FAILED(m_pGameInstance->Add_MRT(TEXT("MRT_Bloom"), TEXT("Target_Bloom_4x4")))) { - return E_FAIL; - } - if (FAILED(m_pGameInstance->Add_MRT(TEXT("MRT_Bloom"), TEXT("Target_Bloom_8x8")))) { - return E_FAIL; - } - if (FAILED(m_pGameInstance->Add_MRT(TEXT("MRT_Bloom"), TEXT("Target_Bloom_16x16")))) { - return E_FAIL; - } - if (FAILED(m_pGameInstance->Add_MRT(TEXT("MRT_Bloom"), TEXT("Target_Bloom_8x8_2")))) { - return E_FAIL; - } - if (FAILED(m_pGameInstance->Add_MRT(TEXT("MRT_Bloom"), TEXT("Target_Bloom_4x4_2")))) { - return E_FAIL; - } - /* MRT_Color */ if (FAILED(m_pGameInstance->Add_MRT(TEXT("MRT_Color"), TEXT("Target_Color")))) { return E_FAIL; diff --git a/Jusin154_Team3D/Engine/Private/VIBuffer_Model_Instance.cpp b/Jusin154_Team3D/Engine/Private/VIBuffer_Model_Instance.cpp index 21e03ff95..65618d248 100644 --- a/Jusin154_Team3D/Engine/Private/VIBuffer_Model_Instance.cpp +++ b/Jusin154_Team3D/Engine/Private/VIBuffer_Model_Instance.cpp @@ -37,56 +37,23 @@ CVIBuffer_Model_Instance::CVIBuffer_Model_Instance(const CVIBuffer_Model_Instanc } } -HRESULT CVIBuffer_Model_Instance::Initialize_Prototype(const _char* pFileName) +HRESULT CVIBuffer_Model_Instance::Initialize_Prototype(const _char* pModelFilePath, const _char* pMatrialPath) { - SaveMesh SaveMesh_Desc = {}; - - CModel* pModel = { nullptr }; - - /* Read File */ - ifstream in(pFileName, ios::binary); - - if (!in.is_open()) - { - MSG_BOX("Failed to Load : Instance Data"); - return E_FAIL; - } - - in.read(reinterpret_cast<_char*>(&SaveMesh_Desc.MeshNameSize), sizeof(_uint)); - in.read(reinterpret_cast<_char*>(&SaveMesh_Desc.VertexCount), sizeof(_uint)); - in.read(reinterpret_cast<_char*>(&SaveMesh_Desc.IndexCount), sizeof(_uint)); - in.read(reinterpret_cast<_char*>(&SaveMesh_Desc.MaterialIndex), sizeof(_uint)); - in.read(reinterpret_cast<_char*>(&SaveMesh_Desc.BoneCount), sizeof(_uint)); - - in.read(reinterpret_cast<_char*>(&SaveMesh_Desc.MeshName), sizeof(char) * SaveMesh_Desc.MeshNameSize); - in.read(reinterpret_cast<_char*>(SaveMesh_Desc.Vertices.data()), sizeof(SaveVertex) * SaveMesh_Desc.VertexCount); - in.read(reinterpret_cast<_char*>(SaveMesh_Desc.Indices.data()), sizeof(_uint) * SaveMesh_Desc.IndexCount); - - SaveMesh_Desc.Bones.resize(SaveMesh_Desc.BoneCount); - - in.read(reinterpret_cast<_char*>(&m_iNumMeshes), sizeof(_uint)); - - if (FAILED(Load_InstanceData(in))) + if (FAILED(Load_ModelData(pModelFilePath))) return E_FAIL; - for (_uint i = 0; i < m_iNumMeshes; ++i) - { - CMesh* pMesh = CMesh::Create(m_pDevice, m_pContext, MODEL::NONANIM, pModel, &SaveMesh_Desc, XMMatrixIdentity()); + if (FAILED(Load_Material(pModelFilePath, pMatrialPath))) + return E_FAIL; - if (nullptr == pMesh) - return E_FAIL; - - m_Meshes.push_back(pMesh); - } - - in.close(); + if (FAILED(Ready_Materials())) + return E_FAIL; return S_OK; } HRESULT CVIBuffer_Model_Instance::Initialize(void* pArg) { - if (FAILED(Load_InstanceData_Editor())) + if (FAILED(Reay_Instance_Buffer())) return E_FAIL; return S_OK; @@ -150,8 +117,6 @@ HRESULT CVIBuffer_Model_Instance::Load_WorldData(vector<_float4x4>& WorldMatrice HRESULT CVIBuffer_Model_Instance::Reay_Instance_Buffer() { - m_iNumInstance = m_InstanceDesc.iNum; - m_iInstanceStride = sizeof(VTX_INSTANCE_MODEL); D3D11_BUFFER_DESC InstanceBufferDesc = {}; @@ -198,6 +163,102 @@ HRESULT CVIBuffer_Model_Instance::Load_InstanceData(ifstream& in) return S_OK; } +HRESULT CVIBuffer_Model_Instance::Load_ModelData(const _char* pModelFilePath) +{ + ifstream In(pModelFilePath, ios::binary); + + if (!In.is_open()) + { + MSG_BOX("Failed to Load : Model Data"); + return E_FAIL; + } + + In.read(reinterpret_cast<_char*>(&m_iNumMeshes), sizeof(_uint)); + + for (_uint i = 0; i < m_iNumMeshes; ++i) + { + SaveMesh mesh{}; + + In.read(reinterpret_cast<_char*>(&mesh.MeshNameSize), sizeof(_uint)); + mesh.MeshName.resize(mesh.MeshNameSize); + In.read(reinterpret_cast<_char*>(mesh.MeshName.data()), mesh.MeshNameSize); + + + In.read(reinterpret_cast<_char*>(&mesh.VertexCount), sizeof(_uint)); + In.read(reinterpret_cast<_char*>(&mesh.IndexCount), sizeof(_uint)); + In.read(reinterpret_cast<_char*>(&mesh.MaterialIndex), sizeof(_uint)); + In.read(reinterpret_cast<_char*>(&mesh.BoneCount), sizeof(_uint)); + + mesh.Vertices.resize(mesh.VertexCount); + In.read(reinterpret_cast<_char*>(mesh.Vertices.data()), sizeof(SaveVertex) * mesh.VertexCount); + + mesh.Indices.resize(mesh.IndexCount); + In.read(reinterpret_cast<_char*>(mesh.Indices.data()), sizeof(_uint) * mesh.IndexCount); + + CModel* pModel = { nullptr }; + + CMesh* pMesh = CMesh::Create(m_pDevice, m_pContext, MODEL::NONANIM, pModel, &mesh, XMMatrixIdentity()); + + if (nullptr == pMesh) + return E_FAIL; + + m_Meshes.push_back(pMesh); + } + In.read(reinterpret_cast<_char*>(&m_iNumInstance), sizeof(_uint)); + + m_iMaxNumInstance = m_iNumInstance; + + In.close(); + + return S_OK; +} + +HRESULT CVIBuffer_Model_Instance::Load_Material(const _char* pModelFilePath, const _char* pMatrialPath) +{ + tinyxml2::XMLDocument xmlDoc; + + if ((tinyxml2::XML_SUCCESS != xmlDoc.LoadFile(pMatrialPath))) + return E_FAIL; + + tinyxml2::XMLElement* root = xmlDoc.FirstChildElement("Instance"); + + _char szName[MAX_PATH] = {}; + + _splitpath_s(pModelFilePath, nullptr, 0, nullptr, 0, szName, MAX_PATH, nullptr, 0); + + tinyxml2::XMLElement* Model = root->FirstChildElement(szName); + + /* Check Mesh Num */ + _uint iNumMesh = {}; + Model->QueryUnsignedAttribute("mesh", &iNumMesh); + + if (iNumMesh != m_iNumMeshes) + return E_FAIL; + + for (auto* Mesh = Model->FirstChildElement("Mesh"); Mesh; Mesh = Mesh->NextSiblingElement("Mesh")) + { + vector MaterialPathes = {}; + + for (auto* Material = Mesh->FirstChildElement("Material"); Material; Material = Material->NextSiblingElement("Material")) + { + MaterialPathes.push_back("../Bin/Resources/Models/InstanceProp/Textures/" + string(Material->GetText()) + ".dds"); + } + + m_MeshMaterialPathes.push_back(MaterialPathes); + + auto* Surface = Mesh->FirstChildElement("Surface"); + string strSurface = Surface->GetText(); + + if (string::npos != strSurface.find("SRO")) + m_SurfaceMaterialFlag.push_back(aiTextureType_SPECULAR); + else + m_SurfaceMaterialFlag.push_back(aiTextureType_METALNESS); + } + + return S_OK; +} + + HRESULT CVIBuffer_Model_Instance::Ready_Materials() { for (_uint i = 0; i < m_iNumMeshes; ++i) @@ -222,70 +283,15 @@ HRESULT CVIBuffer_Model_Instance::Ready_Materials() } #ifdef EDITOR_PROJECT -HRESULT CVIBuffer_Model_Instance::Save_InstanceData(_char* pFileName) + +HRESULT CVIBuffer_Model_Instance::SaveAssimpModel(const _char* pModelFilePath) { -#pragma region SAVE_MESH - SaveMesh saveMesh{}; - - if (SaveAssimpModel(saveMesh)) - return E_FAIL; - - ofstream out(pFileName, ios::binary); - - if (!out.is_open()) - { - MSG_BOX("Failed to Save : Instance Data"); - return E_FAIL; - } - - out.write(reinterpret_cast<_char*>(&saveMesh.MeshNameSize), sizeof(_uint)); - out.write(reinterpret_cast<_char*>(&saveMesh.VertexCount), sizeof(_uint)); - out.write(reinterpret_cast<_char*>(&saveMesh.IndexCount), sizeof(_uint)); - out.write(reinterpret_cast<_char*>(&saveMesh.MaterialIndex), sizeof(_uint)); - out.write(reinterpret_cast<_char*>(&saveMesh.BoneCount), sizeof(_uint)); - - out.write(reinterpret_cast<_char*>(&saveMesh.MeshName), sizeof(char) * saveMesh.MeshNameSize); - out.write(reinterpret_cast<_char*>(saveMesh.Vertices.data()), sizeof(SaveVertex) * saveMesh.VertexCount); - out.write(reinterpret_cast<_char*>(saveMesh.Indices.data()), sizeof(_uint) * saveMesh.IndexCount); - - out.write(reinterpret_cast(&saveMesh.MeshNameSize), sizeof(_uint)); - - out.write(reinterpret_cast<_char*>(&m_iNumMeshes), sizeof(_uint)); -#pragma endregion - - -#pragma region INSTANCE_DATA - out.write(reinterpret_cast<_char*>(&m_iCurrentNumInstance), sizeof(_uint)); - - D3D11_MAPPED_SUBRESOURCE SubResource{}; - - if (FAILED(m_pContext->Map(m_pVBInstance, 0, D3D11_MAP_READ, 0, &SubResource))) - { - out.close(); - return E_FAIL; - } - - VTX_INSTANCE_MODEL* pData = static_cast(SubResource.pData); - - for (_uint i = 0; i < m_iCurrentNumInstance; ++i) - { - out.write(reinterpret_cast<_char*>(&pData[i]), sizeof(VTX_INSTANCE_MODEL)); - } - - m_pContext->Unmap(m_pVBInstance, 0); -#pragma endregion - - out.close(); - - return S_OK; -} - -_bool CVIBuffer_Model_Instance::SaveAssimpModel(SaveMesh& saveMesh) -{ - if (!m_pAIScene) return false; + if (!m_pAIScene) return E_FAIL; for (_uint i = 0; i < m_pAIScene->mNumMeshes; i++) { + SaveMesh saveMesh{}; + aiMesh* mesh = m_pAIScene->mMeshes[i]; saveMesh.MeshName = mesh->mName.C_Str(); @@ -351,23 +357,6 @@ _bool CVIBuffer_Model_Instance::SaveAssimpModel(SaveMesh& saveMesh) saveMesh.Vertices[i].BlendIndex = XMUINT4(0, 0, 0, 0); saveMesh.Vertices[i].BlendWeight = XMFLOAT4(0.f, 0.f, 0.f, 0.f); } - saveMesh.BoneCount = mesh->mNumBones; - saveMesh.Bones.resize(mesh->mNumBones); - for (size_t j = 0; j < mesh->mNumBones; j++) - { - saveMesh.Bones[j].BoneName = mesh->mBones[j]->mName.C_Str(); - saveMesh.Bones[j].BoneNameSize = (_int)saveMesh.Bones[j].BoneName.size(); - - memcpy(&saveMesh.Bones[j].OffsetMatrix, &mesh->mBones[j]->mOffsetMatrix, sizeof(_float4x4)); - XMStoreFloat4x4(&saveMesh.Bones[j].OffsetMatrix, XMMatrixTranspose(XMLoadFloat4x4(&saveMesh.Bones[j].OffsetMatrix))); - saveMesh.Bones[j].WeightsCount = mesh->mBones[j]->mNumWeights; - saveMesh.Bones[j].Weights.resize(mesh->mBones[j]->mNumWeights); - for (size_t k = 0; k < saveMesh.Bones[j].WeightsCount; k++) - { - saveMesh.Bones[j].Weights[k].VertexId = mesh->mBones[j]->mWeights[k].mVertexId; - saveMesh.Bones[j].Weights[k].Weight = mesh->mBones[j]->mWeights[k].mWeight; - } - } saveMesh.Indices.reserve(saveMesh.IndexCount); for (_uint i = 0; i < mesh->mNumFaces; i++) @@ -376,9 +365,45 @@ _bool CVIBuffer_Model_Instance::SaveAssimpModel(SaveMesh& saveMesh) for (_uint idx = 0; idx < face.mNumIndices; idx++) saveMesh.Indices.push_back(face.mIndices[idx]); } + + m_SaveMeshDesc.push_back(saveMesh); } - return true; +#pragma region SAVE_MESH + filesystem::path ModelPath = pModelFilePath; + + string pFileName = ModelPath.parent_path().string() + "/" + ModelPath.stem().string() + ".bin"; + + ofstream out(pFileName, ios::binary); + + if (!out.is_open()) + { + MSG_BOX("Failed to Save : Instance Data"); + return E_FAIL; + } + out.write(reinterpret_cast<_char*>(&m_iNumMeshes), sizeof(_uint)); + + + for (auto& mesh : m_SaveMeshDesc) + { + out.write(reinterpret_cast<_char*>(&mesh.MeshNameSize), sizeof(_uint)); + out.write(reinterpret_cast<_char*>(mesh.MeshName.data()), mesh.MeshNameSize); + out.write(reinterpret_cast<_char*>(&mesh.VertexCount), sizeof(_uint)); + out.write(reinterpret_cast<_char*>(&mesh.IndexCount), sizeof(_uint)); + out.write(reinterpret_cast<_char*>(&mesh.MaterialIndex), sizeof(_uint)); + out.write(reinterpret_cast<_char*>(&mesh.BoneCount), sizeof(_uint)); + + out.write(reinterpret_cast<_char*>(mesh.Vertices.data()), sizeof(SaveVertex) * mesh.VertexCount); + out.write(reinterpret_cast<_char*>(mesh.Indices.data()), sizeof(_uint) * mesh.IndexCount); + } + + out.write(reinterpret_cast<_char*>(&m_iMaxNumInstance), sizeof(_uint)); +#pragma endregion + + out.close(); + + + return S_OK; } HRESULT CVIBuffer_Model_Instance::Initialize_Prototype(const INSTANCE_DESC* pDesc, const _char* pModelFilePath, const _char* pMatrialPath) @@ -395,6 +420,8 @@ HRESULT CVIBuffer_Model_Instance::Initialize_Prototype(const INSTANCE_DESC* pDes if(FAILED(Ready_Materials())) return E_FAIL; + + return S_OK; } @@ -459,21 +486,18 @@ HRESULT CVIBuffer_Model_Instance::Assimp_Model_Load(const _char* pModelFilePath) _uint iFlag = {}; iFlag = aiProcess_ConvertToLeftHanded | aiProcessPreset_TargetRealtime_Fast | aiProcess_PreTransformVertices; - Assimp::Importer Importer = {}; - const aiScene* pAIScene = { nullptr }; - - pAIScene = Importer.ReadFile(pModelFilePath, iFlag); - if (nullptr == pAIScene) { + m_pAIScene = m_Importer.ReadFile(pModelFilePath, iFlag); + if (nullptr == m_pAIScene) { return E_FAIL; } - m_iNumMeshes = pAIScene->mNumMeshes; + m_iNumMeshes = m_pAIScene->mNumMeshes; vector bones; for (_uint i = 0; i < m_iNumMeshes; ++i) { - CMesh* pMesh = CMesh::Create(m_pDevice, m_pContext, MODEL::NONANIM, bones, pAIScene->mMeshes[i], XMMatrixIdentity()); + CMesh* pMesh = CMesh::Create(m_pDevice, m_pContext, MODEL::NONANIM, bones, m_pAIScene->mMeshes[i], XMMatrixIdentity()); if (nullptr == pMesh) return E_FAIL; @@ -481,6 +505,9 @@ HRESULT CVIBuffer_Model_Instance::Assimp_Model_Load(const _char* pModelFilePath) m_Meshes.push_back(pMesh); } + if (FAILED(SaveAssimpModel(pModelFilePath))) + return E_FAIL; + return S_OK; } @@ -498,82 +525,13 @@ CVIBuffer_Model_Instance* CVIBuffer_Model_Instance::Create(ID3D11Device* pDevice } -HRESULT CVIBuffer_Model_Instance::Reay_Instance_Buffer_Editor() -{ - m_iInstanceStride = sizeof(VTX_INSTANCE_MODEL); - - D3D11_BUFFER_DESC InstanceBufferDesc = {}; - - InstanceBufferDesc.ByteWidth = m_iInstanceStride * m_iNumInstance; - InstanceBufferDesc.Usage = D3D11_USAGE_DYNAMIC; - InstanceBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER; - InstanceBufferDesc.StructureByteStride = m_iInstanceStride; - InstanceBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - InstanceBufferDesc.MiscFlags = 0; - - if (FAILED(m_pDevice->CreateBuffer(&InstanceBufferDesc, nullptr, &m_pVBInstance))) - return E_FAIL; - - return S_OK; -} -HRESULT CVIBuffer_Model_Instance::Load_InstanceData_Editor() -{ - if (FAILED(Reay_Instance_Buffer_Editor())) - return E_FAIL; - - return S_OK; -} -HRESULT CVIBuffer_Model_Instance::Load_Material(const _char* pModelFilePath, const _char* pMatrialPath) -{ - tinyxml2::XMLDocument xmlDoc; - - if ((tinyxml2::XML_SUCCESS != xmlDoc.LoadFile(pMatrialPath))) - return E_FAIL; - - tinyxml2::XMLElement* root = xmlDoc.FirstChildElement("Instance"); - - _char szName[MAX_PATH] = {}; - - _splitpath_s(pModelFilePath, nullptr, 0, nullptr, 0, szName, MAX_PATH, nullptr, 0); - - tinyxml2::XMLElement* Model = root->FirstChildElement(szName); - - /* Check Mesh Num */ - _uint iNumMesh = {}; - Model->QueryUnsignedAttribute("mesh", &iNumMesh); - - if (iNumMesh != m_iNumMeshes) - return E_FAIL; - - for (auto* Mesh = Model->FirstChildElement("Mesh"); Mesh; Mesh = Mesh->NextSiblingElement("Mesh")) - { - vector MaterialPathes = {}; - - for (auto* Material = Mesh->FirstChildElement("Material"); Material; Material = Material->NextSiblingElement("Material")) - { - MaterialPathes.push_back("../Bin/Resources/Models/InstanceProp/Textures/" + string(Material->GetText()) + ".dds"); - } - - m_MeshMaterialPathes.push_back(MaterialPathes); - - auto* Surface = Mesh->FirstChildElement("Surface"); - string strSurface = Surface->GetText(); - - if (string::npos != strSurface.find("SRO")) - m_SurfaceMaterialFlag.push_back(aiTextureType_SPECULAR); - else - m_SurfaceMaterialFlag.push_back(aiTextureType_METALNESS); - } - - return S_OK; -} #endif -CVIBuffer_Model_Instance* CVIBuffer_Model_Instance::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _char* pFileName) +CVIBuffer_Model_Instance* CVIBuffer_Model_Instance::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _char* pModelFilePath, const _char* pMatrialPath) { CVIBuffer_Model_Instance* pInstance = new CVIBuffer_Model_Instance(pDevice, pContext); - if (FAILED(pInstance->Initialize_Prototype(pFileName))) + if (FAILED(pInstance->Initialize_Prototype(pModelFilePath, pMatrialPath))) { MSG_BOX("Failed to Created : CVIBuffer_Model_Instance"); SAFE_RELEASE(pInstance); @@ -617,8 +575,9 @@ void CVIBuffer_Model_Instance::Free() m_SurfaceMaterialFlag.clear(); } - +#ifdef _DEBUG void CVIBuffer_Model_Instance::Describe_Entity() { GUI::Text("Instance Count : %d / %d", m_iCurrentNumInstance, m_iMaxNumInstance); } +#endif diff --git a/Jusin154_Team3D/Engine/Public/Engine_Enum.h b/Jusin154_Team3D/Engine/Public/Engine_Enum.h index e90cb29c1..a2f0c036c 100644 --- a/Jusin154_Team3D/Engine/Public/Engine_Enum.h +++ b/Jusin154_Team3D/Engine/Public/Engine_Enum.h @@ -34,7 +34,7 @@ enum class NAVI_POINT { A, B, C, END }; enum class NAVI_LINE { AB, BC, CA, END }; enum class SHADER_PASS_CELL { DEBUG, END }; -enum class SHADER_PASS_DEFERRED { DEBUG, DIRECTIONAL, POINT, COMBINED, BLUR, SPOT, REFIT, END }; +enum class SHADER_PASS_DEFERRED { DEBUG, DIRECTIONAL, POINT, COMBINED, BLUR, SPOT, REFIT, EMBOSSING, BLOOM_BLURX, BLOOM_BLURY, BLOOM_ACCUM, BLOOM_FINISH, END }; enum class QUESTYPE {MAIN, SUB, END}; enum class TEXTURE_MOUNT_SLOT0 { NOT_DEFINED, METALLIC, SPECULAR, HEIGHT, END }; diff --git a/Jusin154_Team3D/Engine/Public/GameInstance.h b/Jusin154_Team3D/Engine/Public/GameInstance.h index 73531840b..9939c98a1 100644 --- a/Jusin154_Team3D/Engine/Public/GameInstance.h +++ b/Jusin154_Team3D/Engine/Public/GameInstance.h @@ -29,6 +29,7 @@ class ENGINE_DLL CGameInstance final : public CBase void Render_Begin(const _float4* pClearColor); void Render_End(); HRESULT Bind_DepthStencil(class CShader* pShader, const _char* pContantName); + void Get_BackBufferPTR(ID3D11Texture2D** pTexture2D); #pragma endregion #pragma region TIMER_MANAGER @@ -157,7 +158,10 @@ class ENGINE_DLL CGameInstance final : public CBase HRESULT End_MRT(); HRESULT Bind_RenderTarget(const _wstring& strTargetTag, class CShader* pShader, const _char* pConstantName); HRESULT Copy_RenderTarget(const _wstring& strTargetTag, ID3D11Texture2D* pTexture2D); - HRESULT Refit_RenderTarget(class CVIBuffer_Rect* pVIBuffer, class CShader* pShader, const _wstring& wstrRenderTargetInput, const _wstring& wstrRenderTargetOutput); + HRESULT Paste_RenderTarget(const _wstring& strTargetTag, ID3D11Texture2D* pTexture2D); + 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); + HRESULT Refit_RenderTarget(class CVIBuffer_Rect* pVIBuffer, class CShader* pShader, const _wstring& wstrRenderTargetInput, const _wstring& wstrRenderTargetOutput, SHADER_PASS_DEFERRED ePass); + HRESULT Finish_RenderTarget(class CVIBuffer_Rect* pVIBuffer, class CShader* pShader, const _wstring& wstrRenderTargetOriginal, const _wstring& wstrRenderTargetBloomed, SHADER_PASS_DEFERRED ePass); #ifdef _DEBUG void RenderTarget_Debuger(); HRESULT Render_RenderTarget_Debug(class CShader* pShader, class CVIBuffer_Rect* pVIBuffer); diff --git a/Jusin154_Team3D/Engine/Public/Graphic_Device.h b/Jusin154_Team3D/Engine/Public/Graphic_Device.h index c41bdacf7..b24ff2118 100644 --- a/Jusin154_Team3D/Engine/Public/Graphic_Device.h +++ b/Jusin154_Team3D/Engine/Public/Graphic_Device.h @@ -20,6 +20,8 @@ class CGraphic_Device final HRESULT Present(); + void Get_BackBufferPTR(ID3D11Texture2D** pTexture2D); + HRESULT Bind_DepthStencil(class CShader* pShader, const _char* pContantName); private: diff --git a/Jusin154_Team3D/Engine/Public/RenderTarget.h b/Jusin154_Team3D/Engine/Public/RenderTarget.h index 14aeebd85..ef0f42f20 100644 --- a/Jusin154_Team3D/Engine/Public/RenderTarget.h +++ b/Jusin154_Team3D/Engine/Public/RenderTarget.h @@ -18,6 +18,7 @@ class CRenderTarget final : public CBase HRESULT Bind_ShaderResource(class CShader* pShader, const _char* pConstantName); void Clear(); void Copy_Resource(ID3D11Texture2D* pTexture2D); + void Paste_Resource(ID3D11Texture2D* pTexture2D); void Get_TextureDesc(D3D11_TEXTURE2D_DESC& Desc); ID3D11ShaderResourceView* Get_SRV() const { return m_pSRV; } diff --git a/Jusin154_Team3D/Engine/Public/RenderTarget_Manager.h b/Jusin154_Team3D/Engine/Public/RenderTarget_Manager.h index 9bd2260cf..1055e8a4d 100644 --- a/Jusin154_Team3D/Engine/Public/RenderTarget_Manager.h +++ b/Jusin154_Team3D/Engine/Public/RenderTarget_Manager.h @@ -18,8 +18,11 @@ class CRenderTarget_Manager final : public CBase HRESULT End_MRT(); HRESULT Bind_RenderTarget(const _wstring& strTargetTag, class CShader* pShader, const _char* pConstantName); HRESULT Copy_RenderTarget(const _wstring& strTargetTag, ID3D11Texture2D* pTexture2D); + HRESULT Paste_RenderTarget(const _wstring& strTargetTag, ID3D11Texture2D* pTexture2D); - HRESULT Refit_RenderTarget(class CVIBuffer_Rect* pVIBuffer, class CShader* pShader, const _wstring& wstrRenderTargetInput, const _wstring& wstrRenderTargetOutput); + 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); + HRESULT Refit_RenderTarget(class CVIBuffer_Rect* pVIBuffer, class CShader* pShader, const _wstring& wstrRenderTargetInput, const _wstring& wstrRenderTargetOutput, SHADER_PASS_DEFERRED ePass); + HRESULT Finish_RenderTarget(class CVIBuffer_Rect* pVIBuffer, class CShader* pShader, const _wstring& wstrRenderTargetOriginal, const _wstring& wstrRenderTargetBloomed, SHADER_PASS_DEFERRED ePass); #ifdef _DEBUG public: diff --git a/Jusin154_Team3D/Engine/Public/Renderer.h b/Jusin154_Team3D/Engine/Public/Renderer.h index d3a28c7ab..83aa33cfe 100644 --- a/Jusin154_Team3D/Engine/Public/Renderer.h +++ b/Jusin154_Team3D/Engine/Public/Renderer.h @@ -44,6 +44,8 @@ class CRenderer final : public CBase SHADOW_LIGHT_DESC m_PreShadowDesc = {}; _float4x4 m_PreShadowMatrices[ENUM_CLASS(D3DTS::END)] = {}; + _bool m_bPostProcessing_BLOOM = { false }; + private: void Render_Priority(); diff --git a/Jusin154_Team3D/Engine/Public/VIBuffer_Model_Instance.h b/Jusin154_Team3D/Engine/Public/VIBuffer_Model_Instance.h index 065a75adb..c459ea1bb 100644 --- a/Jusin154_Team3D/Engine/Public/VIBuffer_Model_Instance.h +++ b/Jusin154_Team3D/Engine/Public/VIBuffer_Model_Instance.h @@ -14,20 +14,22 @@ class ENGINE_DLL CVIBuffer_Model_Instance final : public CVIBuffer_Instance _uint Get_NumMesh() const { return m_iNumMeshes; } public: - virtual HRESULT Initialize_Prototype(const _char* pModelFilePath); + virtual HRESULT Initialize_Prototype(const _char* pModelFilePath, const _char* pMatrialPath); virtual HRESULT Initialize(void* pArg) override; virtual HRESULT Render(_uint iMeshIndex); HRESULT Bind_Matrial(class CShader* pShader, _uint iMeshIndex); HRESULT Load_WorldData(vector<_float4x4>& WorldMatrices); private: - _uint m_iNumBuffer = {}; - _uint m_iNumMeshes = {}; + _uint m_iNumBuffer = {}; + _uint m_iNumMeshes = {}; + _uint m_iCurrentNumInstance = {}; + _uint m_iMaxNumInstance = {}; - INSTANCE_DESC m_InstanceDesc = {}; + INSTANCE_DESC m_InstanceDesc = {}; - vector m_Meshes = {}; + vector m_Meshes = {}; vector> m_MeshMaterialsSRV = {}; vector m_SurfaceMaterialFlag = {}; @@ -36,6 +38,8 @@ class ENGINE_DLL CVIBuffer_Model_Instance final : public CVIBuffer_Instance private: HRESULT Reay_Instance_Buffer(); HRESULT Load_InstanceData(ifstream& in); + HRESULT Load_ModelData(const _char* pModelFilePath); + HRESULT Load_Material(const _char* pModelFilePath, const _char* pMatrialPath); HRESULT Ready_Materials(); #ifdef EDITOR_PROJECT @@ -47,25 +51,18 @@ class ENGINE_DLL CVIBuffer_Model_Instance final : public CVIBuffer_Instance virtual HRESULT Initialize_Prototype(const INSTANCE_DESC* pDesc, const _char* pFileName, const _char* pMatrialPath); HRESULT Assimp_Model_Load(const _char* pModelFilePath); - - HRESULT Save_InstanceData(_char* pFileName); - _bool SaveAssimpModel(SaveMesh& saveMesh); - - HRESULT Reay_Instance_Buffer_Editor(); - HRESULT Load_InstanceData_Editor(); - HRESULT Load_Material(const _char* pModelFilePath, const _char* pMatrialPath); + HRESULT SaveAssimpModel(const _char* pModelFilePath); public: static CVIBuffer_Model_Instance* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const INSTANCE_DESC* pInstanceDesc, const _char* pModelFilePath, const _char* pMatrialPath); const aiScene* m_pAIScene = { nullptr }; Assimp::Importer m_Importer; - _uint m_iCurrentNumInstance = {}; - _uint m_iMaxNumInstance = {}; + vector m_SaveMeshDesc = {}; #endif public: - static CVIBuffer_Model_Instance* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _char* pFileName); + static CVIBuffer_Model_Instance* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _char* pModelFilePath, const _char* pMatrialPath); virtual CComponent* Clone(void* pArg, class CGameObject* pOwner = nullptr) override; virtual void Free() override; #ifdef _DEBUG