O'Reilly logo

Graphics Shaders, 2nd Edition by Steve Cunningham, Mike Bailey

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

69
Using glman
4
Shaders, like many other areas in graphics, have many complexities in their
structure and options, and one of the best ways to learn them is simply to try
out ideas, choices, and dierent parameters in the shaders you write. However,
exploring shaders in this way can be time-consuming when you have to go
through the entire edit-compile-link-run cycle for each change you want to test
in the shader. In order for you to try out many options and ideas for shaders
with a very short turnaround cycle, the glman tool provides a handy OpenGL
program substitute that lets you change shader code and see the results very
quickly, especially since it also lets you experiment with the values of uniform
variables as shader parameters. The cycle of experimentation for developing
shaders with and without glman is shown in Figure 4.1.
To use glman, you need to create a GLIB le. The name GLIB stands for
“GL Interface Bytestream,” and a GLIB le is a scene description script whose
70
4. Using glman
details are described later in this chapter. This is an ASCII-encoded input le
inspired by the Photorealistic RenderMan RIB le. You need to have both a
vertex shader and a fragment shader to use glman; you can also have a tessel-
lation shader or a geometry shader if you want, and if your system supports it.
You start by writing a GLIB le that describes your geometry and speci-
es your vertex, tessellation, geometry, and fragment shaders. The GLIB le
can dene uniform variables, including variables that can be changed using
sliders or color pickers. You can edit GLIB and shader les from within glman,
so you can start adding eects to the shaders, or geometry to the GLIB le, to
get incremental results. The glman system will return error messages if you
have compile errors in your shaders, which is very helpful as you begin to
learn to develop them. This experimental approach and incremental develop-
ment of shaders gives you good feedback on what works and lets you create
some very interesting images along the way.
While glman will let you make some very interesting images that illus-
trate how your shaders work, you should realize that it is not a production
tool for creating general graphics applications. There were conscious design
decisions to support only a limited geometry and interaction set, for example.
What it does is give you a tool to develop shaders easily and fairly quickly and
to experiment with shader parameters, and it does that very well.
When you are satised that the shaders you have developed do the things
you want, you can be condent that they will be useable for your other work.
Later chapters discuss how to use shaders for applications, so the shaders you
develop here will be useful there.
You can get glman from this book’s website at hp://www.cgeducation
.org/glman. It runs on Windows, even if you do not have a compiler and pro-
gramming environment on the system. Linux and Macintosh versions are
Figure 4.1. The cycle of experimentation without glman (left) and with glman (right).

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required