Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Depth Occlusion affected by Near Clip Plane value:: UE5.3 - Plugin v65 & UE5.4 - Plugin v68 & v71 #6

Open
Junnn424 opened this issue Nov 23, 2024 · 1 comment

Comments

@Junnn424
Copy link

Junnn424 commented Nov 23, 2024

Hi all,

We're developing a MR shooting game, and we noticed this interesting relationship between Near Clip Plane setting and Depth Occlusion when we're tweaking the Clip Plane distance so we can hold the gun closer to user's face.
We fond that when the Near Clip Plane is set to 10.0 (Unreal default), it behave correctly; once we start to increase the value, it starts to prioritise virtual objects, and when decrease the value it seems to also bring the camera depth distance down and the virtual object starts to be occluded earlier.
The same behavior can be reproduced in Occlusion Sample:

com.oculus.vrshell-20241122-220547-0.mp4

image

Not a huge issue but would be nice if there's a way to adjust clip plane distance and not mess up Depth occlusion!
We tested in UE53 and UE54, using MetaXR plugin version 65/ 68 / 71 and they all appear to have the same behaviro.

@MartinSherburn
Copy link
Contributor

Hi @Junnn424, thanks for reporting the issue. The code which calculates the matrices needed for occlusions can be found in OculusXRHMD.cpp:

	bool FOculusXRHMD::ComputeEnvironmentDepthParameters_RenderThread(FVector2f& DepthFactors, FMatrix44f ScreenToDepth[ovrpEye_Count], FMatrix44f DepthViewProj[ovrpEye_Count], int& SwapchainIndex)
	{
		float ScreenNearZ = GNearClippingPlane / Frame_RenderThread->WorldToMetersScale;

As you can see above the GNearClippingPlane variable controls the near clipping plane. I'm not sure if r.SetNearClipPlane also updates this variable or not. But if it doesn't then that could be the issue. As a work-around you could try hard-coding the near clip value you want in here to see if it resolves the problem for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants