From 678383062a63514876d252ee856df09900702de7 Mon Sep 17 00:00:00 2001 From: kimnuri Date: Thu, 4 Dec 2025 20:59:56 +0900 Subject: [PATCH] [patch] exclusive Deferred --- Jusin154_Team3D/Client/Private/EffectPool.cpp | 7 +- Jusin154_Team3D/Client/Private/Level_Logo.cpp | 4 + .../ShaderFiles/Shader_Deferred.hlsl | 82 +++++++------ .../ShaderFiles/Shader_VtxAnimMesh.hlsl | 14 +-- .../ShaderFiles/Shader_Deferred.hlsl | 82 +++++++------ Jusin154_Team3D/Engine/Private/Renderer.cpp | 110 +++++++++++++++--- .../Engine/Private/Renderer_Declare.cpp | 19 +-- Jusin154_Team3D/Engine/Public/Engine_Struct.h | 2 +- Jusin154_Team3D/Engine/Public/PhysX/PxShape.h | 2 +- Jusin154_Team3D/Engine/Public/Renderer.h | 1 + 10 files changed, 216 insertions(+), 107 deletions(-) diff --git a/Jusin154_Team3D/Client/Private/EffectPool.cpp b/Jusin154_Team3D/Client/Private/EffectPool.cpp index 9d0a698cb..e4e9d8e36 100644 --- a/Jusin154_Team3D/Client/Private/EffectPool.cpp +++ b/Jusin154_Team3D/Client/Private/EffectPool.cpp @@ -128,6 +128,7 @@ HRESULT CEffectPool::Ready_Effect() return pEffect;} ))) return E_FAIL; +#ifndef 기무리 if (FAILED(Create_Effect(SKILL_TYPE::BOMBARDA, 5, NEXT_LEVEL, NEXT_LEVEL, [&](_uint iPrototypeLevel, _uint iCloneLevel)-> CEffect_Container* { @@ -135,7 +136,7 @@ HRESULT CEffectPool::Ready_Effect() pEffect = m_pGameInstance->Clone_Prototype(iPrototypeLevel, nullptr); - return pEffect;} + return pEffect; } ))) return E_FAIL; if (FAILED(Create_Effect(SKILL_TYPE::DESCENDO, 5, NEXT_LEVEL, NEXT_LEVEL, [&](_uint iPrototypeLevel, _uint iCloneLevel)-> CEffect_Container* { @@ -144,7 +145,7 @@ HRESULT CEffectPool::Ready_Effect() pEffect = m_pGameInstance->Clone_Prototype(iPrototypeLevel, nullptr); - return pEffect;} + return pEffect; } ))) return E_FAIL; if (FAILED(Create_Effect(SKILL_TYPE::PROTEGO, 5, NEXT_LEVEL, NEXT_LEVEL, [&](_uint iPrototypeLevel, _uint iCloneLevel)-> CEffect_Container* { @@ -223,6 +224,8 @@ HRESULT CEffectPool::Ready_Effect() return pEffect; } ))) return E_FAIL; +#endif // 기무리 + return S_OK; diff --git a/Jusin154_Team3D/Client/Private/Level_Logo.cpp b/Jusin154_Team3D/Client/Private/Level_Logo.cpp index c26fdbc90..5b56ffe97 100644 --- a/Jusin154_Team3D/Client/Private/Level_Logo.cpp +++ b/Jusin154_Team3D/Client/Private/Level_Logo.cpp @@ -23,6 +23,10 @@ HRESULT CLevel_Logo::Initialize() void CLevel_Logo::Update(_float fTimeDelta) { +#ifdef 기무리 + m_pGameInstance->Set_LevelToChange(); +#endif // 기무리 + if (m_pGameInstance->Key_Up(DIK_F1)) { m_pGameInstance->Set_LevelToChange(); diff --git a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl index 283f71465..73c6d15bf 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl +++ b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl @@ -18,6 +18,8 @@ float g_fFocusDistance; float g_fFarBlurStart; float g_fFarBlurEnd; float g_fDOFBlurMultiplier; +float g_fSSAO_BIAS; +bool g_bSSAO_INVERT; Texture2D g_Texture; Texture2D g_SSAONoiseTexture; @@ -910,52 +912,60 @@ struct PS_OUT_SSAO_AMBIENT_OCCLUSION PS_OUT_SSAO_AMBIENT_OCCLUSION PS_SSAO_AMBIENT_OCCLUSION(PS_IN In) { PS_OUT_SSAO_AMBIENT_OCCLUSION Out; + float2 uv = In.vTexcoord; - vector vWorldPosition; - vector vDepthDesc = g_DepthTexture.Sample(DefaultSampler, In.vTexcoord); - float fViewZ = vDepthDesc.y * g_fFar; + float4 vDepthDesc = g_DepthTexture.Sample(PointSampler, uv); + float fCenterViewSpaceZ = vDepthDesc.y * g_fFar; // n ~ f - vWorldPosition.x = In.vTexcoord.x * 2.f - 1.f; - vWorldPosition.y = In.vTexcoord.y * -2.f + 1.f; - vWorldPosition.z = vDepthDesc.x; - vWorldPosition.w = 1.f; + float4 vCenterViewPosition; + { + vCenterViewPosition.x = uv.x * 2 - 1; + vCenterViewPosition.y = uv.y * -2 + 1; + vCenterViewPosition.z = vDepthDesc.x; + vCenterViewPosition.w = 1.f; + vCenterViewPosition *= fCenterViewSpaceZ; + vCenterViewPosition = mul(vCenterViewPosition, g_invmatProj); + } + float3 vNormal = normalize(g_NormalTexture.Sample(PointSampler, uv).xyz * 2.f - 1.f); + float3 vCenterViewNormal = mul(vNormal, (float3x3) g_ViewMatrix); + float3 vCenterProjNormal = mul(vCenterViewNormal, (float3x3) g_ProjMatrix); - vWorldPosition = vWorldPosition * fViewZ; + float2 vNoiseScale = g_vResolution / 4.f; + float3 vNoise = g_SSAONoiseTexture.Sample(SsaoDataSampler, uv * vNoiseScale).xyz; - vector vViewPosition = vWorldPosition = mul(vWorldPosition, g_invmatProj); - vViewPosition /= vViewPosition.w; - - float2 vTexcoord = In.vTexcoord; - float3 vNormal = normalize(g_NormalTexture.Sample(DefaultSampler, vTexcoord).xyz * 2.f - 1.f); - vNormal = mul(vNormal, (float3x3)g_ViewMatrix); - float2 vNoiseScale = float2(g_vResolution / 4.f); - - float3 vNoise = g_SSAONoiseTexture.Sample(SsaoDataSampler, vTexcoord * vNoiseScale).xyz; - - float3 vTangent = normalize(vNoise - vNormal * dot(vNoise, vNormal)); - float3 vBiNormal = cross(vTangent.xyz, vNormal.xyz); - float3x3 TBNMatrix = float3x3(vTangent.xyz, vBiNormal.xyz, vNormal.xyz); + float3 vTangent = normalize(vNoise - vCenterViewNormal * dot(vNoise, vCenterViewNormal)); + float3 vBiNormal = cross(vCenterViewNormal, vTangent); + float3x3 toViewTBNMatrix = float3x3(vTangent, vBiNormal, vCenterViewNormal); float fOcclusion = 0.f; for (uint i = 0; i < g_iKernelSize; ++i) { - float3 vSample = mul(SamplePos[i], TBNMatrix); - vSample = vViewPosition.xyz + vSample * g_fSSAORadius; + float3 vViewSamplePosVec = mul(SamplePos[i], toViewTBNMatrix); // TANSPACE -> VIEW + float4 vViewSamplePos = vCenterViewPosition + float4(vViewSamplePosVec * g_fSSAORadius, 0.f); + float4 vNDCSampleOffset = mul(vViewSamplePos, g_ProjMatrix); + vNDCSampleOffset /= vNDCSampleOffset.w; - float4 vOffset = float4(vSample, 1.f); - vOffset = mul(vOffset, g_ProjMatrix); // view -> clip - vOffset.xyz /= vOffset.w; - vOffset.xyz = vOffset.xyz * 0.5 + 0.5; - float fCenterViewZ = fViewZ; - - float fSampleViewDepth = g_DepthTexture.Sample(DefaultSampler, vOffset.xy).y * g_fFar; - - float fSamplePosViewZ = vSample.z; - const float fBias = 0.1f; - float fIsOccluded = (fSampleViewDepth <= fCenterViewZ - fBias) ? 1.0f : 0.0f; + float2 sampleUV = vNDCSampleOffset.xy * 0.5f + 0.5f; + // 스크린 밖이면 스킵 + if (sampleUV.x < 0 || sampleUV.x > 1 + || sampleUV.y < 0 || sampleUV.y > 1) { + continue; + } - float fRangeCheck = smoothstep(0.f, 1.f, g_fSSAORadius / abs(vViewPosition.z - fSampleViewDepth)); - fOcclusion += fIsOccluded * fRangeCheck; + float fRecordedSampleViewPosDepth = g_DepthTexture.Sample(PointSampler, sampleUV).y * g_fFar; + float fIsOccluded = 1.f; + if (g_bSSAO_INVERT) + { + fIsOccluded = (fRecordedSampleViewPosDepth < vViewSamplePos.z - g_fSSAO_BIAS) ? 1.0f : 0.0f; + } + else + { + fIsOccluded = (fRecordedSampleViewPosDepth > vViewSamplePos.z - g_fSSAO_BIAS) ? 1.0f : 0.0f; + } + + float fRangeCheck = smoothstep(0.f, 1.f, g_fSSAORadius / abs(vViewSamplePos.z - fRecordedSampleViewPosDepth)); + fIsOccluded *= fRangeCheck; + fOcclusion += fIsOccluded; } fOcclusion = (1.f - (fOcclusion / g_iKernelSize)); Out.fOcclusion = fOcclusion; diff --git a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_VtxAnimMesh.hlsl b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_VtxAnimMesh.hlsl index e80f2f915..b65b093b0 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_VtxAnimMesh.hlsl +++ b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_VtxAnimMesh.hlsl @@ -82,13 +82,13 @@ VS_OUT VS_MAIN(VS_IN In) matWV = mul(g_WorldMatrix, g_ViewMatrix); matWVP = mul(matWV, g_ProjMatrix); - Out.vPosition = mul(vPosition, matWVP); - Out.vNormal = normalize(mul(vNormal, g_WorldMatrix)).xyz; - Out.vBinormal = normalize(mul(vBinormal, g_WorldMatrix)).xyz; - Out.vTangent = normalize(mul(vTangent, g_WorldMatrix)).xyz; - Out.vTexcoord = In.vTexcoord; - Out.vWorldPos = mul(vPosition, g_WorldMatrix); - Out.vProjPos = Out.vPosition; + Out.vPosition = mul(vPosition, matWVP); + Out.vNormal = normalize(mul(vNormal, g_WorldMatrix)).xyz; + Out.vBinormal = normalize(mul(vBinormal, g_WorldMatrix)).xyz; + Out.vTangent = normalize(mul(vTangent, g_WorldMatrix)).xyz; + Out.vTexcoord = In.vTexcoord; + Out.vWorldPos = mul(vPosition, g_WorldMatrix); + Out.vProjPos = Out.vPosition; return Out; } diff --git a/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl b/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl index d96bf338d..73c6d15bf 100644 --- a/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl +++ b/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl @@ -18,6 +18,8 @@ float g_fFocusDistance; float g_fFarBlurStart; float g_fFarBlurEnd; float g_fDOFBlurMultiplier; +float g_fSSAO_BIAS; +bool g_bSSAO_INVERT; Texture2D g_Texture; Texture2D g_SSAONoiseTexture; @@ -910,52 +912,60 @@ struct PS_OUT_SSAO_AMBIENT_OCCLUSION PS_OUT_SSAO_AMBIENT_OCCLUSION PS_SSAO_AMBIENT_OCCLUSION(PS_IN In) { PS_OUT_SSAO_AMBIENT_OCCLUSION Out; + float2 uv = In.vTexcoord; - vector vWorldPosition; - vector vDepthDesc = g_DepthTexture.Sample(DefaultSampler, In.vTexcoord); - float fViewZ = vDepthDesc.y * g_fFar; + float4 vDepthDesc = g_DepthTexture.Sample(PointSampler, uv); + float fCenterViewSpaceZ = vDepthDesc.y * g_fFar; // n ~ f - vWorldPosition.x = In.vTexcoord.x * 2.f - 1.f; - vWorldPosition.y = In.vTexcoord.y * -2.f + 1.f; - vWorldPosition.z = vDepthDesc.x; - vWorldPosition.w = 1.f; + float4 vCenterViewPosition; + { + vCenterViewPosition.x = uv.x * 2 - 1; + vCenterViewPosition.y = uv.y * -2 + 1; + vCenterViewPosition.z = vDepthDesc.x; + vCenterViewPosition.w = 1.f; + vCenterViewPosition *= fCenterViewSpaceZ; + vCenterViewPosition = mul(vCenterViewPosition, g_invmatProj); + } + float3 vNormal = normalize(g_NormalTexture.Sample(PointSampler, uv).xyz * 2.f - 1.f); + float3 vCenterViewNormal = mul(vNormal, (float3x3) g_ViewMatrix); + float3 vCenterProjNormal = mul(vCenterViewNormal, (float3x3) g_ProjMatrix); - vWorldPosition = vWorldPosition * fViewZ; + float2 vNoiseScale = g_vResolution / 4.f; + float3 vNoise = g_SSAONoiseTexture.Sample(SsaoDataSampler, uv * vNoiseScale).xyz; - vector vViewPosition = vWorldPosition = mul(vWorldPosition, g_invmatProj); - vViewPosition /= vViewPosition.w; - - float2 vTexcoord = In.vTexcoord; - float3 vNormal = normalize(g_NormalTexture.Sample(DefaultSampler, vTexcoord).xyz * 2.f - 1.f); - vNormal = mul(vNormal, (float3x3)g_ViewMatrix); - float2 vNoiseScale = float2(g_vResolution / 4.f); - - float3 vNoise = g_SSAONoiseTexture.Sample(SsaoDataSampler, vTexcoord * vNoiseScale).xyz; - - float3 vTangent = normalize(vNoise - vNormal * dot(vNoise, vNormal)); - float3 vBiNormal = cross(vNormal.xyz, vTangent.xyz); - float3x3 TBNMatrix = float3x3(vTangent.xyz, vBiNormal.xyz, vNormal.xyz); + float3 vTangent = normalize(vNoise - vCenterViewNormal * dot(vNoise, vCenterViewNormal)); + float3 vBiNormal = cross(vCenterViewNormal, vTangent); + float3x3 toViewTBNMatrix = float3x3(vTangent, vBiNormal, vCenterViewNormal); float fOcclusion = 0.f; for (uint i = 0; i < g_iKernelSize; ++i) { - float3 vSample = mul(SamplePos[i], TBNMatrix); - vSample = vViewPosition.xyz + vSample * g_fSSAORadius; + float3 vViewSamplePosVec = mul(SamplePos[i], toViewTBNMatrix); // TANSPACE -> VIEW + float4 vViewSamplePos = vCenterViewPosition + float4(vViewSamplePosVec * g_fSSAORadius, 0.f); + float4 vNDCSampleOffset = mul(vViewSamplePos, g_ProjMatrix); + vNDCSampleOffset /= vNDCSampleOffset.w; - float4 vOffset = float4(vSample, 1.f); - vOffset = mul(vOffset, g_ProjMatrix); // view -> clip - vOffset.xyz /= vOffset.w; - vOffset.xyz = vOffset.xyz * 0.5 + 0.5; - float fCenterViewZ = fViewZ; - - float fSampleViewDepth = g_DepthTexture.Sample(DefaultSampler, vOffset.xy).y * g_fFar; - - float fSamplePosViewZ = vSample.z; - const float fBias = 0.1f; - float fIsOccluded = (fSampleViewDepth <= fCenterViewZ - fBias) ? 1.0f : 0.0f; + float2 sampleUV = vNDCSampleOffset.xy * 0.5f + 0.5f; + // 스크린 밖이면 스킵 + if (sampleUV.x < 0 || sampleUV.x > 1 + || sampleUV.y < 0 || sampleUV.y > 1) { + continue; + } - float fRangeCheck = smoothstep(0.f, 1.f, g_fSSAORadius / abs(vViewPosition.z - fSampleViewDepth)); - fOcclusion += fIsOccluded * fRangeCheck; + float fRecordedSampleViewPosDepth = g_DepthTexture.Sample(PointSampler, sampleUV).y * g_fFar; + float fIsOccluded = 1.f; + if (g_bSSAO_INVERT) + { + fIsOccluded = (fRecordedSampleViewPosDepth < vViewSamplePos.z - g_fSSAO_BIAS) ? 1.0f : 0.0f; + } + else + { + fIsOccluded = (fRecordedSampleViewPosDepth > vViewSamplePos.z - g_fSSAO_BIAS) ? 1.0f : 0.0f; + } + + float fRangeCheck = smoothstep(0.f, 1.f, g_fSSAORadius / abs(vViewSamplePos.z - fRecordedSampleViewPosDepth)); + fIsOccluded *= fRangeCheck; + fOcclusion += fIsOccluded; } fOcclusion = (1.f - (fOcclusion / g_iKernelSize)); Out.fOcclusion = fOcclusion; diff --git a/Jusin154_Team3D/Engine/Private/Renderer.cpp b/Jusin154_Team3D/Engine/Private/Renderer.cpp index c046af2da..861849b4b 100644 --- a/Jusin154_Team3D/Engine/Private/Renderer.cpp +++ b/Jusin154_Team3D/Engine/Private/Renderer.cpp @@ -522,44 +522,124 @@ void CRenderer::Render_Blur() } void CRenderer::Render_SSAO() { +#ifdef _DEBUG + static _bool bSSAO = { true }; + static _uint iKernelSize = SSAO_SAMPLE_NUMBER; + static _float fSSAORadius = 1.5f; + static _float fSSAO_BIAS = 0.1f; + static _bool bInverted = { false }; + GUI::Begin("Renderer"); + GUI::Checkbox("bSSAO ", &bSSAO); + if (true == bSSAO) { + GUI::SameLine(); + if (GUI::CollapsingHeader("SSAO")) { + GUI::DragFloat("fSSAORadius ", &fSSAORadius, 0.001f, 0.f, 3.f, "%.3f"); + GUI::DragFloat("fSSAO_BIAS", &fSSAO_BIAS, 0.001f, 0.f, 2.f, "%.3f"); + GUI::Checkbox("Inverted", &bInverted); + } + } + else { + GUI::End(); + return; + } + GUI::End(); +#endif // _DEBUG if (FAILED(m_pGameInstance->Begin_MRT(TEXT("MRT_SSAO_OCCLUSION")))) { return; } { + _uint iNumViewPort = { 1 }; + D3D11_VIEWPORT vp = {}; + m_pContext->RSGetViewports(&iNumViewPort, &vp); + _float2 vResolution = { vp.Width, vp.Height }; + if (FAILED(m_pShader->Bind_RawValue("g_vResolution", &vResolution, sizeof(_float2)))) { + assert(false); + } + // Bind_Resorces - m_pShader->Bind_Matrix("g_WorldMatrix", &m_WorldMatrix); - m_pShader->Bind_Matrix("g_ViewMatrix", &m_ViewMatrix); - m_pShader->Bind_Matrix("g_ProjMatrix", &m_ProjMatrix); - m_pShader->Bind_Matrix("g_invMatView", m_pGameInstance->Get_Transform_Float4x4(D3DTS::VIEW_INV)); - m_pShader->Bind_Matrix("g_invmatProj", m_pGameInstance->Get_Transform_Float4x4(D3DTS::PROJ_INV)); - m_pShader->Bind_RawValue("g_vCamPosition", m_pGameInstance->Get_CamPosition(), sizeof(_float4)); - m_pShader->Bind_RawValue("g_fFar", m_pGameInstance->Get_CurrentCameraFar(), sizeof(_float)); - _uint iKernelSize = SSAO_SAMPLE_NUMBER; - _float fSSAORadius = 0.5f; - m_pShader->Bind_RawValue("g_iKernelSize", &iKernelSize, sizeof(_uint)); - m_pShader->Bind_RawValue("g_fSSAORadius", &fSSAORadius, sizeof(_float)); + if (FAILED(m_pShader->Bind_Matrix("g_WorldMatrix", &m_WorldMatrix))){ + assert(false); + return ; + } + if (FAILED(m_pShader->Bind_Matrix("g_ViewMatrix", &m_ViewMatrix))){ + assert(false); + return ; + } + if (FAILED(m_pShader->Bind_Matrix("g_ProjMatrix", &m_ProjMatrix))){ + assert(false); + return ; + } + if (FAILED(m_pShader->Bind_Matrix("g_invMatView", m_pGameInstance->Get_Transform_Float4x4(D3DTS::VIEW_INV)))){ + assert(false); + return ; + } + if (FAILED(m_pShader->Bind_Matrix("g_invmatProj", m_pGameInstance->Get_Transform_Float4x4(D3DTS::PROJ_INV)))){ + assert(false); + return ; + } + if (FAILED(m_pShader->Bind_RawValue("g_vCamPosition", m_pGameInstance->Get_CamPosition(), sizeof(_float4)))){ + assert(false); + return ; + } + if (FAILED(m_pShader->Bind_RawValue("g_fFar", m_pGameInstance->Get_CurrentCameraFar(), sizeof(_float)))){ + assert(false); + return ; + } + + if (FAILED(m_pShader->Bind_RawValue("g_iKernelSize", &iKernelSize, sizeof(_uint)))){ + assert(false); + return ; + } + if (FAILED(m_pShader->Bind_RawValue("g_fSSAORadius", &fSSAORadius, sizeof(_float)))){ + assert(false); + return ; + } if (FAILED(m_pShader->Bind_RawValue("g_fFar", m_pGameInstance->Get_CurrentCameraFar(), sizeof(_float)))) { + assert(false); return; } + + if (FAILED(m_pShader->Bind_RawValue("g_fSSAO_BIAS", &fSSAO_BIAS, sizeof(_float)))) { + assert(false); + return; + } + + if (FAILED(m_pShader->Bind_RawValue("g_bSSAO_INVERT", &bInverted, sizeof(_bool)))) { + assert(false); + return; + } + //m_pContext->VSSetConstantBuffers(10, 1, &m_pGlobalStaticCB); + //m_pContext->PSSetConstantBuffers(10, 1, &m_pGlobalStaticCB); } { // Bind_Targets if (FAILED(m_pGameInstance->Bind_RenderTarget(TEXT("Target_Depth"), m_pShader, "g_DepthTexture"))) { + assert(false); return; } if (FAILED(m_pGameInstance->Bind_RenderTarget(TEXT("Target_Normal"), m_pShader, "g_NormalTexture"))) { + assert(false); return; } if (FAILED(m_pShader->Bind_SRV("g_SSAONoiseTexture", m_pSSAO_NoiseSRV))) { + assert(false); return; } } - m_pShader->Begin(ENUM_CLASS(SHADER_PASS_DEFERRED::SSAO_OCCLUSION)); - - m_pVIBuffer->Bind_Resources(); - m_pVIBuffer->Render(); + if (FAILED(m_pShader->Begin(ENUM_CLASS(SHADER_PASS_DEFERRED::SSAO_OCCLUSION)))){ + assert(false); + return ; + } + if (FAILED(m_pVIBuffer->Bind_Resources())){ + assert(false); + return ; + } + if (FAILED(m_pVIBuffer->Render())){ + assert(false); + return ; + } if (FAILED(m_pGameInstance->End_MRT())) { return; } diff --git a/Jusin154_Team3D/Engine/Private/Renderer_Declare.cpp b/Jusin154_Team3D/Engine/Private/Renderer_Declare.cpp index 467f1cb14..b34c151e2 100644 --- a/Jusin154_Team3D/Engine/Private/Renderer_Declare.cpp +++ b/Jusin154_Team3D/Engine/Private/Renderer_Declare.cpp @@ -86,7 +86,7 @@ void CRenderer::Fill_Geometry(_uint iNumSample) vPos = { rand_Minus(m_Rng), rand_Minus(m_Rng), - rand_Normal(m_Rng), 0.f + rand_Minus(m_Rng) }; vPos = XMVector3Normalize(vPos) * rand_Normal(m_Rng); fScale = ((_float)iIndexSample / (_float)iNumSample); @@ -98,7 +98,9 @@ void CRenderer::Fill_Geometry(_uint iNumSample) for (_uint iIndexDir = 0; iIndexDir < 16; ++iIndexDir) { m_tagSSAOGeometryDirections.vDir[iIndexDir] = { rand_Minus(m_Rng), - rand_Minus(m_Rng) + rand_Minus(m_Rng), + rand_Minus(m_Rng), + 0.f }; } D3D11_TEXTURE2D_DESC texDesc = {}; @@ -106,7 +108,7 @@ void CRenderer::Fill_Geometry(_uint iNumSample) texDesc.Height = 4; texDesc.MipLevels = 1; texDesc.ArraySize = 1; - texDesc.Format = DXGI_FORMAT_R32G32_FLOAT; + texDesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT; texDesc.SampleDesc.Count = 1; texDesc.SampleDesc.Quality = 0; texDesc.Usage = D3D11_USAGE_IMMUTABLE; @@ -114,7 +116,7 @@ void CRenderer::Fill_Geometry(_uint iNumSample) D3D11_SUBRESOURCE_DATA initData = {}; initData.pSysMem = &m_tagSSAOGeometryDirections; - initData.SysMemPitch = sizeof(_float2); + initData.SysMemPitch = sizeof(_float4); if (FAILED(m_pDevice->CreateTexture2D(&texDesc, &initData, &m_pSSAO_NoiseTexture))) { assert(false); @@ -130,7 +132,6 @@ void CRenderer::Fill_Geometry(_uint iNumSample) m_pDevice->CreateShaderResourceView(m_pSSAO_NoiseTexture, &srvDesc, &m_pSSAO_NoiseSRV); - ID3D11Buffer* pGlobalStaticCB = nullptr; { D3D11_BUFFER_DESC desc = {}; desc.ByteWidth = sizeof(SSAO_GEOMETRY_HEMISPHERE); @@ -140,12 +141,12 @@ void CRenderer::Fill_Geometry(_uint iNumSample) D3D11_SUBRESOURCE_DATA initData = {}; initData.pSysMem = &m_tagSSAOGeometry; - initData.SysMemPitch = sizeof(_float); + initData.SysMemPitch = sizeof(_float4); - HRESULT hr = m_pDevice->CreateBuffer(&desc, &initData, &pGlobalStaticCB); + HRESULT hr = m_pDevice->CreateBuffer(&desc, &initData, &m_pGlobalStaticCB); - m_pContext->VSSetConstantBuffers(10, 1, &pGlobalStaticCB); - m_pContext->PSSetConstantBuffers(10, 1, &pGlobalStaticCB); + m_pContext->VSSetConstantBuffers(10, 1, &m_pGlobalStaticCB); + m_pContext->PSSetConstantBuffers(10, 1, &m_pGlobalStaticCB); } } HRESULT CRenderer::Initialize() diff --git a/Jusin154_Team3D/Engine/Public/Engine_Struct.h b/Jusin154_Team3D/Engine/Public/Engine_Struct.h index 70f8959b9..25ad46781 100644 --- a/Jusin154_Team3D/Engine/Public/Engine_Struct.h +++ b/Jusin154_Team3D/Engine/Public/Engine_Struct.h @@ -447,7 +447,7 @@ typedef struct tagSSAO_Geometry_Hemisphere { }SSAO_GEOMETRY_HEMISPHERE; typedef struct tagSSAO_GeometryDirections_RANDOM_REAL { - _float2 vDir[16]; + _float4 vDir[16]; }SSAO_GEOMETRYDIRECTIONS_RANDOM_REAL; NS_END diff --git a/Jusin154_Team3D/Engine/Public/PhysX/PxShape.h b/Jusin154_Team3D/Engine/Public/PhysX/PxShape.h index 657c907f3..f15fff9ff 100644 --- a/Jusin154_Team3D/Engine/Public/PhysX/PxShape.h +++ b/Jusin154_Team3D/Engine/Public/PhysX/PxShape.h @@ -1,4 +1,4 @@ -// Redistribution and use in source and binary forms, with or without +// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright diff --git a/Jusin154_Team3D/Engine/Public/Renderer.h b/Jusin154_Team3D/Engine/Public/Renderer.h index 0f4a34084..bb1a27ae1 100644 --- a/Jusin154_Team3D/Engine/Public/Renderer.h +++ b/Jusin154_Team3D/Engine/Public/Renderer.h @@ -44,6 +44,7 @@ class CRenderer final : public CBase ID3D11DepthStencilView* m_pPreShadowDSV = { nullptr }; ID3D11ShaderResourceView* m_pSSAO_NoiseSRV = { nullptr }; ID3D11Texture2D* m_pSSAO_NoiseTexture = { nullptr }; + ID3D11Buffer* m_pGlobalStaticCB = { nullptr }; SHADOW_LIGHT_DESC m_PreShadowDesc = {}; _float4x4 m_PreShadowMatrices[ENUM_CLASS(D3DTS::END)] = {};