@@ -91,7 +91,16 @@ We introduce a few new variables to our script as well:
9191Our updated ready function
9292--------------------------
9393
94- The ready function mostly remains the same but we hook up a number of signals that will be emitted by the :ref: `XRInterface <class_xrinterface >`.
94+ We add a few things to the ready function.
95+
96+ If we're using the mobile or forward+ renderer we set the viewports ``vrs_mode `` to ``VRS_XR ``.
97+ On platforms that support this, this will enable foveated rendering.
98+
99+ If we're using the compatibility renderer, we check if the OpenXR foveated rendering settings
100+ are configured and if not, we output a warning.
101+ See :ref: `OpenXR Settings <doc_openxr_settings >` for further details.
102+
103+ We hook up a number of signals that will be emitted by the :ref: `XRInterface <class_xrinterface >`.
95104We'll provide more detail about these signals as we implement them.
96105
97106We also quit our application if we couldn't successfully initialise OpenXR.
@@ -119,12 +128,18 @@ it is nicer to exit on failure than to hang the system.
119128 # Make sure v-sync is off, v-sync is handled by OpenXR
120129 DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_DISABLED)
121130
131+ # Enable VRS
132+ if RenderingServer.get_rendering_device():
133+ vp.vrs_mode = Viewport.VRS_XR
134+ elif int(ProjectSettings.get_setting("xr/openxr/foveation_level")) == 0:
135+ push_warning("OpenXR: Recommend setting Foveation level to High in Project Settings")
136+
122137 # Connect the OpenXR events
123- xr_interface.connect("session_begun", _on_openxr_session_begun)
124- xr_interface.connect("session_visible", _on_openxr_visible_state)
125- xr_interface.connect("session_focussed", _on_openxr_focused_state)
126- xr_interface.connect("session_stopping", _on_openxr_stopping)
127- xr_interface.connect("pose_recentered", _on_openxr_pose_recentered)
138+ xr_interface.session_begun. connect(_on_openxr_session_begun)
139+ xr_interface.session_visible. connect(_on_openxr_visible_state)
140+ xr_interface.session_focussed. connect(_on_openxr_focused_state)
141+ xr_interface.session_stopping. connect(_on_openxr_stopping)
142+ xr_interface.pose_recentered. connect(_on_openxr_pose_recentered)
128143 else:
129144 # We couldn't start OpenXR.
130145 print("OpenXR not instantiated!")
@@ -153,6 +168,12 @@ it is nicer to exit on failure than to hang the system.
153168 // Make sure v-sync is off, v-sync is handled by OpenXR
154169 DisplayServer.WindowSetVsyncMode(DisplayServer.VSyncMode.Disabled);
155170
171+ // Enable VRS
172+ if (RenderingServer.GetRenderingDevice() != null)
173+ vp.VrsMode = Viewport.VrsModeEnum.XR;
174+ else if ((int)ProjectSettings.GetSetting("xr/openxr/foveation_level") == 0)
175+ GD.PushWarning("OpenXR: Recommend setting Foveation level to High in Project Settings");
176+
156177 // Connect the OpenXR events
157178 _xrInterface.SessionBegun += OnOpenXRSessionBegun;
158179 _xrInterface.SessionVisible += OnOpenXRVisibleState;
0 commit comments