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-tool-balsam.qdoc
Go to the documentation of this file.
1
// Copyright (C) 2019 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4
/*!
5
\page qtquick3d-tool-balsam.html
6
\title Balsam Asset Import Tool
7
\brief Tool for importing assets for use with Qt Quick 3D
8
9
The Balsam tool is an application that is part of Qt Quick 3D's
10
asset conditioning pipeline. The purpose is to take assets created in digital
11
content creation tools like
12
\l{https://www.autodesk.com/products/maya/overview}{Maya},
13
\l{https://www.autodesk.com/products/3ds-max/overview}{3ds Max}, or
14
\l{https://www.blender.org/}{Blender} and convert them into an efficient runtime
15
format for use with Qt Quick 3D. It is not possible, nor does it make sense to
16
reference the interchange formats directly in applications because a large amount
17
of resources are needed to parse and condition the content of the asset before it
18
is usable for realtime rendering. Instead the interchange formats can be
19
converted via the Balsam tool into QML Components and resources like geometry and
20
textures.
21
22
\section1 Balsam Command Line Tool
23
24
To run Balsam through the command line, call the \c balsam executable like
25
this:
26
27
\code
28
balsam [options] sourceFilename
29
\endcode
30
31
To convert a 3D asset contained in the file \c testModel.fbx with \c balsam
32
the following command would be used:
33
34
\code
35
balsam testModel.fbx
36
\endcode
37
38
This would generate the following files:
39
\list
40
\li \c meshes/testModel.mesh
41
\li \c TestModel.qml
42
\endlist
43
44
Which can then be used in a Qt Quick 3D project by using that QML Component:
45
\code
46
import QtQuick3D
47
48
TestModel {
49
id: modelInstance
50
}
51
\endcode
52
53
\note The generated mesh filename depends on the mesh name(s) defined in the
54
source file (in this example, the FBX file) and may differ from
55
\c{testModel.mesh}.
56
57
\section1 Balsam UI
58
59
There is also a GUI frontend for Balsam called \c balsamui that is shipped
60
alongside the \c balsam executable. In \c balsamui you can select your input
61
files and output directory and the command-line options of the \c balsam
62
executable are mapped to interactive elements:
63
64
\image balsamui.webp "A screenshot of the Balsam UI application."
65
66
\section1 Supported 3D Asset Types
67
68
\list
69
\li Wavefront (.obj)
70
\li COLLADA (.dae)
71
\li FBX (.fbx)
72
\li STL (.stl)
73
\li PLY (.ply)
74
\li GLTF2 (.gltf, .glb)
75
\endlist
76
77
Some of the formats supported also allow for either embedding or referencing of
78
texture assets. These assets are also supported, provided Qt also has support
79
for them.
80
81
\section2 glTF 2.0 Import
82
83
glTF 2.0 assets (.gltf and .glb) are imported by a native importer built
84
directly on Qt, instead of going through the Assimp library like the other
85
formats. The native importer supports the core glTF 2.0 feature set,
86
including skinning, morph targets, animations with LINEAR, STEP, and
87
CUBICSPLINE interpolation (the latter baked at a rate controlled by the
88
\c{--animationSampleRate} option), sparse accessors, and quantized meshes,
89
as well as the following extensions:
90
91
\list
92
\li KHR_materials_pbrSpecularGlossiness
93
\li KHR_materials_unlit
94
\li KHR_materials_clearcoat
95
\li KHR_materials_transmission
96
\li KHR_materials_volume
97
\li KHR_materials_ior
98
\li KHR_materials_emissive_strength
99
\li KHR_materials_specular
100
\li KHR_materials_sheen
101
\li KHR_materials_anisotropy
102
\li KHR_materials_iridescence
103
\li KHR_materials_dispersion
104
\li KHR_texture_transform
105
\li KHR_lights_punctual
106
\li KHR_mesh_quantization
107
\li KHR_node_visibility
108
\li EXT_texture_webp
109
\li EXT_meshopt_compression
110
\li EXT_mesh_gpu_instancing
111
\endlist
112
113
For assets using KHR_materials_variants the generated component contains
114
all variant materials, a \c materialVariant property for selecting the
115
active variant by name, and a read-only \c materialVariants property
116
listing the available names. Passing the \c{--materialVariant} option
117
instead bakes the named variant, so only its materials are part of the
118
output.
119
Assets using KHR_xmp_json_ld are accepted, but the metadata is not
120
imported. Assets requiring KHR_draco_mesh_compression or
121
KHR_texture_basisu are not supported and are rejected with an error
122
naming the extension.
123
124
An asset that lists an extension balsam does not convert still loads: the
125
extension is ignored and a warning is logged. Accepting an asset is
126
therefore not the same as applying every extension it names, and an asset
127
that requires an extension the parser understands but the converter does not
128
act on loads rather than failing.
129
130
Some Assimp-specific post-processing options (such as
131
\c{--preTransformVertices} and \c{--optimizeMeshes}) do not apply to the
132
native importer; glTF scene data is imported as authored. Identical
133
vertices are joined by default like before, controlled by
134
\c{--joinIdenticalVertices}.
135
136
Normal generation differs from the Assimp importer. \c{--generateNormals},
137
which asks Assimp for flat normals on every face, is not recognized: the
138
specification mandates flat shading for a mesh without normal data, and that
139
is what the native importer produces. \c{--generateSmoothNormals} computes
140
smooth normals for such meshes instead, and unlike with the Assimp importer
141
it defaults to off. A glTF asset lacking normals therefore comes out flat
142
shaded unless \c{--generateSmoothNormals} is given.
143
144
During the transition period the \c{QT_QUICK3D_DISABLE_NATIVE_GLTF}
145
environment variable can be set to route glTF assets through the Assimp
146
importer instead.
147
148
\section1 Baking for Image-Based Lighting
149
150
Balsam also supports generating a pre-filtered cubemap image from .hdr
151
files. Specifying a file with .hdr extension as the input results in generating
152
a file with the same name but with an extension of .ktx. The application can
153
then ship the resulting .ktx file and reference that from the \l Texture
154
associated with \l SceneEnvironment::lightProbe. This avoids the costly runtime
155
processing that is necessary for image-based lighting. See \l{Pre-generating IBL
156
cubemap} for more details.
157
158
\section1 Supported Options
159
160
The following table lists the command-line options recognized by \c balsam when
161
converting asset files:
162
163
\note For each boolean option it is possible to use \c{--disable-<option-name>}.
164
165
\table
166
\header \li Option \li Description
167
\row \li \c {--outputPath, -o <outputPath>} \li Sets the location to place the
168
generated file(s). Default is the current directory.
169
\row \li \c {--calculateTangentSpace} \li Calculates the tangents and
170
bitangents for the imported meshes.
171
\row \li \c {--joinIdenticalVertices} \li Identifies and joins identical vertex
172
data sets within all imported meshes.
173
\row \li \c {--generateNormals} \li Generates normals for all faces of all
174
meshes.
175
\row \li \c {--generateSmoothNormals} \li Generates smooth normals for all
176
vertices in the mesh.
177
\row \li \c {--splitLargeMeshes} \li Splits large meshes into smaller
178
sub-meshes.
179
\row \li \c {--preTransformVertices} \li Removes the node graph and
180
pre-transforms all vertices with the local transformation matrices of
181
their nodes.
182
\row \li \c {--improveCacheLocality} \li Reorders triangles for better vertex
183
cache locality.
184
\row \li \c {--removeRedundantMaterials} \li Searches for
185
redundant/unreferenced materials and removes them.
186
\row \li \c {--fixInfacingNormals} \li Tries to determine which meshes have
187
normal vectors that are facing inwards and inverts them.
188
\row \li \c {--findDegenerates} \li This step searches all meshes for
189
degenerate primitives and converts them to proper lines or points.
190
\row \li \c {--findInvalidData} \li This step searches all meshes for invalid
191
data, such as zeroed normal vectors or invalid UV coords and removes/fixes
192
them. This is intended to get rid of some common exporter errors.
193
\row \li \c {--transformUVCoordinates} \li This step applies per-texture UV
194
transformations and bakes them into stand-alone texture coordinate channels.
195
\row \li \c {--findInstances} \li This step searches for duplicate meshes and
196
replaces them with references to the first mesh.
197
\row \li \c {--optimizeMeshes} \li A postprocessing step to reduce the number
198
of meshes.
199
\row \li \c {--optimizeGraph} \li A postprocessing step to optimize the scene
200
hierarchy.
201
\row \li \c {--useFloatJointIndices} \li Stores joint indices as floating point
202
numbers for GLES 2.0.
203
\row \li \c {--globalScale} \li This step will perform a global scale of the
204
model.
205
\row \li \c {--globalScaleValue <value>} \li Global Scale factor used by
206
\c --globalScale.
207
\row \li \c {--dropNormals} \li Drops normals for all faces of all meshes.
208
\row \li \c {--removeComponentNormals} \li Removes Normal component from
209
meshes.
210
\row \li \c {--removeComponentTangentsAndBitangents} \li Removes Tangents and
211
Bitangents components from meshes.
212
\row \li \c {--removeComponentColors} \li Removes any Color components from
213
meshes.
214
\row \li \c {--removeComponentUVs} \li Removes any UV components from meshes.
215
\row \li \c {--removeComponentBoneWeights} \li Removes any bone weights from
216
meshes.
217
\row \li \c {--removeComponentAnimations} \li Removes any animation components
218
from meshes.
219
\row \li \c {--removeComponentTextures} \li Removes any embedded texture
220
components from meshes.
221
\row \li \c {--fbxPreservePivots} \li Preserves extra pivot nodes created by
222
FBX assets (can create deep node hierarchies)
223
\row \li \c {--generateMipMaps} \li Force all imported texture components to
224
generate mip maps for mip map texture filtering
225
\row \li \c {--useBinaryKeyframes} \li Record keyframe data as binary files
226
227
\row \li \c {--generateLightmapUV} \li Perform lightmap UV unwrapping and
228
generate an additional UV channel for the meshes. This UV data is then used by
229
the \l{Lightmaps and Global Illumination}{lightmap baker and during run-time
230
lightmapping}.
231
232
\row \li \c {--generateMeshLevelsOfDetail} \li When possible create mesh Levels
233
of Detail by automatically simplifying the source mesh.
234
235
\row \li \c {--recalculateLodNormals} \li Calculate new normals when necessary
236
for Generated Mesh levels of detail.
237
238
\row \li \c {--recalculateLodNormalsMergeAngle <value>} \li Maximum angle in
239
degrees to consider for normal smoothing/merging when recalculating normals
240
for Generated Mesh levels of detail.
241
242
\row \li \c {--recalculateLodNormalsSplitAngle <value>} \li Maximum angle in
243
degrees to consider for normal spliting when recalculating normals for
244
Generated Mesh levels of detail.
245
246
\endtable
247
248
*/
qtquick3d
src
quick3d
doc
src
qtquick3d-tool-balsam.qdoc
Generated on
for Qt by
1.16.1