How This Course is OrganizedWe'll work through the fundamentals to a more advanced level in five lessons, first for vertex and later for pixel shaders. So our road map looks like this:
Let's start by examining the place of vertex shaders in the Direct3D pipeline ... Vertex Shaders in the PipelineThe following diagram shows the Source or Polygon, Vertex and Pixel Operations level of the Direct3D pipeline in a very simplified way:
On the source data level, the vertices are assembled and tessellated. This is the so called high-order primitive module, which works to tessellate high-order primitives such as N-Patches (ATI RADEON in device driver/ATI RADEON 8500 in hardware), quintic béziers, B-splines and rectangular and triangular (RT) patches. It looks like the new 21.81 drivers from nVidia driver doesn't support RT-patches on the Geforce3 anymore. A GPU that supports RT-Patches breaks higher-order lines and surfaces into triangles and vertices. A GPU that supports N-Patches generates, depending on the non-perpendicular angle of the normals of each triangle of an object, so called control points. The more the normals are bent away of the middle of the triangle, the more control points will be built by the GPU. Then a bézier surface, consisting of triangles, will be build out of these control points with the help of a special algorithm. In this course, we're most interested in the vertex operations level: with Direct3D you have two different ways of processing vertices:
Our focus lies on the second method. It is obvious from this simplifying diagramm that Face Culling, User Clip Planes, Frustrum Clipping, Homogenous Divide and Viewport Mapping operate on the vertex-level after the vertex shader. So these operations can't be controlled by a vertex shader. So what kind of operations does a vertex shader do for you? Every vertex shader will accept one input vertex and generate one output vertex. So it is not able to create a new vertex. It is able to process the following steps on such a vertex:
A processed vertex will consist of at least a clip-space position (x, y, z and w) and optionally color, texture coordinate, fog intensity and point size information. A Vertex Shader doesn't do the following:
To summarize this abstract overview on vertex shader functionality: the vertex shader is only able to replace the hardwired- transformation and lighting capabilities. The following pipeline stages are fixed-function. So the developer is able to write their own transformation and lighting engine this way. But why would someone do this? |