Graphics Reference
In-Depth Information
ers, you usually are required to include a vertex
shader, too.
When you're developing shaders, however,
you don't necessarily need to think of the entire
graphics pipeline like this. For each individual
shader, it is helpful to understand what data
comes into this shader, what this shader can do
with it, and what new data gets transmited to
the next stage. For this, it's interesting to consider
how the graphics pipeline looks to shaders; this
is shown in Figure 3.2, with an emphasis on how
data moves among the shader stages. Of course,
if you choose not to include any shader stage, the
in/out variables from the previous stage simply
skip the omited stage and go on to the subsequent
stage.
Notice in Figure 3.2 that all atribute variables
are input to the vertex shader, and all uniform vari-
ables are input to whatever shader needs them.
Uniform variables are writen by the application;
none of them can be writen by any shader. Any
computation that needs to pass data on to the next
shader must do so through an out variable, and
that variable must be read (as an in variable) and
passed along (as an out variable) by intermediate
variables until it is used.
Let's consider how the separate functional-
ities of the graphics pipeline might be enhanced by
using shaders. To begin, let's look at the modeling
functions that begin the geometry pipeline. In the
standard pipeline, you define the vertices of your
model either by using specific statements, such as glVertex3f(2.0, -1.0, 3.0),
or by using a computation to create the vertex coordinates. You can add other
geometric information such as normals and texture coordinates as you need
them and as they are available. You can also add appearance information.
This may be done while the geometry is defined, as you might do with colors
through the glColor*(...) function. Another approach to appearance defines
and enables environments such as lighting, with its associated materials defi-
nition, or textures, with their associated texture parameters, texture environ-
ment, and texture image.
Figure 3.1. The expanded graphics pipeline,
with programmable stages shown in green
and fixed-function stages shown in orange.
Search WWH ::




Custom Search