Real-Time Shading

As of this writing, a proposal has been introduced for full shading language extensions to OpenGL, referred to as OpenGL 2.0 [1]. The proposal was created by 3DLabs, but has support from a large number of OpenGL ARB members. The proposal has already been through a couple of revisions. While some details of the proposal will certainly change between this writing and a final specification, most of what we describe in this chapter will still be correct by the time you read it.
Our coverage will be brief since many aspects of OpenGL 2.0 draw on previous shading systems. The OpenGL 2.0 shading language looks like a cross between C and Stanford s RTSL (Chapter 15). It differs from both in several important aspects, and these aspects are the focus of this chapter.
OpenGL 2.0 simplifies a number of aspects of OpenGL, replacing them with a high-level shading language. This language is used to map procedures directly onto the (current) division of hardware units. As such, the logical model diagram reflects the physical hardware organization. The stages include a high-level language for vertex and fragment processing stages as appear in DirectX (Figure 5.3). They also include a high-level interface for stages to pack and unpack pixel values as they are read in and out of the host processor. These pack and unpack shaders can map from colormapped textures to RGB, or RGB to color-mapped on the fly, or do some forms of texture compression or decompression.