diff --git a/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/Light/Duengon_PointLight_Data.xml b/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/Light/Duengon_PointLight_Data.xml new file mode 100644 index 000000000..7b5472b69 --- /dev/null +++ b/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/Light/Duengon_PointLight_Data.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl index 2fc5db15f..0d14ceee3 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl +++ b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl @@ -33,6 +33,7 @@ float g_fSSAO_BIAS; float g_fSSAOStrength; Texture2D g_Texture; +Texture2D g_NoiseTexture; Texture2D g_SSAONoiseTexture; Texture2D g_SSAOInputTexture; uint g_iKernelSize; @@ -90,6 +91,7 @@ vector g_vLightSpecular; float g_fFogDensity; float g_fFogPow; +float g_fFogHeightValue; bool g_bFogVisible; vector g_vFogColor; @@ -1149,9 +1151,25 @@ PS_OUT_FLT4_SINGLE PS_MAIN_FOG(PS_IN In) return Out; } - vector vFinalColor; float fViewZ = vDepthDesc.y * g_fFar; + float4 vPosition, vPreShadowPosition; + vPosition.x = In.vTexcoord.x * 2.f - 1.f; + vPosition.y = In.vTexcoord.y * -2.f + 1.f; + vPosition.z = vDepthDesc.x; + vPosition.w = 1.f; + + vPosition = vPosition * fViewZ; + + vPosition = mul(vPosition, g_invmatProj); + vPosition = mul(vPosition, g_invMatView); + + float2 NoiseUV = vPosition.xz * 0.01f; + + float fNoise = g_NoiseTexture.Sample(DefaultSampler, NoiseUV).r; + + vector vFinalColor; + float fRatio; fRatio = pow(1.f - saturate(exp(-1.f * vDepthDesc.y * g_fFogDensity)), g_fFogPow); diff --git a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_VtxMesh.hlsl b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_VtxMesh.hlsl index 63e9bb2e1..345ee66cc 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_VtxMesh.hlsl +++ b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_VtxMesh.hlsl @@ -83,7 +83,9 @@ Texture2D g_NormalSubTexture; Texture2D g_DeadDisolveTexture; Texture2D g_DepthTexture; +Texture2D g_NormalMapTexture; Texture2D g_MaskNoiseTexture; +Texture2D g_DiffsueMaskTexture; float g_fNormalValue1; float g_fNormalValue2; @@ -122,6 +124,8 @@ vector g_vFogColor; float g_fSoftMask; float g_fSoftMaskEdge; +float g_fUVTiling; + struct VS_IN { float3 vPosition : POSITION; @@ -944,7 +948,9 @@ PS_OUT_DELCAL PS_MAIN_DECAL(PS_IN_DECAL In) vDepthUV.y = In.vPosition.y / g_fWinSizeY; float4 vDepthDesc = g_DepthTexture.Sample(DefaultSampler, vDepthUV); - + float3 vNormalDesc = g_NormalMapTexture.Sample(DefaultSampler, vDepthUV).xyz; + vNormalDesc = normalize(vNormalDesc * 2.f -1.f); + float fViewZ = vDepthDesc.y * g_fFar; float4 vPosition; @@ -965,35 +971,61 @@ PS_OUT_DELCAL PS_MAIN_DECAL(PS_IN_DECAL In) clip(0.5f - ObjectAbsPos); - float2 vDecalUV =( vLocalPos.xz + 0.5f) * 2.f; - float4 vMaskColor = g_MaskingTexture.Sample(DefaultSampler, vDecalUV); + float3 vAbsNormal = abs(vNormalDesc); + + int iAxisIndex = 0; + + if (vAbsNormal.y > vAbsNormal.x && vAbsNormal.y > vAbsNormal.z) + iAxisIndex = 1; + else if (vAbsNormal.z > vAbsNormal.x && vAbsNormal.z > vAbsNormal.y) + iAxisIndex = 2; + + float2 vDecalUV; + + if (0 == iAxisIndex) + vDecalUV = vLocalPos.zy + 0.5f * 2.f; + else if (1 == iAxisIndex) + vDecalUV = vLocalPos.xz + 0.5f * 2.f; + else + vDecalUV = vLocalPos.xy + 0.5f * 2.f; + + + float2 vTileUV = vDecalUV * g_fUVTiling; + + float4 vMaskColor = g_MaskingTexture.Sample(DefaultSampler, vTileUV); if (vMaskColor.a < 0.2f) { discard; } - vector vNoise = g_NoiseTexture.Sample(DefaultSampler, vDecalUV + g_vTime); + vector vNoise = g_NoiseTexture.Sample(DefaultSampler, vTileUV + g_vTime); - float4 vSurface = g_SurfaceParamsTexture.Sample(DefaultSampler, vDecalUV); - float3 vNormalDecoded = DecodeNormalFromRG(g_NormalTexture, DefaultSampler, vDecalUV); + float4 vSurface = g_SurfaceParamsTexture.Sample(DefaultSampler, vTileUV); + float3 vNormalDecoded = DecodeNormalFromRG(g_NormalTexture, DefaultSampler, vTileUV); float fMaskWeight = vMaskColor.r + vMaskColor.g + vMaskColor.b; - float4 vDiffuseColor = vMaskColor.r * g_vMaskColorRed * 2.f * vNoise.r + + float4 vDiffuseColor = vMaskColor.r * g_vMaskColorRed * 2.f * vNoise.r + vMaskColor.g * g_vMaskColorGreen + vMaskColor.b * g_vMaskColorBlue * 2.f * vNoise.r; vDiffuseColor /= fMaskWeight; vDiffuseColor.a = max(0.001f, vDiffuseColor.a); - + float3x3 WorldMatrix = float3x3(In.vTangent, In.vBinormal * -1.f, In.vNormal); - float3 vNormal = normalize(mul(vNormalDecoded, WorldMatrix)); + float3 vNormal = normalize(vNormalDesc); + + float fMask = g_DiffsueMaskTexture.Sample(DefaultSampler, vDecalUV *0.5f).r; + + if (0.f == fMask) + discard; Out.vAlbedo = vDiffuseColor; - Out.vNormal = float4(vNormal * 0.5f + 0.5f, 0.1f); + Out.vNormal = float4(vNormal * 0.5f + 0.5f, 1.f); + float fSurfaceParam = g_fUsingSurfaceParams; if (true == AlmostEqual7(g_fUsingSurfaceParams, 0.f)) { diff --git a/Jusin154_Team3D/Editor/Default/Editor.vcxproj b/Jusin154_Team3D/Editor/Default/Editor.vcxproj index eca97dc82..38424ff35 100644 --- a/Jusin154_Team3D/Editor/Default/Editor.vcxproj +++ b/Jusin154_Team3D/Editor/Default/Editor.vcxproj @@ -186,6 +186,7 @@ call Update_Shaders.bat + @@ -430,6 +431,7 @@ call Update_Shaders.bat + diff --git a/Jusin154_Team3D/Editor/Default/Editor.vcxproj.filters b/Jusin154_Team3D/Editor/Default/Editor.vcxproj.filters index e4887f53c..e2d181c09 100644 --- a/Jusin154_Team3D/Editor/Default/Editor.vcxproj.filters +++ b/Jusin154_Team3D/Editor/Default/Editor.vcxproj.filters @@ -664,6 +664,9 @@ {ebd7a1c2-4914-4956-ad9c-a0fc2e857f56} + + {48e893e6-2374-44a3-b091-814ad89451c4} + @@ -1350,6 +1353,9 @@ 02.GameObjects\Dummys\DummyDecal + + 02.GameObjects\Env\08.LightSpawner + @@ -2041,6 +2047,9 @@ 02.GameObjects\Dummys\DummyDecal + + 02.GameObjects\Env\08.LightSpawner + diff --git a/Jusin154_Team3D/Editor/Private/DummyDecal.cpp b/Jusin154_Team3D/Editor/Private/DummyDecal.cpp index 968125804..adaf1ce8f 100644 --- a/Jusin154_Team3D/Editor/Private/DummyDecal.cpp +++ b/Jusin154_Team3D/Editor/Private/DummyDecal.cpp @@ -18,6 +18,7 @@ CDummyDecal::CDummyDecal(const CDummyDecal& rhs) HRESULT CDummyDecal::Initialize_Prototype() { + m_fWinSizeX = g_iWinSizeX; m_fWinSizeY = g_iWinSizeY; @@ -43,6 +44,7 @@ HRESULT CDummyDecal::Initialize(void* pArg) void CDummyDecal::Priority_Update(_float fTimeDelta) { + } void CDummyDecal::Update(_float fTimeDelta) @@ -82,6 +84,9 @@ HRESULT CDummyDecal::Render() if (FAILED(m_pShaderCom->Bind_SRV("g_NoiseTexture", m_pFadeTextureCom->Get_SRV(0)))) { return E_FAIL; } + if (FAILED(m_pShaderCom->Bind_SRV("g_DiffsueMaskTexture", m_pDiffuseMaskTextureCom->Get_SRV(0)))) { + return E_FAIL; + } if (FAILED(m_pShaderCom->Begin(22))) { return E_FAIL; } @@ -115,6 +120,10 @@ HRESULT CDummyDecal::Ready_Components(void* pArg) if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, TEXT("Decal_Fade"), reinterpret_cast(&m_pFadeTextureCom)))) return E_FAIL; + /* Com_Texture */ + if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, TEXT("Decal_DiffuseMask"), + reinterpret_cast(&m_pDiffuseMaskTextureCom)))) + return E_FAIL; /* Com_Model */ @@ -163,7 +172,7 @@ HRESULT CDummyDecal::Bind_ShaderResources() if (FAILED(m_pShaderCom->Bind_RawValue("g_fFar", m_pGameInstance->Get_CurrentCameraFar(), sizeof(_float)))) { return E_FAIL; } - if (FAILED(m_pShaderCom->Bind_RawValue("g_fNormalThreshold", &m_fNormalThreshold, sizeof(_float)))) { + if (FAILED(m_pShaderCom->Bind_RawValue("g_fUsingSurfaceParams", &m_fUsingSurfaceParams, sizeof(_float)))) { return E_FAIL; } if (FAILED(m_pShaderCom->Bind_RawValue("g_fWinSizeX", &m_fWinSizeX, sizeof(_float)))) { @@ -176,6 +185,9 @@ HRESULT CDummyDecal::Bind_ShaderResources() if (FAILED(m_pShaderCom->Bind_RawValue("g_vTime", &m_fTimeAcc, sizeof(_float2)))) { return E_FAIL; } + if (FAILED(m_pShaderCom->Bind_RawValue("g_fUVTiling", &m_fUVTiling, sizeof(_float)))) { + return E_FAIL; + } if (FAILED(m_pShaderCom->Bind_RawValue("g_vMaskColorRed", &m_vMaskRed, sizeof(_float4)))) { return E_FAIL; @@ -190,6 +202,9 @@ HRESULT CDummyDecal::Bind_ShaderResources() if (FAILED(m_pGameInstance->Bind_RenderTarget(TEXT("Target_Depth"), m_pShaderCom, "g_DepthTexture"))) { return E_FAIL; } + if (FAILED(m_pGameInstance->Bind_RenderTarget(TEXT("Target_NormalCopy"), m_pShaderCom, "g_NormalMapTexture"))) { + return E_FAIL; + } return S_OK; } @@ -224,6 +239,7 @@ void CDummyDecal::Free() { __super::Free(); + SAFE_RELEASE(m_pDiffuseMaskTextureCom); SAFE_RELEASE(m_pFadeTextureCom); SAFE_RELEASE(m_pMaskTextureCom); SAFE_RELEASE(m_pNormalTextureCom); @@ -236,17 +252,13 @@ void CDummyDecal::Describe_Entity() { GUI::Begin("TEST DECAL"); - _float fAgle = XMConvertToDegrees(m_fNormalThreshold); - - GUI::InputFloat("m_fNormalThreshold", &fAgle); + GUI::InputFloat("m_fUVTiling", (_float*)(&m_fUVTiling)); GUI::InputFloat2("m_fSpeed", (_float*)(&m_vUVSpeed)); GUI::ColorEdit4("Mask Red", (_float*)&m_vMaskRed); GUI::ColorEdit4("Mask Green", (_float*)&m_vMaskGreen); GUI::ColorEdit4("Mask Blue", (_float*)&m_vMaskBlue); - m_fNormalThreshold = XMConvertToRadians(fAgle); - m_pTransformCom->Describe_Entity(); if (m_pGameInstance->Mouse_Down(DIM_LBUTTON) && m_pGameInstance->Key_Pressing(DIK_LSHIFT)) diff --git a/Jusin154_Team3D/Editor/Private/InfoInstance.cpp b/Jusin154_Team3D/Editor/Private/InfoInstance.cpp index 044373050..33a59b1d7 100644 --- a/Jusin154_Team3D/Editor/Private/InfoInstance.cpp +++ b/Jusin154_Team3D/Editor/Private/InfoInstance.cpp @@ -88,6 +88,10 @@ HRESULT CInfoInstance::Load_MapObjects(const _char* pFilePath) { return m_pMapInfo->Load_MapObjects(pFilePath); } +HRESULT CInfoInstance::Load_PointLights(const _char* pFilePath) +{ + return m_pMapInfo->Load_PointLights(pFilePath); +} #pragma endregion #pragma region MAP_INFO diff --git a/Jusin154_Team3D/Editor/Private/LightSpawner.cpp b/Jusin154_Team3D/Editor/Private/LightSpawner.cpp new file mode 100644 index 000000000..50d51bc82 --- /dev/null +++ b/Jusin154_Team3D/Editor/Private/LightSpawner.cpp @@ -0,0 +1,248 @@ +#include "pch.h" +#include "LightSpawner.h" + +#include "GameInstance.h" +#include "Layer.h" + +CLightSpawner::CLightSpawner(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) + : CGameObject{ pDevice, pContext } +{ +} + +CLightSpawner::CLightSpawner(const CLightSpawner& rhs) + : CGameObject(rhs) +{ +} + +void CLightSpawner::Priority_Update(_float fTimeDelta) +{ +} + +void CLightSpawner::Update(_float fTimeDelta) +{ + m_fAttenuationTime += fTimeDelta * m_fLightIntensitySpeed; + + +} + +void CLightSpawner::Late_Update(_float fTimeDelta) +{ + m_pLightCom->Set_AttPower(sinf(m_fAttenuationTime) * sinf(m_fAttenuationTime) * m_fLightIntensity + m_fLightIntensity + 1.f); +} + +HRESULT CLightSpawner::Render() +{ + if (FAILED(Bind_ShaderResources())) { + return E_FAIL; + } + + return S_OK; +} + +HRESULT CLightSpawner::Initialize_Prototype() +{ + return S_OK; +} + +HRESULT CLightSpawner::Initialize(void* pArg) +{ + if (FAILED(__super::Initialize(pArg))) + return E_FAIL; + + if (FAILED(Ready_Components(pArg))) + return E_FAIL; + + return S_OK; +} + +HRESULT CLightSpawner::Ready_Components(void* pArg) +{ + if (FAILED(__super::Ready_Components(pArg))) { + return E_FAIL; + } + + LIGHT_DESC LightDesc{}; + LightDesc.iLevel = NEXT_LEVEL; + LightDesc.pPosition = m_pTransformCom->Get_StatePtr(STATE::POSITION); + if(nullptr == pArg) + { + LightDesc.eType = LIGHT::POINT; + + LightDesc.vDiffuse = _float4(1.f, 0.f, 0.f, 1.f); + LightDesc.vAmbient = _float4(1.f, 0.f, 0.f, 1.f); + LightDesc.vSpecular = _float4(0.2f, 0.f, 0.f, 1.f); + LightDesc.vPosOffset = _float4(0.f, 0.f, 0.f, 1.f); + LightDesc.fRange = 10.f; + + /* Com_Light*/ + if (FAILED(Add_Component(g_iStaticLevel, &m_pLightCom, &LightDesc))) + { + return E_FAIL; + } + } + else + { + LIGHTSPAWNER_DESC* pDesc = static_cast(pArg); + + m_pTransformCom->Set_State(STATE::POSITION, XMVectorSetW(XMLoadFloat3(&pDesc->vPosition), 1.f)); + LightDesc.eType = LIGHT::POINT; + LightDesc.vDiffuse = pDesc->vDiffuse; + LightDesc.vAmbient = pDesc->vAmbient; + LightDesc.vSpecular = pDesc->vSpecular; + LightDesc.vPosOffset = _float4(pDesc->vPosOffset.x, pDesc->vPosOffset.y, pDesc->vPosOffset.z, 1.f); + LightDesc.fRange = pDesc->fRange; + + m_fLightIntensity = pDesc->fLightAttRange; + m_fLightIntensitySpeed = pDesc->fLightAttSpeed; + + /* Com_Light*/ + if (FAILED(Add_Component(g_iStaticLevel, &m_pLightCom, &LightDesc))) + { + return E_FAIL; + } + } + + m_pGameInstance->Add_Light(NEXT_LEVEL, m_pLightCom); + + return S_OK; +} + +HRESULT CLightSpawner::Bind_ShaderResources() +{ + return S_OK; +} + + +CLightSpawner* CLightSpawner::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) +{ + CLightSpawner* pInstance = new CLightSpawner(pDevice, pContext); + + if (FAILED(pInstance->Initialize_Prototype())) + { + MSG_BOX("Failed to Created : CLightSpawner"); + SAFE_RELEASE(pInstance); + } + + return pInstance; +} + +CGameObject* CLightSpawner::Clone(void* pArg, CGameObject* pOwner) +{ + CLightSpawner* pInstance = new CLightSpawner(*this); + pInstance->m_pOwner = pOwner; + if (FAILED(pInstance->Initialize(pArg))) + { + MSG_BOX("Failed to Cloned : CLightSpawner"); + SAFE_RELEASE(pInstance); + } + + return pInstance; +} +void CLightSpawner::Free() +{ + __super::Free(); + + SAFE_RELEASE(m_pLightCom); +} + +void CLightSpawner::Describe_Entity() +{ + GUI::DragFloat("Light Intensity", &m_fLightIntensity, 0.1f, 0.f, 20.f); + + m_pTransformCom->Describe_Entity(); + + if (m_pGameInstance->Mouse_Down(DIM_LBUTTON) && m_pGameInstance->Key_Pressing(DIK_LSHIFT)) + { + _float3 vPosition = {}; + if (m_pGameInstance->isPicking(&vPosition)) + { + m_pTransformCom->Set_State(STATE::POSITION, XMVectorSetW(XMLoadFloat3(&vPosition), 1.f)); + } + } + + m_pLightCom->Describe_Entity(); +} + +HRESULT CLightSpawner::Save_XML(tinyxml2::XMLDocument& doc, tinyxml2::XMLElement* root) +{ + tinyxml2::XMLElement* object = doc.NewElement("Object"); + root->InsertEndChild(object); + +#pragma region TRANSFORM + _float3 vPosition = {}; + XMStoreFloat3(&vPosition, m_pTransformCom->Get_State(STATE::POSITION)); + + _float3 vScale = m_pTransformCom->Get_Scale(); + + _float3 vRotation = {}; + XMStoreFloat3(&vRotation, m_pTransformCom->Get_RollPitchYawVector()); + vRotation.x = XMConvertToDegrees(vRotation.x); + vRotation.y = XMConvertToDegrees(vRotation.y); + vRotation.z = XMConvertToDegrees(vRotation.z); + + tinyxml2::XMLElement* Position = doc.NewElement("Position"); + Position->SetAttribute("x", vPosition.x); + Position->SetAttribute("y", vPosition.y); + Position->SetAttribute("z", vPosition.z); + object->InsertEndChild(Position); + + tinyxml2::XMLElement* Scale = doc.NewElement("Scale"); + Scale->SetAttribute("x", vScale.x); + Scale->SetAttribute("y", vScale.y); + Scale->SetAttribute("z", vScale.z); + object->InsertEndChild(Scale); + + tinyxml2::XMLElement* Rotation = doc.NewElement("Rotation"); + Rotation->SetAttribute("x", vRotation.x); + Rotation->SetAttribute("y", vRotation.y); + Rotation->SetAttribute("z", vRotation.z); + object->InsertEndChild(Rotation); +#pragma endregion + +#pragma region LIGHT_DESC + const LIGHT_DESC* pLight = m_pLightCom->Get_LightDesc(); + + /* Diffuse */ + tinyxml2::XMLElement* Diffuse = doc.NewElement("Diffuse"); + Diffuse->SetAttribute("x", pLight->vDiffuse.x); + Diffuse->SetAttribute("y", pLight->vDiffuse.y); + Diffuse->SetAttribute("z", pLight->vDiffuse.z); + object->InsertEndChild(Diffuse); + + /* Ambient */ + tinyxml2::XMLElement* Ambient = doc.NewElement("Ambient"); + Ambient->SetAttribute("x", pLight->vAmbient.x); + Ambient->SetAttribute("y", pLight->vAmbient.y); + Ambient->SetAttribute("z", pLight->vAmbient.z); + object->InsertEndChild(Ambient); + + /* Specular */ + tinyxml2::XMLElement* Specular = doc.NewElement("Specular"); + Specular->SetAttribute("x", pLight->vSpecular.x); + Specular->SetAttribute("y", pLight->vSpecular.y); + Specular->SetAttribute("z", pLight->vSpecular.z); + object->InsertEndChild(Specular); + + /* PosOffset */ + tinyxml2::XMLElement* PosOffset = doc.NewElement("PosOffset"); + PosOffset->SetAttribute("x", pLight->vPosOffset.x); + PosOffset->SetAttribute("y", pLight->vPosOffset.y); + PosOffset->SetAttribute("z", pLight->vPosOffset.z); + object->InsertEndChild(PosOffset); + + /* Info */ + tinyxml2::XMLElement* Info = doc.NewElement("Info"); + Info->SetAttribute("Range", pLight->fRange); + Info->SetAttribute("LightAttRange", m_fLightIntensity); + Info->SetAttribute("LightAttSpeed", m_fLightIntensitySpeed); + + if (false == m_pLightCom->Is_PowerLightAtt()) + Info->SetAttribute("Pow", 0); + else + Info->SetAttribute("Pow", 1); + + object->InsertEndChild(Info); +#pragma endregion + + return S_OK; +} diff --git a/Jusin154_Team3D/Editor/Private/Loader.cpp b/Jusin154_Team3D/Editor/Private/Loader.cpp index e58dbea9e..2e862e979 100644 --- a/Jusin154_Team3D/Editor/Private/Loader.cpp +++ b/Jusin154_Team3D/Editor/Private/Loader.cpp @@ -152,6 +152,7 @@ #include "MapElement_Lake.h" #include "MapElement_Chest.h" #include "MapElement_Chest_Lid.h" +#include "LightSpawner.h" #pragma endregion @@ -2754,6 +2755,11 @@ HRESULT CLoader::Loading_For_MapViewer() CTexture::Create(m_pDevice, m_pContext, TEXTURE_LOAD_TYPE::SINGLE, TEXT("C:/MeshTable/Game/VFX/Textures/Noises/VFX_T_TankMoteNoiseVinceTest_D.png"), 0)))) { return E_FAIL; } + /* Decal_MaskNoise */ + if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Decal_DiffuseMask"), + CTexture::Create(m_pDevice, m_pContext, TEXTURE_LOAD_TYPE::SINGLE, TEXT("C:/MeshTable/Game/VFX/Textures/VFX_T_DementorTatter_D.dds"), 0)))) { + return E_FAIL; + } /* Terrain_Diffuse */ @@ -3772,6 +3778,8 @@ if(isLoad_Map) } } + +#pragma region SHADER m_strMessage = TEXT("쉐이더를(을) 로딩 중 입니다."); if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, FX_INSTANCE_PROP_MODEL, @@ -3785,6 +3793,8 @@ if(isLoad_Map) VTXPOS::Elements, VTXPOS::iNumElements)))) { return E_FAIL; } +#pragma endregion + m_strMessage = TEXT("객체원형를(을) 로딩 중 입니다."); @@ -4035,6 +4045,10 @@ if(isLoad_Map) if (FAILED(m_pGameInstance->Add_Prototype(g_iStaticLevel, CMapElement_Lake::Create(m_pDevice, m_pContext)))) return E_FAIL; + /* For.Prototype_GameObject_LightSpawner */ + if (FAILED(m_pGameInstance->Add_Prototype(g_iStaticLevel, CLightSpawner::Create(m_pDevice, m_pContext)))) + return E_FAIL; + /* For.Prototype_GameObject_CDummyDecal */ if (FAILED(m_pGameInstance->Add_Prototype(g_iStaticLevel, CDummyDecal::Create(m_pDevice, m_pContext)))) return E_FAIL; diff --git a/Jusin154_Team3D/Editor/Private/MapInfo.cpp b/Jusin154_Team3D/Editor/Private/MapInfo.cpp index 4cde79584..ecdb8a074 100644 --- a/Jusin154_Team3D/Editor/Private/MapInfo.cpp +++ b/Jusin154_Team3D/Editor/Private/MapInfo.cpp @@ -9,6 +9,7 @@ #include "MapElement_Static.h" #include "MapElement_Interactable.h" #include "MapObject_LOD.h" +#include "LightSpawner.h" CMapInfo::CMapInfo() { @@ -255,6 +256,68 @@ HRESULT CMapInfo::Load_MapObjects(const _char* pFilePath) return S_OK; } +HRESULT CMapInfo::Load_PointLights(const _char* pFilePath) +{ + tinyxml2::XMLDocument xmlDoc; + + string strPath = "../Bin/Resources/Data/Map/Light/" + string(pFilePath) + ".xml"; + + if ((tinyxml2::XML_SUCCESS != xmlDoc.LoadFile(strPath.c_str()))) + return E_FAIL; + + tinyxml2::XMLElement* root = xmlDoc.FirstChildElement("MapLightObjects"); + + if (nullptr == root) + { + MSG_BOX("Failed to Find root"); + return S_OK; + } + + for (auto* Object = root->FirstChildElement("Object"); Object; Object = Object->NextSiblingElement("Object")) + { + CLightSpawner::LIGHTSPAWNER_DESC Desc = {}; + + /* Transform */ + auto* Position = Object->FirstChildElement("Position"); + Position->QueryFloatAttribute("x", &Desc.vPosition.x); + Position->QueryFloatAttribute("y", &Desc.vPosition.y); + Position->QueryFloatAttribute("z", &Desc.vPosition.z); + + /* Light Desc */ + auto* Diffuse = Object->FirstChildElement("Diffuse"); + Diffuse->QueryFloatAttribute("x", &Desc.vDiffuse.x); + Diffuse->QueryFloatAttribute("y", &Desc.vDiffuse.y); + Diffuse->QueryFloatAttribute("z", &Desc.vDiffuse.z); + + auto* Ambient = Object->FirstChildElement("Ambient"); + Ambient->QueryFloatAttribute("x", &Desc.vAmbient.x); + Ambient->QueryFloatAttribute("y", &Desc.vAmbient.y); + Ambient->QueryFloatAttribute("z", &Desc.vAmbient.z); + + auto* Specular = Object->FirstChildElement("Specular"); + Specular->QueryFloatAttribute("x", &Desc.vSpecular.x); + Specular->QueryFloatAttribute("y", &Desc.vSpecular.y); + Specular->QueryFloatAttribute("z", &Desc.vSpecular.z); + + auto* PosOffset = Object->FirstChildElement("PosOffset"); + PosOffset->QueryFloatAttribute("x", &Desc.vPosOffset.x); + PosOffset->QueryFloatAttribute("y", &Desc.vPosOffset.y); + PosOffset->QueryFloatAttribute("z", &Desc.vPosOffset.z); + + auto* Info = Object->FirstChildElement("Info"); + Info->QueryFloatAttribute("LightAttRange", &Desc.fLightAttRange); + Info->QueryFloatAttribute("LightAttSpeed", &Desc.fLightAttSpeed); + Info->QueryFloatAttribute("Range", &Desc.fRange); + _uint iPow = {}; + Info->QueryUnsignedAttribute("Pow", &iPow); + + if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, TEXT("Layer_LightSpawer"), &Desc))) + return E_FAIL; + } + + return S_OK; +} + HRESULT CMapInfo::Initialize(ID3D11Device* pDevice, ID3D11DeviceContext* pContex) { diff --git a/Jusin154_Team3D/Editor/Private/MapObject_Manager.cpp b/Jusin154_Team3D/Editor/Private/MapObject_Manager.cpp index a53443809..629e02d9c 100644 --- a/Jusin154_Team3D/Editor/Private/MapObject_Manager.cpp +++ b/Jusin154_Team3D/Editor/Private/MapObject_Manager.cpp @@ -2,6 +2,7 @@ #include "MapObject_Manager.h" #include "GameInstance.h" +#include "InfoInstance.h" #include "Camera_Debug.h" #include "Layer.h" #include "MapObject.h" @@ -12,20 +13,24 @@ #include "MapElement_Interactable.h" #include "MapElement_Light.h" #include "MapElement_Lake.h" +#include "LightSpawner.h" CMapObject_Manager::CMapObject_Manager(ID3D11Device * pDevice, ID3D11DeviceContext * pContext) - : CGameObject(pDevice, pContext) + : CGameObject(pDevice, pContext), m_pInfoInstance{CInfoInstance::GetInstance()} { + SAFE_ADDREF(m_pInfoInstance); } CMapObject_Manager::CMapObject_Manager(const CMapObject_Manager& rhs) : CGameObject(rhs) + , m_pInfoInstance{ rhs.m_pInfoInstance } , m_ModelPrototypeTags{ rhs.m_ModelPrototypeTags } , m_LODModelPrototypeTags{ rhs.m_LODModelPrototypeTags } , m_ModelPrototypePaths{ rhs.m_ModelPrototypePaths } , m_PartObjectKeyCount{ rhs.m_PartObjectKeyCount } { + SAFE_ADDREF(m_pInfoInstance); } HRESULT CMapObject_Manager::Initialize_Prototype(vector<_wstring>& ModelPrototypeTags, vector& ModelPrototypePaths) @@ -83,6 +88,20 @@ HRESULT CMapObject_Manager::Initialize(void* pArg) // return E_FAIL; +#pragma region Light + m_Light_Desc.eType = LIGHT::POINT; + + m_Light_Desc.vDiffuse = _float4(1.f, 1.f, 1.f, 1.f); + m_Light_Desc.vAmbient = _float4(1.f, 1.f, 1.f, 1.f); + m_Light_Desc.vSpecular = _float4(1.f, 1.f, 1.f, 1.f); + m_Light_Desc.vPosOffset = _float4(1.f, 1.f, 1.f, 1.f); + + m_Light_Desc.fRange = 5.f; + m_Light_Desc.iLevel = NEXT_LEVEL; + m_Light_Desc.pPosition = m_pTransformCom->Get_StatePtr(STATE::POSITION); +#pragma endregion + + return S_OK; } @@ -180,6 +199,8 @@ void CMapObject_Manager::Update(_float fTimeDelta) Update_Edit(); + Update_LightSpawer(); + Update_Unified(); if (ADD_TYPE::CONTAINER == m_eType) @@ -1825,6 +1846,52 @@ HRESULT CMapObject_Manager::Load_WaterObject(const _char* pFileName) return S_OK; } + +HRESULT CMapObject_Manager::Save_PointLightObject(const _char* pFileName) +{ + CLayer* pLayer = m_pGameInstance->Get_Layer(ENUM_CLASS(LEVEL::MAP), TEXT("Layer_LightSpawer")); + + if (nullptr == pLayer) + return S_OK; + + tinyxml2::XMLDocument doc; + string strPath = "../Bin/Resources/Data/Map/Light/" + string(pFileName) + ".xml"; + + tinyxml2::XMLError loadResult = doc.LoadFile(strPath.c_str()); + + doc.Clear(); + doc.InsertFirstChild(doc.NewDeclaration()); + + tinyxml2::XMLElement* root = doc.NewElement("MapLightObjects"); + doc.InsertEndChild(root); + + if (nullptr != pLayer) + { + const list* pList = pLayer->Get_Objects(); + + for (auto pGamObject : *pList) + { + CLightSpawner* pLightSpawner = dynamic_cast(pGamObject); + + if (nullptr == pLightSpawner) + return E_FAIL; + + if (FAILED(pLightSpawner->Save_XML(doc, root))) + return E_FAIL; + } + } + + if (doc.SaveFile(strPath.c_str()) != tinyxml2::XML_SUCCESS) { + MSG_BOX("Failed to Save File"); + } + else + { + MSG_BOX("Succeed to Save PointLightObjects"); + } + + return S_OK; +} + void CMapObject_Manager::Update_PrototypeList() { GUI::Begin("Model Prototype List"); @@ -2094,6 +2161,40 @@ void CMapObject_Manager::Update_Unified() GUI::End(); } +void CMapObject_Manager::Update_LightSpawer() +{ + GUI::Begin("Light Spawer"); + if (GUI::Button("Save Lights")) + { + Save_PointLightObject("Duengon_PointLight_Data"); + } + if (GUI::Button("Load Lights")) + { + m_pInfoInstance->Load_PointLights("Duengon_PointLight_Data"); + } + if(GUI::Button("Add Light Spawer")) + { + m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, TEXT("Layer_LightSpawer")); + } + + GUI::InputInt("Index : ", (_int*)&m_iSelectedIndex); + CLayer* pLayer = m_pGameInstance->Get_Layer(ENUM_CLASS(LEVEL::MAP), TEXT("Layer_LightSpawer")); + + if(nullptr != pLayer) + { + _uint iIndex = {}; + for (auto& pLightSpawner : *pLayer->Get_Objects()) + { + if(m_iSelectedIndex == iIndex) + pLightSpawner->Describe_Entity(); + + ++iIndex; + } + } + + GUI::End(); +} + void CMapObject_Manager::Create_PartObject(_wstring& strPrototypeTag) { vector<_uint> LodModelIndices; @@ -2268,6 +2369,8 @@ void CMapObject_Manager::Free() m_Collision.clear(); SAFE_RELEASE(m_pContainer); + + SAFE_RELEASE(m_pInfoInstance); } void CMapObject_Manager::Describe_Entity() diff --git a/Jusin154_Team3D/Editor/Public/DummyDecal.h b/Jusin154_Team3D/Editor/Public/DummyDecal.h index 6e6f9db76..2579b92c2 100644 --- a/Jusin154_Team3D/Editor/Public/DummyDecal.h +++ b/Jusin154_Team3D/Editor/Public/DummyDecal.h @@ -30,14 +30,17 @@ class CDummyDecal final : public CGameObject CTexture* m_pNormalTextureCom = { nullptr }; CTexture* m_pSurfaceTextureCom = { nullptr }; CTexture* m_pFadeTextureCom = { nullptr }; - - _float2 m_fTimeAcc = {}; - _float2 m_vUVSpeed = {}; - _float m_fNormalThreshold = {}; + CTexture* m_pDiffuseMaskTextureCom = { nullptr }; + + _float m_fUVTiling = {1.f}; + _float m_fUsingSurfaceParams = {}; _float m_fWinSizeX = {}; _float m_fWinSizeY = {}; + _float2 m_fTimeAcc = {}; + _float2 m_vUVSpeed = {}; + _float4 m_vMaskRed = {}; _float4 m_vMaskGreen = {}; _float4 m_vMaskBlue = {}; diff --git a/Jusin154_Team3D/Editor/Public/InfoInstance.h b/Jusin154_Team3D/Editor/Public/InfoInstance.h index f7d2bd63e..b93986d1e 100644 --- a/Jusin154_Team3D/Editor/Public/InfoInstance.h +++ b/Jusin154_Team3D/Editor/Public/InfoInstance.h @@ -41,6 +41,7 @@ class CInfoInstance final : public CBase #pragma endregion #pragma region MAP_INFO HRESULT Load_MapObjects(const _char* pFilePath); + HRESULT Load_PointLights(const _char* pFilePath); #pragma endregion #pragma region Spell_INFO HRESULT Load_SpellInfo(const _char* pFilePath); diff --git a/Jusin154_Team3D/Editor/Public/LightSpawner.h b/Jusin154_Team3D/Editor/Public/LightSpawner.h new file mode 100644 index 000000000..56b674b00 --- /dev/null +++ b/Jusin154_Team3D/Editor/Public/LightSpawner.h @@ -0,0 +1,65 @@ +#pragma once + +#include "Editor_Define.h" +#include "GameObject.h" + +NS_BEGIN(Engine) +class CLight; +NS_END + +NS_BEGIN(Editor) + +class CLightSpawner final : public CGameObject +{ +public: + typedef struct tagLightSpawnerDesc + { + _float3 vPosition; + _float4 vDiffuse; + _float4 vAmbient; + _float4 vSpecular; + _float3 vPosOffset; + _float fRange; + _float fLightAttRange; + _float fLightAttSpeed; + _float fPow; + + }LIGHTSPAWNER_DESC; +private: + CLightSpawner(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); + CLightSpawner(const CLightSpawner& rhs); + virtual ~CLightSpawner() = default; + +public: + virtual void Priority_Update(_float fTimeDelta) override; + virtual void Update(_float fTimeDelta) override; + virtual void Late_Update(_float fTimeDelta) override; + virtual HRESULT Render() override; + +private: + CLight* m_pLightCom = { nullptr }; + + _float m_fAttenuationTime = { 0.f }; + _float m_fLightIntensity = { 1.f }; + _float m_fLightIntensitySpeed = { 1.f }; + +#ifdef _DEBUG + _uint m_iSelectIndex = {}; +#endif // _DEBUG + + +private: + virtual HRESULT Initialize_Prototype() override; + virtual HRESULT Initialize(void* pArg) override; + virtual HRESULT Ready_Components(void* pArg) override; + virtual HRESULT Bind_ShaderResources()override; + +public: + static CLightSpawner* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); + virtual CGameObject* Clone(void* pArg, class CGameObject* pOwner) override; + virtual void Free() override; + void Describe_Entity() override; + HRESULT Save_XML(tinyxml2::XMLDocument& doc, tinyxml2::XMLElement* root); +}; + +NS_END diff --git a/Jusin154_Team3D/Editor/Public/MapInfo.h b/Jusin154_Team3D/Editor/Public/MapInfo.h index 40675d0e4..80b9a3bc9 100644 --- a/Jusin154_Team3D/Editor/Public/MapInfo.h +++ b/Jusin154_Team3D/Editor/Public/MapInfo.h @@ -18,6 +18,7 @@ class CMapInfo final : public CBase void Update(_float fTimeDelta); void Change_Level(); HRESULT Load_MapObjects(const _char* pFilePath); + HRESULT Load_PointLights(const _char* pFilePath); /*HRESULT Load_BuildingContainer(tinyxml2::XMLElement* Container, class CMapContainer** ppContainerObject); HRESULT Load_StreetContainer(tinyxml2::XMLElement* Container, class CMapContainer** ppContainerObject); HRESULT Load_MapRenderObjects(tinyxml2::XMLElement* Container, class CMapContainer* pContainerObject); diff --git a/Jusin154_Team3D/Editor/Public/MapObject_Manager.h b/Jusin154_Team3D/Editor/Public/MapObject_Manager.h index 50e0f07ad..6ef825898 100644 --- a/Jusin154_Team3D/Editor/Public/MapObject_Manager.h +++ b/Jusin154_Team3D/Editor/Public/MapObject_Manager.h @@ -44,12 +44,20 @@ class CMapObject_Manager final : public CGameObject vector<_wstring> m_LODModelPrototypeTags; vector m_ModelPrototypePaths; + _uint m_iSelectedIndex = {}; _uint m_iContainerObjectIndex = {}; _int m_iGlassIndex = { 1 }; class CBuildingContainer* m_pContainer = { nullptr }; _char m_szSaveFileName[MAX_PATH] = {}; _char m_szSaveContainerName[MAX_PATH] = {}; + +#pragma region LIGHT + LIGHT_DESC m_Light_Desc = {}; +#pragma endregion + + class CInfoInstance* m_pInfoInstance = { nullptr }; + private: HRESULT Ready_Components(); HRESULT Bind_ShaderResources(); @@ -73,6 +81,8 @@ class CMapObject_Manager final : public CGameObject HRESULT Load_InteractObject(const _char* pFileName); HRESULT Load_WaterObject(const _char* pFileName); + + HRESULT Save_PointLightObject(const _char* pFileName); #pragma endregion void Update_PrototypeList(); @@ -80,6 +90,7 @@ class CMapObject_Manager final : public CGameObject void Update_Edit(); void Update_ContainerObject(); void Update_Unified(); + void Update_LightSpawer(); void Create_PartObject(_wstring& strPrototypeTag); void Create_Elemnt(_wstring& strPrototypeTag); diff --git a/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl b/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl index 2fc5db15f..0d14ceee3 100644 --- a/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl +++ b/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl @@ -33,6 +33,7 @@ float g_fSSAO_BIAS; float g_fSSAOStrength; Texture2D g_Texture; +Texture2D g_NoiseTexture; Texture2D g_SSAONoiseTexture; Texture2D g_SSAOInputTexture; uint g_iKernelSize; @@ -90,6 +91,7 @@ vector g_vLightSpecular; float g_fFogDensity; float g_fFogPow; +float g_fFogHeightValue; bool g_bFogVisible; vector g_vFogColor; @@ -1149,9 +1151,25 @@ PS_OUT_FLT4_SINGLE PS_MAIN_FOG(PS_IN In) return Out; } - vector vFinalColor; float fViewZ = vDepthDesc.y * g_fFar; + float4 vPosition, vPreShadowPosition; + vPosition.x = In.vTexcoord.x * 2.f - 1.f; + vPosition.y = In.vTexcoord.y * -2.f + 1.f; + vPosition.z = vDepthDesc.x; + vPosition.w = 1.f; + + vPosition = vPosition * fViewZ; + + vPosition = mul(vPosition, g_invmatProj); + vPosition = mul(vPosition, g_invMatView); + + float2 NoiseUV = vPosition.xz * 0.01f; + + float fNoise = g_NoiseTexture.Sample(DefaultSampler, NoiseUV).r; + + vector vFinalColor; + float fRatio; fRatio = pow(1.f - saturate(exp(-1.f * vDepthDesc.y * g_fFogDensity)), g_fFogPow); diff --git a/Jusin154_Team3D/Engine/Private/Fog.cpp b/Jusin154_Team3D/Engine/Private/Fog.cpp index 36c8ecdc9..0f655776f 100644 --- a/Jusin154_Team3D/Engine/Private/Fog.cpp +++ b/Jusin154_Team3D/Engine/Private/Fog.cpp @@ -1,10 +1,14 @@ #include "pch.h" #include "Fog.h" #include "Shader.h" +#include "GameInstance.h" CFog::CFog() - : m_bVisible{ true }, m_fFogPow{30.f} + : m_pGameInstance{CGameInstance::GetInstance()}, + m_bVisible {true}, + m_fFogPow{ 30.f } { + SAFE_ADDREF(m_pGameInstance); } void CFog::Set_Fog(_float fFogDensity, _float fPow) @@ -26,6 +30,9 @@ HRESULT CFog::Bind_FogValue(CShader* pShader) pShader->Bind_RawValue("g_fFogPow", &m_fFogPow, sizeof(_float)); pShader->Bind_RawValue("g_vFogColor", &m_vFogColor, sizeof(_float4)); pShader->Bind_RawValue("g_bFogVisible", &m_bVisible, sizeof(_bool)); + pShader->Bind_RawValue("g_fFar", m_pGameInstance->Get_CurrentCameraFar(), sizeof(_bool)); + pShader->Bind_Matrix("g_invMatView", m_pGameInstance->Get_Transform_Float4x4(D3DTS::VIEW_INV)); + pShader->Bind_Matrix("g_invmatProj", m_pGameInstance->Get_Transform_Float4x4(D3DTS::PROJ_INV)); } else { @@ -60,12 +67,32 @@ void CFog::Update_Fog() } #endif // _DEBUG +HRESULT CFog::Initialize() +{ + m_pNoiseTextureSRV = m_pGameInstance->Add_Resource("C:/MeshTable/Game/VFX/Textures/Noises/VFX_T_Noise01_D.png"); + + if (nullptr == m_pNoiseTextureSRV) + return E_FAIL; + + return S_OK; +} + CFog* CFog::Create() { - return new CFog(); + CFog* pInstance = new CFog(); + + if (FAILED(pInstance->Initialize())) + { + MSG_BOX("Failed to Created CFog"); + SAFE_RELEASE(pInstance); + } + return pInstance; } void CFog::Free() { __super::Free(); + + SAFE_RELEASE(m_pNoiseTextureSRV); + SAFE_RELEASE(m_pGameInstance); } diff --git a/Jusin154_Team3D/Engine/Private/GameInstance.cpp b/Jusin154_Team3D/Engine/Private/GameInstance.cpp index 718d6a0e5..3a53bfa8f 100644 --- a/Jusin154_Team3D/Engine/Private/GameInstance.cpp +++ b/Jusin154_Team3D/Engine/Private/GameInstance.cpp @@ -105,13 +105,13 @@ HRESULT CGameInstance::Initialize_Engine(const ENGINE_DESC& EngineDesc, ID3D11De return E_FAIL; } - m_pFog = CFog::Create(); - if (nullptr == m_pFog) { + m_pResource_Manager = CResource_Manager::Create(*ppDevice, 1000, EngineDesc.iNumLevels); + if (nullptr == m_pResource_Manager) { return E_FAIL; } - m_pResource_Manager = CResource_Manager::Create(*ppDevice, 1000, EngineDesc.iNumLevels); - if (nullptr == m_pResource_Manager) { + m_pFog = CFog::Create(); + if (nullptr == m_pFog) { return E_FAIL; } @@ -895,6 +895,11 @@ HRESULT CGameInstance::Bind_CS_RenderTarget(_uint iIndex, const _wstring& strTar return m_pRenderTarget_Manager->Bind_CS_RenderTarget(iIndex, strTargetTag); } +HRESULT CGameInstance::Clear_RenderTarget(const _wstring& strRenderTargetKey) +{ + return m_pRenderTarget_Manager->Clear_RenderTarget(strRenderTargetKey); +} + #ifdef _DEBUG void CGameInstance::RenderTarget_Debuger() { diff --git a/Jusin154_Team3D/Engine/Private/Light.cpp b/Jusin154_Team3D/Engine/Private/Light.cpp index 34f528f09..adc31e056 100644 --- a/Jusin154_Team3D/Engine/Private/Light.cpp +++ b/Jusin154_Team3D/Engine/Private/Light.cpp @@ -1,4 +1,5 @@ -#include "pch.h" +#include "Light.h" +#include "pch.h" #include "Light.h" #include "Shader.h" #include "VIBuffer.h" @@ -202,8 +203,8 @@ void CLight::Describe_Entity() GUI::ColorEdit4("Diffuse", (_float*)&m_LightDesc.vDiffuse); - GUI::DragFloat4("Ambient", reinterpret_cast(&m_LightDesc.vAmbient), 0.01f, 0.f, 1.f); - GUI::DragFloat4("Specular", reinterpret_cast(&m_LightDesc.vSpecular), 0.01f, 0.f, 1.f); + GUI::ColorEdit4("Ambient", (_float*)&m_LightDesc.vAmbient); + GUI::ColorEdit4("Specular", (_float*)&m_LightDesc.vSpecular); GUI::DragFloat("Range", &m_LightDesc.fRange, 1.f, 0.f); GUI::DragFloat2("SpotAngle", reinterpret_cast(&m_LightDesc.vSpotAngles)); GUI::Checkbox("UseLinearAtt", &m_bUsePowerAttenuation); diff --git a/Jusin154_Team3D/Engine/Private/RenderTarget_Manager.cpp b/Jusin154_Team3D/Engine/Private/RenderTarget_Manager.cpp index 6301ab80e..dd9ed2d22 100644 --- a/Jusin154_Team3D/Engine/Private/RenderTarget_Manager.cpp +++ b/Jusin154_Team3D/Engine/Private/RenderTarget_Manager.cpp @@ -240,6 +240,18 @@ HRESULT CRenderTarget_Manager::Bind_CS_RenderTarget(_uint iIndex, const _wstring return S_OK; } +HRESULT CRenderTarget_Manager::Clear_RenderTarget(const _wstring& strRenderTargetKey) +{ + CRenderTarget* pTargetA = Find_RenderTarget(strRenderTargetKey); + if (nullptr == pTargetA) { + return E_FAIL; + } + + pTargetA->Clear(); + + return S_OK; +} + HRESULT CRenderTarget_Manager::Accumulate_RenderTarget(CVIBuffer_Rect* pVIBuffer, CShader* pShader, const _wstring& wstrRenderTarget_SrcA, const _wstring& wstrRenderTarget_SrcB, diff --git a/Jusin154_Team3D/Engine/Private/Renderer.cpp b/Jusin154_Team3D/Engine/Private/Renderer.cpp index 2b8cfc97f..8e6085a7d 100644 --- a/Jusin154_Team3D/Engine/Private/Renderer.cpp +++ b/Jusin154_Team3D/Engine/Private/Renderer.cpp @@ -331,6 +331,7 @@ void CRenderer::Render_NonBlend() void CRenderer::Render_Decal() { + m_pGameInstance->Copy_RenderTargetAToB(TEXT("Target_Normal"), TEXT("Target_NormalCopy")); EVENTSCOPE_("Render_Decal"); if (FAILED(m_pGameInstance->Begin_MRT_NonClear(TEXT("MRT_Decal")))) { return; @@ -351,6 +352,8 @@ void CRenderer::Render_Decal() if (FAILED(m_pGameInstance->End_MRT())) { return; } + + m_pGameInstance->Clear_RenderTarget(TEXT("Target_NormalCopy")); } void CRenderer::Render_LightAcc() diff --git a/Jusin154_Team3D/Engine/Private/Renderer_Declare.cpp b/Jusin154_Team3D/Engine/Private/Renderer_Declare.cpp index 959e896a4..d4b5c2004 100644 --- a/Jusin154_Team3D/Engine/Private/Renderer_Declare.cpp +++ b/Jusin154_Team3D/Engine/Private/Renderer_Declare.cpp @@ -164,6 +164,12 @@ HRESULT CRenderer::Initialize() return E_FAIL; } + /* Target_Normal */ + if (FAILED(m_pGameInstance->Add_RenderTarget(TEXT("Target_NormalCopy"), (_uint)Viewport.Width, (_uint)Viewport.Height, + DXGI_FORMAT_R16G16B16A16_UNORM, _float4(0.0f, 0.f, 0.f, 1.f)))) { + return E_FAIL; + } + /* Target_Depth */ if (FAILED(m_pGameInstance->Add_RenderTarget(TEXT("Target_Depth"), (_uint)Viewport.Width, (_uint)Viewport.Height, DXGI_FORMAT_R32G32B32A32_FLOAT, _float4(0.0f, 1.f, 0.f, 0.f)))) { diff --git a/Jusin154_Team3D/Engine/Public/Fog.h b/Jusin154_Team3D/Engine/Public/Fog.h index 804cec668..8b312c63a 100644 --- a/Jusin154_Team3D/Engine/Public/Fog.h +++ b/Jusin154_Team3D/Engine/Public/Fog.h @@ -3,7 +3,6 @@ #include "Base.h" NS_BEGIN(Engine) - class CFog final : public CBase { private: @@ -13,20 +12,25 @@ class CFog final : public CBase public: void Set_Fog(_float fFogDensity, _float fPow); void Set_FogColor(_float4& vFogColor); - HRESULT Bind_FogValue(class CShader* pShader); #ifdef _DEBUG void Update_Fog(); #endif // _DEBUG - private: _bool m_bVisible = {}; _float m_fFogDensity = { 0.04f }; _float m_fFogPow = { 0.1f }; + _float m_fFogHeightValue = { 0.1f }; _float4 m_vFogColor = { 0.906f, 0.812f, 0.745f, 0.5f }; + class CGameInstance* m_pGameInstance = { nullptr }; + + ID3D11ShaderResourceView* m_pNoiseTextureSRV = { nullptr }; +private: + HRESULT Initialize(); + public: static CFog* Create(); virtual void Free() override; diff --git a/Jusin154_Team3D/Engine/Public/GameInstance.h b/Jusin154_Team3D/Engine/Public/GameInstance.h index 5979532e8..978624970 100644 --- a/Jusin154_Team3D/Engine/Public/GameInstance.h +++ b/Jusin154_Team3D/Engine/Public/GameInstance.h @@ -182,6 +182,7 @@ class ENGINE_DLL CGameInstance final : public CBase 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); HRESULT Bind_CS_RenderTarget(_uint iIndex, const _wstring& strTargetTag); + HRESULT Clear_RenderTarget(const _wstring& strRenderTargetKey); #ifdef _DEBUG void RenderTarget_Debuger(); HRESULT Render_RenderTarget_Debug(class CShader* pShader, class CVIBuffer_Rect* pVIBuffer); diff --git a/Jusin154_Team3D/Engine/Public/RenderTarget_Manager.h b/Jusin154_Team3D/Engine/Public/RenderTarget_Manager.h index 8b1170d45..55923d76f 100644 --- a/Jusin154_Team3D/Engine/Public/RenderTarget_Manager.h +++ b/Jusin154_Team3D/Engine/Public/RenderTarget_Manager.h @@ -22,7 +22,7 @@ class CRenderTarget_Manager final : public CBase HRESULT Copy_RenderTargetFrom(const _wstring& strDstTag, ID3D11Texture2D* pSrc2D); HRESULT Copy_RenderTargetAToB(const _wstring& strATag, const _wstring& strBTag); HRESULT Bind_CS_RenderTarget(_uint iIndex, const _wstring& strTargetTag); - + HRESULT Clear_RenderTarget(const _wstring& strRenderTargetKey); // 두 랜더타겟을 하나로 모음 HRESULT Accumulate_RenderTarget(class CVIBuffer_Rect* pVIBuffer, class CShader* pShader, const _wstring& wstrRenderTarget_SrcA, const _wstring& wstrRenderTarget_SrcB, const _wstring& wstrRenderTarget_Target, SHADER_PASS_DEFERRED ePass);