纳金网

标题: 优化手机的实用指南 - 图形方法 [打印本页]

作者: star-小虎    时间: 2013-10-16 16:14
标题: 优化手机的实用指南 - 图形方法

What are mobile devices capable of? How should you plan your game accordingly? If your game runs slow, and the profiler indicates that it's a rendering bottleneck, how do you know what to change, and how to make your game look good but still run fast? This page is dedicated to a general and non-technical exposition of the methods. If you are looking for the specifics, see the Rendering Optimizations page.

移动设备能够做到什么?如何相应地策划你的游戏?如果游戏的运行速度慢,并且分析器表明这是一个渲染瓶颈,你如何得知要改变什么?以及如何保障你的游戏很好看的同时仍然运行得很快?此页面专门阐述一般和非技术方法。如果你正在寻找具体细节,请参阅 渲染优化页面

What you can reasonably expect to run on current consumer mobiles:
你可以合理地预期在当前消费者手机上的运行状况:

What you CANNOT reasonably expect to run on current consumer mobiles:
那些你无法合理预期在当前消费者手机上的运行(情况):
  • Fullscreen screen image effects like glow and depth of field.
    全屏屏幕效果,像发光和景深。
  • Dynamic per-pixel lighting (multiple lights marked Important and not baked into the lightmap)
    动态逐像素光照(多个灯光标记为“重要”,而不是烘焙到光照贴图)
    • Every affected object is drawn an additional time for every dynamic light you use, and this gets slow quickly.
      每个受影响的对象会由于你所使用的每个动态灯光而绘制更多的时间,这将很快变得比较缓慢。
  • Real time shadows on everything
    所有物体的实时阴影
    • Unity 4 offers native support for real time shadows on mobile platforms, but their use must be very judicious, and likely limited to higher-end devices.
      Unity 4在移动平台上为实时阴影提供了原生支持,但他们的使用必须是非常明智的,而且很可能受限于高端设备。



Examples - How top-notch mobile games are made
示例 - 如何打造一款顶尖游戏
Shadowgun 暗影之枪Shadowgun is an impressive example of what can be done on current mobile hardware. But more specifically, it's a good example of what cannot be done, and how to get around the limitations. Especially because a small part of the game has been made publicly available in this blog post.
暗影之枪是一款展现了可以在当前手机硬件做到什么程度的令人印象深刻的例子。但更确切地说,它是一款说明了什么不能做,以及如何绕开限制的较好示例。更特别的是,游戏的一小部分已经在这个 博客帖子 公之于众。
Here's a basic rundown of things that Shadowgun does in order to keep performance up:
以下是暗影之枪为了保持性能的基本纲要:
  • Dynamic lighting - barely used. 动态照明 - 几乎不用。
    • Blob shadows and Lightmaps are used instead of any real shadows.
      使用blob阴影和光照贴图,而不是任何真实的阴影。
    • Lightprobes, instead of real lights, are used on their characters.
      在角色上使用光探头,而不是真正的灯光。
      • Muzzle flashes added into the lightprobe data via script.
        通过脚本给光探针加入枪口闪烁。
    • The only dynamic per-pixel lighting is an arbitrary light direction used to calculate a BRDF on the characters.
      唯一的动态逐像素光照是一个用来计算双向反射分布函数的特征的任意光照方向。
  • Bumpmapping - barely used. 凹凸贴图 - 几乎不使用。
    • Real bumpmapping only used on characters.
      真正的凹凸贴图只有在角色上才会使用。
    • As much contrast and detail as possible is baked into the diffuse texture maps. Lighting information from bumpmaps is baked in.
      尽可能多的对比度和细节被烘焙成漫反射纹理贴图。来自凹凸贴图的照明信息被烘焙。
    • A good example is their statue texture, or their shiny wall, as seen on the right. No bumpmaps are used to render these, the specularity is faked by baking it into the texture. Lightmapping is combined with a vertex-lighting-based specular highlight to give these models a shiny look.
      有一个很好的示例就是他们的雕像质地,或是那闪亮的墙,如右图所示。没有使用凹凸贴图来渲染这些,镜面反射是通过烘焙到纹理伪造的。光照贴图结合了一个基于顶点光照的镜面高光来给这些模型一个闪亮的外观。
    • If you want to learn how to create textures like this one, check out the Rendering Optimizations page.
      如果你想学习如何创建一个像这样的纹理,查看 渲染优化页面
  • Dense particles - avoided. 密集的粒子 - 要避免。
    • UV-scrolling textures used instead of dense particle effects.
      使用UV滚动纹理来代替密集的粒子效果。
  • Fog effects - avoided. 雾化效果 - 要避免。
    • Their god rays are hand-modeled. 游戏中神的光线都是手工建模。
    • Single planes that fade in and out are used to achieve cinematic fog effects without actually rendering any fog.
      单个平面的淡入淡出可用来实现电影雾化效果,而无需实际渲染任何雾。
      • This is faster because the planes are few and far between, and it means that fog doesn't have to be calculated on every pixel and in every shader.
        这样更快,因为平面少之又少,并且这意味着雾化不需要在每个着色器的每个像素进行计算。

  • Glow - avoided. 辉光 - 要避免。
    • Blended sprite planes are used to give the appearance of a glow on certain objects.
      混合精灵平面用于给特定的平面以辉光外观。



