Graphics Shaders : Theory and Practice, Second Edition book cover
2nd Edition

Graphics Shaders
Theory and Practice, Second Edition

ISBN 9781568814346
Published November 8, 2011 by A K Peters/CRC Press
520 Pages

USD $110.00

Prices & shipping based on shipping country


Book Description

Graphics Shaders: Theory and Practice is intended for a second course in computer graphics at the undergraduate or graduate level, introducing shader programming in general, but focusing on the GLSL shading language. While teaching how to write programmable shaders, the authors also teach and reinforce the fundamentals of computer graphics. The second edition has been updated to incorporate changes in the OpenGL API (OpenGL 4.x and GLSL 4.x0) and also has a chapter on the new tessellation shaders, including many practical examples.

The book starts with a quick review of the graphics pipeline, emphasizing features that are rarely taught in introductory courses, but are immediately exposed in shader work. It then covers shader-specific theory for vertex, tessellation, geometry, and fragment shaders using the GLSL 4.x0 shading language. The text also introduces the freely available glman tool that enables you to develop, test, and tune shaders separately from the applications that will use them. The authors explore how shaders can be used to support a wide variety of applications and present examples of shaders in 3D geometry, scientific visualization, geometry morphing, algorithmic art, and more.

Features of the Second Edition:

  • Written using the most recent specification releases (OpenGL 4.x and GLSL 4.x0) including code examples brought up-to-date with the current standard of the GLSL language.
  • More examples and more exercises
  • A chapter on tessellation shaders
  • An expanded Serious Fun chapter with examples that illustrate using shaders to produce fun effects
  • A discussion of how to handle the major changes occurring in the OpenGL standard, and some C++ classes to help you manage that transition

The authors thoroughly explain the concepts, use sample code to describe details of the concepts, and then challenge you to extend the examples. They provide sample source code for many of the book’s examples at

Table of Contents

The Fixed-Function Graphics Pipeline
The Traditional View
How the Traditional View Is Implemented
Vertex Arrays

OpenGL Shader Evolution
History of Shaders
OpenGL Shader History
How Can You Respond to These Changes?
Our Approach in This Book

Fundamental Shader Concepts
Shaders in the Graphics Pipeline
The GLSL Shading Language
Passing Data from Your Application into Shaders

Using glman
Using glman
GLIB Scene Creation
More on Textures and Noise
Functions in the glman Interface Window

The GLSL Shader Language
Factors that Shape Shader Languages
General GLSL Language Concepts
Language Details
Compatibility Mode

The ADS Lighting Model
Types of Lights
Setting Up Lighting for Shading

Vertex Shaders
Vertex Shaders in the Graphics Pipeline
Replacing Fixed-Function Graphics with Vertex Shaders
Going beyond the Fixed-Function Pipeline with Vertex Shaders
Vertex Modification
Issues in Vertex Shaders

Fragment Shaders and Surface Appearance
Basic Function of a Fragment Shader
Fragment Shader Processing
Replacing Fixed-Function Processing with Fragment Shaders
What Follows a Fragment Shader?
Additional Shader Effects

Surface Textures in the Fragment Shader
Texture Coordinates
Traditional Texture Mapping
GLSL Texture Mapping
Render to Texture
Render to Texture for Multipass Rendering in glman

Fundamental Noise Concepts
Other Noise Concepts
Some Examples of Noise in Different Environments
Advanced Noise Topics
Using Noisegraph

Image Manipulation with Shaders
Basic Concepts
Single-Image Manipulation
The Image Blending Process
Blending an Image with a Constant Base Image
Blending an Image with a Version of Itself
Blending Two Different Images

Geometry Shader Concepts and Examples
What Does the Geometry Shader Do?
Normals in Geometry Shaders

Tessellation Shaders
What Are Tessellation Shaders?
Tessellation Shader Concepts

Shaders in the OpenGL Programming Process
How Is a GLSL Shader Program Created?
Creating and Compiling Shader Objects
Creating, Attaching, Linking, and Activating Shader Programs
Passing Data into Shaders

Using Shaders for Scientific Visualization
Image-Based Visualization Techniques
Hyperbolic Geometry
3D Scalar Data Visualization
More on Transfer Functions
Passing in Data Values with Your Geometry
Terrain Bump-Mapping
Flow Visualization
Geometry Visualization

Serious Fun
Light Interference
Lens Effects
Bathroom Glass
Atmospheric Effects
Fun with One
Using the glman Timer Function
Disco Ball
Fog, with and without Noise
Morphing 3D Geometry
Algorithmic Art
Making Information Visible through Motion
An Explosion Shader




Exercises appear at the end of each chapter.

View More



Mike Bailey is a professor of computer science at Oregon State University. Dr. Bailey is a member of ACM, SIGGRAPH, IEEE, ASME. He earned a Ph.D. in computer graphics and computer aided design from Purdue University. His areas of interest include scientific visualization, high performance computer graphics, GPU programming, solid freeform fabrication, geometric modeling, and computer aided design and analysis.

Steve Cunningham is a professor emeritus of computer science at California State University Stanislaus. A member of ACM SIGGRAPH, ACM SIGCSE, and Eurographics, he has been actively engaged in computer graphics education for many years.


"If you are one of the multitudes of OpenGL programmers wondering about how to get started with programmable shaders or what they are good for, this is the book for you. Mike and Steve have filled their new edition with such a variety of interesting examples that you'll be running to your computer to begin writing your own shaders."
Ed Angel, Chair, Board of Directors, Santa Fe Complex, Founding Director, Art, Research, Technology and Science Laboratory (ARTS Lab), Professor Emeritus of Computer Science, University of New Mexico

"Shaders are an essential tool in today’s computer graphics, from films and games to science and industry. In this excellent book, Bailey and Cunningham not only clearly explain the how and why of shaders, but they provide a wealth of cutting-edge shaders and development tools. If you want to learn about shaders, this is the place to start!"
—Andrew Glassner

Praise for the First Edition:
"Bailey and Cunningham provide a comprehensive, well-written overview of graphics shaders. … Although the book uses the OpenGL Shading Language (GLSL) for its examples, it gives enough theoretical background for readers to learn the fundamentals for any graphics language. … The book also addresses scientific visualization and the GLSL API to call GLSL functions from an OpenGL program. A final chapter offers ideas for using shaders in very entertaining ways. … Highly recommended."
—C. Tappert, CHOICE, December 2009

"… a pick for any college-level, advanced computer library catering to programming professionals. … discusses different types of shaders, how to use the glman program for free, and how to blend shaders into an interactive game environment. Libraries will find it a powerful, appealing lend for intermediate programmers seeking extra spice for their projects."
Midwest Book Review, August 2009