Tutorial 4: Buffers, Shaders, and HLSL

Tutorial 4: Buffers, Shaders, and HLSL
This tutorial will be the introduction to writing vertex and pixel shaders in DirectX 11.
It will also be the introduction to using vertex and index buffers in DirectX 11.
These are the most fundamental concepts that you need to understand and utilize to render 3D graphics.


Vertex Buffers

The first concept to understand is vertex buffers. To illustrate this concept let us take the example of a 3D model of a sphere:

 

The 3D sphere model is actually composed of hundreds of triangles:
3D模型是由很多三角形组成


Each of the triangles in the sphere model has three points to it, we call each point a vertex.
So for us to render the sphere model we need to put all the vertices that form the sphere into a special data array that we call a vertex buffer.
Once all the points of the sphere model are in the vertex buffer we can then send the vertex buffer to the GPU so that it can render the model.
一个特殊的data 数组------vertex buffer
我们可以send v b 去GPU so that 它可以绘制模型

Index Buffers

Index buffers are related to vertex buffers.
Their purpose is to record the location of each vertex that is in the vertex buffer.
The GPU then uses the index buffer to quickly find specific vertices in the vertex buffer.
The concept of an index buffer is similar to the concept using an index in a book,
it helps find the topic you are looking for at a much higher speed.
The DirectX SDK documentation says that using index buffers can also increase the possibility of caching the vertex data in faster locations in video memory. So it is highly advised to use these for performance reasons as well.
它的目的是去记录在v b里面的每个顶点的位置

posted @ 2015-12-21 00:34  shinymood  阅读(164)  评论(0编辑  收藏  举报