This series of articles is mainly translated and referenced from "Real-time 3D Rendering with DirectX and HLSL" (thanks to the author of the original book), but also a bit of personal understanding and development, if there are errors in the article, please correct me.
Here is the code and resources in the book.
This article index:
- A Microsoft that set
- 1 Microsoft Visual Studio
- 2 Windows SDK
- 3 Effects One Library
- 4 DirectX Tool Kit
- Two NVIDIA FX Composer
- 1 Effects and materials
- 2 The Render Panel
- 3 The Textures Panel
- Three for Directx11nvidia nsight Visual Studio Edition
- Four Visual Studio Graphics Debugger
- Five other graphical debuggers
- Vi. Summary
- Reference links
First, Microsoft "that set"
Since it is written HLSL, it is naturally inseparable from its development company-Microsoft. Microsoft has provided a lot of handy and integrated tools for writing DirectX and its shader language HLSL, although it is a bit larger, but it is also more convenient after all. Here is a brief introduction of what Microsoft has to provide us with what convenient "bundle" tool it.
(1) Microsoft Visual Studio
Starting with Microsoft Visual Studio 2010, the IDE has grown to nearly more than 10 large versions, with increasingly integrated capabilities and a larger volume. This IDE provides support for many programming languages and hardware platforms, including Windows Phone,xbox 360, and Xbox One. The best thing for us to be happy about is that it provides support for the C + + and HLSL languages, and also integrates the visual Stuidio Graphics (see the latter part of this article for this tool).
The original book uses the VS2013 version, and is now out of the VS2015U2 version (want to know the relationship between DirectX11 and Vs2015u2?). Please poke here), this series of data will use the latest VS2015U2 version as the programming environment (in fact, because after the VS2015U2 found 13 can not be used, sad a play ...) )。 There are many versions of VS2013, each with some different features, but visual Studio Express for Windows desktop is free, and small partners can download them on their own.
(2) Windows SDK
Currently want to develop Microsoft-related applications of small partners can find that Microsoft is really more and more overbearing, although it is convenient, want to develop what things do not go to find a variety of installation packages, directly a Windows SDK to fix. All right...... Even if I don't want to develop a win Phone, it's really not good news for obsessive-compulsive patients. So, of course, this kind of DirectX is naturally integrated into the Windows SDK (of course, I do not have to use vs2015u2 shoes, and do not have to configure the dependent library path, VS is already integrated).
The following are the integrated library settings in VS2015:
Still in use VS2013 's small partner can refer to the original book corresponding part ~
(3) Effects one Library
Just beginning to understand this east of the time can not help but began to feel its tall on the setting, only to understand the original write shader also has a framework this said, as a before is engaged in the server of small rookie, just beginning to contact 3D programming always thought is a heap of all kinds of interfaces, feel seemingly no server so organized, Everything is well-regulated, framed, neat and orderly. Now suddenly a frame, the heart can't help but some excitement. This article is a comprehensive Chinese article that I reproduced in the blog introducing effect framework. Here are some notes on the effect framework of the original book:
| If you have used the previous version of DirectX, you should be familiar with the Directx3d extension Library (D3DX). This is an integrated library used in older versions of DirectX, but has been abandoned in the Windows SDK (meaning that the library is not available in DirectX). However, some of the features of D3DX are preserved, including some of the interfaces of the special effects file format (that is, we write shader files). Fortunately, Microsoft has provided a new set of interfaces that contain most of the features in the D3DX library, which have been directly included in the effects libraries, but currently Effect11 is removed from the Windows SDK. These features are also transferred to the DirectX Library (the current interface changes really fast, please see the article in this article for more information on the reference link ...). )。 When the original book was edited, the effect framework was updated to version 11.09. |
| The EFFECT11 framework is published separately in the form of source code, allowing users to add or modify some custom content within the framework. This also makes it necessary for you to compile the library yourself before using it. Currently, libraries for the debug and Release,win32 and X64 platforms have been published for the VS2013 and VS2015 editions. The Effect11.lib static library can be generated after configuration and compilation. The third part of the original book will provide examples of the use of relevant interfaces. |
Here is the URL of the effect framework provided in the original book on CodePlex.
This is the GIT address of the effect framework.
(4) DirectX Tool Kit
DirectX Tool Kit (DIRECTXTK) is another D3DX alternative library that provides C + + classes that you can use in DirectX11. The following list shows some of the more important libraries in the toolkit:
The source code of the DIRECTXTK library is similar to the effect framework, providing the appropriate engineering files that can be modified and compiled to the desired version. The third part of the original book will provide examples of the use of relevant interfaces.
| Texture file format |
| Textures are mainly 2D bitmaps that cover the surface of the model. Files in many formats can be used to store these image information. Taking the DIRECTXTK library as an example, these file formats are mainly divided into two categories: |
| Dds:directdraw Surface (. DDS) |
| Wic:windows Imaging components (native:. BMP/.GIF/.JPG/.PNG/.TIFF/HD photo) |
| DDS is a picture storage format provided by Microsoft, which allows the GPU to decompress directly. The compression ratio of the DDS varies with the parameter settings at the time of compression, but the extraction of DDS directly on the GPU makes it very useful. From the name of the DDS (DirectDraw Surface), you can see the benefits of running in DirectX. |
| The second picture type, WIC, is fundamentally different from DDS. WIC is an extended framework for using images. This framework allows third parties to add a number of persistent support interfaces to non-local file formats for use by developers. Images from non-local file formats can be used immediately as long as the user has installed the codec in the corresponding format. |
| In addition, you may also think of another image format, Targa (TGA), which does not provide localized support for this common format. Here (Https://www.leadtools.com/sdk/formats) is a Web site link to the WIC TGA codec provided in the original book. However, the most popular TGA codecs are not free at the moment. However, you can choose to use WIC's Directxtex texture processing library that supports TGA textures. This open source codebase plan will be added to the pipeline to support processing of the DDS format textures. This library can provide WIC support and also has a TGA reader. |
Here is the URL of the DIRECTXTK on CodePlex, which is provided in the original book.
Second, NVIDIA FX Composer
For gamers and game developers, Nvidia has become almost a household name. He is committed to advancing the GPU development process and has become a leader in graphics hardware and software. The many contributions Nvidia has made include the FX Composer, an integrated development environment for writing shader. This part of the article will begin to introduce this tool-and it is also a very extensive tool used in the original book.
First, you need to know that writing shader with HLSL is just like writing other software. Your shader code is stored in the form of a file, and any file editor can modify it. In fact, you might not like to write shader with FX composer at all, and you like tools like Visual Studio. But using target compilation, shader writing style FX composer, this type of tool may provide you with more benefits, especially in real-time display of visual effects that are reflected in the process of modifying shader. and using the FX composer This type of tool allows you to focus more on shader writing without having to put too much effort into the pit of the underlying graphics API interface (such as DirectX and OpenGL). Don't worry that you will focus too much on the non-portable code that can only be used under certain tools, and you need to know that the code you are writing with FX composer can be used directly in the game engine in the future, and will be described in the third part of the original book. The
FX Composer is a free tool that you can download directly from Nvidia's official developer center. The latest version of FX Composer in this article is 2.5 (as it was 2 years ago, because the official is no longer providing update support), is the official note:
So, do we need to study this tool? Of course. The following is an explanation given by the author in the original book, which still applies until now:
| FX composer--obsolete shader authoring tools? |
| nvidia FX Composer no longer provides update development support and is beginning to get a little older. It supports DirectX 9 and DirectX 10 only, and does not support DirectX 11. Similarly, AMD's Shader authoring tool--rendermonkey and no longer supports DirectX 11, and the development of this tool has been discontinued. And, as far as I know, there are no other business tools available to support the rapid development and visualization of shader writing in this book. This brings a lot of problems, of course, along with many opportunities. |
| |
| shader programming tool no longer updates also gives more ambitious developers more opportunities because there is a greater gap to enter the field. |
| so I chose to continue using Nvidia's FX composer as an adjunct to the second part of the book because he provided a preview of the real-time visual effects, and, This tool simply lacks support for DirectX11, so it does not hinder our presentation of rendering techniques. At first we won't be able to directly introduce a specific new feature of DirectX, and the materials we have written will not be available in the latest API version. |
is the interface of the FX composer tool:
As you can see, the interface layout of this tool is similar to that of Visual Studio, with a resizable, draggable panel. The functionality of most panels is obvious (for example, the editor panel, the Properties panel, and the output panel). What we need to explain is the other less obvious features.
(1) Effects and materials
Under the Assets Panel (3.4), you can find a label named effects and materials. Each effect is saved in your shader code by a file. A material is an example of a effect that shows different effects by adjusting different parameters in the shader. Multiple material can correspond to a effect.
An error-free material (meaning that its corresponding effect can be compiled correctly) appears in the material panel, where the sphere will show the current shader rendering effect. If the associated effect is not compiled correctly, which means the material is wrong, the sphere in the panel will appear as a mesh red sphere (3.5). The lower half of the material panel shows the material assigned to this material.
(2) The Render Panel
The render panel appears by default in the lower-right corner of the editor. This panel will present the effect (shown in 3.6) when your shader is applied to the target model in the scene. Here you can use the pre-brought model of the editor, click the ball, teapot, ring, tablet button on the main toolbar to change the model, or you can pour the custom model yourself. To pour a model, simply select the "File->import" button in the menu bar. In the same scenario you can introduce as many models as you want, just drag the corresponding material onto the model in the render panel to display.
In the render panel, you can change the position and angle of the camera in the 3D scene with the mouse and keyboard. If you're familiar with Autodesk Maya (the mainstream 3D modeling software), they're very similar in how they operate.
You can select the model in the scene by clicking the left mouse button.
Press the F key to adjust the camera's focus to the currently selected model.
Hold down the ALT key and drag the mouse button to rotate the camera around the target model.
You can zoom in or out of the camera view by holding down the SHIFT key and dragging the mouse vertically in the left mouse button. You can also use the mouse wheel to transform the camera's field of view.
You can pan the camera by holding down the CTRL key and dragging the mouse button.
In camera view, you can manipulate objects in the scene. The control can be done via the Qwer key or the corresponding button in the toolbar.
The Select object mode corresponds to the keyboard Q key, where you can select but not change the model.
The Translate object mode corresponds to the E key, in which the object in the scene can be moved. When you select an object in this mode, you will have three axes in the direction, you can move in that direction by dragging the axes in a direction, or you can drag the intersection of three axes to move freely in three directions.
Rotate object (E) and scale object (R) mode are similar to the translate mode.
The render panel also contains some other features, including background-color custom modifications, rendering reference grids, tracking through the camera, and screen captures. Again, we encourage you to try these features yourself.
(3) The Textures Panel
The texture panel (shown) can be used to add or remove textures to a project, assign textures to materials, and view the details of each texture. To add textures, click the Plus button in the upper-left corner of the panel, and you can declare specific variables in the Properties panel. Double-click a specific item in the texture panel to see the details of the material and the individual channels.
| Attention: |
| To assign a texture map to a material you need to specify a effect with a texture variable for the material, and if a effect supports multiple materials, dragging a material onto the target model will cause the dialog to fill in multiple corresponding material variables. This topic will be discussed in detail in the fifth chapter "Chapter 5, Texture Mapping" in the original book. |
Third, for Directx11--nvidia nsight Visual Studio Edition
As the Nvidia official mentioned earlier in this article is no longer offering FX composer update support, the latest shader accessibility tool is part of the Nvidia Nsight Visual Studio Edition that is described in this section.
In general, the introduction of this tool has enabled Nvidia to integrate the powerful features written by shader with mainstream Ides such as Visual Studio and Eclipse, which is equivalent to a plug-in. He supports shader authoring, compiling, debugging, performance analysis, and effect viewing, and supports CUDA, C + +, OpenGL, OpenCL, Direct Compute, DirectX.
This is the NVIDIA nsight Visual Studio Edition link, which is officially provided by the authority.
Iv. Visual Studio Graphics Debugger
Visual Studio Graphics Debugger is a tool embedded in Visual Studio that allows you to perform interactive debug custom shader. If you are familiar with older versions of DirectX, you can also use the graphics debugger pix. The Visual Studio Graphics Debugger replaces the PIX and retains the underlying workflow.
| Attention: |
| Visual Studio Graphics Debugger is not available in the Visual studio2013 Express version. You need to download the free version of Visual Studio to run this tool. But don't worry, all the examples in the original book can be used without this tool. |
Here is the official graphic debugger instructions for VS2015.
V. Other graphical debuggers
If you need to find a few more graphical debuggers that you can use in Visual Studio, you will need the following two tools: AMD's GPU Perfstudio 2 and Nvidia's Nsight Visual studio Edition. Both of these tools are free. In contrast, GPU Perfstudio 2 may be a good choice because he is a standalone tool and is not subject to the limitations of the IDE you choose. RELATED links can be found in the URL provided in this book.
Vi. Summary
In this article, we make a general introduction to the tools for writing graphics-related programs. It is recommended to use VS as the primary Ide,fx composer as a beginner shader effect editor and viewer. In addition, the three kinds of shader debug mentioned in this article can be selected according to their own needs.
Reference links
"1" Remove the D3DX, starting from now. (http://www.opengpu.org/forum.php?mod=viewthread&tid=8429&extra=&page=1)
The posts in this BBS refer to some of the D3D's evolution and Klayge shader frameworks, and the responses give some references to the small partners who want to learn D3D, which is worth a look.
"2" about the removal of the effect framework. (http://stackoverflow.com/questions/31994455/reading-hlsl-semantics-annonations-with-directx-11-api/31994724#31994724)
The answer to this link explains the current situation of the effect framework, right, now the effect framework does not natively support the DirectX package, and is similar to the open source package as a separate package needs to be introduced.
"3" Effect Official Document Introduction (HTTPS://MSDN.MICROSOFT.COM/EN-US/LIBRARY/WINDOWS/DESKTOP/FF476136 (v=vs.85). aspx)
"4" Microsoft Open Source set of DirectX toolset (http://www.infoq.com/cn/news/2015/04/mit-directx-github/)
"DirectX11" The third chapter to write shader? --Let's get to the tools.