热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

3D美术实时渲染最佳实践(5):Mesh

5.2-Triangleandpolygonusage原文档:ArmGuide开发人员指南V4.1–移动平台游戏图形优化Tooptimizetheperforma

5.2-Triangle and polygon usage

原文档:Arm® Guide开发人员指南 V4.1 – 移动平台游戏图形优化

To optimize the performance of your game, always track the number of triangles that are on-screen.


It is vital that you use the minimum number of triangles to get the correct balance between the intended quality with your 3D objects, or models, and deliver a consistent performance.


We recommend that you try the following tips:


• Using fewer triangles results in increased performance.


— It is essential to keep the triangle count in mind when creating content for a mobile platform.


— Fewer triangles means that the GPU must process fewer vertices.


— Processing vertices is computationally expensive. Therefore, the fewer the number of vertices that get processed, the better it is for overall performance.


• Using fewer triangles enables the release of the game on more devices. Not just the latest devices that have the most powerful GPUs.


The following image shows a comparison between two 3D objects. One using 584 triangles, versus one using 704 triangles. Both objects look the same in shaded mode. So remove any edges that do not contribute to the silhouette:

Figure 5-2 Use the minimum number of triangles to get the intended result

On mobile devices, the maximum number of vertices that each 3D object, or mesh, can use is 65,535.

在移动设备上,每个3D对象或网格可以使用的最大顶点数为65,535


Therefore, you must stay below this number. Some older GPUs, including Android devices using the Mali-400, do not support more. These devices do not render 3D objects with more vertices.


It is essential to view or test the game on the target device, or as many target devices as possible. Testing your game on just a computer screen does not give you the information you need for optimization.


Keep in mind that mobile device screens are smaller than the average computer monitor. Therefore, any details that are created using lots of triangles may not even be visible on a mobile device.


Use more triangles on 3D objects that are in the foreground, so closer to the camera, and less on 3D objects that are further away in the background. A game that is using a static camera Point-of-View (POV) benefits more from this technique.


The following image shows an example of where 3D models are used in the foreground, but lower quality 3D models are baked into the 2D background

Figure 5-3 An example of triangle usage on foreground and background objects

While there are no fixed numbers for the maximum triangle count that a 3D object can use, the more 3D objects that are on-screen at the same time, the fewer triangles you can use per-object. However, if you are displaying fewer 3D objects on-screen, then you can use more triangles.


The target device also matters. Newer phones, such as the latest Samsung Galaxy S series, are able to handle more complex geometry that older mobile devices.


The following example shows characters from two demos. The Circuit VR demo only has one robot character, so a model with a higher polygon count can be used. While the Armies demo has hundreds of soldiers in one frame, so it needs a tiny polygon count.

Figure 5-4 Triangle count difference example

In the Armies demo, which is a 64-bit mobile device tech demo that was built in Unity, the camera is static with lots of animated characters. Each frame renders around 210,000 triangles in total, and this triangle count enables the demo to run smoothly at approximately 30 Frames Per Second (FPS)

The number of triangles to use depends on both the type of game being created, and the specifications of the target devices The following example shows the total number of triangles that were used in our tech demo:

Figure 5-5 Total number of triangles that are used in our example scene

The largest objects in the scene, the cannon towers, are approximately 3000 triangles each as they occupy a large portion of the screen.


Characters only use around 360 triangles. This is because there are so many of them and they are only seen from a distance. So, from the camera point-of-view, the characters look fine on-screen.

Figure 5-6 Tiny triangle count on soldiers

This section contains the following subsections:
• 5.2.1 Distribute triangles in areas that matter on page 5-66.
• 5.2.2 Why micro triangles are bad on page 5-67.
• 5.2.3 Why long and thin triangles are bad on page 5-69


5.2.1-Distribute triangles in areas that matter( 在重要的区域分布三角形 )

Both polygons and vertices are computationally expensive on mobile platforms. By placing them in areas that really contribute to the visual quality of the game, we are not wasting the processing budget.
在移动平台上,使用多边形和顶点的成本较高。将它们放在真正有助于提高游戏视觉的区域中,使得我们不会浪费成本。

Due to the small screen size on most devices, and where these 3D objects are in the game level, many small triangle details on a 3D object are not visible in-game. Instead, focus on large shapes and parts that contribute to the silhouette of the object instead of detail.
移动平台上的屏幕尺寸较小,这些在游戏关卡中的3D模型,许多小的三角形细节在游戏中是不可见的。相反,应将重点放在有助于对象轮廓的大型形状和零件上,而不是细节上。

