自定义材质编辑器

Custom Material Editor

自定义材质编辑器

The Material Editor tool

“材质编辑器”工具

The Material Editor tool is a GUI tool that makes authoring CustomMaterials for QtQuick3D easier by providing: a real-time preview of the material, syntax highlighting, error reporting, and the ability to export the material to a CustomMaterial QML component.

​“材质编辑器”工具是一个GUI工具,它通过提供材质的实时预览、语法高亮显示、错误报告以及将材质导出到CustomMaterial QML组件的功能,使为QtQuick3D编写CustomMeterials变得更加容易。

Usage

用法

The Material Editor can be launched by running the command:

可以通过运行以下命令启动“材质编辑器”:

$(QTDIR)/bin/materialeditor[.exe]

The Material Editor window consists of two main components, the editor on the left and the preview on the right.

“材质编辑器”窗口由两个主要组件组成,左侧的编辑器和右侧的预览。

Shader editing

着色器编辑

In the editor view there are two editors, one for the vertex shader and one for the fragment shader. When editing the shader snippets the result of those changes will immediately become visible in the preview. If the material could not be assembled a message describing the problem will be visible in the output panel.

在编辑器视图中有两个编辑器,一个用于顶点着色器,另一个用于片段着色器。编辑着色器片段时,这些更改的结果将立即显示在预览中。如果无法组装材料,输出面板中将显示描述问题的消息。

The language used for writing the CustomMaterial's shader snippets is Vulkan-style GLSL with some additional keywords that are specific for QtQuick3D, these are easily identifiable by being written in all upper-case characters. The QtQuick3D specific keywords will also be highlighted by the editor.

​用于编写CustomMaterial着色器片段的语言是Vulkan风格的GLSL,其中包含一些特定于QtQuick3D的附加关键字,这些关键字可以通过使用所有大写字符轻松识别。编辑器还将突出显示QtQuick3D特定的关键字。

For a more detailed overview of the language used in shaders snippets and how they interact with the rest of the rendering pipeline, see the Programmable Materials documentation.

​有关着色器片段中使用的语言以及它们如何与其余渲染管道交互的更详细概述,请参见“可编程材质”文档。

Material properties

材质属性

The Material Properties section contains the common QML properties for the material. These properties and how they affect the material are described in more details in the CustomMaterial documentation.

​“材质属性”部分包含材质的常见QML属性。CustomMaterial文档中详细描述了这些属性及其如何影响材质。

Preview

预览

In addition to showing how the current material is rendered, the preview panel contains a selection of controls that can be adjusted to see how the material looks under different conditions. These controls allows the user to: Select a different model, toggle the usage of Image Based Lighting, turn the scene light on or off, and adjust the rotation of the environment. It's also possible to orbit around the model using the mouse.

​除了显示当前材质的渲染方式外,预览面板还包含一系列控件,可以对这些控件进行调整,以查看材质在不同条件下的外观。这些控件允许用户:选择不同的模型,切换基于图像的照明的使用,打开或关闭场景灯光,以及调整环境的旋转。也可以使用鼠标围绕模型进行动态观察。

Uniforms

The uniform table is where the uniforms used by the shaders are listed. Uniforms can be added, removed or changed at any time, but all uniforms used by the shader snippets needs to be added to the uniform table. Once a uniform is added it will become accessible to both shaders. When exporting the material to a QML component the uniforms will become properties on the material component.

uniform表列出了着色器使用的uniform。uniform可以随时添加、删除或更改,但着色器片段使用的所有uniform都需要添加到uniform表中。添加uniform后,两个着色器都可以访问它。将材料导出到QML组件时,uniform将成为材料组件上的属性。

Output panel

输出面板

The output panel shows diagnostic messages, for example, errors found in the shader snippets.

输出面板显示诊断消息,例如着色器片段中发现的错误。

Importing shaders

导入着色器

Shaders snippets can be imported into the application, these have the file extension .vert and .frag and are expected to contain plain-text. Imported shader snippets will of course need to be adapted, manually, if the shader code is not in a language or in a form that's compatible with the CustomMaterial already (no translation is attempted by the tool.)

​着色器片段可以导入到应用程序中,这些片段的文件扩展名为.vert和.frag的纯文本。如果着色器代码的语言或格式与CustomMaterial不兼容,则导入的着色器片段当然需要手动调整(该工具不尝试翻译)

Saving and loading projects.

保存和加载项目。

The Material Editor can save or load project files using it's own project format. The extension of the Material Editor project files are .qmp.

材质编辑器可以使用自己的项目格式保存或加载项目文件。材质编辑器项目文件的扩展名为.qmp。

Note: The Material Editor's project file-format is not intended for runtime usage, it is only intended to be used with the Material Editor.

注意:材质编辑器的项目文件格式不适用于运行时使用,它仅适用于材质编辑器。

Exporting.

导出

For the material to be usable from an application it needs to be exported as a QML Component, this can be done by opening the export dialog from the application menu. The export dialog will ask for an output folder, the name of the material component, and the name(s) of the shader snippets. When the material has been successfully exported the output folder will contain a QML Component describing the material together with any shader snippet and texture needed by the material.

为了使材质能够从应用程序中使用,它需要作为QML组件导出,可以通过从应用程序菜单打开导出对话框来完成。导出对话框将要求输入输出文件夹、材质组件的名称和着色器片段的名称。成功导出材质后,输出文件夹将包含一个QML组件,该组件描述材质以及材质所需的任何着色器片段和纹理。

© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值