Graphics Reference
In-Depth Information
is to implement shader model 5 by applying more of an object model to the
GLSL shader language. This includes such features as shader subroutines, giv-
ing you runtime selection of the particular function to be called so you can
keep multiple ways of doing things in a single shader.
GLSL 4.00 includes significant developments for geometry shaders,
which are discussed in more detail in Chapter 12. You can now have mul-
tiple iterations of a single geometry shader to create multiple instances of the
shader, leting you recursively subdivide geometry primitives. You can also
create multiple vertex streams from a geometry shader, with the first stream
being the normal output to primitive assembly and the rasterizer, and with
additional streams going to transform feedback objects.
Texture interpolation is enhanced in GLSL 4.00. It includes the texture
gather operation, returning the four texel values that would be returned by
standard texel interpolation so that you can apply your own interpolation to
them.
The GLSL compiler is designed to optimize expressions for the sake of
efficiency, but the optimization makes it impossible to know exactly how an
expression is implemented. GLSL 4.00 introduces the invariant qualifier for
a variable that requires the compiler to compute the same variable expression
the same way in two different shaders. This lets you maintain computational
consistency in multipass algorithms.
With GLSL 4.00, the shader language becomes even more C-like. You
finally get the functionality of the #include statement, you get full 64-bit IEEE
floating point variables with the keyword double , function overloading, and
you get a wider set of implicit type conversions, including float → double,
int → double, uint → double, and int → int. You also get a new operator,
the fused multiply-add, writen as fma(a,b,c) ; this performs the operation
(a*b)+c with a single operation and no loss of precision.
OpenGL 4.x/GLSL 4.x0
OpenGL 4.x and GLSL 4.x0 are probably best characterized by the way they
increase the generality of shader operations. They support shader binaries , pre-
compiled shaders that can be writen to a ile and loaded separately to save
recompilation, as well as separable shader pipeline stages, linking shaders to
a shader program at runtime so you can select different shader stages then.
This standard level also supports viewport arrays, supporting drawing into
multiple viewports by allowing the geometry shader to select which viewport
to render into.
One of the newest features in OpenGL 4.x and GLSL 4.x0 is the ability to
generate “side effects.” GLSL programs can now read and write to image tex-
Search WWH ::




Custom Search