Figure 5-7 Focus on large shapes and silhouettes


Use fewer triangles on the areas that are not often shown on-screen. An example of this would be the bottom of a car, or the back of a wardrobe.
Avoid using high-density triangle meshes for modeling small details. Instead, use textures and normal maps for fine detail.
在屏幕上不常显示的区域上使用较少的三角形。如汽车的底部或衣柜的背部。避免使用高密度三角形网格为小细节建模,要使用纹理和法线贴图获得好的细节。


The following images show the same mesh with and without normal map:

没有法线和有法线的区别

Consider deleting the back, or bottom, part of an object that is never seen from the camera POV.
However, this needs to be done carefully as it might limit the re-usability of the scene. For example, you delete the bottom part of a table mesh, as you think that it is never seen by the end user. Doing this would mean that you could no longer place that model upside down or reuse it for something different.

考虑删除摄像机看不到的背或底部。 但这要小心,这可能会限制场景的可重用性。例如删除Mesh的底部,我们认为用户不会看到。这样做就不能将模型颠倒了。 

 


5.2.2-Why micro triangles are bad 为什么小三角形不好

Micro triangles are tiny triangles that do not contribute much to the final look of an object or scene.When a 3D object with a large polygon count is moved further away from the camera, a micro triangles problem occurs. A micro triangle is often referred to as triangles that are between one and ten pixels in size on a device.
小三角形比较小,对最终物体或场景的外观影响不大。当多边形数量较多的3D模型远离相机时,会出现小三角形的问题。小三角形一般在屏幕上占用1~10像素。

Micro triangles are bad because the GPU must process all of these triangles. But, they do not contribute much to the final image as they are too small to see. Remember, vertices are computationally expensive
to process, and lots of tiny triangles on-screen at the same time means more vertices to process.
小三角形很不好,因为GPU必须处理所有的小三角形。但是,由于它们太小而看不到,它们对最终表现的影响不大。谨记: 处理顶点是需要成本的,同屏显示大量的小三角形则要处理更多的顶点!


The following two approaches cause micro triangles:
以下两个方法会导致小三角形:


• Details that are too small and consist of many triangles.
细节过小,导致许多小三角形

• Objects with many triangles that are further from the camera.
摄像机较远的物体上有许多三角形

The following image shows the number of triangles that are used when a 3D object is both near the camera, and further away. The left image uses fewer triangles, and the example on the right uses a normal map instead to display the same amount of visible detail:
下图显示了当3D对象既靠近相机又远离相机时使用的三角形数量。左图使用更少的三角形,右图示例使用法线贴图显示相同数量的可见细节:

Figure 5-9 Micro triangles on an object that is far away from the camera

For the following image, most of the triangles in the highlighted area are too small to be visible on a mobile device. Therefore, they are not contributing much to the final look:
下图框中区域大部分三角形太小而无法在移动设备上看到。所以它们对最终表现没啥用。

Figure 5-10 Micro triangles up close

How to minimize this problem
如何优化

Here are a few steps that you can take to mitigate this issue:

• For an object that changes its distance from the camera, use Level of Detail (LOD). Using the correct LOD simplifies an object when it is further away, with the object using fewer triangles.
与摄像机距离之间距离会改变的模型,可使用LOD,使用正常的LOD可以简化距离较远的模型,并使用较少的三角形

• Use fewer triangles on background objects.
在背部使用较少的面

Avoid using polygons to create the finer details in a mode. Instead, use a combination of textures and a normal map instead.
避免用多边形创建精细的模型细节。要使用纹理和法线贴图替代细节

• Merge any vertices or triangles that are either too small to see on-screen, or are not adding much value to the final image.
合并小的无法在屏幕上看清的顶点或三角形,或者没有为最终表现带来加分项的顶点或者三角形

• Try to keep triangles above 10 pixels in area.
让单个三角形屏幕显示10+像素

Why minimizing the use of micro triangles is important There are several reasons as to why minimizing the use of micro triangles. These are:
优化小三角形很重要,为什么:

• The GPU must process all of the triangles, and vertices. Even when they are not adding any value to the final scene on-screen.
GPU要处理所有的三角形,即使他最终没给表现带来任何影响

