Mojtaba Rajabi

Mojtaba Rajabi photo
Company:
Novin Games
Position:
Founder & CEO
Talk title:

Performance optimization and final build file size reduction in Unity3D (Mobile Oriented Tips&Tricks)

Country:

Iran

Bio:

I've been developing games for 10 years now and I have around 8 years of experience with Unity. I'm teaching Unity at the "University of Science and Culture" for two years now. Some of my published games are: Ava'a Quest | 2013 | Project Manager and Programmer | best casual game in 3rd TGF | best technical game in 3rd TGF The Guest | 2016 | Project Manager and Programmer X Racer | 2018 | Project Manager and Programmer

Talk abstract:

Performance optimization: Limitations and Bottlenecks in File Size, Memory, CPU, GPU Using Unity3D Profiler Tool Drawcalls: Why drawcalls are important and how decrease its count. Custom Skybox Creation Avoid changing scale and especially negative scale values Use “Shared Material” instead of material Garbage Collection: Find heap allocations Use integer id reference instead of object reference Call collect function manually Use Coroutines properly How use strings to prevent GC Cash variables to prevent GC Don’t allocate in functions that call frequently Use clear on list instead of creating new one Prevent boxing Struct or Class? Scripts: Timing update function Don’t use unnecessary codes in update functions Don’t use circular functions and pow function Don’t use new and GetComponnect in update functions Don’t use find object (use singleton, reference, etc) Don’t use Playerprefs in update functions Disable scripts or use simple code for far objects (like LOD) Erase update function if you didn’t use it Fish-Pool Design Pattern Remove unnecessary codes from loops (like if in for) Use localPosition instead of position whenever possible Cash position if you want to use it a lot Reduce mathematical calculations on vectors (use other variable types) In length comparison use sqrMagnitude instead of magnitude Don’t use Camera.main (it is like find functions) Active scripts that change visual, only when it is in camera view Be careful using nested loops Cash component in other scripts instead of using GetComponent Meshes: Be conscious about vertices and triangles count Use vertex weld to reduce vertices count Combine meshes Combine near objects Reduce UV mapping seams (prevent double vertices) Use smooth groups Use less triangles in less curvy surfaces and sections of meshes Use Terrain to Mesh tools and appropriate shaders (for mobile platform) Turn vertex tangents off if you’re not using Normal Maps Textures: Best settings for textures Texture Atlas When to use texture compression What is mipmap and when use it Shaders: Use mobile optimized shaders Use unlit shaders (if scene light won’t change) Use cutout shaders instead of transparent shaders Try to minimize the use of heavy calculative methods and functions (e.g. pow, exp, log, cos, sin, tan) Do not try to reinvent the wheel (use already made methods like normalize, dot, inversesqrt) Use float value with less precision where possible (float vs half vs fixed variables) Audios: Divide audios to 3 main sections (fx audios, mid long audios like dialogs, musics) Play only one file with streaming option enabled Physics: Use layer collision matrix Use simple unity colliders instead of mesh collider use rigidbody components on objects with colliders Increase fixed timestep in time settings (not is fast paced games) Particle Systems: Restrict max particle counts Be careful about slow and overlapped particles like smoke and fire Cache and use non-looped particle effects like gun fire Move particles with camera to reduce overall particle count Other: Reduce Resolution Use bone animation instead of vertex animation Static and dynamic batching Baked Lighting Occlusion Culling Don’t use realtime shadow Use Light Probes Use reflection probe Use lens flares, fake boom, fake shadow Use only one light (sun) Quality Settings Use LOD Use FOG When use separated scenes? Merge two fonts (e.g Persian and English) instead of using two fonts Prevent an object to have lots of children if they will translate, rotate and/or scale Prevent overlapping lots of sprites Use UV scrolling for creating effects like rivers Reduce far clip plane Use textures to create fake light reflections like brake light reflection Final build file size reduction: Textures: Texture Atlasing Mipmaps Texture Separation Tiled Images and Sliced Images Don’t use repetitive sprites (like coins, windows) Use cutout animations instead of frame animations Be careful about Texture Bleeding Custom Skybox Use vertex colors instead of texture baked lighting Use mesh instead of textures (like lines in vehicles) Disable Read/Write Enabled Use lower texture resolutions on fast moving objects Audios: Divide audios to 3 main sections (Fx audios, mid long audios like dialogs and musics) Use force to mono option Compress audio as far as you can’t tell the difference in audio quality Use loop audios Create ambient audios with a few short and small audios Use pitch to create variety in audios (like step audio) Meshes: Setting explanations Use mesh compression Assign more texture space (Texel per unit) to more important parts of meshes Remove duplicate meshes (like cylinder section in rims) Use multiple separate meshes to create and design game environments instead of creating the whole environment in 3D packages. Use modular 3D modeling is possible Other: Use UV2 for shared decals in objects Don’t reference resources that shouldn’t be in the final build Choose ARMv7 in Device Filter Set Stripping Level Use .Net 2.0 Subnet Use scale factor in Baked Lighting

Audience:

Intermediate