[Unity3D] Optimization – Make Atlas textures for ParticleSystem, reduce drawcall, why not ?
2017-05-27 16:58
375 查看
ParticleSystem and Atlas texture
These are familiar concepts to Game developers.ParticleSystem
A familiar feature, available in most of GameEngine nowaday, which is used to create a variety of effects in the games (fire,
explodsion, smoke, falling leaves, snow ….).
Atlas textures
We often pack all small textures into one big texture (call Atlas), to reduce drawcall, save a lot of game performance.
We are also familiar with SpritePacker in
Unity – a tool for packing sprites in to one atlas. Currently, this tool support only Sprite2D.
Why ParticleSystem cost a lot of drawcalls ?
With each ParticleSystem we need one material. Using difference materials will make particleSystem not batch together, read more hereDepending on the game, the number of ParticleSystem will be difference, but in most cases, we used them quite a lot. Drawcall amount costly for ParticleSystem therefore also very high.
The benefit of making atlas for ParticleSystem ?
I made a simple demo on Github,a comparison between using and not using atlas for ParticleSystem
Not using
I create some effects using ParticleSystem, you can see here we spend 7 drawcall, corresponding to 7 materials was used for ParticleSystem :
Using Atlas:
Use the same amount of ParticleSystem, but now there’re only 1 drawcall :
How to ?
Texture Sheet Animation Module
Throught a very useful feature of ParticleSystem in Unity : TextureSheet Animation Module . This feature is used to make animationSheet for ParticleSystem (some effects need a few frames, not just one). Like this:
Take advantage of this feature, we’ll make atlas for ParticleSystem. As the demo on Github,
I used only 1 atlas for all ParticleSystem, then just one material is used.
Configuration steps
For example, I make a ParticleSystem, use the second tile in above atlasFrame over lifetime
Here, we only need 1 frame, so select Constant
Split the atlas
For the second tile, I have to set :
* Tile : 4 x 2
* Frame over Time : 1
If you want to choose the smaller tiles, you have to change the divide ratio
Here, with the particle need the Smoke tile, I have to set:
* Tile is 8 x 4
* Frame over Time : 17
That it, very simple huh? Check out my sample on Github.
Some notes
Atlas texure size must be POT (Power of two)The size of texture must be 64, 128, 256, 512 …. This is relate to device’s GPU, you can read more here.
For mobile devices, keep the atlas size lower than 2048×2048
I’ve read many “best practice” articles, they all say that the good texture size for mobile devices is not bigger than 2048. Texture size too large will cause the application consumes a lot of RAM, GPU overheating, reduce game performance.
Using Mobile Shader for Materials
Unity have some basic built-in shaders for Mobile, thoes shader written for more optimal for mobile devices. Of couse, the effects that use them will not “beautiful” as the default shaders, but don’t worry, the result won’t difference much. Unless you
plan to make a big game like BattleField or Assassin’s creed on mobile
相关文章推荐
- Unity3D优化之Draw Call Batching
- 2013.4.15 Particle Swarm Optimization with Skyline Operator for Fast Cloud-based Web Service Composition
- Unity3d 场景大小和drawcall优化
- Unity3D性能优化:DrawCall优化
- unity项目优化--绘制调用批处理unity3d Draw Call Batching
- Unity3D优化之Draw Call Batching
- 转载-慕容小匹夫细说Unity3D(七)——从Draw Call到GC
- [原]Unity3D深入浅出 - 粒子系统(Particle System)
- Unity3d特效DrawCall优化介绍
- 【原】unity3D之Draw Call
- Unity3D性能优化之Draw Call Batching
- 各种 基于Unity3d 引擎的Android游戏优化 (drawcall)
- Cooperatively Coevolving Particle Swarms for Large Scale Optimization
- System Call Optimization with the SYSENTER Instruction
- linux新增system call(for kernel 2.6)
- Unity3d开发(十一)编辑器DrawCall参数解析
- 【转】 各种 基于Unity3d 引擎的Android游戏优化 (drawcall)
- Unity3d开发(十一)编辑器DrawCall参数解析
- linux新增system call(for kernel 2.6)
- 【风宇冲】Unity3D性能优化:DrawCall优化