12 第1页 | 共2 页下一页
返回列表 发新帖
查看: 4754|回复: 16
打印 上一主题 下一主题

[经验分享] 优化手机的实用指南 - 图形方法

[复制链接]

1557

主题

1

听众

1万

积分

资深设计师

Rank: 7Rank: 7Rank: 7

纳金币
454
精华
31

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

跳转到指定楼层
楼主
发表于 2013-10-16 16:14:07 |只看该作者 |倒序浏览

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:
你可以合理地预期在当前消费者手机上的运行状况:
  • Lightmapped static geometry. But beware of:
    光照贴图的静态几何。要注意:
    • Using a lot of alpha-test shaders
      使用大量alpha测试着色器
    • Bumpmapping, especially using built-in shaders.
      凹凸贴图,尤其在使用内置着色器的时候
    • High polygon count
      高多边形数
  • Animated characters, even with fancy shaders! But beware of:
    动画角色,甚至那些使用花哨着色器(的角色)!要注意:
    • Massive crowds or high-poly characters
      大量人群或高聚角色
  • 2D games with sprites. But beware of:
    使用精灵的2D游戏,要注意:
    • Overdraw, or, lots of layers drawn on top of eachother.
      超量绘制,或者,绘制在彼此顶部的大量图层。
  • Particle effects. But beware of:
    粒子效果。要注意:
    • High density on large particles. (Lots of particles drawn on top of each other. This is another overdraw situation)
      较大粒子的高密度(情况)。(大量的粒子在彼此的顶部绘制。这是另一个中超量绘制的情况)
    • Ridiculous numbers of particles, or particle colliders.
      粒子或粒子碰撞器出现的荒谬数量。
  • Physics. But beware of:
    物理。要注意:
    • Mesh colliders. 网格碰撞器。
    • Lots of active bodies. 大量的激活对象。


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: 行之有效的做法:
  • Lightmapped static geometry 静态几何体光照贴图
    • Dramatic lighting and largely dynamic environments don't mix. Pick one or the other.
      舞台照明和大量动态环境不要混用。选择前者或者后者。
  • Lightprobes for moving objects 移动对象使用灯光探测器
    • Current mobile hardware is not really cut out for lots of dynamic lights, and it can't do shadows. Lightprobes are a really neat solution for complex game worlds with static lighting.
      当前手机硬件是不能真的切除大量的动态灯,也不能做阴影。光探针为使用静态灯光的复杂游戏世界提供了很好的解决方案。
  • Specialized shaders and detailed, high-contrast textures
    专门着色器和详细的、高对比纹理。
    • The shaders in ShadowGun minimize per-pixel calculations and exploit complex and high-quality textures. See our Rendering Optimizations page for information on how to make textures that look great even when the shader is simple.
      暗影之枪的着色器减少了每个像素的计算量、开发复杂度和高质量纹理。如何使纹理看起来很棒,即使是使用简单的着色器,参看我们的 渲染优化页面
  • Cartoon Graphics 卡通图形
    • Who says your game has to look like a photo? If you make lighting and atmosphere the responsibility of the texture artist, not the engine, you hardly even have to worry about optimizing rendering.
      谁说你的游戏看起来像一张照片?如果你让纹理贴图师而不是引擎(工程师)负责光照和氛围,你就不必担心渲染优化了。

What does not work: 不会起什么作用的做法:
  • Glow and other Post processing effects 发光和其他后期处理效果
    • Approximate such effects when possible by using blended quads, check out the Shadowgun project for an example of this.
      通过使用混合四边形可能实现近似的效果,查阅暗影之枪工程的此示例。
  • Bumpmapping, especially with the built-in shaders 凹凸贴图,尤其是内置着色器
    • Use it sparingly, only on the most important characters or objects. Anything that can take up the whole screen probably shouldn't be bumpmapped.
      只在最重要的角色或物体上有节制地使用它。任何会占据整个屏幕的事物不应该使用凹凸贴图。
    • Instead of using bump maps, bake more detail and contrast into the diffuse texture. The effect from League of Legends is an interesting example of this being used successfully in the industry.
      烘焙更多的细节和对比度到漫反射纹理,来代替凹凸贴图的使用。英雄联盟的效果就是在行业中成功使用的一个有趣的例子。

But how do I actually do it? 但我实际上应该怎么做?

See our Rendering Optimizations page.


分享到: QQ好友和群QQ好友和群 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
转播转播0 分享淘帖0 收藏收藏1 支持支持0 反对反对0
回复

使用道具 举报

1557

主题

1

听众

1万

积分

资深设计师

Rank: 7Rank: 7Rank: 7

纳金币
454
精华
31

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

沙发
发表于 2013-10-16 16:16:59 |只看该作者
顶一下!!!!
回复

使用道具 举报

ku 智囊团   

89

主题

2

听众

5万

积分

首席设计师

Rank: 8Rank: 8

纳金币
25
精华
1

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

板凳
发表于 2013-10-16 16:32:06 |只看该作者
这也太密了吧,看了几眼,眼睛生痛啊,
回复

使用道具 举报

955

主题

164

听众

7万

积分

版主

Rank: 7Rank: 7Rank: 7

纳金币
59338
精华
28

活跃会员 荣誉管理 突出贡献 优秀版主 论坛元老

地板
发表于 2013-10-16 16:38:08 |只看该作者
需要注意一下文章的编排间隔
回复

使用道具 举报

nts    

3

主题

1

听众

743

积分

初级设计师

Rank: 3Rank: 3

纳金币
7
精华
0

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

5#
发表于 2013-10-17 09:39:52 |只看该作者
文档中的内容哦
回复

使用道具 举报

2

主题

1

听众

1143

积分

助理设计师

Rank: 4

纳金币
350
精华
0
6#
发表于 2013-10-28 10:41:36 |只看该作者
感谢楼主分享
回复

使用道具 举报

2

主题

7

听众

5583

积分

高级设计师

Rank: 6Rank: 6

纳金币
87
精华
0

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

7#
发表于 2013-10-28 13:20:17 |只看该作者
谢谢整理分享。d
回复

使用道具 举报

1

主题

1

听众

4795

积分

中级设计师

Rank: 5Rank: 5

纳金币
955
精华
0

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

8#
发表于 2014-4-25 17:43:24 |只看该作者
学习了,感谢
回复

使用道具 举报

0

主题

1

听众

1174

积分

助理设计师

Rank: 4

纳金币
92
精华
0
9#
发表于 2014-5-6 08:18:28 |只看该作者
感謝分享!
回复

使用道具 举报

0

主题

2

听众

4092

积分

中级设计师

Rank: 5Rank: 5

纳金币
530
精华
0

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

10#
发表于 2014-5-14 09:02:27 |只看该作者
thank you thanks sharing
回复

使用道具 举报

12 第1页 | 共2 页下一页
返回列表 发新帖
您需要登录后才可以回帖 登录 | 立即注册

手机版|纳金网 ( 闽ICP备2021016425号-2/3

GMT+8, 2024-11-25 00:38 , Processed in 0.109744 second(s), 31 queries .

Powered by Discuz!-创意设计 X2.5

© 2008-2019 Narkii Inc.

回顶部