Graphics Reference
In-Depth Information
as discussed in Chapter 8. The keyword noperspective indicates that these
variables are interpolated in screen space, rather than being interpolated in a
perspective-correct way. The usage is
noperspective in float variable_name;
The keyword centroid indicates that values are to be centroid sampled,
that is, sampled at an implementation-defined position in the intersection of
a pixel and a primitive, for the purpose of determining what value to apply to
the pixel. This is an advanced topic, but it could be useful if you are applying
functions across a primitive that may be discontinuous or highly non-linear.
New Function Parameter Types
GLSL function parameters are passed by value-return , rather than by value. This
allows two-way communication between the calling function and the called
function by copying values into and out of function parameters. Parameters
are modified by the keywords in , out , and inout . The parameter keyword in
describes the traditional pass-by-value of C, while the parameter keywords
out and inout , described later in this chapter, replace the need for reference
parameters. GLSL does not use pointers.
Language Details
In the sections below, we discuss specific features of the GLSL shader lan-
guage. In most cases, it should be clear how these features support the kinds
of computation needed for shaders. In a few cases, however, we will briefly
discuss some examples, such as swizzle operations where the language fea-
tures make capabilities possible that go beyond those implicit in the nature of
the language.
Omitted Language Features
Because GLSL is not a general-purpose language, it does not have some capa-
bilities we are used to seeing in C and other languages. In fact, it cannot have
some of these features because the graphics processor does not support all the
operations that a general-purpose processor must. The features that are omit-
ted are probably less important for most processing than they are convenient,
so you will probably not miss them too much. They include
Search WWH ::




Custom Search