Chapter II introduces vertex shader
Read this article shows that you have agreed to the statement
[Translator's Order] After the previous chapter, the knowledge cards of HLSL, now you should only have two states, the first one is that there is already an unrespoated amount of interest, and the other is that the other is too easy to say, read It's awkward. If you are the first case, then I suggest you take the knowledge of computer graphics and C , then learn; if you are the second case, then it is right! We will start learning this most exciting three chapters from now on. These three can be said to cover the basis of the latest Direct3D's latest graphics technology, ready? Let's go!
Overview
The vertex shader is a program executed on the GPU of the graphics card, which replaces the transformation and lighting phase in the fixed function pipeline. (This is not 100% correct, because the vertex shader can be operated by Direct3D (Direct3D Runtime) with software simulation, if the hardware does not support the vertex shader.). Figure 2.1 illustrates the components replaced in the vertex shader in the pipeline.
Figure 2.1: The vertex shader replaces the light and deformation stage of the fixed function line
From Figure 2.1, we know that the vertex inputs to the vertex shader with a local coordinate, and the vertex shader must output the light-lighted (colored) vertex entry tailoring space. (In order to maintain a simple reason, we have not deeply study the details of the projection transformation. However, the space of the projection matrix transform vertex is called homogeneous clip space. Therefore, to transform a vertex from local space to Submissive coordinate space, we must apply the following transform sequences: World Transformation, View Transformation and Projection Transformation, which are completed by the world matrix, view matrix and projection matrix.) For points Point Primitive, the vertex shader is also used to operate the vertex size of each vertex.
Since the vertex shader is a custom program written by our (in HLSL), we have gained great freedom we can achieve in terms of graphics effects. We no longer be limited to fixed lighting algorithms for Direct3D. In addition, the ability to operate the length of the application can also have diversity, such as: Cloth Simulation, the point size of the particle system, and vertices mix / Morphing. In addition, our vertex data structure is more free, and can include multiple data more than in the fixed function line in the programmable line.
The vertex shader is still relatively new features, and many graphics cards do not support them, especially with newer versions of the DirectX 9. Vertex shader. You can test the version of the vertex shader by checking the VertexShaderversion member of the D3DCaps9 structure. The following code segments show this:
// if the device's supported version is Less Than Version 2.0
Caps.vertexShaderversion // Then Vertex Shader Version 2.0 is not supported on this // device. We see the two parameters of D3D_Version receive the master and subsection number. Now, the D3DXCompileshaderFromFile function supports the vertex shader version 1.1 and 2.0. Target N Learn how to define a vertex structure in the programmable pipeline N to understand how different usage n learning how to create, set and destroy a vertex shader n learning how to use the vertex shader to implement cartoon animation rendering effect [declaration]: This article "Introduction to 3D Game Programming With DirectX 9.0" is translated, it is limited to the translator level, and it is inevitable that you are not allowed to leak. Welcome all users criticize and correct; this article is only used for learning exchange and reference purposes, and cannot be used in any form of business Use; if you need to reprint the author's consent of the author and the translator, maintain the integrity of the article, and indicate the author, translator and source, and the translator is not responsible for the consequences of violating the above terms. My email address is raymond_king123@hotmade.com, welcome 3D graphics and games, and friends with a certain graphical programming experience to communicate.