Qt Quick 3D的更改

Changes to Qt Quick 3D

Qt Quick 3D的更改

Qt 6 is a result of the conscious effort to make the framework more efficient and easy to use.

Qt 6是有意识地努力使框架更加高效和易于使用的结果。

We try to maintain binary and source compatibility for all the public APIs in each release. But some changes were inevitable in an effort to make Qt a better framework. Parts of the Qt Quick 3D API have been substantially modified.

我们试图保持每个版本中所有公共API的二进制和源代码兼容性。但为了使Qt成为更好的框架,一些变化是不可避免的。Qt Quick 3D API的部分已进行了实质性修改。

In this topic we summarize those changes in Qt Quick 3D, and provide guidance to handle them.

在本主题中,我们总结了Qt Quick 3D中的这些变化,并提供了处理这些变化的指导。

RHI

From Qt 6.0 onwards, the default adaptation of Qt Quick always renders via a graphics abstraction layer, the Qt Rendering Hardware Interface (RHI), provided by the QtGui module. This means that, unlike Qt 5, no direct OpenGL calls are made by the scene graph. Rather, it records resource and draw commands by using the RHI APIs, which then translate the command stream into OpenGL, Vulkan, Metal, or Direct 3D calls. Shader handling is also unified by writing shader code once, compiling to SPIR-V, and then translating to the language appropriate for the various graphics APIs.

​从Qt 6.0开始,Qt Quick的默认自适应始终通过图形抽象层进行渲染,即Qt渲染硬件接口(RHI),由QtGui模块提供。这意味着,与Qt 5不同,场景图不直接调用OpenGL。相反,它使用RHI API记录资源和绘制命令,然后将命令流转换为OpenGL、Vulkan、Metal或直接3D调用。着色器处理也通过编写一次着色器代码,编译为SPIR-V,然后翻译为适合各种图形API的语言来统一。

For Qt Quick 3D the biggest change in Qt 6.0 is the migration to the common Rendering Hardware Interface, which allows Qt Quick 3D to run on Direct3D, Metal and Vulkan in addition to OpenGL and OpenGL ES.

对于Qt Quick 3D,Qt 6.0中最大的变化是迁移到通用渲染硬件接口,除了OpenGL和OpenGL ES之外,还允许Qt Quick3D在Direct3D、Metal和Vulkan上运行。

Qt Quick and Qt Quick 3D are now fully unified in this regard. Any configuration setting related to the RHI, for example, which graphics API to choose to render with, are applicable to both.

在这方面,Qt Quick和Qt Quick3D现已完全统一。与RHI相关的任何配置设置(例如,选择使用哪个图形API进行渲染)都适用于两者。

See Qt Quick 3D Graphics Requirements for further details.

​有关详细信息,请参阅Qt Quick 3D图形要求。

Other API changes

其他API更改

QML import version

QML导入版本

Starting with Qt 6.0, the version number for QML import statements is the same as the Qt version number. It is now also possible to import a module without specifying a version: this will import the latest version of the module.

从Qt 6.0开始,QML导入语句的版本号与Qt版本号相同。现在还可以在不指定版本的情况下导入模块:这将导入模块的最新版本。

Lighting

灯光

Light brightness now represents an energy multiplier defaulting to 1.0, where Qt 5 would use a percentage value defaulting to 100. In practice this means that all brightness values should be divided by 100.

灯光亮度现在表示默认为1.0的能量乘数,其中Qt 5将使用默认为100的百分比值。实际上,这意味着所有亮度值都应除以100。

SceneEnvironment.probeBrightness is renamed to probeExposure and is also redefined to be a multiplier with a default value of 1.0. That is, all probeBrightness values should be renamed to probeExposure and divided by 100.

SceneEnvironment.probeBrightness重命名为probeExposure,并重新定义为默认值为1.0的乘数。也就是说,所有ProbBrightness值都应重命名为probeExposure并除以100。

AreaLight has been removed for performance reasons. In many cases it can be replaced with SpotLight, which was added in Qt Quick 3D 5.15.

​由于性能原因,AreaLight已被移除。在许多情况下,它可以被添加到Qt Quick 3D 5.15中的SpotLight替代。

Custom Materials

自定义材质

The custom materials API has been completely reworked in 6.0. This means any existing custom materials will have to be substantially rewritten. See the CustomMaterial documentation for details of the new API.

​自定义材质API已在6.0中完全重写。这意味着任何现有的自定义材质都必须进行实质性重写。有关新API的详细信息,请参阅CustomMaterial文档。

Post-processing Effects

后处理效果

Effect has been enhanced to allow for shader code that is very close to what CustomMaterial supports, following the same patterns when it comes to structure and built-in keywords. This means that existing effects involving custom shader code will need to be migrated before they can function in Qt 6.0. See the Effect documentation for details.

