44
44
#include " GraphicsAccessories.hpp"
45
45
#include " EnvMapRenderer.hpp"
46
46
#include " VectorFieldRenderer.hpp"
47
+ #include " PostFXContext.hpp"
47
48
#include " ScreenSpaceReflection.hpp"
48
49
#include " Utilities/include/DiligentFXShaderSourceStreamFactory.hpp"
49
50
#include " ShaderSourceFactoryUtils.h"
@@ -57,6 +58,7 @@ namespace HLSL
57
58
#include " Shaders/Common/public/BasicStructures.fxh"
58
59
#include " Shaders/PBR/public/PBR_Structures.fxh"
59
60
#include " Shaders/PBR/private/RenderPBR_Structures.fxh"
61
+ #include " Shaders/PostProcess/ScreenSpaceReflection/public/ScreenSpaceReflectionStructures.fxh"
60
62
61
63
} // namespace HLSL
62
64
@@ -592,7 +594,8 @@ void GLTFViewer::Initialize(const SampleInitInfo& InitInfo)
592
594
CreateGLTFRenderer ();
593
595
CrateEnvMapRenderer ();
594
596
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);
596
599
597
600
RefCntAutoPtr<IRenderStateNotationParser> pRSNParser;
598
601
{
@@ -983,13 +986,14 @@ void GLTFViewer::UpdateUI()
983
986
CrateEnvMapRenderer ();
984
987
}
985
988
989
+ ImGui::SliderFloat (" SSAO scale" , &m_ShaderAttribs.SSAOScale , 0 .f , 1 .f );
986
990
ImGui::SliderFloat (" SSR scale" , &m_ShaderAttribs.SSRScale , 0 .f , 1 .f );
987
991
988
- ImGui::Combo (" SSR Debug View" , &m_ShaderAttribs.SSRDebugMode ,
992
+ ImGui::Combo (" Debug View" , &m_ShaderAttribs.PostFXDebugMode ,
989
993
" 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 " );
993
997
994
998
ImGui::TreePop ();
995
999
}
@@ -1063,7 +1067,7 @@ void GLTFViewer::Render()
1063
1067
{
1064
1068
FrameAttribs->PrevCamera .f4ExtraData [0 ] = float4{
1065
1069
m_ShaderAttribs.SSRScale ,
1066
- static_cast <float >(m_ShaderAttribs.SSRDebugMode ),
1070
+ static_cast <float >(m_ShaderAttribs.PostFXDebugMode ),
1067
1071
0 ,
1068
1072
0 ,
1069
1073
};
@@ -1212,33 +1216,30 @@ void GLTFViewer::Render()
1212
1216
}
1213
1217
1214
1218
{
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
+
1215
1233
ScreenSpaceReflection::RenderAttributes SSRRenderAttribs{};
1216
1234
SSRRenderAttribs.pDevice = m_pDevice;
1217
1235
SSRRenderAttribs.pDeviceContext = m_pImmediateContext;
1236
+ SSRRenderAttribs.pPostFXContext = m_PostFXContext.get ();
1218
1237
SSRRenderAttribs.pColorBufferSRV = m_GBuffer->GetBuffer (GBUFFER_RT_RADIANCE)->GetDefaultView (TEXTURE_VIEW_SHADER_RESOURCE);
1219
1238
SSRRenderAttribs.pDepthBufferSRV = m_GBuffer->GetBuffer (GBUFFER_RT_DEPTH)->GetDefaultView (TEXTURE_VIEW_DEPTH_STENCIL);
1220
1239
SSRRenderAttribs.pNormalBufferSRV = m_GBuffer->GetBuffer (GBUFFER_RT_NORMAL)->GetDefaultView (TEXTURE_VIEW_SHADER_RESOURCE);
1221
1240
SSRRenderAttribs.pMaterialBufferSRV = m_GBuffer->GetBuffer (GBUFFER_RT_MATERIAL_DATA)->GetDefaultView (TEXTURE_VIEW_SHADER_RESOURCE);
1222
1241
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;
1242
1243
m_SSR->Execute (SSRRenderAttribs);
1243
1244
}
1244
1245
0 commit comments