[Suggestion/Bugfix] Orthographic projection Oculus Rift canvas rendering

Hi,

We ran into an issue with the Console/stats UI having a strange offset when we adjust the world to meter scale to a larger value (3600 for example).

This is what it looks like it’s when adjusted to that value:

Adjusting the GetOrthoProjection function in FOculusRiftHMD (OculusRiftHMD.cpp:1195) to the following, makes the values readable and sharp again when looking through the Oculus.

void FOculusRiftHMD::GetOrthoProjection(int32 RTWidth, int32 RTHeight, float /* OrthoDistance */, FMatrix OrthoProjection[2]) const
{
	const auto frame = GetFrame();
	check(frame);

	const FSettings* FrameSettings = frame->GetSettings();

	const OVR::Vector2f orthoScale[2] = 
	{
		OVR::Vector2f(1.f) / OVR::Vector2f(FrameSettings->EyeRenderDesc[0].PixelsPerTanAngleAtCenter),
		OVR::Vector2f(1.f) / OVR::Vector2f(FrameSettings->EyeRenderDesc[1].PixelsPerTanAngleAtCenter)
	};

	OVR::Matrix4f SubProjection[2];
	SubProjection[0] = ovrMatrix4f_OrthoSubProjection(FrameSettings->PerspectiveProjection[0], orthoScale[0], 1.0f, FrameSettings->EyeRenderDesc[0].HmdToEyeViewOffset.x);
	SubProjection[1] = ovrMatrix4f_OrthoSubProjection(FrameSettings->PerspectiveProjection[1], orthoScale[1], 1.0f, FrameSettings->EyeRenderDesc[1].HmdToEyeViewOffset.x);

	OrthoProjection[0] = FTranslationMatrix(FVector(SubProjection[0].M[0][3] * RTWidth * .25, 0 , 0));
	//Right eye gets translated to right half of screen
	OrthoProjection[1] = FTranslationMatrix(FVector(SubProjection[1].M[0][3] * RTWidth * .25 + RTWidth * .5, 0 , 0));
}

This is what it looks like afterwards:

However I have some questions regarding this change. I removed the usage of the OrthoDistance argument. Why is distance involved in an orthographic projection? Orthographic projections usually don’t have a variable distance as far as I know. Also, why is this scaled with the world to meter scale?

I have also removed the texture padding per eye. It would be nice to have more information on why texture padding is involved with the projection calculation.

Thanks in advance!

I noticed this behavior as well and the suggested solution seems to work pretty well.

@EpicGames, can acknowledge the issue and add it to the bugtracker?
Or should I make a pull request although I agree that I’m not sure if this is the way you want to have this issue addressed?

Hello sparkie,

I was able to reproduce this issue on our end. I have written up a report ( UE-24880) and I have submitted it to the developers for further consideration. I will provide updates with any pertinent information as it becomes available. Thank you for your time and information.

Make it a great day

Still an issue, 4.27.1
Print String also offset, I use 1200 as my W2M scale.