Skip to content

Commit 329a9ac

Browse files
authored
Merge pull request #174886 from ChristopherManthei/UpdateReprojection
Update Reprojection chapter with new OpenXR support.
2 parents 24d0337 + f766dfa commit 329a9ac

File tree

1 file changed

+48
-3
lines changed

1 file changed

+48
-3
lines changed

articles/remote-rendering/overview/features/late-stage-reprojection.md

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,55 @@ In the Unity editor, go to *:::no-loc text="File > Build Settings":::*. Select *
2525

2626
If it is, your app will use Depth LSR, otherwise it will use Planar LSR.
2727

28+
When using OpenXR, the depth buffer should always be submitted. The setting can be found in *:::no-loc text="XR Plug-in Management > OpenXR":::*. The reprojection mode can then be changed via an extension in the OpenXR plugin:
29+
30+
```cs
31+
using Microsoft.MixedReality.OpenXR;
32+
33+
public class OverrideReprojection : MonoBehaviour
34+
{
35+
void OnEnable()
36+
{
37+
RenderPipelineManager.endCameraRendering += RenderPipelineManager_endCameraRendering;
38+
}
39+
void OnDisable()
40+
{
41+
RenderPipelineManager.endCameraRendering -= RenderPipelineManager_endCameraRendering;
42+
}
43+
44+
// When using the Universal Render Pipeline, OnPostRender has to be called manually.
45+
private void RenderPipelineManager_endCameraRendering(ScriptableRenderContext context, Camera camera)
46+
{
47+
OnPostRender();
48+
}
49+
50+
// Called directly when using Unity's legacy renderer.
51+
private void OnPostRender()
52+
{
53+
ReprojectionSettings reprojectionSettings = default;
54+
reprojectionSettings.ReprojectionMode = ReprojectionMode.PlanarManual; // Or your favorite reprojection mode.
55+
56+
// In case of PlanarManual you also need to provide a focus point here.
57+
reprojectionSettings.ReprojectionPlaneOverridePosition = ...;
58+
reprojectionSettings.ReprojectionPlaneOverrideNormal = ...;
59+
reprojectionSettings.ReprojectionPlaneOverrideVelocity = ...;
60+
61+
foreach (ViewConfiguration viewConfiguration in ViewConfiguration.EnabledViewConfigurations)
62+
{
63+
if (viewConfiguration.IsActive && viewConfiguration.SupportedReprojectionModes.Contains(reprojectionSettings.ReprojectionMode))
64+
{
65+
viewConfiguration.SetReprojectionSettings(reprojectionSettings);
66+
}
67+
}
68+
}
69+
}
70+
```
71+
2872
## Depth LSR
2973

3074
For Depth LSR to work, the client application must supply a valid depth buffer that contains all the relevant geometry to consider during LSR.
3175

32-
Depth LSR attempts to stabilize the video frame based on the contents of the supplied depth buffer. As a consequence, content that hasn't been rendered to it, such as transparent objects, can't be adjusted by LSR and may show instability and reprojection artifacts.
76+
Depth LSR attempts to stabilize the video frame based on the contents of the supplied depth buffer. As a consequence, content that hasn't been rendered to it, such as transparent objects, can't be adjusted by LSR and may show instability and reprojection artifacts.
3377

3478
To mitigate reprojection instability for transparent objects, you can force depth buffer writing. See the material flag *TransparencyWritesDepth* for the [Color](color-materials.md) and [PBR](pbr-materials.md) materials. Note however, that visual quality of transparent/opaque object interaction may suffer when enabling this flag.
3579

@@ -41,9 +85,10 @@ Planar LSR reprojects those objects best that lie close to the supplied plane. T
4185

4286
### Configure Planar LSR in Unity
4387

44-
The plane parameters are derived from a so called *focus point*, which you have to provide every frame through `UnityEngine.XR.WSA.HolographicSettings.SetFocusPointForFrame`. See the [Unity Focus Point API](/windows/mixed-reality/focus-point-in-unity) for details. If you don't set a focus point, a fallback will be chosen for you. However that automatic fallback often leads to suboptimal results.
88+
The plane parameters are derived from a so called *focus point*. When using WMR, the focus point has to be set every frame through `UnityEngine.XR.WSA.HolographicSettings.SetFocusPointForFrame`. See the [Unity Focus Point API](/windows/mixed-reality/focus-point-in-unity) for details. For OpenXR, the focus point needs to be set via the `ReprojectionSettings` shown in the previous section.
89+
If you don't set a focus point, a fallback will be chosen for you. However that automatic fallback often leads to suboptimal results.
4590

46-
You can calculate the focus point yourself, though it might make sense to base it on the one calculated by the Remote Rendering host. Call `RemoteManagerUnity.CurrentSession.GraphicsBinding.GetRemoteFocusPoint` to obtain that. You are asked to provide a coordinate frame in which to express the focus point. In most cases, you'll just want to provide the result from `UnityEngine.XR.WSA.WorldManager.GetNativeISpatialCoordinateSystemPtr` here.
91+
You can calculate the focus point yourself, though it might make sense to base it on the one calculated by the Remote Rendering host. Call `RemoteManagerUnity.CurrentSession.GraphicsBinding.GetRemoteFocusPoint` to obtain that.
4792

4893
Usually both the client and the host render content that the other side isn't aware of, such as UI elements on the client. Therefore, it might make sense to combine the remote focus point with a locally calculated one.
4994

0 commit comments

Comments
 (0)