Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qtquick3d-lod.qdoc
Go to the documentation of this file.
1
// Copyright (C) 2023 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4
/*!
5
\page qtquick3d-lod.html
6
\title Qt Quick 3D Level of Detail
7
\brief An overview of the usages of Level of Detail in Qt Quick 3D.
8
9
\section1 Level of Detail (LoD)
10
11
Level of Detail (LoD) refers to the technique of using alternative versions of a 3D
12
model at different distances from the camera. The goal of doing this is to optimize
13
resource usage by using simpler versions of the model when it is far away or a small
14
share of the screen, while using more detailed versions when it is closer or larger
15
portion of screen space. This approach allows for efficient use of GPU resources
16
while maintaining visual fidelity.
17
18
Qt Quick 3D provides both an automatic as well as an explicit level of detail system.
19
The automatic system is based on using a single mesh with multiple levels of detail
20
stored in the mesh file. The explicit system is based on using a LodManager component
21
to specify the different levels of detail as child models.
22
23
\section1 Automatic Level of Detail
24
25
The primary way to use the the automatic level of detail support is by importing
26
content with the \l {Balsam Asset Import Tool}. By using the flag
27
\c {--generateMeshLevelsOfDetail} when importing assets, the tool will generate
28
levels of detail for each mesh when possible. This is done by trying to simplify the
29
geometry of the original mesh, while still maintaining the overall features. What
30
results is additional geometry as well as new index values for each additional
31
level of detail, as well as a distance factor used to determine which
32
mesh to use for a given render size. This distance factor is related to the distance
33
of the object being rendered to the camera, but the most important thing is having a
34
good ratio of geometry per pixel. This data is written to the .mesh file and will
35
be used automatically when used by a Model.
36
37
\image lod_balsamui.png
38
39
A tradeoff to the automatic system, and the reason why it is not enabled by default
40
is that it is possible that when the geometry is reduced, visual artifacts can also
41
be introduced. The geometry simplification algorithm used attempts to preserve
42
the features of the model, but in some cases it may be necessary to recalculate
43
the normals of the mesh to maintain the intended visual appearance. This can be
44
done by using the \c {--recalculateLodNormals} flag when importing the asset.
45
The normal recalculation process can be further tuned by passing euler angle
46
values to the arguments \c {--recalculateLodNormalsMergeAngle} and
47
\c {--recalculateLodNormalsSplitAngle} to control the angle at which normals
48
are merged or split respectively.
49
50
The main advantage of the automatic system is that it is easy to use once the
51
asset has been imported with the appropriate settings. No additional code is
52
required to use the automatic system and any Models that reference the generated
53
mesh files containing levels of detail geometry will automatically choose the
54
appropriate geometry based on how many pixels the model takes up on the screen.
55
56
It is possible to tweak automatic level of detail selection behavior
57
either at the \l {Camera::levelOfDetailBias}{global level} or at the
58
\l {Model::levelOfDetailBias}{per-model level} by using the \c levelOfDetailBias
59
property of either \l Camera or \l Model. The default level of 1.0 of each
60
of these bias properties means to trust the value calculated by the automatic
61
system. This value is a bias to the ideal value such that a value smaller
62
than 1.0 will require an even smaller rendered size before switching to a
63
lesser level of detail. Values above 1.0 will lead to lower levels of detail
64
being used sooner. A value of 0.0 will disable the usage of levels of detail
65
completely and always use the original mesh geometry.
66
67
The automatic system is not as flexible as the explicit system. For example
68
the automatic system always uses the same material for all levels of detail,
69
which may not always be desirable. Another potential downside is that there
70
is not transition between the different levels of detail which ideally
71
should not be necessary with automatic level of detail, but may be desireable
72
for certain use cases.
73
74
\section1 Explicit Level of Detail
75
76
The Explicit level of detail system is more flexible than the automatic
77
system, but requires more work to use. The explicit system is based on using
78
a LodManager component to specify the different levels of detail as child
79
\l Model components. Any children of the LodManager that are instances of Model
80
will be considered a level of detail. This is quite powerful because each level of
81
detail can be a completely custom model, with it's own geometries and materials.
82
83
The LodManager component also has a \l {LodManager::distances}{distances} property which is used to
84
determine which child \l Model to use. The LodManager node will transition to the
85
next child \l Model as the camera distance approach each distance boundary.
86
The \l {LodManager::fadeDistance}{fadeDistance} property can be used to set at which
87
distance the cross fade transition begins and ends around the distances boundaries.
88
89
This is an \l {Qt Quick 3D - Level of Detail Helper Example}{example} of how to use
90
the explicit level of detail system:
91
92
\image lodhelper-example.jpg
93
94
In the referenced example the \l LodManager is used to explicitly specify different mesh
95
files for each level of detail of the marble bust.
96
97
\snippet lodhelper/main.qml example
98
99
For this code this is a diagram of what is being defined which points out how the distances
100
list is used to define where the boundaries between the different levels of detail as well
101
as the fadeDistance property which is used to define the cross fade transition.
102
103
\image lodmanager_diagram.png
104
105
*/
qtquick3d
src
quick3d
doc
src
qtquick3d-lod.qdoc
Generated on
for Qt by
1.14.0