Setting bConstrainAspectRatio=true in CameraComponent causes DrawDebug rendering to display in the incorrect position. This can be avoided by setting DrawDebug's Depth Priority to Foreground.
Related to [Link Removed] Closed .
Workaround:
static FDebugPrimitivesDrawingContext InitializeDebugPrimitiveTextures(
FRDGBuilder& GraphBuilder,
const FViewInfo& View,
const FCompositePrimitiveInputs& Inputs,
const FScreenPassRenderTarget& Output)
{
// Setup view
// Use View.ViewRect instead of Output.ViewRect to match the projection matrix.
// When bConstrainAspectRatio is enabled, View.ViewRect corresponds to ConstrainedViewRect,
// which is what the projection matrix was calculated based on.
// Output.ViewRect may use UnscaledViewRect, which would cause a mismatch.
// Before:
// const FIntRect ViewRect = Output.ViewRect;
// After:
const FIntRect ViewRect = View.ViewRect;
static bool DrawDebugPDE(
FRDGBuilder& GraphBuilder,
FDebugPrimitivesDrawingContext& Context,
const FScreenPassTextureViewport& OutputViewport)
{
if (!Context.DebugView->DebugSimpleElementCollector.HasAnyPrimitives())
{
return false;
}
// Before:
// None
// After:
const FIntRect DebugViewRect = Context.DebugView->ViewRect;
// Draw SDPG_World elements, depth tested with SceneColor
if (Context.DebugView->DebugSimpleElementCollector.HasPrimitives(SDPG_World))
{
FDebugPrimitivesPassParameters* PassParameters = GraphBuilder.AllocParameters<FDebugPrimitivesPassParameters>();
PassParameters->View = Context.DebugView->GetShaderParameters();
PassParameters->RenderTargets[0] = FRenderTargetBinding(Context.SceneColor.Texture, ERenderTargetLoadAction::ELoad);
PassParameters->RenderTargets.DepthStencil = FDepthStencilBinding(Context.UpscaledSceneDepth, ERenderTargetLoadAction::ELoad, ERenderTargetLoadAction::ELoad, FExclusiveDepthStencil::DepthWrite_StencilWrite);
GraphBuilder.AddPass(
RDG_EVENT_NAME("DrawDebugPrimitives(SDPG_World)"),
PassParameters,
ERDGPassFlags::Raster,
// Before:
// [PassParameters, DebugView=Context.DebugView, OutputViewport](FRDGAsyncTask, FRHICommandList& RHICmdList)
// After:
[PassParameters, DebugView=Context.DebugView, DebugViewRect](FRDGAsyncTask, FRHICommandList& RHICmdList)
{
// Before:
// RHICmdList.SetViewport(OutputViewport.Rect.Min.X, OutputViewport.Rect.Min.Y, 0.0f, OutputViewport.Rect.Max.X, OutputViewport.Rect.Max.Y, 1.0f);
// After:
RHICmdList.SetViewport(DebugViewRect.Min.X, DebugViewRect.Min.Y, 0.0f, DebugViewRect.Max.X, DebugViewRect.Max.Y, 1.0f);
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-361551 in the post.
| 1 |
| Component | UE - Gameplay |
|---|---|
| Affects Versions | 5.7 |
| Created | Jan 21, 2026 |
|---|---|
| Updated | Jan 27, 2026 |