The latest 3D graphics cards bring us amazing visuals in the latest games, from Indie to AAA titles. This is made possible on Microsoft platforms including PC, Xbox consoles, and mobile devices thanks to Direct3D—a component of the DirectX API dedicated to exposing 3D graphics hardware to programmers. Microsoft DirectX is the graphics technology powering today's hottest games on Microsoft platforms. DirectX 11 features hardware tessellation for rich geometric detail, compute shaders for custom graphics effects, and improved multithreading for better hardware utilization. With it comes a number of fundamental game changing improvements to the way in which we render 3D graphics.
The last decade has also seen the rise of General-Purpose computation on Graphics Processing Units (GPGPU), exposing the massively parallel computing power of Graphics Processing Units (GPUs) to programmers for scientific or technical computing. Some uses include implementing Artificial Intelligence (AI), advanced postprocessing and physics within games, powering complex scientific modeling, or contributing to large scale distributed computing projects.
Direct3D and related DirectX graphics APIs continue to be an important part of the Microsoft technology stack. Remaining an integral part of their graphics strategy on all platforms, the library advances in leaps and bounds with each new release, opening further opportunities for developers to exploit. With the release of the third generation Xbox console—the Xbox One—and the latest games embracing the recent DirectX 11 changes in 11.1 and 11.2, we will continue to see Direct3D be a leading 3D graphics API.
Direct3D Rendering Cookbook is a practical, example-driven, technical cookbook with numerous Direct3D 11.1 and 11.2 rendering techniques supported by illustrations, example images, strong sample code, and concise explanations.
Chapter 1, Getting Started with Direct3D, reviews the components of Direct3D and the graphics pipeline, explores the latest features in DirectX 11.1 and 11.2, and looks at how to build and debug Direct3D applications with C# and SharpDX.
Chapter 2, Rendering with Direct3D, introduces a simple rendering framework, teaches how to render primitive shapes, and compiles HLSL shaders and use textures.
Chapter 3, Rendering Meshes, explores rendering more complex objects and demonstrates how to use the Visual Studio graphics content pipeline to compile and render 3D assets.
Chapter 4, Animating Meshes with Vertex Skinning, teaches how to implement vertex skinning for the animation of 3D models.
Chapter 5, Applying Hardware Tessellation, covers tessellating primitive shapes, parametric surfaces, mesh subdivision/refinement, and techniques for optimizing tessellation performance.
Chapter 6, Adding Surface Detail with Normal and Displacement Mapping, teaches how to combine tessellation with normal and displacement mapping to increase surface detail. Displacement decals are explored and then optimized for performance with displacement adaptive tessellation.
Chapter 7, Performing Image Processing Techniques, describes how to use compute shaders to implement a number of image-processing techniques often used within postprocessing.
Chapter 8, Incorporating Physics and Simulations, explores implementing physics, simulating ocean waves, and rendering particles.
Chapter 9, Rendering on Multiple Threads and Deferred Contexts, benchmarks multithreaded rendering and explores the impact of multithreading on two common environment-mapping techniques.
Chapter 10, Implementing Deferred Rendering, provides insight into the techniques necessary to implement deferred rendering solutions.
Chapter 11, Integrating Direct3D with XAML and Windows 8.1, covers how to implement Direct3D Windows Store apps and optionally integrate with XAML based UIs and effects. Loading and compiling resources within Windows 8.1 is also explored.
Appendix, Further Reading, includes all the references and papers that can be referred for gathering more details and information related to the topics covered in the book.
To complete the recipes in this book, it is necessary that you have a graphics card that supports a minimum of DirectX 11.1.
It is recommended that you have the following software:
Microsoft Visual Studio 2013 Express (or higher edition)
Microsoft .NET Framework 4.5
Windows Software Development Kit (SDK) for Windows 8.1
SharpDX 2.5.1 or higher—http://sharpdx.org/news/
Other resources and libraries are indicated in individual recipes.
For those running Windows 7 or Windows 8, you will require a minimum of the following software. Please note that although some portions of Chapter 11, Integrating Direct3D with XAML and Windows 8.1, can be adapted to Windows 8, you will not be able to complete the final chapter in its entirety as it is specific to Windows 8.1.
Microsoft Visual Studio 2012 or 2013 Express (or higher edition)
Microsoft .NET Framework 4.5
Windows 8 or Windows 7 with Platform Update for SP1*
Windows Software development Kit (SDK) for Windows 8
SharpDX 2.5.1 or higher—http://sharpdx.org/news/
Other resources and libraries as indicated in individual recipes.
Chapter 11, Integrating Direct3D with XAML and Windows 8.1, is not compatible with Windows 7, and the Rendering to a XAML SwapChainPanel recipe requires a minimum of Windows 8.1.
Direct3D Rendering Cookbook is for C# .NET developers who want to learn the advanced rendering techniques made possible with DirectX 11.1 and 11.2. It is expected that the reader has at least a cursory knowledge of graphics programming, and although some knowledge of Direct3D 10+ is helpful, it is not necessary. An understanding of vector and matrix algebra is recommended.
In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.
Code words in text are shown as follows: A command list is represented by the
ID3D11CommandList interface in unmanaged C++ and the
Direct3D11.CommandList class in managed C# with SharpDX.
A block of code is set as follows:
SharpDX.Direct3D.FeatureLevel.Level_11_1, SharpDX.Direct3D.FeatureLevel.Level_11_0, SharpDX.Direct3D.FeatureLevel.Level_10_1, SharpDX.Direct3D.FeatureLevel.Level_10_0,
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
// Create the device and swapchain
New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "These are accessible by navigating to the DEBUG/Graphics menu".
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.
To send us general feedback, simply send an e-mail to
<[email protected]>, and mention the book title via the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
We also provide you a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from: https://www.packtpub.com/sites/default/files/downloads/7101OT_ColoredImages.pdf
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.
Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at
<[email protected]> with a link to the suspected pirated material.
We appreciate your help in protecting our authors, and our ability to bring you valuable content.
You can contact us at
<[email protected]> if you are having a problem with any aspect of the book, and we will do our best to address it.