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.
// 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 |
Gets or sets whether submitting the depth buffer to the XR compositor is enabled.
By default the value is false
and 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 support by the underlying stack. Inspect the debug output to see if depth submission is in use.
Submitting the depth buffer may improve reprojections that may be performed by the XR compositor. This could happen for example when the system cannot maintain the target frame rate, and thus has to resort to predicting frame contents, in order to improve and stabilize the user's perception of the scene and reduce possibly nauseating effects. However, the application and Qt has no control over the usage of the data. It could also happen that submitting depth data has no practical effects and is simply 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/renderbuffer created and managed by Qt. This has certain lower-level consequences that can have a performance impact:
When multisample antialiasing (MSAA) is used, enabling depth submission implies rendering into a multisample depth texture and resolving the samples into the XR runtime provided non-multisample depth texture. Without depth submission, the resolve step would not be necessary at all. In addition, some 3D APIs have no support at all for resolving multisample depth-stencil data. (see the QRhi::ResolveDepthStencil flag for details) Attempts to enable depth submission in combination with MSAA will be gracefully ignored if this is the case.
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 normally indicated by Qt as not necessary, which can have positive effects for performance on tiled GPU architectures in particular. With depth submission this is not done, because depth data has to then be written out always from Qt's perspective.
Note: It is 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 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, or there is no control over, fixed foveated rendering. For example, VisionOS-based devices perform dynamic, eye-tracked foveation, and thus the value of this property is ignored in practice. Whereas other devices, such as the Meta Quest 3, only have support for fixed foveation, in which case this property becomes 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.
The default value is false
. Changing the value to true
has an effect only when multiViewRenderingSupported is true
. See Multiview Rendering for details.
This property can also be used to query whether multiview rendering is really in use at run time. When not supported, the value will flip back to false
.
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 then may cause visual effects that are undesirable, for example the scene may disappear and reappear.
Note: Enabling multiview rendering is recommended, in general. It can improve performance, reduce CPU and GPU load, as well as reduce power consumption. It defaults to disabled in order 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 afterwards.
Certain Qt Quick and Quick 3D features that involve application-provided shader code, in particular custom 2D and 3D materials and postprocessing effects, require awareness from the developers in order to make the application-provided shader assets multiview-compatible. See Multiview Rendering for details.
See also multiViewRenderingSupported.
multiViewRenderingSupported : bool |
This read-only property reports the availability of Multiview Rendering.
See also multiViewRenderingEnabled.
passthroughEnabled : bool |
Holds whether passthrough is enabled for the XR view.
passthroughSupported : bool |
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 rendering statistics for the XR view.
runtimeInfo : QQuick3DXrRuntimeInfo |
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 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.
This can, for instance, be called with 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. 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.