Graphics Reference
In-Depth Information
The Need to Support Graphics Operations
Another key fact about graphics cards is that they must carry out a large num-
ber of matrix operations at high speeds, so matrix and vector operations are
native to the language, and most likely supported at some level in your hard-
ware. Thus, the GLSL language is shaped by its goal of supporting the opera-
tions needed for computer graphics. This is done by adding specific support
for matrix and vector data types and operations, including both operations
and useful functions; supporting functions that are frequently used for geo-
metric operations; adding language support for noise functions; and adding
functions for texture and fragment operations. Some of these are included
so they can be optimized, and some are included in anticipation of higher-
level operations moving onto graphics cards. GLSL developments so far have
extended the original scope of the language, and there is every reason to
believe that when additional graphical capabilities are available, such as the
recent development of geometry shaders, the language will be extended to
support them.
Built-In Data
General-purpose processors have registers that can be used for many kinds
of variables, so each must be capable of any kind of operation. Graphics cards
designed as OpenGL 2.1 was being released, on the other hand, have a num-
ber of special-purpose registers that are loaded with specific data when infor-
mation is received from the general OpenGL application program. This gives
these graphics cards known environments that can be read or writen by a
shader program, leading to the use of specific names for variables that have
particular information.
This aspect of the graphics environment is primarily handled in GLSL
by a number of built-in variables that let you access standard data passed to
the graphics card from the OpenGL API. This data describes geometry, light-
ing, transformations, and textures. By using the appropriate GLSL variables,
you can use this information for computation in your shaders.
More recently, however, graphics cards have become much more gen-
eral processors, and these special-purpose registers have been deprecated. A
few specific variables have been retained, but the task of building the graph-
ics environment has been passed to the graphics programmer. This increases
the programmer's task, but returns significant improvements in performance
and in the generality of graphics operations you can create. These changes are
described below and in the chapters on each kind of shader.
Search WWH ::




Custom Search