Qt Quick 3D细节级别

Qt Quick 3D Level of Detail

Qt Quick 3D细节级别

Level of Detail (LoD)

细节级别(LoD)

Level of Detail (LoD) refers to the technique of using alternative versions of a 3D model at different distances from the camera. The goal of doing this is to optimize resource usage by using simpler versions of the model when it is far away or a small share of the screen, while using more detailed versions when it is closer or larger portion of screen space. This approach allows for efficient use of GPU resources while maintaining visual fidelity.

细节级别(LoD)是指在距离相机不同距离处使用3D模型的替代版本的技术。这样做的目的是通过在模型距离较远或屏幕份额较小时使用更简单的版本来优化资源使用,而在模型距离较小或屏幕空间较大时使用更详细的版本。这种方法允许有效地使用GPU资源,同时保持视觉保真度。

Qt Quick 3D provides both an automatic as well as an explicit level of detail system. The automatic system is based on using a single mesh with multiple levels of detail stored in the mesh file. The explicit system is based on using a LodManager component to specify the different levels of detail as child models.

​Qt Quick 3D提供了一个自动和明确的细节系统。自动系统基于使用单个网格,网格文件中存储了多个细节级别。显式系统基于使用LodManager组件将不同级别的细节指定为子模型。

Automatic Level of Detail

自动细节级别

The primary way to use the the automatic level of detail support is by importing content with the Balsam Asset Import Tool. By using the flag --generateMeshLevelsOfDetail when importing assets, the tool will generate levels of detail for each mesh when possible. This is done by trying to simplify the geometry of the original mesh, while still maintaining the overall features. What results is additional geometry as well as new index values for each additional level of detail, as well as a distance factor used to determine which mesh to use for a given render size. This distance factor is related to the distance of the object being rendered to the camera, but the most important thing is having a good ratio of geometry per pixel. This data is written to the .mesh file and will be used automatically when used by a Model.

​使用自动细节级别支持的主要方法是使用Balsam Asset Import Tool导入内容。通过在导入资源时使用标记--generateMeshLevelsOfDetail,该工具将在可能的情况下为每个网格生成细节级别。这是通过尝试简化原始网格的几何图形来实现的,同时仍然保持整体特征。结果是额外的几何体以及每个额外细节级别的新索引值,以及用于确定给定渲染大小使用哪个网格的距离因子。这个距离因子与渲染对象到相机的距离有关,但最重要的是每像素的几何体比例要好。此数据将写入.mesh文件,并在模型使用时自动使用。

A tradeoff to the automatic system, and the reason why it is not enabled by default is that it is possible that when the geometry is reduced, visual artifacts can also be introduced. The geometry simplification algorithm used attempts to preserve the features of the model, but in some cases it may be necessary to recalculate the normals of the mesh to maintain the intended visual appearance. This can be done by using the --recalculateLodNormals flag when importing the asset. The normal recalculation process can be further tuned by passing euler angle values to the arguments --recalculateLodNormalsMergeAngle and --recalculateLodNormalsSplitAngle to control the angle at which normals are merged or split respectively.

与自动系统的权衡,以及默认情况下不启用它的原因是,当几何图形减少时,也可能引入视觉伪影。所使用的几何简化算法试图保留模型的特征,但在某些情况下,可能需要重新计算网格的法线以保持预期的视觉外观。这可以通过在导入资源时使用--recalculateLodNormals标志来完成。通过将欧拉角值传递给参数-recalculateLodNormalsMergeAngle和-recalculated LodNormals SplitAngle,可以进一步调整正常的重新计算过程,以分别控制法线合并或分割的角度。

The main advantage of the automatic system is that it is easy to use once the asset has been imported with the appropriate settings. No additional code is required to use the automatic system and any Models that reference the generated mesh files containing levels of detail geometry will automatically choose the appropriate geometry based on how many pixels the model takes up on the screen.

自动系统的主要优点是,一旦使用适当的设置导入资产,就很容易使用。使用自动系统不需要额外的代码,任何引用包含详细几何图形级别的生成网格文件的模型都会根据模型在屏幕上占据的像素数自动选择合适的几何图形。

