Skip to content

Commit ea4f4ca

Browse files
GLTF Viewer: use proper opacity when applying post effects
1 parent de17bde commit ea4f4ca

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

Samples/GLTFViewer/assets/shaders/ApplyPostEffects.psh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ float4 main(in FullScreenTriangleVSOutput VSOut) : SV_Target
4949

5050
float3 SSR = GetSpecularIBL_GGX(SrfInfo, IBLInfo, SSRRadiance.rgb);
5151

52+
float Opacity = 1.0 - OutColor.a;
5253
if (DebugMode == 0.0)
5354
{
54-
OutColor.rgb += (SSR.rgb - SpecularIBL.rgb) * SSRRadiance.w * OutColor.a * SSRScale;
55+
OutColor.rgb += (SSR.rgb - SpecularIBL.rgb) * SSRRadiance.w * Opacity * SSRScale;
5556
}
5657
else if (DebugMode == 1.0)
5758
{

Samples/GLTFViewer/src/GLTFViewer.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,9 +1321,7 @@ void GLTFViewer::Render()
13211321
EnvMapAttribs.pEnvMap = pEnvMapSRV;
13221322
EnvMapAttribs.AverageLogLum = m_ShaderAttribs.AverageLogLum;
13231323
EnvMapAttribs.MipLevel = m_EnvMapMipLevel;
1324-
// It is essential to write zero alpha because we use alpha channel
1325-
// to attenuate SSR for transparent surfaces.
1326-
EnvMapAttribs.Alpha = 0.0;
1324+
EnvMapAttribs.Alpha = 1.0;
13271325
if ((m_RenderParams.Flags & GLTF_PBR_Renderer::PSO_FLAG_CONVERT_OUTPUT_TO_SRGB) != 0)
13281326
EnvMapAttribs.Options |= EnvMapRenderer::OPTION_FLAG_CONVERT_OUTPUT_TO_SRGB;
13291327
if (m_bEnablePostProcessing)

0 commit comments

Comments
 (0)