roberto mangiafico, cto badseed entertainment - sleep attach: a technical post-mortem (how to web...
TRANSCRIPT
![Page 1: Roberto Mangiafico, CTO BadSeed Entertainment - Sleep Attach: A Technical Post-Mortem (How to Web Conference 2014 - Game Development Track)](https://reader034.vdocuments.us/reader034/viewer/2022051516/55a4f9bb1a28ab876e8b4743/html5/thumbnails/1.jpg)
Sleep Attack TDThe Technical Post Mortem
Roberto Mangiafico
![Page 2: Roberto Mangiafico, CTO BadSeed Entertainment - Sleep Attach: A Technical Post-Mortem (How to Web Conference 2014 - Game Development Track)](https://reader034.vdocuments.us/reader034/viewer/2022051516/55a4f9bb1a28ab876e8b4743/html5/thumbnails/2.jpg)
Gameplay Programmer in Ubisoft Milan since 2007
In 2012 left Ubisoft and created Bad Seed with other colleagues
About Me
![Page 3: Roberto Mangiafico, CTO BadSeed Entertainment - Sleep Attach: A Technical Post-Mortem (How to Web Conference 2014 - Game Development Track)](https://reader034.vdocuments.us/reader034/viewer/2022051516/55a4f9bb1a28ab876e8b4743/html5/thumbnails/3.jpg)
Bad Seed
![Page 4: Roberto Mangiafico, CTO BadSeed Entertainment - Sleep Attach: A Technical Post-Mortem (How to Web Conference 2014 - Game Development Track)](https://reader034.vdocuments.us/reader034/viewer/2022051516/55a4f9bb1a28ab876e8b4743/html5/thumbnails/4.jpg)
Sheep Up!
![Page 5: Roberto Mangiafico, CTO BadSeed Entertainment - Sleep Attach: A Technical Post-Mortem (How to Web Conference 2014 - Game Development Track)](https://reader034.vdocuments.us/reader034/viewer/2022051516/55a4f9bb1a28ab876e8b4743/html5/thumbnails/5.jpg)
Sleep Attack
![Page 6: Roberto Mangiafico, CTO BadSeed Entertainment - Sleep Attach: A Technical Post-Mortem (How to Web Conference 2014 - Game Development Track)](https://reader034.vdocuments.us/reader034/viewer/2022051516/55a4f9bb1a28ab876e8b4743/html5/thumbnails/6.jpg)
Sleep Attack: featuring and critics
![Page 7: Roberto Mangiafico, CTO BadSeed Entertainment - Sleep Attach: A Technical Post-Mortem (How to Web Conference 2014 - Game Development Track)](https://reader034.vdocuments.us/reader034/viewer/2022051516/55a4f9bb1a28ab876e8b4743/html5/thumbnails/7.jpg)
Engine and Tools
![Page 8: Roberto Mangiafico, CTO BadSeed Entertainment - Sleep Attach: A Technical Post-Mortem (How to Web Conference 2014 - Game Development Track)](https://reader034.vdocuments.us/reader034/viewer/2022051516/55a4f9bb1a28ab876e8b4743/html5/thumbnails/8.jpg)
3D Camera in 2D game: Why
1. Circles in perspective2. 3D movement feeling
![Page 9: Roberto Mangiafico, CTO BadSeed Entertainment - Sleep Attach: A Technical Post-Mortem (How to Web Conference 2014 - Game Development Track)](https://reader034.vdocuments.us/reader034/viewer/2022051516/55a4f9bb1a28ab876e8b4743/html5/thumbnails/9.jpg)
3D Camera in 2D game
Gameplay camera
![Page 10: Roberto Mangiafico, CTO BadSeed Entertainment - Sleep Attach: A Technical Post-Mortem (How to Web Conference 2014 - Game Development Track)](https://reader034.vdocuments.us/reader034/viewer/2022051516/55a4f9bb1a28ab876e8b4743/html5/thumbnails/10.jpg)
3D Camera in 2D game: Issue #1
Z fight problem
Not good looking perspective on objects
![Page 11: Roberto Mangiafico, CTO BadSeed Entertainment - Sleep Attach: A Technical Post-Mortem (How to Web Conference 2014 - Game Development Track)](https://reader034.vdocuments.us/reader034/viewer/2022051516/55a4f9bb1a28ab876e8b4743/html5/thumbnails/11.jpg)
3D Camera in 2D game: Issue #1
Solution: Every object is counter rotated towards the gameplay camera
![Page 12: Roberto Mangiafico, CTO BadSeed Entertainment - Sleep Attach: A Technical Post-Mortem (How to Web Conference 2014 - Game Development Track)](https://reader034.vdocuments.us/reader034/viewer/2022051516/55a4f9bb1a28ab876e8b4743/html5/thumbnails/12.jpg)
3D Camera in 2D game: Issue #1
![Page 13: Roberto Mangiafico, CTO BadSeed Entertainment - Sleep Attach: A Technical Post-Mortem (How to Web Conference 2014 - Game Development Track)](https://reader034.vdocuments.us/reader034/viewer/2022051516/55a4f9bb1a28ab876e8b4743/html5/thumbnails/13.jpg)
3D Camera in 2D game: Issue #2
Border artifact
![Page 14: Roberto Mangiafico, CTO BadSeed Entertainment - Sleep Attach: A Technical Post-Mortem (How to Web Conference 2014 - Game Development Track)](https://reader034.vdocuments.us/reader034/viewer/2022051516/55a4f9bb1a28ab876e8b4743/html5/thumbnails/14.jpg)
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
![Page 15: Roberto Mangiafico, CTO BadSeed Entertainment - Sleep Attach: A Technical Post-Mortem (How to Web Conference 2014 - Game Development Track)](https://reader034.vdocuments.us/reader034/viewer/2022051516/55a4f9bb1a28ab876e8b4743/html5/thumbnails/15.jpg)
Possible solution:
High value of cut off on the shader
Cons:
Very aliased borders
3D Camera in 2D game: Issue #2
![Page 16: Roberto Mangiafico, CTO BadSeed Entertainment - Sleep Attach: A Technical Post-Mortem (How to Web Conference 2014 - Game Development Track)](https://reader034.vdocuments.us/reader034/viewer/2022051516/55a4f9bb1a28ab876e8b4743/html5/thumbnails/16.jpg)
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
![Page 17: Roberto Mangiafico, CTO BadSeed Entertainment - Sleep Attach: A Technical Post-Mortem (How to Web Conference 2014 - Game Development Track)](https://reader034.vdocuments.us/reader034/viewer/2022051516/55a4f9bb1a28ab876e8b4743/html5/thumbnails/17.jpg)
Very high draw call number for mobile game
200+ object per level
Almost every object is animated
3D Camera in 2D game: Issue #3
![Page 18: Roberto Mangiafico, CTO BadSeed Entertainment - Sleep Attach: A Technical Post-Mortem (How to Web Conference 2014 - Game Development Track)](https://reader034.vdocuments.us/reader034/viewer/2022051516/55a4f9bb1a28ab876e8b4743/html5/thumbnails/18.jpg)
Possible Solution:
Use Unity batching
Cons:
Objects must be static : No animation, No movement
3D Camera in 2D game: Issue #3
![Page 19: Roberto Mangiafico, CTO BadSeed Entertainment - Sleep Attach: A Technical Post-Mortem (How to Web Conference 2014 - Game Development Track)](https://reader034.vdocuments.us/reader034/viewer/2022051516/55a4f9bb1a28ab876e8b4743/html5/thumbnails/19.jpg)
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
![Page 20: Roberto Mangiafico, CTO BadSeed Entertainment - Sleep Attach: A Technical Post-Mortem (How to Web Conference 2014 - Game Development Track)](https://reader034.vdocuments.us/reader034/viewer/2022051516/55a4f9bb1a28ab876e8b4743/html5/thumbnails/20.jpg)
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
![Page 21: Roberto Mangiafico, CTO BadSeed Entertainment - Sleep Attach: A Technical Post-Mortem (How to Web Conference 2014 - Game Development Track)](https://reader034.vdocuments.us/reader034/viewer/2022051516/55a4f9bb1a28ab876e8b4743/html5/thumbnails/21.jpg)
Mesh Merger at mesh registration:
Disable the renderer of the registered mesh
Order the vertices from up to bottom
Mesh Merger – How it works
![Page 22: Roberto Mangiafico, CTO BadSeed Entertainment - Sleep Attach: A Technical Post-Mortem (How to Web Conference 2014 - Game Development Track)](https://reader034.vdocuments.us/reader034/viewer/2022051516/55a4f9bb1a28ab876e8b4743/html5/thumbnails/22.jpg)
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
…
![Page 23: Roberto Mangiafico, CTO BadSeed Entertainment - Sleep Attach: A Technical Post-Mortem (How to Web Conference 2014 - Game Development Track)](https://reader034.vdocuments.us/reader034/viewer/2022051516/55a4f9bb1a28ab876e8b4743/html5/thumbnails/23.jpg)
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
![Page 24: Roberto Mangiafico, CTO BadSeed Entertainment - Sleep Attach: A Technical Post-Mortem (How to Web Conference 2014 - Game Development Track)](https://reader034.vdocuments.us/reader034/viewer/2022051516/55a4f9bb1a28ab876e8b4743/html5/thumbnails/24.jpg)
No dynamic List<>
Optimized for quad
Mesh Merger – Optimizations
![Page 25: Roberto Mangiafico, CTO BadSeed Entertainment - Sleep Attach: A Technical Post-Mortem (How to Web Conference 2014 - Game Development Track)](https://reader034.vdocuments.us/reader034/viewer/2022051516/55a4f9bb1a28ab876e8b4743/html5/thumbnails/25.jpg)
Before:
Mesh Merger – Comparison
After:
![Page 26: Roberto Mangiafico, CTO BadSeed Entertainment - Sleep Attach: A Technical Post-Mortem (How to Web Conference 2014 - Game Development Track)](https://reader034.vdocuments.us/reader034/viewer/2022051516/55a4f9bb1a28ab876e8b4743/html5/thumbnails/26.jpg)
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
![Page 27: Roberto Mangiafico, CTO BadSeed Entertainment - Sleep Attach: A Technical Post-Mortem (How to Web Conference 2014 - Game Development Track)](https://reader034.vdocuments.us/reader034/viewer/2022051516/55a4f9bb1a28ab876e8b4743/html5/thumbnails/27.jpg)
Adapt the HUD
Different screen types: Issue #1
New Unity GUI system not yet available
Created our own dynamic HUD system
![Page 28: Roberto Mangiafico, CTO BadSeed Entertainment - Sleep Attach: A Technical Post-Mortem (How to Web Conference 2014 - Game Development Track)](https://reader034.vdocuments.us/reader034/viewer/2022051516/55a4f9bb1a28ab876e8b4743/html5/thumbnails/28.jpg)
Dynamic HUD system
• Dedicated camera• 3D panels• Position relative to screen
![Page 29: Roberto Mangiafico, CTO BadSeed Entertainment - Sleep Attach: A Technical Post-Mortem (How to Web Conference 2014 - Game Development Track)](https://reader034.vdocuments.us/reader034/viewer/2022051516/55a4f9bb1a28ab876e8b4743/html5/thumbnails/29.jpg)
Adapt the 3D view
Different screen types: Issue #2
No need to change nothing for different ratioSimply we see more background elements
![Page 30: Roberto Mangiafico, CTO BadSeed Entertainment - Sleep Attach: A Technical Post-Mortem (How to Web Conference 2014 - Game Development Track)](https://reader034.vdocuments.us/reader034/viewer/2022051516/55a4f9bb1a28ab876e8b4743/html5/thumbnails/30.jpg)
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
![Page 31: Roberto Mangiafico, CTO BadSeed Entertainment - Sleep Attach: A Technical Post-Mortem (How to Web Conference 2014 - Game Development Track)](https://reader034.vdocuments.us/reader034/viewer/2022051516/55a4f9bb1a28ab876e8b4743/html5/thumbnails/31.jpg)
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
![Page 32: Roberto Mangiafico, CTO BadSeed Entertainment - Sleep Attach: A Technical Post-Mortem (How to Web Conference 2014 - Game Development Track)](https://reader034.vdocuments.us/reader034/viewer/2022051516/55a4f9bb1a28ab876e8b4743/html5/thumbnails/32.jpg)
Q/A
![Page 33: Roberto Mangiafico, CTO BadSeed Entertainment - Sleep Attach: A Technical Post-Mortem (How to Web Conference 2014 - Game Development Track)](https://reader034.vdocuments.us/reader034/viewer/2022051516/55a4f9bb1a28ab876e8b4743/html5/thumbnails/33.jpg)
Thank you!