roberto mangiafico, cto badseed entertainment - sleep attach: a technical post-mortem (how to web...
TRANSCRIPT
Sleep Attack TDThe Technical Post Mortem
Roberto Mangiafico
Gameplay Programmer in Ubisoft Milan since 2007
In 2012 left Ubisoft and created Bad Seed with other colleagues
About Me
Bad Seed
Sheep Up!
Sleep Attack
Sleep Attack: featuring and critics
Engine and Tools
3D Camera in 2D game: Why
1. Circles in perspective2. 3D movement feeling
3D Camera in 2D game
Gameplay camera
3D Camera in 2D game: Issue #1
Z fight problem
Not good looking perspective on objects
3D Camera in 2D game: Issue #1
Solution: Every object is counter rotated towards the gameplay camera
3D Camera in 2D game: Issue #1
3D Camera in 2D game: Issue #2
Border artifact
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
Possible solution:
High value of cut off on the shader
Cons:
Very aliased borders
3D Camera in 2D game: Issue #2
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
Very high draw call number for mobile game
200+ object per level
Almost every object is animated
3D Camera in 2D game: Issue #3
Possible Solution:
Use Unity batching
Cons:
Objects must be static : No animation, No movement
3D Camera in 2D game: Issue #3
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
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
Mesh Merger at mesh registration:
Disable the renderer of the registered mesh
Order the vertices from up to bottom
Mesh Merger – How it works
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
…
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
No dynamic List<>
Optimized for quad
Mesh Merger – Optimizations
Before:
Mesh Merger – Comparison
After:
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
Adapt the HUD
Different screen types: Issue #1
New Unity GUI system not yet available
Created our own dynamic HUD system
Dynamic HUD system
• Dedicated camera• 3D panels• Position relative to screen
Adapt the 3D view
Different screen types: Issue #2
No need to change nothing for different ratioSimply we see more background elements
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
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
Q/A
Thank you!