XrView QML Type
Sets up the view for an Xr application. More...
Import Statement: | import QtQuick3D.Xr |
Since: | Qt 6.8 |
Inherits: | |
Status: | Technical Preview |
Properties
- depthSubmissionEnabled : bool
- environment : SceneEnvironment
- fixedFoveation : enumeration
- isQuitOnSessionEndEnabled : bool
- multiViewRenderingEnabled : bool
- multiViewRenderingSupported : bool
- passthroughEnabled : bool
- passthroughSupported : bool
- referenceSpace : enumeration
- renderStats : RenderStats
- runtimeInfo : QQuick3DXrRuntimeInfo
- xrOrigin : XrOrigin
Signals
- initializeFailed(const QString &errorString)
- sessionEnded()
Methods
- vector3d processTouch(vector3d position, int pointId)
- pickResult rayPick(vector3d origin, vector3d direction)
- List<pickResult> rayPickAll(vector3d origin, vector3d direction)
- setTouchpoint(Item target, point position, int pointId, bool pressed)
- object touchpointState(int pointId)
Detailed Description
An XrView sets up the view for an XR application. The following snippet is from the Qt Quick 3D Xr Simple Example and shows how to use the type.
// Copyright (C) 2023 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause import QtQuick import QtQuick.Layouts import QtQuick3D.Helpers //! [XrView] import QtQuick3D import QtQuick3D.Xr XrView { id: xrView XrErrorDialog { id: err } onInitializeFailed: (errorString) => err.run("XRView", errorString) referenceSpace: XrView.ReferenceSpaceLocalFloor //! [XrView] environment: SceneEnvironment { clearColor: "black" backgroundMode: SceneEnvironment.Color }
Property Documentation
depthSubmissionEnabled : bool |
Controls whether submitting the depth buffer to the XR compositor is enabled.
By default, the depth buffer used by the 3D scene in the XrView is not exposed to the XR compositor. However, in some platforms, depth submission is implicit and cannot be disabled or controlled by the application. An example of this is VisionOS. Changing this property has no effect on those platforms. Elsewhere, with OpenXR in particular, support depends on the OpenXR implementation used at run time.
It is always safe to set depthSubmissionEnabled to true
. It will just have no effect when not supported by the underlying stack. To be sure, you can inspect the debug output to see if depth submission is in use. Submitting the depth buffer may improve reprojections that the XR compositor may perform. Reprojection could happen, for example, when the system cannot maintain the target frame rate and thus has to resort to predicting frame contents to improve and stabilize the user's perception of the scene and reduce possible motion sickness. However, the application and Qt have no control over data usage. It could also happen that submitting depth data has no practical effects and is ignored by the underlying XR runtime and compositor.
In practice, submitting the depth buffer implies rendering into a depth texture provided by the XR runtime instead of the intermediate texture/render buffer created and managed by Qt. Rendering into a depth texture has certain lower-level consequences that can have a performance impact:
When using multisample antialiasing (MSAA), enabling depth submission implies rendering into a multisample depth texture and resolving the samples into the non-multisample depth texture provided by the XR runtime. Without depth submission, the resolve step would not be necessary. In addition, some 3D APIs do not support resolving multisample depth-stencil data (see the QRhi::ResolveDepthStencil flag for details). Without this support, attempts to enable depth submission in combination with MSAA are gracefully ignored.
Even when MSAA is not used, enabling depth submission triggers writing out depth data with 3D APIs that have control over this. The store operation for depth/stencil data is typically indicated by Qt as unnecessary, which can have positive performance impacts on tiled GPU architectures. This is not done with depth submission because depth data must always be written out from Qt's perspective.
Note: We recommended that developers test their applications with depth submission enabled, evaluate the advantages and disadvantages, and make a conscious choice based on their testing if they wish to enable it or not.
environment : SceneEnvironment |
Holds
Holds the SceneEnvironment for the XR view.
fixedFoveation : enumeration |
Controls the level of fixed foveated rendering for the XrView.
Foveated rendering reduces GPU load by reducing image quality (resolution) in areas where the difference is less perceptible to the eye. With fixed foveated rendering, the areas with reduced visual fidelity are fixed and do not change. On some platforms, there is no concept of fixed foveated rendering or control over it. For example, VisionOS-based devices perform dynamic, eye-tracked foveation; thus, the value of this property is ignored in practice. Other devices, such as the Meta Quest 3, only support fixed foveation, which makes this property relevant.
The value can be one of:
Constant | Description |
---|---|
XrView.NoFoveation | 0, no foveation. |
XrView.LowFoveation | 1, low foveation. |
XrView.MediumFoveation | 2, medium foveation. |
XrView.HighFoveation | 3, high foveation. |
Where supported, the default is HighFoveation
. Therefore, changing this value in applications should be rarely needed in practice.
isQuitOnSessionEndEnabled : bool |
Holds whether the application should quit when the XR session ends.
multiViewRenderingEnabled : bool |
Gets or sets whether Multiview Rendering is enabled for the XR view.
Changing the value to true
has an effect only when multiViewRenderingSupported is true
.
This property tells you if multiview rendering is actually in use at run time. When not supported, the value will flip back to false
.
Enabling multiview rendering is recommended. It can improve performance and reduce CPU and GPU power usage. It defaults to disabled to ensure maximum compatibility. Developers are encouraged to verify that their application renders as expected with multiViewRenderingEnabled set to true
and then leave it set afterward.
Certain Qt Quick and Quick 3D features that involve shader code that is provided by the application may need this code to be modified to be multiview compatible. Examples of these are custom 2D and 3D materials and postprocessing effects.
Note: Changing the value dynamically while the scene is already up and running is possible but not recommended because enabling or disabling multiview mode involves releasing and recreating certain graphics and XR resources. Depending on the platform and headset, this may cause undesirable visual effects. For example, the scene may disappear and reappear.
See also multiViewRenderingSupported and Multiview Rendering.
multiViewRenderingSupported : bool |
This read-only property reports the availability of Multiview Rendering.
See also multiViewRenderingEnabled.
passthroughEnabled : bool |
Holds
Holds whether passthrough is enabled for the XR view.
passthroughSupported : bool |
Indicates
Indicates whether passthrough is supported for the XR view.
referenceSpace : enumeration |
Gets or sets the reference space for the XR view.
It can be one of:
Constant | Value |
---|---|
XrView.ReferenceSpaceUnknown | |
XrView.ReferenceSpaceLocal | |
XrView.ReferenceSpaceStage | |
XrView.ReferenceSpaceLocalFloor |
renderStats : RenderStats |
Holds
Holds rendering statistics for the XR view.
runtimeInfo : QQuick3DXrRuntimeInfo |
Provides
Provides information about the XR runtime for the XR view.
xrOrigin : XrOrigin |
Holds the active XR origin.
The XR origin is the point in the scene that is considered the origin of the XR coordinate system. The XR origin is used to position tracked objects like the camera and controllers in the scene. An application can have multiple XrOrigins but only one can be active at a time.
Note: This property must be set for the scene to be rendered in XR.
See also XrOrigin.
Signal Documentation
initializeFailed(const QString &errorString) |
Emitted when initialization fails, and there is a new errorString describing the failure.
Note: The corresponding handler is onInitializeFailed
.
sessionEnded() |
Emitted when the session ends.
Note: The corresponding handler is onSessionEnded
.
Method Documentation
This method will search for an XrItem near position and send a virtual touch event with touch point ID pointId if position maps to a point on the surface.
The return value is the offset between position and the touched point on the surface. This can be used to prevent a hand model from passing through an XrItem.
See also XrHandModel.
pickResult rayPick(vector3d origin, vector3d direction) |
This method will shoot a ray into the scene starting at origin and in direction and return information about the nearest intersection with an object in the scene.
For example, pass the position and forward vector of any object in a scene to see what object is in front of an item. This makes it possible to do picking from any point in the scene.
List<pickResult> rayPickAll(vector3d origin, vector3d direction) |
This method will shoot a ray into the scene starting at origin and in direction and return a list of information about the nearest intersections with objects in the scene. The list is presorted by distance from the origin along the direction vector with the nearest intersections appearing first and the furthest appearing last.
This can, for instance, be called with the position and forward vector of any object in a scene to see what objects are in front of an item. This makes it possible to do picking from any point in the scene.
Sends a synthetic touch event to target, moving the touch point with ID pointId to position, with pressed determining if the point is pressed. Also sends the appropriate touch release event if pointId was previously active on a different item.
object touchpointState(int pointId) |
This method returns the state of the touch point with ID pointId. The state is represented by a map from property names to values:
Key | Type | Description |
---|---|---|
grabbed | bool | Is the point grabbed by an item? If false , all other values are undefined . |
target | XrItem | The item that is grabbing the touch point. |
pressed | bool | Is the touch point pressed? |
cursorPos | point | The 2D position of the touch point within target |
touchDistance | real | The distance from the plane to the touch point. It will be 0 if pressed is true . |
© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.