• Memory bandwidth is negatively affected as more data must be sent to the GPU for processing.
消耗更大的内存带宽,需要发送更大的数据到GPU上处理(导致发热)

• The amount of processing that is required directly impacts the battery life of a mobile device.
这些处理影响电池耗电量

Therefore, the less data that the GPU must process, the longer the battery lasts.
越少的GPU数据处理量, 电池的寿命就更长


5.2.3-Why long and thin triangles are bad(为什么细长的三角形不好)

Long, thin triangles are vertices that, when rendered in the final image, are smaller than ten pixels and span along the screen. Long, thin triangles are bad because they are more expensive to process on the GPU, when compared with normal triangles.
细长的三角形指在最终渲染时顶点小于10像素,在屏幕表现上又细又长。细长三角形不好,相较于普通三角形,GPU的处理成本更高。

The following screenshot shows an example of a long, thin triangle in use. The screenshot highlights the bevel on the pillar when it is viewed from a distance. However, the bevels are not a problem when seen close-up:
以下为细长三角形的示例。从远处观看时支柱上的[斜角]。但在近距离观察时斜角不是问题

Figure 5-11 Long, thin triangle example

How to minimize this problem
怎么改善

Here are a few steps that you can take to mitigate this issue:


• Remove any long, thin triangles that you see from all objects where it is possible. While there can be situations where this is not possible, the best solution is to remove the long, thin triangles completely.
删除细长三角形,尽管在某些情况下这是不可能的。最好的方案是完全删除细长三角形

• Avoid using shiny materials on an object with long thin triangles as it causes flickering.
避免在细长三角形模型上使用亮的材质,因为它们会引起闪烁

• Use Level of Detail (LOD) and remove the long, thin triangles when they are further away on-screen.
当模型离摄像机过远时,使用LOD

• Technically, it is better to keep triangles close to equilateral. Ensure that the triangles have more inside area, when compared to the edges.
从技术上讲,最好用等边三角形,让三角形的内部区域充分地大

有关于此问题,也可以参考:
http://www.humus.name/index.php?page=News&ID=228


Smoothing groups 光滑组

Use smoothing groups, or custom vertex normals, to define the hardness of an edge and alter the look of a model. Smoothing groups helps to create better shading when the art direction intentionally uses a tiny polygon count.
使用光滑组或自定义顶点法线来展示硬边缘,改善模型外观。当美术有意使用少量多边形时,光组有助于创建更好的光影效果

Take extra care as smoothing groups affect the UV islands of a model, and also the quality of a normal map when you do baking. This is explained in further detail in our Texturing Best Practice chapter on page 6-73.
光滑组会影响模型的UV岛以及进行烘焙时法线贴图的质量时,请格外小心。在第6-73页的“纹理化最佳实践”一章中对此进行了详细说明。

If smoothing is implemented on a 3D model, then it must be exported from the 3D software and get imported into the engine.

The following image shows an example of how smoothing works when applied to an object:

使用光滑组示例

 


Mesh topology(模型拓扑)

Remember these tips when using mesh topology:
当使用Mesh Topology时:

• When creating a 3D asset, do use a reasonably tidy and clean topology.
使用合理的拓扑

• Clean topology is essential for characters, or other objects, that are deforming or animated.
清晰的拓扑对于变形或动画的角色或其他对象非常重要

• Do not be obsessed with having perfect topology on a 3D model. While not all objects need a perfect edge flow, try to keep the model tidy.
不要痴迷于在3D模型上具有完美的拓扑。尽管并非所有对象都需要完美的边缘流,但请尝试使模型保持整洁


— The player, or end user, does not see the wireframe of a 3D model.
— The texture and material that is applied to the mesh have a bigger contribution to the look of a 3D model.


The following image shows an example of a wireframe of the rock cliff mesh that uses simple geometry and topology. The rock cliff looks much better with the material that has been applied. Therefore, any issues with the topology have disappeared:


Shape exaggeration(形状放大)

Shape exaggeration is a technique where certain parts and shapes are made bigger than normal to help with readability. However, whether this is the correct approach for your game depends on the type and style of the game that you are creating.
形状放大是将某些部件做得更大,以提高表现性。(但这和游戏风格相关)

For example:

• A mobile device screen is small and it is sometimes hard to capture certain shapes when they are tiny.
移动设备的屏幕很小,很难看到小形状

