Graphics Reference
In-Depth Information
Our Approach in this Topic
In this topic we take something of a hybrid approach to the question of OpenGL
standard levels. We generally use GLSL at the 1.50 level, but do use many
of the more advanced constructions of OpenGL 3.* and 4.*. We do cover tes-
sellation shaders and geometry shaders, and we use the most current syntax
for passing data between shaders. For the most part, we don't use the depre-
cated built-in variable names in our sample code. However, to make life easier,
later on we will show you a file we've created for our own use, gstap.h , which
#defines the un-deprecated names to the deprecated names. In this way, you
can get the best of both worlds—your code looks cleaner and more modern,
but underneath you are still using the easy-to-get-at built-ins.
Variable Name Convention
As we will discuss in the next chapter, variables take on a number of different
roles for shaders. Two kinds of variables are provided by your application (or
by the OpenGL system, if you are using older OpenGL standards): atribute
and uniform variables. Atribute variables are used to describe individual ver-
tices, while uniform variables are used to define whole graphics primitives
or larger-scale graphics concepts. Other variables are used to pass variables
between shaders: out and in variables. Each shader passes data to other shad-
ers or other OpenGL stages as out variables, and each shader takes data from
other shaders or the application program as in variables.
In this text we will adopt a convention for variable names that are passed
between the application and the various shaders that we will present. This
convention is entirely arbitrary, but it helps us keep track of the source of vari-
ables that come into each of the shaders. We will use the convention in the
Prefix
Stage that wrote it
Example
a
Atribute (from application)
aColor
u
Uniform (from application)
uModelViewMatrix
v
Vertex Shader
vST
tc
Tessellation Control Shader
tcRadius
te
Tessellation Evaluation Shader
teNormal
g
Geometry Shader
gNormal
f
Fragment Shader
fFragColor
Table 2.2. Our initial leter naming convention.
Search WWH ::




Custom Search