Sky Castle Demo 天空城堡演示This demo was designed to show what Unity is capable of on high-end Android devices.
这个demo旨在展现Unity能够适用于Android高端设备。
  • Dynamic lighting - not used. 动态照明 - 不使用。
    • Lightmaps only. 仅用光照贴图。
  • Bumpmapping - used 凹凸贴图 - 使用
    • The bricks are all bumpmapped, lit by directional lightmaps. This is where the "high-end devices" part comes into play.
      砖块全部使用的是凹凸贴图,点亮由平行光照贴图实现。这里就是“高端设备”使用的地方。
  • Real time reflections - limited. 实时反射 - 有限的。
    • They carefully placed their real-time reflecting surfaces separately and in isolated areas, so that only one runs at a time, and the environment that needs to be rendered twice can be easily culled.
      它们被小心地单独摆放在它们的实时反射面,并且是在一个独立的区域,因此仅仅需要运行一次,环境需要渲染两次后就可以被轻松地拣选出来。



Bottom line - What this means for your game
底线 - 这对你的游戏而言意味着什么

The more you respect and understand the limitations of the mobile devices, the better your game will look, and the smoother it will perform. If you want to make a high-class game for mobile, you will benefit from understanding Unity's graphics pipeline and being able to write your own shaders. But if you want something to grab to use right away, ShadowGun's shaders, available here, are a good place to start.

你越尊重和理解移动设备的局限性,你的游戏会看起来很好,运行起来也会更流畅。如果你想做一款高档的手机游戏,更好地理解Unity图形渲染管线并能够编写自己的着色器会使你受益匪浅。但是,如果你想要抓住某些东西马上使用,暗影之枪的着色器在 这里 提供,这是一个好的开端。 不要模仿它,烘焙它!

Don't Simulate It, Bake It !

There is no question that games attempt to follow the laws of nature. The movement of every parabolic projectile and the color of every pixel of shiny chrome is derived by formulas first written to mimic observations of the real world. But a game is one part scientific simulation and one part painting. You can't compete in the mobile market with physically accurate rendering; the hardware simply isn't there yet, if you try to imitate the real world all the way, your game will end up limited, drab, and laggy.

毫无疑问,游戏应遵循自然规律。每个抛弹的运动和闪亮镀铬的每一像素颜色都源于首先写好的用于模拟现实世界观测的公式。但一款游戏只是(使用)科学模拟和绘画的一部分。你不能使用物理上的准确渲染在移动市场上竞争;硬件现在还没有到位,如果你尝试模拟现实世界中的所有方式,你的游戏会因为受限、单调和延迟而宣告结束。

You have to pick up your polygons and your blend modes like they're paintbrushes.

你必须拾起多边形和混合模式把它们当成画笔。

The baked bumpmaps shown in Shadowgun are great examples of this. There are specular highlights already in the texture - the human eye doesn't notice that they don't actually line up with the reflected light and view directions - they are simply high-contrast details on the texture, completely faked, yet they end up looking great. This is a common cheating technique which has been used in many successful games. Compare the visor in the first Halo screenshot ever released with the visor from this release screenshot. It appears that the armor protrusions from the top of the helmet are reflected in the visor, but the reflection is actually baked into the visor texture. In League of Legends, a spell effect appears to have a pixel-light attached to it, but it actually is a blended plane with a texture that was probably generated by taking a screenshot of a pixel light shining on the ground.

暗影之枪 烘焙的凹凸贴图 就是很好的例子。有些已经在纹理中的镜面高光-人眼不会注意到它们实际上没有与反射光和视图方向排成一行-它们只是高对比度的细节纹理,完全是伪造的,但它们最终看起来很赞。这是一种常见的作弊技术,它已被用于许多成功的游戏。比较 第一个发布过的光环游戏截图 中的面罩和 这个版本截图 中的面罩。看起来从头盔顶部的盔甲突出是反射到面罩的,但反射实际是烘焙到面罩贴图上。英雄联盟里面,一个魔法效果 似乎有一个连接到它的像素光,但它实际上是由可能产生的照射在地面上的像素光截图纹理形成的混合平面。

What works well: 行之有效的做法:What does not work: 不会起什么作用的做法:But how do I actually do it? 但我实际上应该怎么做?

See our Rendering Optimizations page.



作者: star-小虎    时间: 2013-10-16 16:16
顶一下!!!!
作者: ku    时间: 2013-10-16 16:32
这也太密了吧,看了几眼,眼睛生痛啊,
作者: 艾西格亚    时间: 2013-10-16 16:38
需要注意一下文章的编排间隔
作者: nts    时间: 2013-10-17 09:39
文档中的内容哦
作者: 幸福小猪    时间: 2013-10-28 10:41
感谢楼主分享
作者: 徐徐的风    时间: 2013-10-28 13:20
谢谢整理分享。d
作者: gxf5168    时间: 2014-4-25 17:43
学习了,感谢
作者: run0006    时间: 2014-5-6 08:18
感謝分享!
作者: Kadina    时间: 2014-5-14 09:02
thank you thanks sharing
作者: 1547373072    时间: 2014-6-16 17:22
这。。。。。。。 贴的吧。
作者: louis_some    时间: 2014-6-16 20:26
BU CUO DE DONG XI
作者: louis_some    时间: 2014-6-16 20:26
希望多点啊啊啊啊啊啊
作者: 爱诺娃    时间: 2014-6-17 09:15

thank you thanks sharing
作者: a51383036    时间: 2014-6-23 17:10
美工很漂亮哦,不知道是作什么的
作者: fangxur    时间: 2014-6-23 23:55
好东东,感谢分享
作者: cjhworld    时间: 2014-7-28 12:42
谢谢分享!!!!!!




欢迎光临 纳金网 (http://wwww.narkii.com/club/) Powered by Discuz! X2.5