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

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


推荐阅读
  • 尽管在WPF中工作了一段时间,但在菜单控件的样式设置上遇到了一些基础问题,特别是关于如何正确配置前景色和背景色。 ... [详细]
  • 长期从事ABAP开发工作的专业人士,在面对行业新趋势时,往往需要重新审视自己的发展方向。本文探讨了几位资深专家对ABAP未来走向的看法,以及开发者应如何调整技能以适应新的技术环境。 ... [详细]
  • 想把一组chara[4096]的数组拷贝到shortb[6][256]中,尝试过用循环移位的方式,还用中间变量shortc[2048]的方式。得出的结论:1.移位方式效率最低2. ... [详细]
  • 深入解析C语言中的关键字及其分类
    本文将全面介绍C语言中的关键字,并按照功能将其分为数据类型关键字、控制结构关键字、存储类别关键字和其他关键字四大类,旨在帮助读者更好地理解和运用这些基本元素。C语言中共有32个关键字。 ... [详细]
  • 处理Android EditText中数字输入与parseInt方法
    本文探讨了如何在Android应用中从EditText组件安全地获取并解析用户输入的数字,特别是用于设置端口号的情况。通过示例代码和异常处理策略,展示了有效的方法来避免因非法输入导致的应用崩溃。 ... [详细]
  • 在1995年,Simon Plouffe 发现了一种特殊的求和方法来表示某些常数。两年后,Bailey 和 Borwein 在他们的论文中发表了这一发现,这种方法被命名为 Bailey-Borwein-Plouffe (BBP) 公式。该问题要求计算圆周率 π 的第 n 个十六进制数字。 ... [详细]
  • 二维码的实现与应用
    本文介绍了二维码的基本概念、分类及其优缺点,并详细描述了如何使用Java编程语言结合第三方库(如ZXing和qrcode.jar)来实现二维码的生成与解析。 ... [详细]
  • 问题描述现在,不管开发一个多大的系统(至少我现在的部门是这样的),都会带一个日志功能;在实际开发过程中 ... [详细]
  • D17:C#设计模式之十六观察者模式(Observer Pattern)【行为型】
    一、引言今天是2017年11月份的最后一天,也就是2017年11月30日,利用今天再写一个模式,争取下个月(也就是12月份& ... [详细]
  • 在Android中实现黑客帝国风格的数字雨效果
    本文将详细介绍如何在Android平台上利用自定义View实现类似《黑客帝国》中的数字雨效果。通过实例代码,我们将探讨如何设置文字颜色、大小,以及如何控制数字下落的速度和间隔。 ... [详细]
  • 本文详细介绍如何在 Apache 中设置虚拟主机,包括基本配置和高级设置,帮助用户更好地理解和使用虚拟主机功能。 ... [详细]
  • td{border:1pxsolid#808080;}参考:和FMX相关的类(表)TFmxObjectIFreeNotification ... [详细]
  • 本文详细介绍了Oracle 11g中的创建表空间的方法,以及如何设置客户端和服务端的基本配置,包括用户管理、环境变量配置等。 ... [详细]
  • Maven + Spring + MyBatis + MySQL 环境搭建与实例解析
    本文详细介绍如何使用MySQL数据库进行环境搭建,包括创建数据库表并插入示例数据。随后,逐步指导如何配置Maven项目,整合Spring框架与MyBatis,实现高效的数据访问。 ... [详细]
  • 一、Advice执行顺序二、Advice在同一个Aspect中三、Advice在不同的Aspect中一、Advice执行顺序如果多个Advice和同一个JointPoint连接& ... [详细]
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社区 版权所有