|
Shader Reference
|
|
| |
Shader: A custom shading and lighting procedure that allows the motivated artist/programmer to specify the rendering of a vertex or pixel.
"Shader"
comes from Pixar's RenderMan - which is a program that takes an entire
description of a scene, from camera positions - through object geometry - to
a final rendering. RenderMan was introduced in 1989, but it wasn't really until
the 1995 release of the movie Toy Story that the general public was introduced
to the power of RenderMan. About this same time there was a revolution taking
place on the graphics boards of PC's - the boards were evolving at a faster
and faster clip and the features that were showing up on "commodity"
boards were rivaling those previously found only on workstations.
As
Pixar continued to make hit after hit using RenderMan. Soon other movie studios
joined in. Meanwhile, the PC games community was finding new uses for the powerful
graphics cards that new PCs were now equipped with. Light maps in particular
were soon finding their way into games, followed by bump maps and procedural
vertex generation. In fact it was the games community that soon started clamoring
for more features, and in order to differentiate themselves from the pack, some
graphics card vendors heeded this call and soon started layering more and more
features onto their cards. This had a snowball effect of creating a larger and
larger installed base of fairly sophisticated PC that had a good selection of
graphics features.
Shaders
are simply simple programs that describe the traits of either a vertex or a
pixel. Vertex shaders describe the traits (position, texture coordinates, colors,
etc.) of a vertex, while pixel shaders describe the traits (color, z depth and
alpha value) of a pixel. (Note: In OpenGL parlance this is called a fragment,
so OpenGL calls these fragment shaders). A vertex shader is called for each
vertex in a primitive (possibly after tessellation) - thus one vertex in - one
(updated) vertex out. Each vertex is then rendered as a series of pixels on
the screen (or more correctly, onto a surface (block of memory) that will eventually
be sent to the screen).
Shaders
replace a section of video hardware that's typically called the Fixed Function
Pipeline (FFP). This is because it performs lighting and texture mapping in
a hard-coded manner, while shaders let you replace this hard-coded approach
with a programmable one. Learning to program shaders isn't something that you
can learn over a weekend, but it isn't that hard either. You have the option
of letting the FFP decide how to shade your object or you can take control and
shade the objects to achieve just about any effect you desire.