Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
27\section2 Shader editing
28
29In the editor view there are two editors, one for the vertex shader and one for the fragment shader.
30When editing the shader snippets the result of those changes will immediately become visible in the preview.
31If the material could not be assembled a message describing the problem will be visible in the output panel.
32
33The language used for writing the \l[QtQuick3D]{CustomMaterial}'s shader snippets is Vulkan-style GLSL
34with some additional keywords that are specific for QtQuick3D, these are easily identifiable by being
35written in all upper-case characters. The QtQuick3D specific keywords will also be highlighted by the editor.
36
37For a more detailed overview of the language used in shaders snippets and how they interact with the rest of
38the rendering pipeline, see the \l {Programmable Materials, Effects, Geometry, and Texture data}{Programmable Materials}
39documentation.
40
41\image MaterialEditor-vertex.png
42
43\section2 Material properties
44
45The Material Properties section contains the common QML properties for the material.
46These properties and how they affect the material are described in more details in the \l [QtQuick3d]{CustomMaterial} documentation.
47
48\image MaterialEditor-properties.png
49
50\section2 Preview
51
52In addition to showing how the current material is rendered, the preview panel contains a selection of controls
53that can be adjusted to see how the material looks under different conditions. These controls allows the
54user to: Select a different model, toggle the usage of \l{Using Image-Based Lighting}{Image Based Lighting},
55turn the scene light \b on or \b off, and adjust the rotation of the environment. It's also possible to orbit
56around the model using the mouse.
57
58\image MaterialEditor-preview.jpg
59
60\section2 Uniforms
61
62The uniform table is where the uniforms used by the shaders are listed. Uniforms can be added, removed or changed
63at any time, but all uniforms used by the shader snippets needs to be added to the uniform table.
64Once a uniform is added it will become accessible to both shaders.
65When exporting the material to a QML component the uniforms will become properties on the material component.
66
67\image MaterialEditor-uniforms.png
68
69\section2 Output panel
70
71The output panel shows diagnostic messages, for example, errors found in the shader snippets.
72
73\image MaterialEditor-output.png
74
75\section2 Importing shaders
76
77Shaders snippets can be imported into the application, these have the file extension \c{.vert} and \c{.frag} and
78are expected to contain plain-text.
79Imported shader snippets will of course need to be adapted, manually, if the shader code is not in a language or in a form
80that's compatible with the \l[QtQuick3D]{CustomMaterial} already (no translation is attempted by the tool.)
81
82\section2 Saving and loading projects.
83
84The Material Editor can save or load project files using it's own project format.
85The extension of the Material Editor project files are \c{.qmp}.
86\note The Material Editor's project file-format is not intended for runtime usage, it is only intended to
87be used with the Material Editor.
88
89\section2 Exporting.
90
91For the material to be usable from an application it needs to be exported as a QML Component,
92this can be done by opening the export dialog from the application menu. The export dialog will
93ask for an output folder, the name of the material component, and the name(s) of the shader snippets.
94When the material has been successfully exported the output folder will contain a QML Component
95describing the material together with any shader snippet and texture needed by the material.
96
97\image MaterialEditor-export.png
98
99*/