Making a game with Molehill: Zombie Tycoon

1,165 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,165
On SlideShare
0
From Embeds
0
Number of Embeds
8
Actions
Shares
0
Downloads
9
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • GameplayVideo
  • Here is a quick overview of what we will go through in this session. I will start by looking at the current state of Flash and I will present the Molehill API that Adobe is offering us. JP will then take over and dig deeper in the technical aspects of it all.
  • Is Flash Dead? Look this up in Google and you’ll find many interesting discussions. I have no intention on going into the politics of it, so here are some facts.According to AppData, the top two FB apps attracts close to 150M MAU. Both are Flash games. From known metrics, this amounts to a conservative 30M $ per month, all going to the same company, but still WebGL = Final draft was done a month ago.The Flash player provided advances that « helped » 3D based applications. AS3 was a big one, providing a much faster Virtual Machine, but it’s still non-native software rendering. Molehill provides the jump ahead to real 3D on the browser.35 devices by 2010 – Close to 100 deviceswillshipwithit in 2011Flash Stats based on : http://www.adobe.com/products/player_census/flashplayer/version_penetration.html (December 2010)http://tv.adobe.com/watch/industry-trends/strong-mobile-adoption-of-flash-platform-in-2011/
  • Molehill opens a low-level API to access the GPU. Adobe decided to limit this API to a lowest supported denominator. This decision has been made to keep a consistent experience across all supported platforms.Those are some Pros and Cons, you can probably draw your own list after playing with it No CPU threading API yet on the Flash player. Adobe has been using it more internally and I’m sure they are working on something for us to use soon One thing to note, is the software fallback. Be careful when designing Molehill games, decide if you can afford the software renderer as soon as possible. If you don’t support it, always validate that hardware is used and show a prompt otherwise.I will now let JP discuss the technical aspects of all of this 
  • Starting with the base, the file formatAnd the I Will cover some of the system that we have in ZombieTycoon
  • Starting with the base, the file formatAnd the I Will cover some of the system that we have in ZombieTycoon
  • If you have 1000 quad particles, itmeansyou have to update around 6000 vertex to update, and witharound 10 values soAt the end it’s 60 000 update on yourbytearray.VB: of 64 DWORD
  • If you have 1000 quad particles, itmeansyou have to update around 6000 vertex to update, and witharound 10 values soAt the end it’s 60 000 update on yourbytearray.VB: of 64 DWORD
  • If you have 1000 quad particles, itmeansyou have to update around 6000 vertex to update, and witharound 10 values soAt the end it’s 60 000 update on yourbytearray.VB: of 64 DWORD
  • If you have 1000 quad particles, itmeansyou have to update around 6000 vertex to update, and witharound 10 values soAt the end it’s 60 000 update on yourbytearray.VB: of 64 DWORD
  • If you have 1000 quad particles, itmeansyou have to update around 6000 vertex to update, and witharound 10 values soAt the end it’s 60 000 update on yourbytearray.VB: of 64 DWORD
  • Making a game with Molehill: Zombie Tycoon

    1. 1. Making a game with Molehill: Zombie Tycoon Luc Beaulieu CTO – Frima Studio Jean-Philippe Auclair Lead R&D Software Architect
    2. 2. Session Overview• State of Flash• Molehill’s API presentation• Digging deeper into Molehill
    3. 3. State of Flash• Is Flash Dead? • FB: Top 10 = 250M MAU • Desktops: Flash 10 installed on 99%+ • SmartPhones: Flash/Air 200+M, 100 devices • Streaming: 120 petabytes per month• Advances in Flash for 3D games • AS3 • 10.1, 10.2 … • Molehill
    4. 4. Molehill’s API Presentation• Pros: – GPU Accelerated API – Relies on DirectX 9 and OpenGL ES 2.0 – Native Software fallback• Cons: – No point sprite support, branching, MRT, depth buffer – No CPU threading support – Native Software fallback
    5. 5. This Page Intentionally Left Green
    6. 6. Digging deeper into Molehill• Assuming a basic knowledge of 3D development terminology• Display Layers• Model/Animation File Format• Character Animation: Matrix vs Quaternion• Texturing• Optimizing the Particle System• Fast Lights & Shadows• CPU Post-Processing effects• Profiling & Debugging tools• Bonus! – 3D GameDev Lexicon – The math explaining all the numbers I’m going to talk about – Cheat sheets
    7. 7. Display Layers
    8. 8. Frima 3D File Format• Many 3D engines for flash try to support multiple input format• …Or support only generic format such as ColladaXML• Using a format optimized for 3D game made in Flash – Small File Size – Small Memory footprint – No processing required Model & Animation File Processing on low-end computer 6000 5250 5000 4000 3000 2000 Time to process (ms) 1000 15 0 Collada XML Frima Binary Format
    9. 9. Frima 3D File Format• Export pipeline 3DS Max Scene Build Tool Max Script Exporter Collada XML
    10. 10. Frima 3D File Format• Export pipeline Build Tool Game Serialize (AMF) Game Model / Animation Object Compress File
    11. 11. Frima 3D File Format• In-Game usage Game Uncompress Game Add To Scene File Unserialize Object
    12. 12. Zombie Re-Animation• Techniques – Matrix linear blending – DualQuaternion linear blending• Molehill Constraint – Vertex Shader constants limits: 128 Float4 Zombie: 24 bones
    13. 13. Animation techniques• Matrix linear blending can cause loss of volume when joints are twisted or extremely bent• When using matrix, each bone take 3 constants – Maximum number of bones is 40• When using DualQuats, each bone take only 2 constants – Maximum number of bones is 60 Matrix (left) / Dual Quaternion (Right)
    14. 14. Transitions & interpolation• Animation transition require two sets of bones • Idle blending to walk• Same thing for frame interpolation (ex: Bullet time Animation) DualQuaternion 48 matrix 72 0 32 64 96 128 VertexShader constant required for animating a character (24 bones) DualQuaternion Anim1 (48) Anim2 (48) matrix Anim1 (72) Anim2 (72) Too Much 0 32 64 96 128 Constant for anim 1 Constant for anim 2
    15. 15. File size? Performance? Animation file size (k)DualQuaternion 60 matrix 50DualQuaternion 136 matrix 54 0 32 64 96 128 160 192 224 256 VertexShader assembler instructions for animation processing Vertex Shader processing timeDualQuaternion 130% matrix 100%
    16. 16. Texturing in Molehill
    17. 17. Texturing in Molehill• The first version of the engine was only using PNGs• Adobe Texture Format (ATF) – Texture are kept compressed in Video Memory – Native support for multi-device publishing – One file containing 3 encoding: DXT1, ETC1 and PVRTC – 1.3x bigger than original PNG – Contain the MipMapping of the texture – Does not support transparency
    18. 18. Texturing in Molehill• Transparency – Use PNGs with indexed color – Sample a “alpha mask texture” in the pixel shader ATF PNG Avatar = opaque Fence = Transparent
    19. 19. Texturing in Molehill• Many effects can use ATF when using the good blend modes• No need for transparency Splatter = Multiply Fire = Additive
    20. 20. Particle System• Using a divided workload (CPU/GPU) for better performance – Each particle property update is computed on the CPU at each frame • Alpha, Color, Direction, Rotation, frame(If SpriteSheet), etc. – On the GPU • Applying theses properties • Expending billboard vertex to face the screen
    21. 21. Particle System : Optimization• How many particle? – Due to the VertexBuffer and IndexBuffer limits, – In ZombieTycoon we were limited to around 16383 particles per draw call• Using Fast ByteArray (also known as Alchemy memory or DomainMemory) – Using Azoth, properties updates were 10 times faster• Batching draw calls using the same texture• Using a 100% GPU particle system – It’s expensive on the GPU – Support only linear transformation – Zero CPU required
    22. 22. Particle System
    23. 23. Lights & shadows• Techniques – ShadowMap & LightMap – Dynamic lighting – Fake Volumetric lights – Fake projected shadows
    24. 24. Lights & shadows• ShadowMap & LightMap – We used two textures, a “multiplied” ShadowMap and an “additive” LightMap Diffuse * ShadowMap + Lightmap = Composite
    25. 25. Lights & shadows• Dynamic lighting – Lighting required expensive pixel shader, currently limited to 256 instructions – Zombie Tycoon support up to 7-9 lights (spot or points) per object.
    26. 26. Lights & shadows• Pixel Shader assembly code – Per light, without Normal/Specular mapping.
    27. 27. Lights & shadows• Fake Volumetric Lights – Using a few billboard particles, it’s easy to fake a nice and lightweight volumetric lighting – All object are sampling Shadow and light maps, and since the light particles are “additive”, if an object is behind the lights, it will look brighter
    28. 28. Lights & shadows
    29. 29. Lights & shadows• Fake projected shadows – We created a particle of a gradient black spot aligned to the ground – Orientation and scale of the particle depends on light position and intensity
    30. 30. CPU Post-Processing• Possibility of reading the BackBuffer – Strongly recommended not to use Readback – Fast pipeline for data from the System memory to Video memory – VERY slow pipeline from video to system memory• Effects: Bloom, Blur, Depth of Field, etc. Motion Blur
    31. 31. CPU Post-ProcessingNormal Bloom post-processing
    32. 32. Profiling and Debugging tools (CPU)• FlashDevelop (O.S.S.) – Most of the production is using FlashDevelop – Now with a profiler and a debugger, it’s very easy to work with it
    33. 33. Profiling and Debugging tools (CPU)• Adobe Flash Builder Profiler – Profile Function calls – Profile Memory allocation
    34. 34. Profiling and Debugging tools (CPU)• FlashPreloadProfiler (O.S.S.) – Profile Function calls – Profile Memory allocation – Profile Loaders status – Can be used in Debug/Release & browser/Projector
    35. 35. Profiling and Debugging tools (GPU)• Pix for windows – List of API calls – Shaders assembly code – Pixel debugger – Texture viewer
    36. 36. Profiling and Debugging tools (GPU)• Intel® Graphics Performance Analyzers (GPA) – Render in wireframe – Profile Vertex and Pixel shader performance – Visualize overdraw and draw call sequence – Save a frame, and make real-time experiment – Identification of bottlenecks
    37. 37. Sources & References• Geometric Skinning with Approximate Dual Quaternion Blending • TD-Matt blog – http://isg.cs.tcd.ie/kavanl/papers/sdq-tog08.pdf • http://td-matt.blogspot.com/• Intel® Graphics Performance Analyzers (GPA) • FlashPreloadProfiler – http://software.intel.com/en-us/articles/intel-gpa/ • http://jpauclair.net/flashpreloadprofiler/• Pix for windows • Azoth – http://msdn.microsoft.com/en-us/library/ee417072(v=VS.85).aspx • http://www.buraks.com/azoth/ • Flash in Facebook • AppData.com • Flash Stats Contact • • http://adobe.ly/rwXU http://adobe.ly/gnlUEH Luc Beaulieu luc@frimastudio.com Jean-Philippe Auclair jpauclair@frimastudio.com  @jpauclair  jpauclair.net
    38. 38. What it means?• VertexBuffer• IndexBuffer• Vertex Constants• MipMapping• Quaternion• Billboard
    39. 39. Bonus Slide: The maths!• Character animation: – Matrix linear blending: • 128 Float4 VertexConstant – WorldMatrix – ViewProj matrix = 120Float4 • 120Float4 / / 3Float4 per bone = 40 bones in the constants • Bullet time and transitions require two sets of bones: 40/2 = 20 bones per character max – DualQuaternion linear blending: • 128 Float4 VertexConstant – WorldMatrix – ViewProj matrix = 120Float4 • 120Float4 / / 2Float4 per bone = 60 bones in the constants • Bullet time and transitions require two sets of bones: 60/2 = 30 bones per character max• Max Particle Count – The VertexBuffer is limited to 65536 vertex, the IndexBuffer is limited to 983040 index of type SHORT – In theory, you could have up to 327680 triangle in one draw call – In practice, with no vertex re-use between particles and using quads (4 vertex): 65536/6 = 16383 particle max per draw call• Lighting – With the PixelShader limit of 256 instructions, we were able to fit around 7 to 9 dynamic lights per object (point or spot light)
    40. 40. Achievement: Geek• Cheat Sheet
    41. 41. Achievement: Super Geek!
    42. 42. Thank You! Questions?Contact Luc Beaulieu luc@frimastudio.com Jean-Philippe Auclair jpauclair@frimastudio.com  @jpauclair  jpauclair.net

    ×