unite2016上海Unity大会--Unity3D性能优化篇

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/nemo_free/article/details/51161847
目录结构
  • 项目简述
  • 策划文案
  • 美术资源
  • 程序逻辑
  • 性能优化

项目简述
  1. 项目方向
  2. 时间计划
  3. 人员配置
  4. 具体内容执行 GO!


策划文案(略过)
“兵马未动,粮草先行~”,优秀的策划文档是项目良好的开端


美术资源
  • Standard
  • Model
  • Shader
  • Texture
  • Lighting
  • Animator/Controller
  • Audioclip
          
                   Standard

Material使用
Model三角面
Texture尺寸
Particle限制
Animation帧频

               Model

  • Enabled运行时更改(makes a copy in memory),Disable 节省内存

  • Optimize Mesh 必须选择

  • Normals & Tangents 设置为非Import选项可以降低memory以及减少ipa/apk包体大小

                      Shader
  • Check对应的Vertex/fragment
  • Compile 汇编代码/GLSL代码
  • Shader性能分析工具 - AMD GPU ShaderAnalyzer/PVRShaderEditor
  • Shader compile when need
  • Comiled Shader缓存

                             Texture
  • PSD,TIFF,JPG,TGA,PNG,GIF,BMP,IFF,PICT
  • Scence/Mipmaps check纹理精度
  • Enabled Runtime 可更改(Make a copy in memory),Disable save memory
  • PVRTC格式Texture需要为正方形
  • Mipmap空间换时间

                                   Light
  • Mobile device推荐使用Baked or Mixed
  • Rendeer Mode 尽量少用Important
  • Window->Lighting
  • Scale in light map
  • Preserve UVs
                   Animator/Controller
  • Apply Root Motion 动画驱动位置
  • State 切换 & Bleed Tree
  • Window -> Animator

AudioClip
  • 常用格式aif,wav,mp3,ogg
  • Verbis-encoded(ogg)解压变大10倍
  • PCM高质量单低压缩率
  • ADPCM性能结余PCM与Mp3之间
  • Mp3格式在IOS设备你有硬件解码器



程序逻辑
  • Logic架构
  • Script应用
  • Assert管理
  • Dynamic update

Logic架构
  • Modular Design
  • "Plug and Play"
  • independence and encapsulation(封装)
Script应用
  • Edit->Project Setting ->Script Execution
  • MonoBehavior 执行机制
  • C++到托管C#存在调用开销
  • Script Call Optimization 可忽略 Exception
  • Script serialization (ScriptableObject)
Asset管理
  • Asset Serialization (Text,Binary,Mixed)
  • .meta file
  • UI atlas arrange
  • Prefab(模型文件都变成prefab)
  • Asset bundle
Dynamic Update
  • Script updata(使用C#前提下Android使用dll反射,其他平台暂不支持)
  • 美术Assets(使用Asset bundle)
  • 配置数据



性能优化
  • Graphics
  • Physics
  • Scripts
  • File size
  • Tools

Graphics
  • Bottlenecks on CPU or GPU
  • GPU limitaiton  (verticle not more than 10w on mobile,several millions on PC)
  • Vertex processiong on GPU.(skinned meshes,cloth simulation,particles etc.)
CPU optimization
  • Combine objects(manually or batching)
  • Use less materials
  • Putting separate textures into a larger
  • Use less muliple render(reflections,shadows,perpixel lights etc)
GPU optimaization
  • Model Geometry
    • Don't use any more triangles than necessary
    • Static batching non-moving objects
    • Try to keep the numbers of UV mapping seams and hard edges(doubled-up vertices) as low as possible
  • Lighting Performance
    • LightMap replace real time lighting
    • Shader instad of lighting
    • Use the least pixel lighting saves both CPU and the GPU
  • High-performance shaders
    • Alpha Blend replace Alpha Test
    • Complex mathematical operations pow,exp,log,cos,sin,tan
    • Floating point operations Cg/HLSL(float ,half,fixed) GLSL ES(highp,mediump,lowp)
  • Texture Compression and Mipmaps
    • Compression save memory and bandwidth
    • Always Mipmaps for textures used in a 3D scene
  • LOD and Pre-Layer Cull
    • LOD forlarge object
    • Camera,layCullDistances for small object
 Physics
  • Fixed Timestep
  • Mesh colliders and wheel colliders
  • Rigidbody
  • Physics.RaycastAll in scripts  存在内存中
Scripts
  • Optimized by Design
  • Use IL2CPP
  • Script Call Optimization
  • Aviod allcating memory frequently
  • Profiler is King
File Size
  • Identify the assets size by Consonle->Open Editor Log
  • Replach assets in Resources with AssetBundles
  • Use .NET Subset if you can
  • IOS  Stripping
  • Specific operaiton
Tools


Search 打法:在Manual 输入 Optimiziing  优化的所有项都出现了 



猜你喜欢

转载自blog.csdn.net/nemo_free/article/details/51161847