Description

A licensee has reported that the ZoomFactor variable inside of the DrawPoint function is being calculated incorrectly. It currently is calculated using the lesser of the projection matrix's horizontal or vertical scale. Later in the function when the point is being drawn, horizontal values are used in either case. This causes points to grow in size when the viewport is taller than it is wide.

This is where the ZoomFactor is calculated
Engine\Source\Runtime\Renderer\Private\DynamicPrimitiveDrawing.inl:

bool bIsPerspective = (ViewInfo->ViewMatrices.GetProjectionMatrix().M[3][3] < 1.0f) ? true : false;
	if( !bIsPerspective )
	{
		const float ZoomFactor = FMath::Min<float>(View->ViewMatrices.GetProjectionMatrix().M[0][0], View->ViewMatrices.GetProjectionMatrix().M[1][1]);
		ScaledPointSize = ScaledPointSize / ZoomFactor;
	}

This is where the point is drawn:
Engine\Source\Runtime\Engine\Private\BatchedElements.cpp

// Generate vertices for the point such that the post-transform point size is constant.
 const uint32 ViewportMajorAxis = ViewportSizeX;//FMath::Max(ViewportSizeX, ViewportSizeY);
 const FVector WorldPointX = CameraX * Point.Size / ViewportMajorAxis * TransformedPosition.W;
 const FVector WorldPointY = CameraY * -Point.Size / ViewportMajorAxis * TransformedPosition.W;

The licensee proposes that this can be fixed by changing the following line:

 const float ZoomFactor = FMath::Min<float>(View->ViewMatrices.ProjMatrix.M[0][0], View->ViewMatrices.ProjMatrix.M[1][1]); 

to

 const float ZoomFactor = View->ViewMatrices.ProjMatrix.M[0][0]; 

Regression?: No
This was present in 4.13 as well

Steps to Reproduce

Code issue - N/A

Have Comments or More Details?

There's no existing public thread on this issue, so head over to AnswerHub just mention UE-42157 in the post.

0
Login to Vote

Unresolved
ComponentRendering
Affects Versions4.134.144.154.164.20
Target Fix5.0
CreatedFeb 20, 2017
ResolvedMay 27, 2021
UpdatedAug 2, 2021