4444#include " GraphicsAccessories.hpp"
4545#include " EnvMapRenderer.hpp"
4646#include " VectorFieldRenderer.hpp"
47+ #include " PostFXContext.hpp"
4748#include " ScreenSpaceReflection.hpp"
4849#include " Utilities/include/DiligentFXShaderSourceStreamFactory.hpp"
4950#include " ShaderSourceFactoryUtils.h"
@@ -57,6 +58,7 @@ namespace HLSL
5758#include " Shaders/Common/public/BasicStructures.fxh"
5859#include " Shaders/PBR/public/PBR_Structures.fxh"
5960#include " Shaders/PBR/private/RenderPBR_Structures.fxh"
61+ #include " Shaders/PostProcess/ScreenSpaceReflection/public/ScreenSpaceReflectionStructures.fxh"
6062
6163} // namespace HLSL
6264
@@ -592,7 +594,8 @@ void GLTFViewer::Initialize(const SampleInitInfo& InitInfo)
592594 CreateGLTFRenderer ();
593595 CrateEnvMapRenderer ();
594596 CreateVectorFieldRenderer ();
595- m_SSR = std::make_unique<ScreenSpaceReflection>(m_pDevice);
597+ m_PostFXContext = std::make_unique<PostFXContext>(m_pDevice);
598+ m_SSR = std::make_unique<ScreenSpaceReflection>(m_pDevice);
596599
597600 RefCntAutoPtr<IRenderStateNotationParser> pRSNParser;
598601 {
@@ -983,13 +986,14 @@ void GLTFViewer::UpdateUI()
983986 CrateEnvMapRenderer ();
984987 }
985988
989+ ImGui::SliderFloat (" SSAO scale" , &m_ShaderAttribs.SSAOScale , 0 .f , 1 .f );
986990 ImGui::SliderFloat (" SSR scale" , &m_ShaderAttribs.SSRScale , 0 .f , 1 .f );
987991
988- ImGui::Combo (" SSR Debug View" , &m_ShaderAttribs.SSRDebugMode ,
992+ ImGui::Combo (" Debug View" , &m_ShaderAttribs.PostFXDebugMode ,
989993 " None\0 "
990- " Radiance\0 "
991- " Reflection\0 "
992- " Confidence\0\0 " );
994+ " SSR: Radiance\0 "
995+ " SSR: Reflection\0 "
996+ " SSR: Confidence\0\0 " );
993997
994998 ImGui::TreePop ();
995999 }
@@ -1063,7 +1067,7 @@ void GLTFViewer::Render()
10631067 {
10641068 FrameAttribs->PrevCamera .f4ExtraData [0 ] = float4{
10651069 m_ShaderAttribs.SSRScale ,
1066- static_cast <float >(m_ShaderAttribs.SSRDebugMode ),
1070+ static_cast <float >(m_ShaderAttribs.PostFXDebugMode ),
10671071 0 ,
10681072 0 ,
10691073 };
@@ -1212,33 +1216,30 @@ void GLTFViewer::Render()
12121216 }
12131217
12141218 {
1219+ PostFXContext::RenderAttributes PostFXAttibs;
1220+ PostFXAttibs.pDevice = m_pDevice;
1221+ PostFXAttibs.pDeviceContext = m_pImmediateContext;
1222+ PostFXAttibs.pCameraAttribsCB = m_FrameAttribsCB;
1223+ PostFXAttibs.FrameIndex = m_CurrentFrameNumber;
1224+ m_PostFXContext->PrepareResources (PostFXAttibs);
1225+ }
1226+
1227+ {
1228+ HLSL::ScreenSpaceReflectionAttribs SSRAttribs{};
1229+ SSRAttribs.IBLFactor = m_ShaderAttribs.IBLScale ;
1230+ SSRAttribs.RoughnessChannel = 0 ;
1231+ SSRAttribs.IsRoughnessPerceptual = true ;
1232+
12151233 ScreenSpaceReflection::RenderAttributes SSRRenderAttribs{};
12161234 SSRRenderAttribs.pDevice = m_pDevice;
12171235 SSRRenderAttribs.pDeviceContext = m_pImmediateContext;
1236+ SSRRenderAttribs.pPostFXContext = m_PostFXContext.get ();
12181237 SSRRenderAttribs.pColorBufferSRV = m_GBuffer->GetBuffer (GBUFFER_RT_RADIANCE)->GetDefaultView (TEXTURE_VIEW_SHADER_RESOURCE);
12191238 SSRRenderAttribs.pDepthBufferSRV = m_GBuffer->GetBuffer (GBUFFER_RT_DEPTH)->GetDefaultView (TEXTURE_VIEW_DEPTH_STENCIL);
12201239 SSRRenderAttribs.pNormalBufferSRV = m_GBuffer->GetBuffer (GBUFFER_RT_NORMAL)->GetDefaultView (TEXTURE_VIEW_SHADER_RESOURCE);
12211240 SSRRenderAttribs.pMaterialBufferSRV = m_GBuffer->GetBuffer (GBUFFER_RT_MATERIAL_DATA)->GetDefaultView (TEXTURE_VIEW_SHADER_RESOURCE);
12221241 SSRRenderAttribs.pMotionVectorsSRV = m_GBuffer->GetBuffer (GBUFFER_RT_MOTION_VECTORS)->GetDefaultView (TEXTURE_VIEW_SHADER_RESOURCE);
1223-
1224- SSRRenderAttribs.SSRAttribs .ProjMatrix = CurrCamAttribs.mProjT ;
1225- SSRRenderAttribs.SSRAttribs .ViewMatrix = CurrCamAttribs.mViewT ;
1226- SSRRenderAttribs.SSRAttribs .ViewProjMatrix = CurrCamAttribs.mViewProjT ;
1227- SSRRenderAttribs.SSRAttribs .InvProjMatrix = CurrCamAttribs.mProjInvT ;
1228- SSRRenderAttribs.SSRAttribs .InvViewMatrix = CurrCamAttribs.mViewInvT ;
1229- SSRRenderAttribs.SSRAttribs .InvViewProjMatrix = CurrCamAttribs.mViewProjInvT ;
1230- SSRRenderAttribs.SSRAttribs .PrevViewProjMatrix = PrevCamAttribs.mViewProjT ;
1231- SSRRenderAttribs.SSRAttribs .InvPrevViewProjMatrix = PrevCamAttribs.mViewProjInvT ;
1232- SSRRenderAttribs.SSRAttribs .CameraPosition = CurrCamAttribs.f4Position ;
1233-
1234- SSRRenderAttribs.SSRAttribs .RenderSize .x = SCDesc.Width ;
1235- SSRRenderAttribs.SSRAttribs .RenderSize .y = SCDesc.Height ;
1236- SSRRenderAttribs.SSRAttribs .InverseRenderSize .x = 1 .0f / static_cast <float >(SCDesc.Width );
1237- SSRRenderAttribs.SSRAttribs .InverseRenderSize .y = 1 .0f / static_cast <float >(SCDesc.Height );
1238- SSRRenderAttribs.SSRAttribs .FrameIndex = m_CurrentFrameNumber;
1239- SSRRenderAttribs.SSRAttribs .IBLFactor = m_ShaderAttribs.IBLScale ;
1240- SSRRenderAttribs.SSRAttribs .RoughnessChannel = 0 ;
1241- SSRRenderAttribs.SSRAttribs .IsRoughnessPerceptual = true ;
1242+ SSRRenderAttribs.pSSRAttribs = &SSRAttribs;
12421243 m_SSR->Execute (SSRRenderAttribs);
12431244 }
12441245
0 commit comments