Skip to content

Commit a3d798c

Browse files
GLTF Viewer: added SSR scale parameter; disable SSR when debug view is enabled
1 parent 01c7f5b commit a3d798c

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

Samples/GLTFViewer/assets/shaders/ApplyPostEffects.psh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ 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-
Color.rgb += (SSR.rgb - IBL.rgb) * SSR.w * Color.a;
24+
float SSRScale = g_Frame.PrevCamera.f4ExtraData[0].x;
25+
Color.rgb += (SSR.rgb - IBL.rgb) * SSR.w * Color.a * SSRScale;
2526

2627
{
2728
// Perform tone mapping

Samples/GLTFViewer/src/GLTFViewer.cpp

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -929,11 +929,6 @@ void GLTFViewer::UpdateUI()
929929
CreateGLTFRenderer();
930930
LoadModel(m_ModelPath.c_str());
931931
}
932-
if (ImGui::Checkbox("Post processing", &m_bEnablePostProcessing))
933-
{
934-
CreateGLTFRenderer();
935-
CrateEnvMapRenderer();
936-
}
937932

938933
ImGui::TreePop();
939934
}
@@ -955,6 +950,19 @@ void GLTFViewer::UpdateUI()
955950
AlphaModeCheckbox("Blend", GLTF_PBR_Renderer::RenderInfo::ALPHA_MODE_FLAG_BLEND);
956951
ImGui::TreePop();
957952
}
953+
954+
if (ImGui::TreeNode("Post Processing"))
955+
{
956+
if (ImGui::Checkbox("Enable", &m_bEnablePostProcessing))
957+
{
958+
CreateGLTFRenderer();
959+
CrateEnvMapRenderer();
960+
}
961+
962+
ImGui::SliderFloat("SSR scale", &m_ShaderAttribs.SSRScale, 0.f, 1.f);
963+
964+
ImGui::TreePop();
965+
}
958966
}
959967
ImGui::End();
960968
}
@@ -1021,6 +1029,11 @@ void GLTFViewer::Render()
10211029
FrameAttribs->Camera = CurrCamAttribs;
10221030
FrameAttribs->PrevCamera = PrevCamAttribs;
10231031

1032+
FrameAttribs->PrevCamera.f4ExtraData[0].x =
1033+
(m_RenderParams.DebugView == GLTF_PBR_Renderer::DebugViewType::None) ?
1034+
m_ShaderAttribs.SSRScale :
1035+
0;
1036+
10241037
{
10251038
if (m_BoundBoxMode != BoundBoxMode::None)
10261039
{

Samples/GLTFViewer/src/GLTFViewer.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ class GLTFViewer final : public SampleBase
9898

9999
float4 HighlightColor = float4{0, 0, 0, 0};
100100
float4 WireframeColor = float4{0.8f, 0.7f, 0.5f, 1.0f};
101+
102+
float SSRScale = 1;
101103
};
102104
ShaderParams m_ShaderAttribs;
103105

0 commit comments

Comments
 (0)