Unity开发IOS游戏的优化建议

Unity开发IOS游戏的优化建议

Posted on 2011-06-08 15:43 mcwind 阅读(436) 评论(0) 编辑 收藏

   

From:  http://www.cnblogs.com/mcwind/archive/2011/06/08/2075208.html

最近社团筹划开发IOS平台上的游戏。考虑到设备性能的局限性,为此专门做了些研究。本文主要讲图形美术方面的注意事项,对编程等方面的建议我会陆续出文。

    Unity官网针对IOS开发有比较好的建议,我总结了翻译如下,后面附上原文。

  • 尽量控制定点数量(注意所谓顶点不是建模时的顶点,而是引擎渲染时的顶点。例如,模型一个顶点如果设置了2个法向,那么对引擎来说就是2个顶点) :
    • 对Iphone3或更高设备,每帧渲染的顶点不超过4万个
    • 对更早的设备,每帧渲染的顶点不超过1万个
  • 场景所用的材质尽量减少。即使是不同的物件,也尽量采用同一个材质。
  • 将固定的场景物件设置为静态(static)。
  • 尽量使用PVRTC(这是Apple推荐的一种格式)纹理,不行的话,也尽量用16位纹理取代32位的。
  • 不要在shader中使用multi-pass,通过用混合或者像素shader来合并不同的纹理以达到相同效果。
  • 如果自行编写shader,尽量避免使用浮点数。下面是建议的类型:
    • fixed/lowp——适用于颜色,光照等
    • half/mediump——适用于纹理UV
    • float/highp——避免在像素shader里使用,可以在顶点shader里面用于计算顶点位置
  • 在像素shader中尽量少用复杂的数学计算,例如幂函数、三角函数等。
  • 没必要的话不要使用像素光照(Pixel Lights)
  • 不要使用动态光照,用烘焙的lightmap
  • 不要使用alpha测试,用alpha混合来代替
  • 不要使用雾
  • 大场景中使用Occlusion culling来削减不可见区域。关卡设计时考虑到实施 Occlusion culling 的便利性
  • 使用sky box 来实现远景

 原文如下:

  • Keep vertex count below:
    • 40K per frame when targeting iPhone 3GS and newer devices (with SGX GPU)
    • 10K per frame when targeting older devices (with MBX GPU)
  • Keep the number of different materials per scene low - share as many materials between different objects as possible.
  • Set Static property on a non-moving objects to allow internal optimizations.
  • Use PVRTC formats for textures when possible, otherwise choose 16bit textures over 32bit.
  • Use combiners or pixel shaders to mix several textures per fragment instead of multi-pass approach.
  • If writing custom shaders, always use smallest possible floating-point types:
    • fixed / lowp -- perfect for color, lighting information and normals,
    • half / mediump -- for texture UV coordinates,
    • float / highp -- avoid in pixel shaders, fine to use in vertex shader for vertex position calculations.
  • Minimize use of complex mathematical operations such as pow, sin, cos etc in pixel shaders.
  • Do not use Pixel Lights when it is not necessary -- choose to have only a single (preferably directional) pixel light affecting your geometry.
  • Do not use dynamic lights when it is not necessary -- choose baking lighting instead.
  • Choose to use less textures per fragment.
  • Avoid alpha-testing, choose alpha-blending instead.
  • Do not use fog when it is not necessary.
  • Learn benefits of Occlusion culling and use it to reduce amount of visible geometry and draw-calls in case of complex static scenes with lots of occlusion. Plan your levels to benefit from Occlusion culling.
  • Use skyboxes to "fake" distant geometry.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值