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-materialeditor.qdoc
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5\page qtquick3d-tool-materialeditor.html
6\title Custom Material Editor
7\brief GUI tool for creating custom materials.
8
9\section1 The Material Editor tool
10
11The Material Editor tool is a GUI tool that makes authoring \l [QtQuick3D] {CustomMaterial}{CustomMaterials} for QtQuick3D
12easier by providing: a real-time preview of the material, syntax highlighting, error reporting,
13and the ability to export the material to a \l[QtQuick3D]{CustomMaterial} QML component.
14
15\section2 Usage
16
17The Material Editor can be launched by running the command:
18
19\badcode
20$(QTDIR)/bin/materialeditor[.exe]
21\endcode
22
23The Material Editor window consists of two main components, the editor on the left and the preview on the right.
24
25\image MaterialEditor-main.png
26 {Material Editor window with shader editors and preview panel}
27
28\section2 Shader editing
29
30In the editor view there are two editors, one for the vertex shader and one for the fragment shader.
31When editing the shader snippets the result of those changes will immediately become visible in the preview.
32If the material could not be assembled a message describing the problem will be visible in the output panel.
33
34The language used for writing the \l[QtQuick3D]{CustomMaterial}'s shader snippets is Vulkan-style GLSL
35with some additional keywords that are specific for QtQuick3D, these are easily identifiable by being
36written in all upper-case characters. The QtQuick3D specific keywords will also be highlighted by the editor.
37
38For a more detailed overview of the language used in shaders snippets and how they interact with the rest of
39the rendering pipeline, see the \l {Programmable Materials, Effects, Geometry, and Texture data}{Programmable Materials}
40documentation.
41
42\image MaterialEditor-vertex.png {Vertex shader editor with displacement code}
43
44\section2 Material properties
45
46The Material Properties section contains the common QML properties for the material.
47These properties and how they affect the material are described in more details in the \l [QtQuick3d]{CustomMaterial} documentation.
48
49\image MaterialEditor-properties.png
50 {Material Properties panel with blend and shading settings}
51
52\section2 Preview
53
54In addition to showing how the current material is rendered, the preview panel contains a selection of controls
55that can be adjusted to see how the material looks under different conditions. These controls allows the
56user to: Select a different model, toggle the usage of \l{Using Image-Based Lighting}{Image Based Lighting},
57turn the scene light \b on or \b off, and adjust the rotation of the environment. It's also possible to orbit
58around the model using the mouse.
59
60\image MaterialEditor-preview.jpg
61 {Preview panel showing sphere with custom material}
62
63\section2 Uniforms
64
65The uniform table is where the uniforms used by the shaders are listed. Uniforms can be added, removed or changed
66at any time, but all uniforms used by the shader snippets needs to be added to the uniform table.
67Once a uniform is added it will become accessible to both shaders.
68When exporting the material to a QML component the uniforms will become properties on the material component.
69
70\image MaterialEditor-uniforms.png {Uniforms panel with float parameters}
71
72\section2 Output panel
73
74The output panel shows diagnostic messages, for example, errors found in the shader snippets.
75
76\image MaterialEditor-output.png {Shader output panel with error message}
77
78\section2 Importing shaders
79
80Shaders snippets can be imported into the application, these have the file extension \c{.vert} and \c{.frag} and
81are expected to contain plain-text.
82Imported shader snippets will of course need to be adapted, manually, if the shader code is not in a language or in a form
83that's compatible with the \l[QtQuick3D]{CustomMaterial} already (no translation is attempted by the tool.)
84
85\section2 Saving and loading projects.
86
87The Material Editor can save or load project files using it's own project format.
88The extension of the Material Editor project files are \c{.qmp}.
89\note The Material Editor's project file-format is not intended for runtime usage, it is only intended to
90be used with the Material Editor.
91
92\section2 Exporting.
93
94For the material to be usable from an application it needs to be exported as a QML Component,
95this can be done by opening the export dialog from the application menu. The export dialog will
96ask for an output folder, the name of the material component, and the name(s) of the shader snippets.
97When the material has been successfully exported the output folder will contain a QML Component
98describing the material together with any shader snippet and texture needed by the material.
99
100\image MaterialEditor-export.png {Export material dialog}
101
102*/