Download presentation
Presentation is loading. Please wait.
Published byLetitia Hutchinson Modified over 9 years ago
1
Advanced techniques for the development of 2D Windows 8 games using Direct X and C++ Markus Jost CEO, Lead Programmer, Codebox GmbH markus.jost@codebox.ch
2
Agenda
3
Cross-Device UI Design Chapter 1/4
6
Illustrating design thoughts by sample
7
Performance tuning Chapter 2/4
9
Texture Atlases © Gango Games <!--Format: n => name of the sprite x => sprite x pos in texture y => sprite y pos in texture w => sprite width (may be trimmed) h => sprite height (may be trimmed) oX => sprite's x-corner offset (only available if trimmed) oY => sprite's y-corner offset (only available if trimmed) oW => sprite's original width (only available if trimmed) oH => sprite's original height (only available if trimmed) r => 'y' only set if sprite is rotated -->
10
Build-time processing media Pipeline Direct3D 11: http://code.msdn.microsoft.com/windowsapps/Direct3D-Resource-Loading-25406148 http://code.msdn.microsoft.com/windowsapps/Direct3D-Resource-Loading-25406148
12
SpriteBatch Sample: http://code.msdn.microsoft.com/windowsapps/Direct3D-sprite-sample-97ae6262http://code.msdn.microsoft.com/windowsapps/Direct3D-sprite-sample-97ae6262
14
Sample optimization optimization
15
Advanced Techniques Chapter 3/4
16
Sprite-Level1 x:-150 y:-100 angle: 0 Sprite-Level1 x:100 y:-60 angle: 15
17
SpriteSheet Animation Create animation sequences from an Atlas Pros: High level of detail Easy to implement Cons: Very High Memory use Low FPS resolution Hand drawn frames take time
18
Bone Animations Create animations using a tool (e.g. Flash) combining body parts Pros: Way less memory consumption Allows many many animations to reuse same texture parts Runs at max FPS Artists are used to using Flash Fast creation Cons: Low level of details Restrictions in design More work to implement
19
3D Animations Use 3D Animations made with 3DSMax or any other 3D Animation Tool Pros: Smooth Animations High Level of Details Depending on LOD, fast production Cons: Doesn’t mix well with 2D GPU intense Also Memory intense due to Animation data
20
Used for example for smoke, fire, dust, snow, rain etc. Lots of tiny textures that face the camera Each particle has its own state Position Rotation Scale Color 1 Texture… Using PointSprites, particles have only 1 vertex Usually alpha blended -> performance Avoid filling Particle Sytsems Supported by most GPUs
21
Sample
22
Implementation S s = V h * S i * sqrt(1/(A + B * D e + C *( D e 2 ))) V h : Viewport height S i : Initial point size D e 2 : The Distance from eye to position A, B, C : User defined values float fPointSize = 1.0f, fPointScaleB = 1.0f; m_d3dDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, true); //create vertices? m_d3dDevice->SetRenderState(D3DRS_POINTSCALEENABLE, true); //use scale function? m_d3dDevice->SetRenderState(D3DRS_POINTSIZE, *((DWORD*)&fPointSize)); m_d3dDevice->SetRenderState(D3DRS_POINTSCALE_B, *((DWORD*)&fPointScaleB)); m_d3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,true); m_d3dDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_ONE); m_d3dDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_ONE); #define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ | D3DFVF_PSIZE | D3DFVF_DIFFUSE) struct D3DVERTEX { float fX, fY, fZ, fSize; DWORD dwColor; }; D3DXCreateTextureFromFile(m_d3dDevice,"texture.png",&pTex); m_d3dDevice->SetTexture(0,pTex); m_d3dDevice->SetStreamSource(0,pVB,0,sizeof(D3DVERTEX)); m_d3dDevice->DrawPrimitive(D3DPT_POINTLIST, 0, numPoints);
23
Box2D
26
Questions? Chapter 4/4
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.