热门标签 | 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:
夸大的形状有助于克服这一问题。例如,将角色上的手变大,以便在小屏幕上更容易看到它们。 

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


推荐阅读
  • 本文分享了一个关于在C#中使用异步代码的问题,作者在控制台中运行时代码正常工作,但在Windows窗体中却无法正常工作。作者尝试搜索局域网上的主机,但在窗体中计数器没有减少。文章提供了相关的代码和解决思路。 ... [详细]
  • Iamtryingtomakeaclassthatwillreadatextfileofnamesintoanarray,thenreturnthatarra ... [详细]
  • Java序列化对象传给PHP的方法及原理解析
    本文介绍了Java序列化对象传给PHP的方法及原理,包括Java对象传递的方式、序列化的方式、PHP中的序列化用法介绍、Java是否能反序列化PHP的数据、Java序列化的原理以及解决Java序列化中的问题。同时还解释了序列化的概念和作用,以及代码执行序列化所需要的权限。最后指出,序列化会将对象实例的所有字段都进行序列化,使得数据能够被表示为实例的序列化数据,但只有能够解释该格式的代码才能够确定数据的内容。 ... [详细]
  • baresip android编译、运行教程1语音通话
    本文介绍了如何在安卓平台上编译和运行baresip android,包括下载相关的sdk和ndk,修改ndk路径和输出目录,以及创建一个c++的安卓工程并将目录考到cpp下。详细步骤可参考给出的链接和文档。 ... [详细]
  • 拥抱Android Design Support Library新变化(导航视图、悬浮ActionBar)
    转载请注明明桑AndroidAndroid5.0Loollipop作为Android最重要的版本之一,为我们带来了全新的界面风格和设计语言。看起来很受欢迎࿰ ... [详细]
  • WhenIusepythontoapplythepymysqlmoduletoaddafieldtoatableinthemysqldatabase,itdo ... [详细]
  • 本文由编程笔记#小编为大家整理,主要介绍了logistic回归(线性和非线性)相关的知识,包括线性logistic回归的代码和数据集的分布情况。希望对你有一定的参考价值。 ... [详细]
  • 本文讨论了如何优化解决hdu 1003 java题目的动态规划方法,通过分析加法规则和最大和的性质,提出了一种优化的思路。具体方法是,当从1加到n为负时,即sum(1,n)sum(n,s),可以继续加法计算。同时,还考虑了两种特殊情况:都是负数的情况和有0的情况。最后,通过使用Scanner类来获取输入数据。 ... [详细]
  • 本文介绍了OC学习笔记中的@property和@synthesize,包括属性的定义和合成的使用方法。通过示例代码详细讲解了@property和@synthesize的作用和用法。 ... [详细]
  • 本文讨论了一个关于cuowu类的问题,作者在使用cuowu类时遇到了错误提示和使用AdjustmentListener的问题。文章提供了16个解决方案,并给出了两个可能导致错误的原因。 ... [详细]
  • 不同优化算法的比较分析及实验验证
    本文介绍了神经网络优化中常用的优化方法,包括学习率调整和梯度估计修正,并通过实验验证了不同优化算法的效果。实验结果表明,Adam算法在综合考虑学习率调整和梯度估计修正方面表现较好。该研究对于优化神经网络的训练过程具有指导意义。 ... [详细]
  • Android JSON基础,音视频开发进阶指南目录
    Array里面的对象数据是有序的,json字符串最外层是方括号的,方括号:[]解析jsonArray代码try{json字符串最外层是 ... [详细]
  • 自动轮播,反转播放的ViewPagerAdapter的使用方法和效果展示
    本文介绍了如何使用自动轮播、反转播放的ViewPagerAdapter,并展示了其效果。该ViewPagerAdapter支持无限循环、触摸暂停、切换缩放等功能。同时提供了使用GIF.gif的示例和github地址。通过LoopFragmentPagerAdapter类的getActualCount、getActualItem和getActualPagerTitle方法可以实现自定义的循环效果和标题展示。 ... [详细]
  • CF:3D City Model(小思维)问题解析和代码实现
    本文通过解析CF:3D City Model问题,介绍了问题的背景和要求,并给出了相应的代码实现。该问题涉及到在一个矩形的网格上建造城市的情景,每个网格单元可以作为建筑的基础,建筑由多个立方体叠加而成。文章详细讲解了问题的解决思路,并给出了相应的代码实现供读者参考。 ... [详细]
  • 本文详细介绍了Java中vector的使用方法和相关知识,包括vector类的功能、构造方法和使用注意事项。通过使用vector类,可以方便地实现动态数组的功能,并且可以随意插入不同类型的对象,进行查找、插入和删除操作。这篇文章对于需要频繁进行查找、插入和删除操作的情况下,使用vector类是一个很好的选择。 ... [详细]
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社区 版权所有