1 / 43

3D Graphics in Metro Style Apps and Games

PLAT-751T. 3D Graphics in Metro Style Apps and Games. Chas Boyd Principal Program Manager Microsoft Corporation. You can use 3D graphics to enhance and differentiate your Metro style app. demo . Globe. A 3D foundation for geotagging , map mash-ups, etc. 3D a pp s cenarios.

bernad
Télécharger la présentation

3D Graphics in Metro Style Apps and Games

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. PLAT-751T 3D Graphics in Metro Style Apps and Games Chas Boyd Principal Program Manager Microsoft Corporation

  2. You can use 3D graphics to enhance anddifferentiate your Metro style app.

  3. demo Globe A 3D foundation for geotagging, map mash-ups, etc.

  4. 3D app scenarios • Map mashups • Visualization • Data-mining • Medical • Scientific • Games

  5. Agenda • A lap around Direct3D -object model • New features of Direct3D11 • Supporting the whole range of PCs • Resources available for Direct3D developers Takeaways • You will understand how to get started writing a 3D Metro style app

  6. DirectX 11.1 • DirectX11.1 is the version of DirectX11 that ships in Windows 8 • It has some minor new features added, but most of the improvements are behind the scenes in terms of integration with the other core OS components

  7. Architecture HTML, XAML C++ AMP Direct2D Media Foundation DirectCompute Direct3D Video DXGI

  8. Direct3D object model

  9. Direct3D object model Vertex Decl Vertex Shader Pixel Shader OutputMerger State Graphics State Direct3D Device Interface Graphics Memory Resources Texture Object Mesh Object RenderTarget Objects

  10. The Direct3D device object • Primary Direct3D API object • Represents the core rendering engine • Properties of the device == state of graphics chip • All rendering resources are bound to the context • Context abstraction enables multi-threading Direct3D Device Context Output Merger Vertex Processor Vertex Processor Triangle Rasterizer Pixel Processor

  11. Mesh object Vertex Format Vertex Decl • Meshes are stored in vertex buffers • Indexed with index buffers • Vertex buffers enable mesh data to be cached in graphics memory • Vertex declaration defines a the data formats for the hardware Vertex Buffer Index Buffer

  12. Texture object Shader Resource View Pixel Format Texture Data MIP Chain Base Image

  13. RenderTarget object Render Target View Pixel Format Swap Chain = BackBuffer + FrontBuffer Pixel Data

  14. Creating a swap chain Windows::UI::Core::CoreWindow^ coreWindow; // app’s core window Microsoft::WRL::ComPtr<ID3D11Device1> d3dDevice; // renderer Microsoft::WRL::ComPtr<IDXGISwapChain1> dxgiSwapChain; // front/back buffers of RT // Obtain the final swap chain for this window from the DXGI factory. dxgiFactory->CreateSwapChainForImmersiveWindow( d3dDevice.Get(), // the Direct3D device that will render to it DX::GetIUnknown(coreWindow), // IUnknown interface on our core window &swapChainDesc, // double or triple buffered, stereo, etc. nullptr, // allow on all displays &dxgiSwapChain// the resulting swap chain object );

  15. Depth stencil object Depth/Stencil View Pixel Format Pixel Data Depth Buffer

  16. HLSL shaders float4 SimplePixelShader( sPSInput input ) : SV_TARGET { float3 toLight = normalize( float3(1,1,0) ); float intensity = saturate( dot( input.norm, toLight ) ); return SimpleTexture.Sample( SimpleSampler, input.tex)*intensity; } Direct3D Device Context Vertex Decl Vertex Shader Pixel Shader OutputMerger State

  17. Compiling a shader • HLSL is compiled off-line with fxc.exe • This enables 90% of the work to happen up front • Driver translates (JITs) to it’s own instruction set at load time • On call to d3dDevice->CreatePixelShader() • Enables operation across hardware vendors and generations

  18. Direct3D supports a large hardware base • Hardware is organized into a sequence of feature levels • From Feature_Level_9_1 to Feature_Level_11_1 • Many algorithms can use the same code across levels • Others may need separate codepaths for optimal performance • See Talk <752> Tuning GPU Usage for Any Form Factor

  19. New Features of Direct3D11.1

  20. Direct3D capabilities Advanced features Power-oriented features Low-precision HLSL instructions Optimizations for tiling GPUs • Tessellation • DirectCompute • Double precision • HQ texture compression

  21. Tessellation • Available on DX11 feature level hardware • Enhances mesh quality and detail • Render using base mesh on slower PCs • Use subdivided mesh on faster ones

  22. DirectCompute • Delivers general-purpose GPU processing to Metro style apps • Teraflops of performance • Foundation of C++ AMP (Accelerated Massive Parallelism) • Runs on same device object as Direct3D • So sharing resources for rendering is instantaneous

  23. New shaderinstructions • Technical computing needs fast double precision math • New instructions were added for key transcendentals • Full performance on newer GPUs • Emulated on older ones • HLSL now supports an image search instruction • msad4: Vector Sum of Absolute Differences • Accelerated in future hardware, emulated on Windows 8 drivers

  24. Texture compression • Direct3D supports texture compression • BC1 4-bits/pixel for RGB formats 6x compression ratio • BC2,3 8-bits/pixel for RGBA formats 4x compression ratio • This is strongly recommended • Smaller package means faster downloads of your app • Feature Level 11 hardware added 2 new formats • BC6 for high dynamic range imagery • BC7 for higher quality content

  25. Texture compression example 8k x 4k image @ 24 bits/pixel = 32MPix WorldMap.bmp 98MB 1x WorldMap.dds (BC1) + mip maps 22MB 5x WorldMap.zip (e.g. in .appx package) 7MB 14x WorldMap.jpg 5.5MB 17x

  26. Texture compression quality .Worldmap.jpg Worldmap.dds BC1 compressed

  27. Power optimizations: precision • Optimizing for power and battery life is important • All shaders in DirectX currently default to 32-bit precision • As of Windows 8, you can use 16-bit float or int data • Enables some hardware to work at twice the rate for the same power

  28. Optimizations: tiled renderers • Some power-optimized GPUs use an output image cache called a tile • These chips can get a performance boost with a special flag • m_swapChain->Present(1, 0); // present the image on the display • ComPtr<ID3D11View> view; • m_renderTargetView.As(&view) // get the view on the RT • m_d3dContext->DiscardView(view.Get()); // release the view

  29. Developer resources

  30. Visual Studio 11

  31. Asset compilation • Goal: optimize 3D assets as part of build phase • Runtime app package contains only optimized data • Keep the package download as small as possible • Don’t keep users waiting for your app!

  32. Asset compilation Author-time Asset Build Step Run-time Asset Packager Package Shader.hlsl Shader.cso fxc.exe Texture.bmp Texture.dds myApp.appx dxtex Mesh.obj Mesh.vbo obj2vbo Music.wav Music.wma myTool

  33. New samples for Metro style apps • The samples are designed to • Make it easy to see the API calls used and how they work • Show incremental steps toward building a real app • Samples tip: set a breakpoint in DirectXSample.h #line 18 • to see HRESULTS before the exception

  34. Spectrum of sample types • Tutorials • Introduce very basic initial conceptsfrom step 1 • In-line code to favor readability over factoring of functionality • Simple samples • Provide starting points for developers adding specific techniques • Each sample builds on the last demonstrating another technique • SimpleD3D, Simple3DTouch, ResourceLoading, D3DPostProcessing, Stereo… • E2E sample ‘starter kits’ with source • Demonstrate integration of all components (basic*.cpp) • Simple3DGame, ModernMarbleMaze

  35. Hands-on Labs • <764> Direct3D Tutorial • Basic elements of 3D graphics taught step-by-step using Direct3D • <709> Visual Studio 11 Visualization and Debugging • DirectX-oriented features like texture viewing, shader analysis, mesh validation, API call debugging • <763> Visual Studio Debugging • More chances to try out the debugging and 3D basics

  36. Related sessions • [PLAT-766T] Introduction to DirectX for Metro style apps • [PLAT-750T] Build your first Metro style game • [PLAT-752T] Tuning GPU usage for any form factor • [TOOL-761T] A lap around DirectX game development tools • [PLAT-756T] Building Xbox LIVE games for Windows 8

  37. Windows 8 is the ideal platform for 3D apps.

  38. Use 3D in Metro style apps • 3D is a valuable way to differentiate your Metro style app • Direct3D11 is the solution for 3D in Windows 8 • Direct3D is fully supported with APIs, tools, and samples • Go build your 3D Metro style app!

  39. thank you Feedback and questions http://forums.dev.windows.com Session feedbackhttp://bldw.in/SessionFeedback

  40. © 2011 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

More Related