This presentation tackles the technical challenges behind the creation of Sleep Attack for iOS and Android, a 3D game with a 2D look, with all the movements of a 3D world. The challenges and solutions regarding the rendering process, the memory and the performance of the game were reviewed.
Similar to Roberto Mangiafico, CTO BadSeed Entertainment - Sleep Attach: A Technical Post-Mortem (How to Web Conference 2014 - Game Development Track) (20)
14. 3D Camera in 2D game: Issue #2
Rendering order:
A
B
Draw B
Blend border transparence with background color
Write on the Z buffer
Draw A
Find Z buffer with higher value
Can’t blend with the B object border
16. Possible solutions:
Setup the camera to use Z distance only for rendering
order
Cons:
1. Very hard to manage for 200+ object per scene
2. Prompt to error
3. Don’t work for moving objects
3D Camera in 2D game: Issue #2
17. Very high draw call number for mobile game
200+ object per level
Almost every object is animated
3D Camera in 2D game: Issue #3
18. Possible Solution:
Use Unity batching
Cons:
Objects must be static : No animation, No movement
3D Camera in 2D game: Issue #3
19. The Mesh Merger
Create a big mesh with all the meshes vertices
Apply the transforms animations of objects
Keep the meshes UV’s
Order the meshes from top to bottom of the screen
The solution we chose
20. Every mesh:
At scene loading register himself to its MeshMerger
Mesh Merger at mesh registration:
Store the vertices and the transform into a struct inside an array
containing all the registered meshes info
Mesh Merger – How it works
21. Mesh Merger at mesh registration:
Disable the renderer of the registered mesh
Order the vertices from up to bottom
Mesh Merger – How it works
22. Every frame:
Apply the transformation to the vertices of the mesh
Order the vertices from up to bottom IF NEEDED
Mesh Merger – How it works
…
23. Pro:
1. Resolve draw call issue
2. Resolve rendering order issues
3. Work with transform animated objects
4. Work with uv animated object
Cons:
1. Script a bit heavy on the cpu
2. All the meshes registered into a mesh merger must
have the same material
Mesh Merger
24. No dynamic List<>
Optimized for quad
Mesh Merger – Optimizations
26. Different screen ratio 16:9 – 4:3 – 1:1 – 3.2:19
Different resolutions and dpi
Problems:
• Adapt the HUD
• Adapt the 3D view
• Adapt the resolution for dpi
Different screen types
27. Adapt the HUD
Different screen types: Issue #1
New Unity GUI system not yet available
Created our own dynamic HUD system
29. Adapt the 3D view
Different screen types: Issue #2
No need to change nothing for different ratio
Simply we see more background elements
30. Adapt for different resolutions
For devices with high resolution we needed an hd version
For almost everything we have a double version – SD and HD
HD has twice the resolution of SD
At the level load we load HD version if needed
Different screen types: Issue #3
31. Big memory load due to high number of textures with low
compression and sounds
Average 150MB for SD Level
Average 300MB for HD Level
1. Load only needed sounds and textures
2. Mid loading level
3. Load everything at startup, nothing during gameplay
4. Load only needed resolution HD/SD
Memory issues
Unity: Multiplatform, used for previous projects, easy and deep
Camera rotated 15 degrees
Every object but the circles is rotated toward the main camera to solve the prospective deformation
3D World
2 Cameras
One for ingame - one for UI
Game camera 15 degrees rotation –
Every object but the circles is rotated toward the main camera to solve the prospective deformation
Every object but the circles is rotated toward the main camera to solve the prospective deformation
Every object but the circles is rotated toward the main camera to solve the prospective deformation
Border Artifact
Using real camera distance problem can’t manage the rendering order as 2D view need due to frustum distance computation.
Avoid border blending with background
Rendering Order
No for cicles
Placed on a dedicated camera
Use 3D panel placed near the camera – This means they are independent from the screen resolution
Every panel keep the position relative to the screen and reading some settings adapt itself to the new screen ratio if needed
We had to draw the background elements thinking to the wider ratio (16:9)