内容处理优化
So, the above are the basic optimization techniques available in UNIGINE.因此,以上便是UNIGINE中可用的基础优化技术。
However, the optimization process is not limited to these tools. In most cases, it starts at the stage of importing your content into the project. In addition, most objects have a set of parameters that allow you to control their impact on performance.然而,优化过程并不局限于这些工具。在大多数情况下,它始于将您的内容导入项目的阶段。此外,大多数对象都有一组参数,可用于控制它们对性能的影响。
We'd like to share some recommendations on working with content that will help you keep your application's performance at a high level. 我们想分享一些关于处理内容的建议,这些建议将帮助您保持应用程序的高性能水平。
Geometry几何体#
We have already mentioned that geometry is the main part of a virtual scene that significantly affects performance, and UNIGINE has enough tools to optimize it. But to achieve maximum efficiency when using these tools, you should also follow these rules:我们已经提到,几何体是虚拟场景中显著影响性能的主要部分,而UNIGINE提供了足够的工具来优化它。但为了在使用这些工具时达到最高效率,您还应遵循以下规则:
- Try to create LODs as separate surfaces of one mesh. This way you will reduce the number of nodes in the hierarchy and simplify configuring the LODs visibility.尽量将LOD创建为单一网格的独立表面。这样可以减少层级结构中的节点数量,并简化LOD可见性的配置。
- The number of polygons in neighboring LODs should differ by 2-3 times at least.相邻LOD的多边形数量应至少相差2-3倍。
- The optimal number of LODs is 2 or 3. Using more levels of detail in most cases will only create an additional CPU load.LOD的最佳数量是2或3级。在大多数情况下,使用更多细节层级只会增加额外的CPU负载。
- Avoid using occluders with large objects that have multiple surfaces, as well as in scenes with flat objects, as this can lead to a performance drop instead.避免对具有多个表面的大型物体使用遮挡物,同时在包含平坦物体的场景中也应谨慎,因为这可能导致性能下降而非提升。
- Export models from a 3D editor in local coordinates, so that the size of the mesh bounding box is as close as possible to the size of the mesh itself. This will provide a more accurate occlusion culling.从3D编辑器中导出模型时使用局部坐标,使网格包围盒的尺寸(其bounding box)尽可能接近网格本身。这将提供更精确的遮挡剔除效果。
Terrain, Grass, Water and Cloud Layer地形、草地、水体与云层#
As you know, besides being imported from other 3D editors, geometry can be created directly in UnigineEditor using the built-in tools. The most performance-consuming objects created in this way are Terrain, Grass, Water and Cloud Layer. They have a set of parameters (both global and local for each object) that are designed to optimize the rendering.众所周知,除了从其他3D编辑器导入外,几何体还可以直接通过UnigineEditor的内置工具创建。以这种方式创建的性能消耗最大的对象包括Terrain、Grass、 Water与Cloud Layer。它们拥有一系列参数(既有全局参数,也有针对每个对象的局部参数),专门用于优化渲染效果。
Textures纹理#
As a rule, in any project a 3D model has several textures assigned for various purposes, consuming quite a lot of memory. The following techniques can help you reduce their impact on performance:通常情况下,任何项目中的3D模型都会包含用于不同目的的多张纹理,这会消耗相当多的内存。以下技术可以帮助您减少纹理对性能的影响:
- Try to use smaller textures wherever possible, but always check that the visual performance hasn't degraded.尽量使用较小尺寸的纹理,但需确保视觉效果不受影响。
- Configure the global texture settings: set the optimal Quality and Maximum Resolution values for all textures in the project to reduce the amount of GPU memory consumption.配置全局纹理设置:为所有纹理设置合理的Quality和Maximum Resolution值以降低GPU内存占用。
- Use asynchronous streaming of graphics resources to load textures smoothly. Try not to set a low Textures Memory Limit to avoid re-uploading them from disk.启用异步流式加载实现纹理平滑加载。避免设置过低的Textures Memory Limit以防止重复从磁盘加载。
- When importing textures, enable the Unchanged flag only for *.dds or *.texture textures, and for your custom textures (e.g. HDR) that should not be compressed.导入纹理时:仅对*.dds或*.texture格式及自定义纹理(如HDR)启用Unchanged标记。
- Choose the appropriate Texture Preset when importing the texture, or customize your own. This will allow you to apply the correct compression to the texture and avoid creating unused texture channels.选择合适纹理预设(Texture Preset)或自定义预设,确保正确压缩纹理并避免生成无用通道。
- Use texture channels to store multiple textures in a single texture.利用纹理通道实现多重纹理存储。
Decals贴花#
Decals are usually used to add extra detail to objects in a scene. Each decal has settings that may contribute to performance optimization:贴花通常用于为场景中的对象添加额外细节。每个贴花都有一些可帮助优化性能的设置:
- Configure the decal visibility distances (Min/Max Visibility, Min/Max Fade).配置可见距离参数(Min/Max Visibility, Min/Max Fade)。
- Use the Viewport bit mask to control the decals visibility.使用Viewport位掩码控制贴花可见性。
Particle System粒子系统#
If you use particle systems in your scene, you can reduce the frame refresh rate for their simulation to improve performance. This can be done using the Periodic Update section parameters in the Particle System settings.如果在场景中使用粒子系统,您可以降低其模拟的帧刷新率以提高性能。这可以通过粒子系统设置中的"周期性更新"(Periodic Update)部分参数来实现。
Here you can also specify the distance at which the particles stop updating and freeze (the Update Distance Limit parameter), as well as the frequency of their updating when only the shadow of the particle system is visible in the frame or nothing is visible at all.在此处,您还可以指定粒子停止更新并冻结的距离(Update Distance Limit参数),以及当帧中仅可见粒子系统的阴影或完全不可见时的更新频率。
Lighting光照#
Lighting in a scene also requires quite a bit of resources. Each light source, depending on its type, may require up to 6 rendering passes to calculate the shadows cast by the objects it illuminates. The individual settings of each source can also affect performance.场景中的光照也需要相当多的资源。每个光源根据其类型,可能需要多达6个渲染通道来计算其照射物体投射的阴影。每个光源的单独设置也会影响性能。
You can apply any of these methods to optimize the rendering of light sources:您可以应用以下任何方法来优化光源的渲染:
- Disable shadow rendering for some illuminated surfaces and materials. For example, you can do this for the farthest LOD surface (where shadows are not important).禁用某些被照射表面和材质的阴影渲染。例如,可以为最远的LOD表面(阴影不重要的地方)这样做。
- Use static lighting and shadows for immovable objects instead of dynamic lighting.对不可移动的物体使用静态光照和阴影,而不是动态光照。
- Use Shadow Mask to control the rendering of shadows from lit objects.使用阴影遮罩(Shadow Mask)来控制被照射物体阴影的渲染。
- Use Screen Space Shadows instead of Shadow maps at long distances, since screen-space effects depend on screen resolution rather than geometry: the higher the resolution, the more accurate the shadows.在远距离使用屏幕空间阴影(Screen Space Shadows)替代阴影贴图(Shadow maps),因为屏幕空间效果依赖于屏幕分辨率而非几何体:分辨率越高,阴影越精确。
- Reduce the size of the light source.减小光源的尺寸。
- Enable Interlaced rendering of light sources.启用光源的交错渲染(Interlaced)。
- Configure the distance at which light sources and shadows are rendered.配置光源和阴影的渲染距离。
- Use as few light sources that affect transparent objects as possible.尽可能减少影响透明物体的光源数量。
- Disable rendering of light sources on water.禁用在水体上的光源渲染。
- Use as few World Lights as possible.尽可能少使用世界光源(World Lights)。
- Reduce the number of cascades for World Lights.减少世界光源的级联数量(number of cascades)。
- Use Point-shaped Omni Light sources and disable shadow rendering for surfaces illuminated by such sources. Since the UNIGINE engine uses tile-based rendering, these light sources will be grouped and rendered in the batched mode. Batch rendering settings are available in the Settings window (Lights -> Batching).使用点形状的全向光源(Point-shaped Omni Light)并禁用被此类光源照射表面的阴影渲染。由于UNIGINE引擎使用基于瓦片的渲染,这些光源将被分组并以批处理模式渲染。批处理渲染设置可在设置窗口中找到(Lights -> Batching)。
- Create fake lighting: use Billboards and Volumetric objects instead of real light sources.创建伪光照:使用公告板(Billboards)和体积对象(Volumetric objects)替代真实光源。
Physics物理#
To optimize the modeling of physical phenomena and interactions, we recommend the following:为了优化物理现象和相互作用的模拟,我们建议:
- Configure the global physics settings: adjust the distance from the camera within which the physical interaction of objects takes place, specify the optimal number of computational iterations per one frame (for example, for simple scenes, one computational iteration is enough), and select a suitable time budget within which the physical calculations take place in the current frame (if the physical interactions look like slow motion, the time budget should be increased).配置全局物理设置:调整摄像机距离,在此范围内发生物体的物理相互作用;指定每帧的最佳计算迭代次数(例如,对于简单场景,一次计算迭代就足够了);在当前帧中选择合适的物理计算时间预算(如果物理交互看起来像慢动作,则应增加时间预算)。
- Use bit masks to fine-tune physical interactions between objects. For example, you can limit object collisions by using the Collision Mask.使用位掩码来微调物体间的物理交互。例如,您可以使用碰撞遮罩(Collision Mask)来限制物体碰撞。
- Use a simplified geometry for Collision Shapes used in collision detection. For example, you can use the least detailed LOD or just a primitive.在碰撞检测中使用简化的几何体作为碰撞形状。例如,可以使用最不详细的LOD或基本几何体。
- Try to use as few Collision Shapes for a single object as possible.尽量为一个物体使用尽可能少的碰撞形状。
- Use discrete collision detection wherever possible.尽可能使用离散碰撞检测。
- Enable the Freezing option for Rigid, Ragdoll, and Fracture bodies to stop physics calculations when no external force is affecting the body.为刚体(Rigid)、布娃娃(Ragdoll)和破碎体(Fracture)启用冻结选项(Freezing),以在不受外力影响时停止物理计算。
Adjust the amount of pieces for Fracture bodies, as too many pieces can reduce performance.调整破碎体(Fracture)的碎片数量,因为过多的碎片会降低性能。
本页面上的信息适用于 UNIGINE 2.20 SDK.