This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
基础
专业(SIM)
UnigineEditor
界面概述
资源工作流程
Version Control
设置和首选项
项目开发
调整节点参数
Setting Up Materials
设置属性
照明
Sandworm
使用编辑器工具执行特定任务
如何擴展編輯器功能
嵌入式节点类型
Nodes
Objects
Effects
Decals
光源
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
使用范例
C++
C#
UnigineScript
统一的Unigine着色器语言 UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
材质和着色器
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
Animations-Related Classes
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
VR-Related Classes
创建内容
内容优化
材质
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials

异步数据流

Data streaming is an optimization technique intended to reduce spikes caused by loading graphic resources and compiling shaders. With this technique, not all the data is loaded into memory at once. Instead, only the required data is loaded, and the rest is loaded progressively on demand.数据流是一种优化技术,旨在减少加载图形资源引起的峰值。使用这种技术,并不是所有的数据都一次加载到内存中。相反,只加载所需的数据,其余的根据需要逐步加载。

Resource loading is performed and transferred to the GPU in separate asynchronous threads. After that, resources are synchronized and added to the virtual scene on the CPU side.在单独的异步线程中执行资源加载并将其传输到GPU。之后,资源被同步并添加到CPU侧的虚拟场景中。

The output of the Microprofile tool.Microprofile工具的输出

In UNIGINE, asynchronous data streaming is enabled by default. You can disable asynchronous data streaming in UnigineEditor or via the console:在UNIGINE中,异步数据流是默认启用的。您可以在UnigineEditor或通过控制台禁用异步数据流:

  • In UnigineEditor, open the Settings window and go to the Streaming section. Here you can switch the streaming mode for textures and/or meshes.在UnigineEditor中,打开Settings窗口并转到Streaming部分。在这里您可以为纹理和/或网格切换流模式。
  • In the console, run the corresponding commands that switch the streaming mode for textures and/or meshes.在控制台中,运行相应的命令,切换纹理和/或网格的流模式。

There are two main streaming modes — asynchronous (Async) and forced (Force). The Force mode ensures force-loading of all resources required for each frame simultaneously (e.g., grabbing frame sequences, rendering node previews, warmup, etc.).有两种主要的流模式:异步(Async)和强制(Force)。Force模式确保同时加载每帧所需的所有资源(例如,抓取帧序列,渲染节点预览,预热等)。

注意
The Force mode may cause freezes, so use it only if you are sure that the resources in your world fit into the available memory.Force模式可能会导致死机,所以只有在您确信您的世界中的图形资源适合可用的视频内存时才使用它。

The streaming system provides asynchronous loading of the following data to RAM:流系统提供以下数据异步加载到RAM:

Procedurally generated objects such as ObjectMeshClutter are generated in a separate thread, significantly reducing performance costs.过程生成的对象,如ObjectMeshClutter是在一个单独的线程中生成的,这大大降低了性能成本。

You can obtain general information on streamed resources by using the render_streaming_meshes_info and render_streaming_textures_info console commands.可以通过使用render_streaming_meshes_inforender_streaming_textures_info控制台命令获取流资源的一般信息。

The render_streaming_meshes_info output.render_streaming_meshes_info输出

It is also possible to print the list of loaded resources and detailed information on them by using the render_streaming_meshes_list and render_streaming_textures_list console commands.还可以通过使用render_streaming_meshes_listrender_streaming_textures_list控制台命令输出已加载资源的列表和有关它们的详细信息。

The render_streaming_meshes_list output.render_streaming_meshes_list输出

Asynchronous Shader Compilation
异步着色器编译#

In addition to the asynchronous loading of meshes and textures, the streaming system provides asynchronous shader compilation and loading.除了网格和纹理的异步加载之外,流系统还提供了异步着色器编译和加载

There are also 2 modes — asynchronous (Async) and forced (Force). In the Force mode, all shaders required for the current frame are compiled and loaded to RAM simultaneously in the current thread. By default, the asynchronous mode is used.也有2种模式:异步(Async)和强制(Force)。 在强制模式下,当前帧所需的所有着色器都在当前线程中同时编译并加载到RAM中。 默认情况下,使用异步模式。

注意
You can switch the compilation mode in UnigineEditor or by using the render_shaders_compile_mode console command.您可以在UnigineEditor中或使用render_shaders_compile_mode控制台命令切换编译模式。

The number of compiled and loaded shaders are available in the Performance Profiler tool.编译和加载的着色器的数量在Performance Profiler工具中可用。

Memory Usage Limits
内存使用限制#

All memory allocations for graphic resources are limited by the committed memory size, which includes both RAM and VRAM.图形资源的所有内存分配都受提交内存大小的限制,其中包括RAM和VRAM。

