Skip to content

Commit 4ceffc5

Browse files
GLTF Viewer: added SSR debug views
1 parent a3d798c commit 4ceffc5

File tree

3 files changed

+44
-10
lines changed

3 files changed

+44
-10
lines changed

Samples/GLTFViewer/assets/shaders/ApplyPostEffects.psh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,21 @@ float4 main(in FullScreenTriangleVSOutput VSOut) : SV_Target
2121
float4 SSR = g_tex2DSSR.Load(int3(VSOut.f4PixelPos.xy, 0));
2222
float4 IBL = g_tex2DIBL.Load(int3(VSOut.f4PixelPos.xy, 0));
2323

24-
float SSRScale = g_Frame.PrevCamera.f4ExtraData[0].x;
25-
Color.rgb += (SSR.rgb - IBL.rgb) * SSR.w * Color.a * SSRScale;
26-
24+
float SSRScale = g_Frame.PrevCamera.f4ExtraData[0].x;
25+
float DebugMode = g_Frame.PrevCamera.f4ExtraData[0].y;
26+
if (DebugMode == 0.0)
27+
{
28+
Color.rgb += (SSR.rgb - IBL.rgb) * SSR.w * Color.a * SSRScale;
29+
}
30+
else if (DebugMode == 1.0)
31+
{
32+
Color.rgb = SSR.rgb;
33+
}
34+
else if (DebugMode == 2.0)
35+
{
36+
Color.rgb = float3(SSR.w, SSR.w, SSR.w);
37+
}
38+
2739
{
2840
// Perform tone mapping
2941
ToneMappingAttribs TMAttribs;

Samples/GLTFViewer/src/GLTFViewer.cpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2023 Diligent Graphics LLC
2+
* Copyright 2019-2024 Diligent Graphics LLC
33
* Copyright 2015-2019 Egor Yusov
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -961,6 +961,11 @@ void GLTFViewer::UpdateUI()
961961

962962
ImGui::SliderFloat("SSR scale", &m_ShaderAttribs.SSRScale, 0.f, 1.f);
963963

964+
ImGui::Combo("SSR Debug View", reinterpret_cast<int*>(&m_ShaderAttribs.SSRDebugMode),
965+
"None\0"
966+
"SSR\0"
967+
"Confidence\0\0");
968+
964969
ImGui::TreePop();
965970
}
966971
}
@@ -1029,10 +1034,19 @@ void GLTFViewer::Render()
10291034
FrameAttribs->Camera = CurrCamAttribs;
10301035
FrameAttribs->PrevCamera = PrevCamAttribs;
10311036

1032-
FrameAttribs->PrevCamera.f4ExtraData[0].x =
1033-
(m_RenderParams.DebugView == GLTF_PBR_Renderer::DebugViewType::None) ?
1034-
m_ShaderAttribs.SSRScale :
1035-
0;
1037+
if (m_RenderParams.DebugView == GLTF_PBR_Renderer::DebugViewType::None)
1038+
{
1039+
FrameAttribs->PrevCamera.f4ExtraData[0] = float4{
1040+
m_ShaderAttribs.SSRScale,
1041+
static_cast<float>(m_ShaderAttribs.SSRDebugMode),
1042+
0,
1043+
0,
1044+
};
1045+
}
1046+
else
1047+
{
1048+
FrameAttribs->PrevCamera.f4ExtraData[0] = float4{0};
1049+
}
10361050

10371051
{
10381052
if (m_BoundBoxMode != BoundBoxMode::None)

Samples/GLTFViewer/src/GLTFViewer.hpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2023 Diligent Graphics LLC
2+
* Copyright 2019-2024 Diligent Graphics LLC
33
* Copyright 2015-2019 Egor Yusov
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -87,6 +87,13 @@ class GLTFViewer final : public SampleBase
8787

8888
GLTF_PBR_Renderer::RenderInfo m_RenderParams;
8989

90+
enum class SSRDebugViewMode : int
91+
{
92+
None,
93+
SSR,
94+
Confidence
95+
};
96+
9097
struct ShaderParams
9198
{
9299
float OcclusionStrength = 1;
@@ -99,7 +106,8 @@ class GLTFViewer final : public SampleBase
99106
float4 HighlightColor = float4{0, 0, 0, 0};
100107
float4 WireframeColor = float4{0.8f, 0.7f, 0.5f, 1.0f};
101108

102-
float SSRScale = 1;
109+
float SSRScale = 1;
110+
SSRDebugViewMode SSRDebugMode = SSRDebugViewMode::None;
103111
};
104112
ShaderParams m_ShaderAttribs;
105113

0 commit comments

Comments
 (0)