Description
  • Display DrawDebugSphere at the DefaultPawn's position
  • Set bConstrainAspectRatio=true on the DefaultPawn's CameraComponent

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);
Steps to Reproduce
  1. Open the attached repro project
  2. Run PIE in the Selected Viewport
    Result:
    The debug sphere is displayed at a position offset from the actor's location
    Expected:
    The debug sphere is displayed at the actor's location

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-361551 in the post.

1
Login to Vote

Unresolved
ComponentUE - Gameplay
Affects Versions5.7
CreatedJan 21, 2026
UpdatedJan 27, 2026
View Jira Issue