You can limit the memory available to the application to avoid crashes and find the balance between performance and memory consumption. There are two main parameters for this:您可以限制应用程序可用的内存,以避免崩溃,并在性能和内存消耗之间找到平衡。这里有两个主要参数:

  • Usage limits for RAM and VRAM that restrict memory consumption to a specified percentage of the committed memory. However, you should remember that if the streaming system exceeds the VRAM usage limit, it will start using RAM for loading graphic resources. If it exceeds the RAM usage limit, the application will crash.RAM和VRAM的使用限制,将内存消耗限制在已提交内存的指定百分比内。但是,您应该记住,如果流媒体系统超过了VRAM使用限制,它将开始使用RAM加载图形资源。如果超过RAM使用限制,应用程序将崩溃。
  • Free space for RAM and VRAM that defines how much memory is additionally reserved for allocations per frame. These parameters ensure that there is always enough memory for resource loading in the current frame. The values should be determined empirically, depending on the application.RAM和VRAM的空闲空间,它定义了每帧额外为分配保留多少内存。这些参数确保在当前帧中总是有足够的内存来加载资源。这些值应该根据应用程序的实际情况来确定。
注意
You can disable VRAM limits if necessary by toggling on the VRAM overcommit option. It may lead to spikes and freezes of the application but will ensure continuous loading of graphic resources. This option is unavailable for RAM, as exceeding available RAM will result in the application crash.如果需要,您可以通过切换VRAM overcommit选项来禁用VRAM限制。 它可能会导致应用程序的峰值和冻结,但会确保图形资源的持续加载。 此选项对于RAM不可用,因为超过可用RAM将导致应用程序崩溃。

You can specify the usage limits and free space via UnigineEditor or the console:您可以通过UnigineEditor或控制台指定使用限制和可用空间:

注意
For particle systems, there is a separate memory limit in percentage of the total GPU memory.对于粒子系统,在GPU总内存的百分比上有一个单独的内存限制

Texture Streaming
纹理流#

The streaming system manages textures automatically. There are two modes of texture streaming:流系统自动管理纹理。 纹理流有两种模式:

  • Asynchronous mode that provides asynchronous loading of textures.提供纹理异步加载的Asynchronous模式。
  • Forced mode for force-loading of textures required for the current frame at once.Forced模式,用于一次强制加载当前帧所需的纹理。

For texture streaming optimization, you can enable texture mipmap loading, which significantly improves performance by reducing the memory consumption of texture streaming. This feature allows for the correct mipmap to be loaded at the current moment. When mipmaps loading is enabled, the textures that are not currently in use are unloaded.对于纹理流优化,您可以启用纹理mipmap加载,这通过减少纹理流的内存消耗来显着提高性能。 此功能允许在当前时刻加载正确的mipmap。 启用mipmaps加载后,将卸载当前未使用的纹理。

To enable and configure mipmaps loading via UnigineEditor, do the following:要通过UnigineEditor启用和配置mipmap加载,请执行以下操作:

  1. Open the Settings window and go to the Streaming section.打开Settings窗口并转到Streaming部分。
  2. Toggle on the Mipmaps flag and specify the required Mipmaps Density.切换Mipmaps标志并指定所需的Mipmaps Density
注意
You can do the same via the console using the render_streaming_textures_mipmaps and render_streaming_textures_mipmaps_density commands.您可以通过控制台使用render_streaming_textures_mipmapsrender_streaming_textures_mipmaps_density命令执行相同的操作。

Mipmaps Density sets the density of mipmaps relative to the screen resolution and helps to define which mipmap should be loaded at the current moment. You can specify different values for different quality presets. For example, you can set the density to less than 1 for the low-quality preset. In this case, the engine will load the low-resolution mipmaps, and the textures will look blurry.Mipmaps Density设置相对于屏幕分辨率的mipmap的密度,并帮助定义当前应该加载哪个mipmap。您可以为不同的质量预设指定不同的值。例如,对于低质量预设,可以将密度设置为小于1。在这种情况下,引擎将加载低分辨率的mipmaps,纹理将看起来模糊。

Additionally, you may need to configure the Texture Streaming Density Multiplier for each texture in some materials to achieve the desired visual effect.此外,您可能需要为某些材质中的每个纹理配置Texture Streaming Density Multiplier以实现所需的视觉效果。

Forced Streaming for Textures in Post-Effect Materials
后效材质中纹理的强制流式处理#

To ensure all textures for your post-effects are available when needed, the forced streaming mode is set for all post materials by default. You can find this setting in Material Editor.为了确保所有后期效果的纹理在需要时可用,默认情况下为所有后期材质设置强制流模式。您可以在Material Editor中找到这个设置。

