aboutsummaryrefslogtreecommitdiffstats
path: root/doc/qtcreator/src/qtquick/qtdesignstudio-optimized-3d-scenes.qdoc
blob: 43379fdc355cdfb6d7bfa318a2d5bf6e64cb3244 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/****************************************************************************
**
** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Design Studio documentation.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
**
****************************************************************************/

/*!
    \page studio-optimized-3d-scenes.html
    \previouspage qtquick-optimizing-designs.html
    \if defined(qtdesignstudio)
    \nextpage studio-implementing-applications.html
    \else
    \nextpage qtquick-iso-icon-browser.html
    \endif

    \title Creating Optimized 3D Scenes

    In \QC, you can use various means to create a 3D scene. Your choice of
    strategy should always depend on the target platform of your scene.
    The way the content of your scene is authored can have dramatic effects on
    the runtime performance of your UI. The Optimal 3D Scene described
    below illustrates four different ways to create a scene. Also see guidelines
    for \l{Optimizing your 3D Scene}{optimizing the graphics performance of your 3D scene}
    and \l{Best Practices for 3D Scenes Based on Use Cases}.

    \section1 The Optimal 3D Scene Example

    \if defined(qtdesignstudio)
    The \l {Optimal 3D Scene}
    \else
    The Optimal 3D Scene
    \endif
    example features four versions of the same kitchen
    scene that have been created using different strategies: High, Low, Combined,
    and Vertex Color. The High Scene includes a significantly higher number of
    objects compared to the other versions of the scene. The Low, Combined and
    Vertex scenes include less objects since they have been optimized by, for
    example, combining geometry and baking materials into textures. The
    following image displays the components in each scene in \l Navigator to
    illustrate the structural differences between the scenes.

    \image studio-kitchen-navigators.png "Navigators for the four scenes in the Optimal 3D Scene."

    \section2 The High Scene

    \image studio-kitchen-high.png "The High Scene in the Optimal 3D Scene"

    The High scene (1) includes a total of 27 objects. The scene is otherwise
    similar to the Low scene, but has more details and animated components, such
    as cabinet doors that can be opened and a latch for the oven.

    \section2 The Low Scene

    \image studio-kitchen-low.png "The Low Scene in the Optimal 3D Scene"

    The Low scene (2) includes a total of 12 objects. Each model, for example
    cabinets, lamps, plates, and the sink, are separate meshes.

    \section2 The Combined Scene

    \image studio-kitchen-combined.png "The Combined Scene in the Optimal 3D Scene"

    The Combined scene (3) has all the meshes combined into a single object. All
    materials are baked into one single texture.

    \section2 The Vertex Color Scene

    \image studio-kitchen-vertex.png "The Vertex Color Scene in the Optimal 3D Scene"

    The Vertex Color scene (4) has all the meshes combined into a single object,
    and colors for the mesh are provided from .mesh file's vertex data, which
    includes one material and no textures.

    \section1 Optimizing Your 3D Scene

    To optimize the graphics performance of your 3D scene, you should first
    consider whether you need to animate the 3D objects, lights, camera, or
    other components in your scene. If not, simplify the scene structure by, for
    example, combining geometries and baking materials into textures. Ideally,
    pre-render your 3D image into a 2D image. You should not waste resources
    by rendering static 3D objects. You should also check if your scene has
    multiple instances of the same mesh. If so, import only one instance of the
    mesh, duplicate it in the scene, and use the same material for each
    duplicate.

    See also the following guidelines related to scene graph, asset complexity,
    CPU specific optimization, and model geometry.

    \section2 Scene Graph

    The scene graph is the hierarchy of nodes that describe the scene to be
    rendered.

    In \QC, the scene graph is represented by the tree-like view in
    \uicontrol Navigator. You can also view the hierarchy of nodes in the
    \l {Text Editor} view. By minimizing the size of the scene graph,
    you can minimize the effort needed when running the scene. In terms of
    optimization, you should avoid unnecessary groups and complex hierarchy when
    possible. Deep hierarchies with complex parenting increase the performance
    cost.

    \section2 Asset Complexity

    The performance of your UI or scene may sometimes be bottlenecked at render
    time. Avoid this by simplifying your assets.

    For 3D models, you should try to use the minimum number of triangles or
    vertices to achieve the desired result. Also note that smaller images
    require less memory and render faster.

    \section2 Optimizing CPU Performance

    Rendering objects requires plenty of processing work from the CPU.
    Processing each component consumes resources, so reducing the visible object
    count reduces the amount of work required from the CPU.

    To reduce the visible object count:
    \list
        \li Combine objects that are positioned closely and share a texture.
        \note Combining objects that do not share a texture does not increase
        the CPU performance while running the scene.
        \li Use fewer materials by combining separate textures into a single
            texture atlas (like in the Merged scene in the
            Kitchen Scene Example).
        \li Minimize the number of factors that cause objects to be rendered
            multiple times, for example reflections and shadows.
    \endlist

    \section2 Optimizing Model Geometry

    To optimize the geometry of a model:

    \list
        \li Minimize the number of triangles used in the model.
        \li Minimize the number of UV mapping seams and hard edges created with
        doubled-up vertices.
    \endlist

    \section1 Best Practices for 3D Scenes Based on Use Cases

    The following table summarizes best practices related to optimizing 3D
    scenes in the form of use cases.

    \table
    \header
        \li How to...
        \li Solution
    \row
        \li Get best performance from the 3D scene.
        \li If no animation is required, pre-render your 3D scene into a 2D
            image.

    \row
        \li Include animation for some of the objects in the scene
            (for example, to open doors).
        \li Merge all objects that are static, and export only one of
            each animated component (for example, each door type).

    \row
        \li Get best performance with animated camera.
        \li While using a 2D image is not an option in this case, you should
            combine all geometry and bake lighting and materials into a single
            material.

    \row
        \li Get best performance with animated light.
        \li While using a 2D image is not an option in this case, you should
            combine all geometry and bake all materials into a single
            material.

    \row
        \li Get best performance in a 3D scene where all meshes are
            separated.
        \li Use the same material for each instance of the same mesh.

    \row
        \li Disable rendering for one of the meshes during runtime.
        \li Keep that particular mesh separate but merge the rest of the
            components.

    \row
        \li Use baked textures with low memory.
        \li Bake mesh colors into vertex colors (see the Vertex Color Scene
            in the example project).
    \endtable
*/