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
9The Balsam tool is an application that is part of Qt Quick 3D's
10asset conditioning pipeline. The purpose is to take assets created in digital
11content 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
15format for use with Qt Quick 3D. It is not possible, nor does it make sense to
16reference the interchange formats directly in applications because a large amount
17of resources are needed to parse and condition the content of the asset before it
18is usable for realtime rendering. Instead the interchange formats can be
19converted via the Balsam tool into QML Components and resources like geometry and
20textures.
21
22\section1 Balsam Command Line Tool
23
24To run Balsam through the command line, call the \c balsam executable like
25this:
26
27\code
28balsam [options] sourceFilename
29\endcode
30
31To convert a 3D asset contained in the file \c testModel.fbx with \c balsam
32the following command would be used:
33
34\code
35balsam testModel.fbx
36\endcode
37
38This would generate the following files:
39\list
40 \li \c meshes/testModel.mesh
41 \li \c TestModel.qml
42\endlist
43
44Which can then be used in a Qt Quick 3D project by using that QML Component:
45\code
46import QtQuick3D
47
48TestModel {
49 id: modelInstance
50}
51\endcode
52
53\note The generated mesh filename depends on the mesh name(s) defined in the
54source file (in this example, the FBX file) and may differ from
55\c{testModel.mesh}.
56
57\section1 Balsam UI
58
59There is also a GUI frontend for Balsam called \c balsamui that is shipped
60alongside the \c balsam executable. In \c balsamui you can select your input
61files and output directory and the command-line options of the \c balsam
62executable 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
77Some of the formats supported also allow for either embedding or referencing of
78texture assets. These assets are also supported, provided Qt also has support
79for them.
80
81\section2 glTF 2.0 Import
82
83glTF 2.0 assets (.gltf and .glb) are imported by a native importer built
84directly on Qt, instead of going through the Assimp library like the other
85formats. The native importer supports the core glTF 2.0 feature set,
86including skinning, morph targets, animations with LINEAR, STEP, and
87CUBICSPLINE interpolation (the latter baked at a rate controlled by the
88\c{--animationSampleRate} option), sparse accessors, and quantized meshes,
89as 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
113For assets using KHR_materials_variants the generated component contains
114all variant materials, a \c materialVariant property for selecting the
115active variant by name, and a read-only \c materialVariants property
116listing the available names. Passing the \c{--materialVariant} option
117instead bakes the named variant, so only its materials are part of the
118output.
119Assets using KHR_xmp_json_ld are accepted, but the metadata is not
120imported. Assets requiring KHR_draco_mesh_compression or
121KHR_texture_basisu are not supported and are rejected with an error
122naming the extension.
123
124An asset that lists an extension balsam does not convert still loads: the
125extension is ignored and a warning is logged. Accepting an asset is
126therefore not the same as applying every extension it names, and an asset
127that requires an extension the parser understands but the converter does not
128act on loads rather than failing.
129
130Some Assimp-specific post-processing options (such as
131\c{--preTransformVertices} and \c{--optimizeMeshes}) do not apply to the
132native importer; glTF scene data is imported as authored. Identical
133vertices are joined by default like before, controlled by
134\c{--joinIdenticalVertices}.
135
136Normal generation differs from the Assimp importer. \c{--generateNormals},
137which asks Assimp for flat normals on every face, is not recognized: the
138specification mandates flat shading for a mesh without normal data, and that
139is what the native importer produces. \c{--generateSmoothNormals} computes
140smooth normals for such meshes instead, and unlike with the Assimp importer
141it defaults to off. A glTF asset lacking normals therefore comes out flat
142shaded unless \c{--generateSmoothNormals} is given.
143
144During the transition period the \c{QT_QUICK3D_DISABLE_NATIVE_GLTF}
145environment variable can be set to route glTF assets through the Assimp
146importer instead.
147
148\section1 Baking for Image-Based Lighting
149
150Balsam also supports generating a pre-filtered cubemap image from .hdr
151files. Specifying a file with .hdr extension as the input results in generating
152a file with the same name but with an extension of .ktx. The application can
153then ship the resulting .ktx file and reference that from the \l Texture
154associated with \l SceneEnvironment::lightProbe. This avoids the costly runtime
155processing that is necessary for image-based lighting. See \l{Pre-generating IBL
156cubemap} for more details.
157
158\section1 Supported Options
159
160The following table lists the command-line options recognized by \c balsam when
161converting 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
168generated file(s). Default is the current directory.
169\row \li \c {--calculateTangentSpace} \li Calculates the tangents and
170bitangents 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
174meshes.
175\row \li \c {--generateSmoothNormals} \li Generates smooth normals for all
176vertices in the mesh.
177\row \li \c {--splitLargeMeshes} \li Splits large meshes into smaller
178sub-meshes.
179\row \li \c {--preTransformVertices} \li Removes the node graph and
180pre-transforms all vertices with the local transformation matrices of
181their nodes.
182\row \li \c {--improveCacheLocality} \li Reorders triangles for better vertex
183cache locality.
184\row \li \c {--removeRedundantMaterials} \li Searches for
185redundant/unreferenced materials and removes them.
186\row \li \c {--fixInfacingNormals} \li Tries to determine which meshes have
187normal vectors that are facing inwards and inverts them.
188\row \li \c {--findDegenerates} \li This step searches all meshes for
189degenerate primitives and converts them to proper lines or points.
190\row \li \c {--findInvalidData} \li This step searches all meshes for invalid
191data, such as zeroed normal vectors or invalid UV coords and removes/fixes
192them. This is intended to get rid of some common exporter errors.
193\row \li \c {--transformUVCoordinates} \li This step applies per-texture UV
194transformations and bakes them into stand-alone texture coordinate channels.
195\row \li \c {--findInstances} \li This step searches for duplicate meshes and
196replaces them with references to the first mesh.
197\row \li \c {--optimizeMeshes} \li A postprocessing step to reduce the number
198of meshes.
199\row \li \c {--optimizeGraph} \li A postprocessing step to optimize the scene
200hierarchy.
201\row \li \c {--useFloatJointIndices} \li Stores joint indices as floating point
202numbers for GLES 2.0.
203\row \li \c {--globalScale} \li This step will perform a global scale of the
204model.
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
209meshes.
210\row \li \c {--removeComponentTangentsAndBitangents} \li Removes Tangents and
211Bitangents components from meshes.
212\row \li \c {--removeComponentColors} \li Removes any Color components from
213meshes.
214\row \li \c {--removeComponentUVs} \li Removes any UV components from meshes.
215\row \li \c {--removeComponentBoneWeights} \li Removes any bone weights from
216meshes.
217\row \li \c {--removeComponentAnimations} \li Removes any animation components
218from meshes.
219\row \li \c {--removeComponentTextures} \li Removes any embedded texture
220components from meshes.
221\row \li \c {--fbxPreservePivots} \li Preserves extra pivot nodes created by
222FBX assets (can create deep node hierarchies)
223\row \li \c {--generateMipMaps} \li Force all imported texture components to
224generate 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
228generate an additional UV channel for the meshes. This UV data is then used by
229the \l{Lightmaps and Global Illumination}{lightmap baker and during run-time
230lightmapping}.
231
232\row \li \c {--generateMeshLevelsOfDetail} \li When possible create mesh Levels
233of Detail by automatically simplifying the source mesh.
234
235\row \li \c {--recalculateLodNormals} \li Calculate new normals when necessary
236for Generated Mesh levels of detail.
237
238\row \li \c {--recalculateLodNormalsMergeAngle <value>} \li Maximum angle in
239degrees to consider for normal smoothing/merging when recalculating normals
240for Generated Mesh levels of detail.
241
242\row \li \c {--recalculateLodNormalsSplitAngle <value>} \li Maximum angle in
243degrees to consider for normal spliting when recalculating normals for
244Generated Mesh levels of detail.
245
246\endtable
247
248*/