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\section1 Baking for Image-Based Lighting
82
83Balsam also supports generating a pre-filtered cubemap image from .hdr
84files. Specifying a file with .hdr extension as the input results in generating
85a file with the same name but with an extension of .ktx. The application can
86then ship the resulting .ktx file and reference that from the \l Texture
87associated with \l SceneEnvironment::lightProbe. This avoids the costly runtime
88processing that is necessary for image-based lighting. See \l{Pre-generating IBL
89cubemap} for more details.
90
91\section1 Supported Options
92
93The following table lists the command-line options recognized by \c balsam when
94converting asset files:
95
96\note For each boolean option it is possible to use \c{--disable-<option-name>}.
97
98\table
99\header \li Option \li Description
100\row \li \c {--outputPath, -o <outputPath>} \li Sets the location to place the
101generated file(s). Default is the current directory.
102\row \li \c {--calculateTangentSpace} \li Calculates the tangents and
103bitangents for the imported meshes.
104\row \li \c {--joinIdenticalVertices} \li Identifies and joins identical vertex
105 data sets within all imported meshes.
106\row \li \c {--generateNormals} \li Generates normals for all faces of all
107meshes.
108\row \li \c {--generateSmoothNormals} \li Generates smooth normals for all
109vertices in the mesh.
110\row \li \c {--splitLargeMeshes} \li Splits large meshes into smaller
111sub-meshes.
112\row \li \c {--preTransformVertices} \li Removes the node graph and
113pre-transforms all vertices with the local transformation matrices of
114their nodes.
115\row \li \c {--improveCacheLocality} \li Reorders triangles for better vertex
116cache locality.
117\row \li \c {--removeRedundantMaterials} \li Searches for
118redundant/unreferenced materials and removes them.
119\row \li \c {--fixInfacingNormals} \li Tries to determine which meshes have
120normal vectors that are facing inwards and inverts them.
121\row \li \c {--findDegenerates} \li This step searches all meshes for
122degenerate primitives and converts them to proper lines or points.
123\row \li \c {--findInvalidData} \li This step searches all meshes for invalid
124data, such as zeroed normal vectors or invalid UV coords and removes/fixes
125them. This is intended to get rid of some common exporter errors.
126\row \li \c {--transformUVCoordinates} \li This step applies per-texture UV
127transformations and bakes them into stand-alone texture coordinate channels.
128\row \li \c {--findInstances} \li This step searches for duplicate meshes and
129replaces them with references to the first mesh.
130\row \li \c {--optimizeMeshes} \li A postprocessing step to reduce the number
131of meshes.
132\row \li \c {--optimizeGraph} \li A postprocessing step to optimize the scene
133hierarchy.
134\row \li \c {--useFloatJointIndices} \li Stores joint indices as floating point
135numbers for GLES 2.0.
136\row \li \c {--globalScale} \li This step will perform a global scale of the
137model.
138\row \li \c {--globalScaleValue <value>} \li Global Scale factor used by
139\c --globalScale.
140\row \li \c {--dropNormals} \li Drops normals for all faces of all meshes.
141\row \li \c {--removeComponentNormals} \li Removes Normal component from
142meshes.
143\row \li \c {--removeComponentTangentsAndBitangents} \li Removes Tangents and
144Bitangents components from meshes.
145\row \li \c {--removeComponentColors} \li Removes any Color components from
146meshes.
147\row \li \c {--removeComponentUVs} \li Removes any UV components from meshes.
148\row \li \c {--removeComponentBoneWeights} \li Removes any bone weights from
149meshes.
150\row \li \c {--removeComponentAnimations} \li Removes any animation components
151from meshes.
152\row \li \c {--removeComponentTextures} \li Removes any embedded texture
153components from meshes.
154\row \li \c {--fbxPreservePivots} \li Preserves extra pivot nodes created by
155FBX assets (can create deep node hierarchies)
156\row \li \c {--generateMipMaps} \li Force all imported texture components to
157generate mip maps for mip map texture filtering
158\row \li \c {--useBinaryKeyframes} \li Record keyframe data as binary files
159
160\row \li \c {--generateLightmapUV} \li Perform lightmap UV unwrapping and
161generate an additional UV channel for the meshes. This UV data is then used by
162the \l{Lightmaps and Global Illumination}{lightmap baker and during run-time
163lightmapping}.
164
165\row \li \c {--generateMeshLevelsOfDetail} \li When possible create mesh Levels
166of Detail by automatically simplifying the source mesh.
167
168\row \li \c {--recalculateLodNormals} \li Calculate new normals when necessary
169for Generated Mesh levels of detail.
170
171\row \li \c {--recalculateLodNormalsMergeAngle <value>} \li Maximum angle in
172degrees to consider for normal smoothing/merging when recalculating normals
173for Generated Mesh levels of detail.
174
175\row \li \c {--recalculateLodNormalsSplitAngle <value>} \li Maximum angle in
176degrees to consider for normal spliting when recalculating normals for
177Generated Mesh levels of detail.
178
179\endtable
180
181*/