It is possible to tweak automatic level of detail selection behavior either at the global level or at the per-model level by using the levelOfDetailBias property of either Camera or Model. The default level of 1.0 of each of these bias properties means to trust the value calculated by the automatic system. This value is a bias to the ideal value such that a value smaller than 1.0 will require an even smaller rendered size before switching to a lesser level of detail. Values above 1.0 will lead to lower levels of detail being used sooner. A value of 0.0 will disable the usage of levels of detail completely and always use the original mesh geometry.

​通过使用Camera或model的levelOfDetailBias属性,可以在全局级别或每个模型级别调整自动细节选择行为。每个偏差属性的默认级别为1.0,表示信任自动系统计算的值。此值与理想值存在偏差,因此小于1.0的值在切换到较低级别的细节之前需要更小的渲染大小。高于1.0的值将导致更快地使用较低级别的细节。值为0.0将完全禁用细节级别的使用,并始终使用原始网格几何体。

The automatic system is not as flexible as the explicit system. For example the automatic system always uses the same material for all levels of detail, which may not always be desirable. Another potential downside is that there is not transition between the different levels of detail which ideally should not be necessary with automatic level of detail, but may be desireable for certain use cases.

自动系统不如显式系统灵活。例如,自动系统总是对所有细节级别使用相同的材料,这可能并不总是可取的。另一个潜在的缺点是,不同细节级别之间没有过渡,理想情况下,自动细节级别不需要过渡,但对于某些用例来说可能是可取的。

Explicit Level of Detail

明确的细节层次

The Explicit level of detail system is more flexible than the automatic system, but requires more work to use. The explicit system is based on using a LodManager component to specify the different levels of detail as child Model components. Any children of the LodManager that are instances of Model will be considered a level of detail. This is quite powerful because each level of detail can be a completely custom model, with it's own geometries and materials.

​显式细节级别系统比自动系统更灵活,但需要更多的工作来使用。显式系统基于使用LodManager组件将不同级别的细节指定为子模型组件。LodManager的任何子对象,只要是Model的实例,都将被视为一个细节级别。这非常强大,因为每个细节级别都可以是一个完全自定义的模型,具有自己的几何形状和材料。

The LodManager component also has a distances property which is used to determine which child Model to use. The LodManager node will transition to the next child Model as the camera distance approach each distance boundary. The fadeDistance property can be used to set at which distance the cross fade transition begins and ends around the distances boundaries.

​LodManager组件还有一个距离属性,用于确定使用哪个子模型。当相机距离接近每个距离边界时,LodManager节点将转换到下一个子模型。fadeDistance属性可用于设置交叉淡入淡出过渡在距离边界周围开始和结束的距离。

This is an example of how to use the explicit level of detail system:

​这是一个如何使用显式细节级别系统的示例:

In the referenced example the LodManager is used to explicitly specify different mesh files for each level of detail of the marble bust.

​在引用的示例中,LodManager用于为大理石半身像的每个细节级别明确指定不同的网格文件。

LodManager {
    camera: camera
    distances: [100, 140, 180]
    fadeDistance: 10

    Model {
        scale: Qt.vector3d(100, 100, 100);
        source: "meshes/marble_bust_01_LOD_0.mesh"
        materials: [ marbleMaterial ]
    }

    Model {
        scale: Qt.vector3d(100, 100, 100);
        source: "meshes/marble_bust_01_LOD_1.mesh"
        materials: [ marbleMaterial ]
    }

    Model {
        scale: Qt.vector3d(100, 100, 100);
        source: "meshes/marble_bust_01_LOD_2.mesh"
        materials: [ marbleMaterial ]
    }

    Model {
        scale: Qt.vector3d(100, 100, 100);
        source: "meshes/marble_bust_01_LOD_3.mesh"
        materials: [ marbleMaterial ]
    }
}

For this code this is a diagram of what is being defined which points out how the distances list is used to define where the boundaries between the different levels of detail as well as the fadeDistance property which is used to define the cross fade transition.

对于这段代码,这是一个定义内容的图表,指出了如何使用距离列表来定义不同细节级别之间的边界,以及用于定义交叉淡入淡出过渡的fadeDistance属性。

Instanced RenderingCustom Material Editor

© 2024 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、付费专栏及课程。

余额充值