However, if some textures in the post material continuously change (via code, Tracker, etc.), it is recommended to specify the forced streaming mode per texture:但是,如果后期素材中的一些纹理持续变化(通过代码、Tracker等),建议为每个纹理指定强制流模式:

  1. In the Material Editor, set Setting For Each Texture in the Textures Streaming Mode parameter for your post-effect material.Material Editor中,在后期效果材质的Textures Streaming Mode参数中设置Setting For Each Texture
  2. Toggle the forced streaming on and off for each texture individually in the Parameters panel of the Material Editor.在材质Material Editor的Parameters面板中单独切换每个纹理的强制流。

These settings override the global texture streaming settings specified in the Settings window.这些设置覆盖了在Settings窗口中指定的全局纹理流设置。

Mesh Streaming
网流#

Meshes can be loaded to RAM and VRAM separately for more efficient work with geometry. This allows eliminating memory leaks: meshes participating in collisions and intersections can be loaded to RAM only, if they are not currently rendered.网格可以分别加载到RAM和VRAM中,以便更有效地处理几何图形。这允许消除内存泄漏:参与碰撞和交叉点的网格只能加载到RAM中,如果它们当前没有渲染。

There are two modes of mesh streaming to RAM/VRAM:有两种模式的网格流到RAM/VRAM:

  • Asynchronous mode that provides asynchronous loading of meshes.异步模式,提供网格的异步加载。
  • Forced mode for force-loading of meshes required for the current frame at once.强制模式,用于立即加载当前框架所需的网格。

The asynchronous loading to RAM and VRAM differs. Even if a mesh hasn't been loaded to video memory in time, it doesn't affect the application behavior (you may only notice some lag). However, if a mesh hasn't been loaded to memory in time, it may lead to incorrect physical behavior of objects in the scene.异步加载到RAM和VRAM是不同的。即使网格没有及时加载到显存,它也不会影响应用程序的行为(您可能只会注意到一些延迟)。但是,如果网格没有及时加载到内存中,可能会导致场景中对象的物理行为不正确。

First of all, we highly recommend you to use shapes for collision and intersection detection as it is faster. If, for some reason, it doesn't suit you, use the following methods:首先,我们强烈建议您使用形状进行碰撞和交叉检测,因为它更快。如果由于某种原因,它不适合您的项目,请使用以下方法:

  • Load meshes and hold them in memory while they exist. API of some mesh-based objects provides this functionality out of the box. It may partially solve the problem with incorrect behavior, however, only a few meshes can remain loaded.加载网格并在它们存在时将它们保存在内存中。一些基于网格的对象的API提供了开箱即用的功能。它可以部分解决不正确行为的问题,然而,只有少数网格可以保持加载。
  • Use the prefetch system that allows asynchronous pre-loading of meshes participating in collisions and intersections to memory before they are used:使用预取系统,允许在使用之前异步预加载参与碰撞和交叉点的网格到内存:

    1. Set the Radius prefetch mode.设置Radius预取模式。
    2. Specify the physics radius (for collisions) and/or the radius within which intersections are calculated.指定物理半径(碰撞)和/或计算交集的半径。
    3. Specify the prefetch radius that should exceed the collison and intersection radius values.指定应该超过碰撞和交叉半径值的预取半径。

    You can also preload all meshes for which collisions and intersections are calculated (the Full prefetch mode), however it will significantly increase RAM usage.您也可以预加载计算碰撞和交叉的所有网格(Full预取模式),但是这会显著增加RAM的使用。

  • API of some mesh-based objects, as well as the MeshRender class API provides also methods which allow implementing a custom prefetch logic for pre-loading meshes.一些基于网格对象的API,以及MeshRender类API也提供了允许实现预加载网格的自定义预取逻辑的方法。
注意
It is highly recommended to use shapes for collision and intersection detection.强烈建议使用形状进行碰撞和交叉检测。

Asynchronously streamed meshes shouldn't be modified. The only way to change such mesh is to make it procedural. A procedural mesh is a mesh created via code, such meshes have a specific streaming mode — they are always kept in memory after creation and never unloaded until the object is destroyed via code or the mesh returns to its normal mode (streaming from a source file). The mesh-based objects API allows switching a mesh to the procedural mode and apply changes.异步流网格不应该被修改。改变这种网格的唯一方法是使其程序化。过程网格是通过代码创建的网格,这样的网格有一个特定的流模式:它总是在创建后保存在内存中,并且永远不会卸载,直到对象被代码破坏或网格返回到其正常模式(从源文件流)。基于网格的对象API允许将网格切换到过程模式并应用更改。

最新更新: 2024-09-16
Build: ()