Vertex shader

From Tech Artists Wiki

Jump to: navigation, search

The Vertex Shader, also called a Vertex Program, is a shader program executed on the GPU.

A vertex shader processes vertices. How it processes these verts is determined by the program. A normal vertex shader will get an input of the vertex position in object space, normal vector, texture coordinate, in addition to other data determined by the shader and engine (such as tangent and binormal data, vertex colors, etc.). It generally will transform the vertex position to clip space, and pass out any other specified data, such as the light vector to the vertex, texture coordinates, the view vector, etc. It may also perform Vertex Skinning.

After data exits the vertex shader, rasterization occurs, and the programmable pipeline then moves over to the pixel shader.

[edit] Tips

Vertex shaders are rarely the bottleneck in modern games. The bottleneck is usually on the CPU, but if it is on the GPU, it is almost always the pixel shader. This means everything should be offloaded to the vertex shader as possible; for example, it would be cheaper to calculate the half angle on the vertex shader and normalize it in the pixel shader, than it would be to construct it in the pixel shader.

What can be done in the vertex shader is very interesting and pretty unlimited (other than modifying image appearance, which only the pixel shader can do), especially with DX10 and the geometry shader. The main roadblock for a technical artist, however, is being able to access the inputs to the vertex shader. It is one thing to specify new constants and globals, but there is lots of power in being able to send extra data per-vertex (such as miscellaneous data in the W coordinate of a UVW, or disguising other data as a binormal). Some of this can be overcome by creating a plugin for the shader (see MaxScript DirectX Scripted Material Plugin.

Personal tools