效果得到了增强,以允许着色器代码非常接近CustomMaterial支持的内容,在结构和内置关键字方面遵循相同的模式。这意味着涉及自定义着色器代码的现有效果需要迁移才能在Qt 6.0中运行。有关详细信息,请参阅效果文档。

Principled Material

原则材质

The PrincipledMaterial QML type has been greatly improved in Qt Quick 6.0, and now more closely follows the principles of Physically Based Rendering. Imported models should now render correctly without changing properties of the materials. Existing materials will need to be changed to undo any compensations for previous inaccuracies.

​PrincipleMaterial QML类型在Qt Quick 6.0中得到了极大改进,现在更接近基于物理渲染的原理。导入的模型现在应正确渲染,而不更改材质的属性。现有材料需要更改,以撤销对先前不准确的任何补偿。

PrincipledMaterial in Qt 5PrincipledMaterial in Qt 6

Some properties change their defaults:

某些属性更改其默认值:

  • metalness defaults to 0 instead of 1.
  • metalness属性更改其默认值:
  • specularAmount defaults to 0.5 instead of 0.
  • specularAmount默认为0.5而不是0。

Default Material

默认材质

Some properties change their defaults:

某些属性更改其默认值:

  • specularRoughness defaults to 0 instead of 50.
  • specularRoughness默认为0而不是50。

Predefined materials

预定义材质

There are no predefined materials included in QtQuick3D 6.0. Any materials added in future releases will probably not be compatible with the old ones. The Materials import does not exist. (The CustomMaterial type is moved to the base QtQuick3D import.)

​QtQuick3D 6.0中没有包含预定义的材质。未来版本中添加的任何材质可能与旧材质不兼容。材质导入不存在。(CustomMaterial类型移动到基本QtQuick3D导入。)​

These are the material QML types that have been removed in Qt 6.0:

以下是Qt 6.0中删除的材料QML类型:

  • AluminumAnodizedEmissiveMaterial
  • AluminumAnodizedMaterial
  • AluminumBrushedMaterial
  • AluminumEmissiveMaterial
  • AluminumMaterial
  • CopperMaterial
  • FrostedGlassMaterial
  • FrostedGlassSinglePassMaterial
  • GlassMaterial
  • GlassRefractiveMaterial
  • PaperArtisticMaterial
  • PaperOfficeMaterial
  • PlasticStructuredRedEmissiveMaterial
  • PlasticStructuredRedMaterial
  • SteelMilledConcentricMaterial

Tessellation and displacement maps

细分和置换贴图

Model tesselation mode is gone due to increased focus on supporting embedded hardware. In addition, as a result, displacement map support has been removed from materials. Similar effects can be achieved with a custom material.

​由于越来越关注支持嵌入式硬件,模型tesselation模式已经消失。此外,因此,置换贴图支持已从材质中移除。使用自定义材质可以实现类似的效果。

Qt Quick Items as children of 3D Nodes

​Qt Quick项作为三维节点的子项

While syntactically identical, the way 2D child items are handled is quite different internally. In Qt 6.0 there is no implicit render to texture step. Rather, the 2D Qt Quick content is rendered in line, with the appropriate perspective projection, in the same render pass, which provides better performance, lower resource usage, and in some cases potentially improved visual fidelity (with Text, for example). See Qt Quick 3D Scenes with 2D Content for an overview.

​虽然语法上相同,但处理2D子项的方式在内部是完全不同的。在Qt 6.0中,没有隐式渲染纹理步骤。相反,2D Qt Quick内容在同一渲染过程中使用适当的透视投影进行在线渲染,这提供了更好的性能、更低的资源使用率,并且在某些情况下可能提高视觉逼真度(例如,文本)。有关概述,请参阅包含2D内容的Qt Quick 3D场景。

If going through a texture is important for some reason (clipping, opacity), make the 2D Item subtree a layer explicitly by setting layer.enabled: true. This way the behavior is closer to what Qt 5.15 provided.

​如果由于某些原因(剪裁、不透明度)穿过纹理很重要,请通过设置图层将2D项目子树显式设置layer.enabled: true。这样,行为更接近Qt 5.15提供的行为。

The 2D content is no longer centered at the parent Node's origin. Rather, it is the top-level 2D Item's top-left corner that is placed to the 3D Node's origin. Therefore, the top-level 2D Item will often want to specify an anchor, such as, anchors.centerIn: parent, to get results matching Qt 5.15.

二维内容不再以父节点的原点为中心。相反,放置到3D节点原点的是顶层2D项的左上角。因此,顶级2D项通常需要指定锚,例如anchors.centerIn: parent,以获得与Qt 5.15匹配的结果。

© 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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值