[Unity3D] Optimization – Make Atlas textures for ParticleSystem, reduce drawcall, why not ?
来源:互联网 发布:php虚拟物品商城 编辑:程序博客网 时间:2024/06/08 04:21
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 here
Depending 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 : Texture Sheet 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 atlas
Frame 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.
- Atlas texure size must be POT (Power of two)
- 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阅读全文0 0- [Unity3D] Optimization – Make Atlas textures for ParticleSystem, reduce drawcall, why not ?
- Why and how to pack your textures for iOS/Android
- unity3D drawcall
- unity3d DrawCall
- Unity3D ParticleSystem粒子系统
- Unity3D ParticleSystem粒子系统 【初级】
- unity3d优化DrawCall
- [Unity3d]DrawCall优化手记
- [Unity3d]DrawCall优化手记
- Unity3D-优化之一 Drawcall
- why not better than her for English?
- Why Map/Reduce?
- Why Map/Reduce?
- OpenGL ES Tutorial for Android – Part VI – Textures
- OpenGL ES Tutorial for Android – Part VI – Textures
- Why does the method of Lagrange multipliers work for optimization in multivariable calculus?
- Unity3D性能优化:DrawCall优化
- Unity3d特效DrawCall优化介绍
- mybatis 中sql语句传递多个参数
- springboot集成mybatis
- leetcoe.557 Reverse Words in a String III
- Android编译时报错:Ensure that you have installed a JDK(not just a JRE)and configured your JAVA_HOME......
- SwipeRefrshLayout+RecyclerView实现刷新功能
- [Unity3D] Optimization – Make Atlas textures for ParticleSystem, reduce drawcall, why not ?
- [RK3288][Android6.0] 调试笔记 --- Volume up键改成Back键
- 数据库主键生成方式分析
- SQA度量
- 安卓apk加密,几维安全帮你及时规避app潜在风险
- 在比较对象的时候为什么要重写equls()与hashCode()方法
- IMWeb提升营Day3
- Walle(瓦力)多渠道打包(含加固)-----------命令行
- 虚拟机网络工作模式
- Using Mobile Shader for Materials