Skip to content

Commit 14bc4e4

Browse files
HnPostProcessTask: disabled depth rescaling shader logic if scene depth mode is not enabled
1 parent d6b5622 commit 14bc4e4

File tree

3 files changed

+28
-13
lines changed

3 files changed

+28
-13
lines changed

Hydrogent/interface/Tasks/HnPostProcessTask.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,12 +294,13 @@ class HnPostProcessTask final : public HnTask
294294
PPTask{_PPTask}
295295
{}
296296
void PreparePRS();
297-
void PreparePSO(TEXTURE_FORMAT RTVFormat);
297+
void PreparePSO(TEXTURE_FORMAT RTVFormat, HN_VIEW_MODE _ViewMode);
298298
void PrepareSRB(ITextureView* pClosestSelectedLocationSRV, Uint32 FrameIdx);
299299

300300
private:
301-
bool ConvertOutputToSRGB = false;
302-
int ToneMappingMode = 0;
301+
HN_VIEW_MODE ViewMode = HN_VIEW_MODE_SHADED;
302+
bool ConvertOutputToSRGB = false;
303+
int ToneMappingMode = 0;
303304

304305
CoordinateGridRenderer::FEATURE_FLAGS GridFeatureFlags = CoordinateGridRenderer::FEATURE_FLAG_NONE;
305306
} m_PostProcessTech;

Hydrogent/shaders/HnPostProcess.psh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ void main(in FullScreenTriangleVSOutput VSOut,
4343
float4 Pos = VSOut.f4PixelPos;
4444

4545
Color = g_ColorBuffer.Load(int3(Pos.xy, 0));
46-
if (g_Frame.Renderer.DebugView == DEBUG_VIEW_SCENE_DEPTH && g_Frame.Renderer.LoadingAnimation.Factor == 0.0)
46+
#if VIEW_MODE == VIEW_MODE_SCENE_DEPTH
47+
if (g_Frame.Renderer.LoadingAnimation.Factor == 0.0)
4748
{
4849
// The overlay was rendered with Scene Range == Camera Range.
4950
// At the end of the frame, we computed the accurate scene depth range in HnComputeDepthBoundsTask,
@@ -55,9 +56,10 @@ void main(in FullScreenTriangleVSOutput VSOut,
5556
RelZ = saturate(RelZ);
5657
Color.rgb = float3(RelZ, RelZ, RelZ);
5758
}
58-
59+
#endif
60+
5961
float Opacity = 1.0 - Color.a;
60-
62+
6163
float SSRScale = g_Attribs.SSRScale * Opacity;
6264
if (SSRScale > 0.0)
6365
{
@@ -66,7 +68,7 @@ void main(in FullScreenTriangleVSOutput VSOut,
6668
float3 Normal = g_Normal.Load(int3(VSOut.f4PixelPos.xy, 0)).xyz;
6769
float4 BaseColor = g_BaseColor.Load(int3(Pos.xy, 0));
6870
float4 Material = g_MaterialData.Load(int3(Pos.xy, 0));
69-
71+
7072
float Roughness = saturate(Material.x);
7173
float Metallic = saturate(Material.y);
7274
SurfaceReflectanceInfo SrfInfo = GetSurfaceReflectanceMR(BaseColor.rgb, Metallic, Roughness);
@@ -79,9 +81,9 @@ void main(in FullScreenTriangleVSOutput VSOut,
7981
g_PreintegratedGGX_sampler,
8082
Normal,
8183
ViewDir);
82-
84+
8385
float3 SSR = GetSpecularIBL_GGX(SrfInfo, IBLInfo, SSRRadiance.rgb);
84-
86+
8587
Color.rgb += (SSR.rgb - SpecularIBL.rgb) * SSRRadiance.w * SSRScale;
8688
}
8789

@@ -93,7 +95,7 @@ void main(in FullScreenTriangleVSOutput VSOut,
9395
float Occlusion = lerp(1.0, g_SSAO.Load(int3(Pos.xy, 0)).x, SSAOScale);
9496
Color.rgb *= Occlusion;
9597
}
96-
98+
9799
#if TONE_MAPPING_MODE > TONE_MAPPING_MODE_NONE
98100
Color.rgb = ToneMap(Color.rgb, g_Attribs.ToneMapping, g_Attribs.AverageLogLum * exp2(-g_Frame.Camera.fExposure));
99101
#endif

Hydrogent/src/Tasks/HnPostProcessTask.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ static GraphicsPipelineStateCreateInfoX& CreateShaders(RenderDeviceWithCache_E&
154154
return PsoCI;
155155
}
156156

157-
void HnPostProcessTask::PostProcessingTechnique::PreparePSO(TEXTURE_FORMAT RTVFormat)
157+
void HnPostProcessTask::PostProcessingTechnique::PreparePSO(TEXTURE_FORMAT RTVFormat, HN_VIEW_MODE _ViewMode)
158158
{
159159
bool IsDirty = PSO && PSO->GetGraphicsPipelineDesc().RTVFormats[0] != RTVFormat;
160160

@@ -185,6 +185,17 @@ void HnPostProcessTask::PostProcessingTechnique::PreparePSO(TEXTURE_FORMAT RTVFo
185185
}
186186
}
187187

188+
{
189+
if (_ViewMode != HN_VIEW_MODE_SCENE_DEPTH)
190+
_ViewMode = HN_VIEW_MODE_SHADED;
191+
192+
if (ViewMode != _ViewMode)
193+
{
194+
ViewMode = _ViewMode;
195+
IsDirty = true;
196+
}
197+
}
198+
188199
if (IsDirty)
189200
PSO.Release();
190201

@@ -202,7 +213,8 @@ void HnPostProcessTask::PostProcessingTechnique::PreparePSO(TEXTURE_FORMAT RTVFo
202213
ShaderMacroHelper Macros;
203214
Macros.Add("CONVERT_OUTPUT_TO_SRGB", ConvertOutputToSRGB);
204215
Macros.Add("TONE_MAPPING_MODE", ToneMappingMode);
205-
Macros.Add("DEBUG_VIEW_SCENE_DEPTH", static_cast<int>(PBR_Renderer::DebugViewType::SceneDepth));
216+
Macros.Add("VIEW_MODE_SCENE_DEPTH", static_cast<int>(HN_VIEW_MODE_SCENE_DEPTH));
217+
Macros.Add("VIEW_MODE", static_cast<int>(ViewMode));
206218
if (GridFeatureFlags != CoordinateGridRenderer::FEATURE_FLAG_NONE)
207219
{
208220
Macros.Add("ENABLE_GRID", 1);
@@ -632,7 +644,7 @@ void HnPostProcessTask::Prepare(pxr::HdTaskContext* TaskCtx,
632644
// Initialize post-processing and copy frame techniques first as they
633645
// don't use async shader compilation.
634646
m_PostProcessTech.PreparePRS();
635-
m_PostProcessTech.PreparePSO((m_UseTAA ? m_FrameTargets->JitteredFinalColorRTV : m_FinalColorRTV)->GetDesc().Format);
647+
m_PostProcessTech.PreparePSO((m_UseTAA ? m_FrameTargets->JitteredFinalColorRTV : m_FinalColorRTV)->GetDesc().Format, ViewMode);
636648

637649
m_CopyFrameTech.PreparePRS();
638650
m_CopyFrameTech.PreparePSO(m_FinalColorRTV->GetDesc().Format);

0 commit comments

Comments
 (0)