Exaggerating the shape helps to overcome this. For example, make the hands on a character larger so they are more easily seen on a small screen.
The following image shows how an exaggeration in the size of a hand could look. The hand, sword, and general body proportions are all emphasized in different ways. This was done to improve the visibility, while accounting for the lower polygon count that was used:
夸大的形状有助于克服这一问题。例如,将角色上的手变大,以便在小屏幕上更容易看到它们。 

下图显示了手的夸张外观。手,剑和全身的比例都以不同的方式强调。这样做是为了提高可见性,同时考虑到所使用的较低的多边形数量


推荐阅读
  • yikesnews第11期:微软Office两个0day和一个提权0day
    点击阅读原文可点击链接根据法国大选被黑客干扰,发送了带漏洞的文档Trumps_Attack_on_Syria_English.docx而此漏洞与ESET&FireEy ... [详细]
  • YB02 防水车载GPS追踪器
    YB02防水车载GPS追踪器由Yuebiz科技有限公司设计生产,适用于车辆防盗、车队管理和实时追踪等多种场合。 ... [详细]
  • 嵌入式开发环境搭建与文件传输指南
    本文详细介绍了如何为嵌入式应用开发搭建必要的软硬件环境,并提供了通过串口和网线两种方式将文件传输到开发板的具体步骤。适合Linux开发初学者参考。 ... [详细]
  • This post discusses an issue encountered while using the @name annotation in documentation generation, specifically regarding nested class processing and unexpected output. ... [详细]
  • vivo Y5s配备了联发科Helio P65八核处理器,这款处理器采用12纳米工艺制造,具备两颗高性能Cortex-A75核心和六颗高效能Cortex-A55核心。此外,它还集成了先进的图像处理单元和语音唤醒功能,为用户提供卓越的性能体验。 ... [详细]
  • 深入解析 Android IPC 中的 Messenger 机制
    本文详细介绍了 Android 中基于消息传递的进程间通信(IPC)机制——Messenger。通过实例和源码分析,帮助开发者更好地理解和使用这一高效的通信工具。 ... [详细]
  • 探讨ChatGPT在法律和版权方面的潜在风险及影响,分析其作为内容创造工具的合法性和合规性。 ... [详细]
  • 本文深入探讨了UNIX/Linux系统中的进程间通信(IPC)机制,包括消息传递、同步和共享内存等。详细介绍了管道(Pipe)、有名管道(FIFO)、Posix和System V消息队列、互斥锁与条件变量、读写锁、信号量以及共享内存的使用方法和应用场景。 ... [详细]
  • 烤鸭|本文_Spring之Bean的生命周期详解
    烤鸭|本文_Spring之Bean的生命周期详解 ... [详细]
  • 本文介绍了如何通过ARM编译器组件重定向标准C运行时库的I/O函数,以适应不同的硬件平台。原文链接:https://www.keil.com/pack/doc/compiler/RetargetIO/html/retarget_overview.html ... [详细]
  • iTOP4412开发板QtE5.7源码编译指南
    本文详细介绍了如何在iTOP4412开发板上编译QtE5.7源码,包括所需文件的位置、编译器设置、触摸库编译以及QtE5.7的完整编译流程。 ... [详细]
  • 新手指南:在Windows 10上搭建深度学习与PyTorch开发环境
    本文详细记录了一名新手在Windows 10操作系统上搭建深度学习环境的过程,包括安装必要的软件和配置环境变量等步骤,旨在帮助同样初入该领域的读者避免常见的错误。 ... [详细]
  • NVIDIA Titan RTX深度评测
    NVIDIA的Titan RTX被誉为当前最强大的桌面显卡之一,其卓越的性能和高昂的价格吸引了众多专业人士和技术爱好者的关注。本文将详细介绍Titan RTX的技术规格、性能表现及应用场景。 ... [详细]
  • 三星Galaxy S8/S8+即将登场,全面解析新旗舰
    3月29日晚11点,备受瞩目的三星Galaxy S8/S8+将正式发布。作为三星在Note 7爆炸事件后的重磅产品,S8/S8+不仅承载着恢复消费者信心的重任,其创新的设计和技术也备受期待。 ... [详细]
  • 本文深入探讨了WebGL与Three.js在构建多样化3D场景中的应用,详细解析了两者如何协同工作以实现高性能的3D渲染,并提供了实践指南。 ... [详细]
author-avatar
俊惠芸菁亚扬
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有