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-cmake-macros.qdoc
Go to the documentation of this file.
1// Copyright (C) 2025 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5\page qt-add-materials.html
6\ingroup cmake-commands-qtquick3d
7
8\title qt_add_materials
9\keyword qt6_add_materials
10\deprecated
11
12\summary {Generates shaders from files, adding them as Qt resources.}
13
14\preliminarycmakecommand
15
16The command is defined in the \c Quick3D component of the \c Qt6 package, which can
17be loaded like this:
18
19\badcode
20find_package(Qt6 REQUIRED COMPONENTS Quick3D)
21\endcode
22
23\cmakecommandsince 6.2
24
25\section1 Synopsis
26
27\badcode
28qt_add_materials(target resource_name
29 [PREFIX prefix]
30 FILES file1.qml, file2.qml ...)
31\endcode
32
33\versionlessCMakeCommandsNote qt6_add_materials()
34
35\section1 Description
36
37Use the command to pre-generate the material shaders used in a \l{Qt Quick 3D} scene
38at compile time, for a certain \c target.
39
40Use \c FILES to list the QML files that are part of the project. The command will call
41the \l{Shadergen Tool} at build time to extract and generate material shaders,
42making them available in the Qt resource system. \l{Qt Quick 3D} will automatically
43load these at runtime.
44
45Using \c RESOURCES is currently not supported.
46
47\section1 Example
48
49The following autogenerates the lightprobe map at build time and
50includes it in the executable under \c{:/maps/OpenfootageNET_garage-1024.ktx}:
51
52\badcode
53qt6_add_materials(offlineshaders "shaders"
54 PREFIX
55 "/"
56 FILES
57 MaterialRed.qml
58 MaterialRedExtended.qml
59 main.qml
60)
61\endcode
62
63\section1 Caveats
64
65Shadergen uses a heuristic to determine the shaders it generates, which might not
66always be the ones that are actually used at runtime. See the \l{Shadergen Tool}
67documentation on further details.
68
69When adding multiple resources, \c resource_name must be unique across
70all resources linked into the final target. This especially affects static builds.
71There, the same resource name in different static libraries conflict in the consuming
72target.
73
74\sa {Shadergen Tool}, {Qt Quick 3D - Offline Shaders Example}
75*/
76
77/*!
78\page qt-add-lightprobe-images.html
79\ingroup cmake-commands-qtquick3d
80
81\title qt_add_lightprobe_images
82\keyword qt6_add_lightprobe_images
83
84\summary {Bakes HDRI map files to KTX files, adding them as Qt resouces.}
85
86\preliminarycmakecommand
87
88The command is defined in the \c Quick3D component of the \c Qt6 package, which can
89be loaded like this:
90
91\badcode
92find_package(Qt6 REQUIRED COMPONENTS Quick3D)
93\endcode
94
95\cmakecommandsince 6.2
96
97\section1 Synopsis
98
99\badcode
100qt_add_lightprobe_images(target resource_name
101 [PREFIX prefix]
102 [BASE base]
103 FILES file1.hdr, file2.hdr ..
104 [OUTPUTS file1.ktx, file2.ktx ..]
105)
106\endcode
107
108\versionlessCMakeCommandsNote qt6_add_lightprobe_images()
109
110\section1 Description
111
112Use the command to bake \c{.hdr} files listed under \c FILES
113to \c{.ktx} files. The files will be included under in the binary
114or library \c target.
115
116\c FILES should list paths to local HDRI map files. Each file must have either
117the suffix \c{.hdr}, or \c{.exr}. These files will be converted at build time
118to \c .ktx files, using the \l{Balsam Asset Import Tool}.
119
120By default, the \c .ktx files will show up in embedded Qt resources of
121the target binary under the same base name and relative path. Use \c BASE
122to remove a common directory from the relative paths at runtime. That is, if all
123the file paths under \c FILES point to a common directory \c maps/, then you
124can use \c{BASE maps/} to hide the directory in the Qt resource system. In a similar
125vein, you can use \c PREFIX to add a common prefix directory in the Qt resource
126system.
127
128While \c BASE and \c PREFIX allow you to change the comon relative paths of
129the \c .ktx files in the Qt resource system, \c OUTPUTS allow you to control
130the full path of the \c .ktx files, including the file name. If you use \c OUTPUTS,
131the number of paths have to match the number of paths to \c FILES.
132
133
134\section1 Example
135
136The following autogenerates the lightprobe map at build time and
137includes it in the executable under \c{:/maps/OpenfootageNET_garage-1024.ktx}:
138
139\badcode
140qt_add_lightprobe_images(principledmaterial "ibl_assets"
141 PREFIX
142 "/"
143 FILES
144 "maps/OpenfootageNET_garage-1024.hdr"
145)
146\endcode
147
148\section1 Caveats
149
150When adding multiple resources, \c resource_name must be unique across
151all resources linked into the final target.
152
153This especially affects static builds. There, the same resource name in
154different static libraries conflict in the consuming target.
155
156\sa{Pre-generating IBL cubemap}
157*/