|OpenGL Shading Language (Second Edition)|
|author||Randi J. Rost|
|summary||A solid introduction to developing shaders in the OpenGL Shading Language GLSL.|
GLSL is now officially a part of OpenGL 2.0, whereas it was only an extension to core OpenGL at the time of release of the book's first edition. Naturally, the Orange Book has been updated to reflect all the changes. Not much has changed in the shading language itself, though. However, there were some minor modifications to the C shader API used to create and upload shaders to the graphics hardware from the program running on the CPU. In order to make the transition easier for old-timers like me who have worked with the old API, the book contains an appendix that details all the changes that the shader API has undergone with the promotion to core OpenGL.
The most notable additions to the book in its second edition are the new chapters on lighting, shadows, surface characteristics, and RealWorldz, a demo that uses shaders exclusively for all rendering and that generates even the rendered models purely procedurally via shaders.
The new chapter on lighting goes into the details of developing lighting shaders that differ from traditional fixed-function lighting offered by the OpenGL fixed-function pipeline. In particular, shaders for hemi-sphere lighting, image-based lighting using environment maps as light probes, and spherical harmonics lighting are developed in this chapter. Note that the theory behind spherical harmonics lighting is not presented in the book. So if you want to fully understand the presented shaders, you will have to read up on the theory in the references given in the book. The chapter on lighting is concluded by a discussion of the ÜberLight shader, a shader for a very versatile lighting model initially presented as RenderMan shader by Pixar Animation Studios.
An important topic in computer graphics now has its own chapter in the Orange Book: Shadows. The new chapter on shadows presents ambient occlusion, shadow maps, and an interesting technique for rendering shadow volumes using deferred shading. The latter technique can be used to render soft shadows convincingly.
Another new chapter in the second edition of the book is on surface characteristics. This chapter discusses and develops shaders to render surface materials that exhibit complex light interaction. The chapter starts out with a discussion of refraction and presents shaders to archive the classic Fresnel reflection/refraction and chromatic aberration effects. Then diffraction, i.e. light bending around sharp edges, is discussed and a shader is developed that renders a vinyl record realistically. Finally, the chapter focuses on BRDF-based lighting and develops various material shaders using the BRDF model.
The final new chapter in the second edition is on RealWorldz. RealWorldz is a demo that renders planets with fractal terrain, oceans, sky, and other effects. Everything in the demo is generated procedurally through GLSL shaders and the chapter describes the techniques used in implementing the demo. At the end of the chapter it says that the demo is available upon request from 3Dlabs, which I find ab it disappointing. Let's hope that the authors put up a downloadable version of the demo, or at least a video of the demo, on the book's webpage.
As in the previous edition, all images and diagrams in the book are in black and white, except for a few pages that contain 38 color plates in the middle of the book. In addition to the images from the first edition, the book now has some very impressive images from the RealWorldz demo. A nice addition to the book is the detachable cheat sheet at the end of the book, which contains a quick reference of GLSL and the shader API entry points - very handy to have on your desk in the heat of a late-night coding session.
The book's accompanying website at http://www.3dshaders.com/ offers the source code to all the shaders presented in the book for download. Also available are other shaders not mentioned in the book and a demo application including source code, which nicely demonstrates the shaders in action. The demo application and most of the shaders are available under a very liberal BSD-style open source license.
The book "OpenGL Shading Language (Second Edition)" remains an excellent introduction to shader programming with GLSL. It provides a profound discussion of the shading language itself as well as the C shader API used to create and manage shaders in the host program. The book also has numerous chapters on developing shaders for various applications, such as lighting, shadows, animation, and other areas of real-time computer graphics. The newly added chapters in the second edition nicely complement an already good book. If you're interested in learning GLSL and shader programming in OpenGL, this is the book to get.
About the review author:
The author has been involved in real-time graphics programming for more than 10 years and works as a games developer for arcade games. In his rare spare time he works on a graphics-related open source project called XEngine http://xengine.sourceforge.net./"
You can purchase OpenGL Shading Language from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.