Game Development Reference
In-Depth Information
3.11 P ROGRAMMABLE R ENDERING P IPELINE
The programmable rendering pipeline is a part of the overall rendering pipeline in which
graphics programmers have the ability to manipulate vertex and pixel data before they are
rasterized.
Data sent to the graphics device will pass through different programmable stages, these
stages are programmed in a language that depends on the target platform in which the
game is running. Commonly, Direct3D uses the High Level Shading Language, HLSL and
OpenGLĀ® uses the OpenGLĀ® Shading Language, GLSL. The languages share similarities
and it is often not difficult to port features from one to another. That said, there is often sig-
nificant overhead in maintaining shaders when working on multiple platforms concurrently.
To abstract the platform-specific language details away from programmers and to provide
special effect, or shader artists with user-friendly environments to develop effects, teams
usually acquire or develop visual graph-based tools that allow for quick development and
iteration on shaders, without writing any code.
3.11.1 Vertex Shaders
We can think of a vertex shader as a small executable program that is run on every vertex
in a set prior to rendering. This program may apply different properties to vertices as they
are processed, color, lighting, deformations, the job of the vertex shader is to transform ver-
tices and prepare them for the next stage in the pipeline. The programming languages used
by vertex shaders vary slightly depending on the hardware vendor, API or platform. At the
core, shaders are a form of assembly language, which tends to frighten many programmers,
however,forafewyearsvertexandotherhardware shadershaveevolvedtouseahighlevel
languages that greatly simplifies programming the GPU.
A vertex shader receives vertex data as input, at the least this means a position, but often it
may include texture coordinates, blend indices or custom data for special effects.
A straightforward vertex shader that transforms geometry from world space into screen
space may be implemented as follows:
float4x4 view;
float4x4 projection;
float4x4 world;
Search WWH ::




Custom Search