Programming Books C Java PHP Python Learn more Browse Programming Books
OpenGL® Shading Language and over one million other books are available for Amazon Kindle. Learn more
Have one to sell? Sell on Amazon
Flip to back Flip to front
Listen Playing... Paused   You're listening to a sample of the Audible audio edition.
Learn more
See this image

OpenGL® Shading Language (2nd Edition) Paperback – February 4, 2006

ISBN-13: 978-0321334893 ISBN-10: 0321334892 Edition: 2nd

12 New from $39.74 22 Used from $1.17 1 Collectible from $107.68
Amazon Price New from Used from
"Please retry"
"Please retry"
$39.74 $1.17

There is a newer edition of this item:

Free Two-Day Shipping for College Students with Amazon Student Free%20Two-Day%20Shipping%20for%20College%20Students%20with%20Amazon%20Student

Special Offers and Product Promotions

  • Have the next big idea for a movie? Submit a 2-15 min. concept video to Amazon Studios for a chance to have your movie made. Learn more.


Shop the new
New! Introducing the, a hub for Software Developers and Architects, Networking Administrators, TPMs, and other technology professionals to find highly-rated and highly-relevant career resources. Shop books on programming and big data, or read this week's blog posts by authors and thought-leaders in the tech industry. > Shop now

Product Details

  • Paperback: 800 pages
  • Publisher: Addison-Wesley Professional; 2 edition (February 4, 2006)
  • Language: English
  • ISBN-10: 0321334892
  • ISBN-13: 978-0321334893
  • Product Dimensions: 7 x 1.6 x 9.1 inches
  • Shipping Weight: 3.4 pounds
  • Average Customer Review: 3.4 out of 5 stars  See all reviews (8 customer reviews)
  • Amazon Best Sellers Rank: #298,937 in Books (See Top 100 in Books)

Editorial Reviews

About the Author

Randi Rost is an ISV Manager in the Software and Solutions Group at Intel. Previously he held several positions at 3Dlabs, Inc., the company that led the creation of the OpenGL Shading Language (GLSL). Randi was a core contributor to the development of GLSL and the OpenGL API that supports it, as well as one of the first programmers to design and implement shaders using this technology.

Excerpt. © Reprinted by permission. All rights reserved.

For just about as long as there has been graphics hardware, there has been programmable graphics hardware. Over the years, building flexibility into graphics hardware designs has been a necessary way of life for hardware developers. Graphics APIs continue to evolve, and because a hardware design can take two years or more from start to finish, the only way to guarantee a hardware product that can support the then current graphics APIs at its release is to build in some degree of programmability from the very beginning.

Until recently, the realm of programming graphics hardware belonged to just a few people, mainly researchers and graphics hardware driver developers. Research into programmable graphics hardware has been taking place for many years, but the point of this research has not been to produce viable hardware and software for application developers and end users. The graphics hardware driver developers have focused on the immediate task of providing support for the important graphics APIs of the time: PHIGS, PEX, Iris GL, OpenGL, Direct3D, and so on. Until recently, none of these APIs exposed the programmability of the underlying hardware, so application developers have been forced into using the fixed functionality provided by traditional graphics APIs.

Hardware companies have not exposed the programmable underpinnings of their products because of the high cost of educating and supporting customers to use low-level, device-specific interfaces, and because these interfaces typically change quite radically with each new generation of graphics hardware. Application developers who use such a device-specific interface to a piece of graphics hardware face the daunting task of updating their software for each new generation of hardware that comes along. And forget about supporting the application on hardware from multiple vendors!

As we moved into the 21st century, some of these fundamental tenets about graphics hardware were challenged. Application developers pushed the envelope as never before and demanded a variety of new features in hardware in order to create more and more sophisticated onscreen effects. As a result, new graphics hardware designs became more programmable than ever before. Standard graphics APIs were challenged to keep up with the pace of hardware innovation. For OpenGL, the result was a spate of extensions to the core API as hardware vendors struggled to support a range of interesting new features that their customers were demanding.

The creation of a standard, cross-platform, high-level shading language for commercially available graphics hardware was a watershed event for the graphics industry. A paradigm shift occurred, one that took us from the world of rigid, fixed functionality graphics hardware and graphics APIs to a brave new world where the visual processing unit, or VPU (i.e., graphics hardware), is as important as the central processing unit, or CPU. The VPU is optimized for processing dynamic media such as 3D graphics and video. Highly parallel processing of floating-point data is the primary task for VPUs, and the flexibility of the VPU means that it can also be used to process data other than a stream of traditional graphics commands. Applications can take advantage of the capabilities of both the CPU and the VPU, using the strengths of each to optimally perform the task at hand.

This book describes how graphics hardware programmability is exposed through a high-level language in the leading cross-platform 3D graphics API: OpenGL. This language, the OpenGL Shading Language, lets applications take total control over the most important stages of the graphics processing pipeline. No longer restricted to the graphics rendering algorithms and formulas chosen by hardware designers and frozen in silicon, software developers are beginning to use this programmability to create stunning effects in real time.

Intended Audience

The primary audience for this book is application programmers who want to write shaders. This book can be used as both a tutorial and a reference book by people interested in learning to write shaders with the OpenGL Shading Language. Some will use the book in one fashion, and some in the other. The organization is amenable to both uses and is based on the assumption that most people won't read the book in sequential order from back to front (but some intrepid readers of the first edition reported that they did just that!).

Readers do not need previous knowledge of OpenGL to absorb the material in this book, but such knowledge is very helpful. A brief review of OpenGL is included, but this book does not attempt to be a tutorial or reference book for OpenGL. Anyone attempting to develop an OpenGL application that uses shaders should be armed with OpenGL programming documentation in addition to this book.

Computer graphics has a mathematical basis, so some knowledge of algebra, trigonometry, and calculus will help readers understand and appreciate some of the details presented. With the advent of programmable graphics hardware, key parts of the graphics processing pipeline are once again under the control of software developers. To develop shaders successfully in this environment, developers must understand the mathematical basis of computer graphics.

About This Book

This book has three main parts. Chapters 1 through 8 teach the reader about the OpenGL Shading Language and how to use it. This part of the book covers details of the language and details of the OpenGL commands that create and manipulate shaders. To supply a basis for writing shaders, Chapters 9 through 20 contain a gallery of shader examples and some explanation of the underlying algorithms. This part of the book is both the baseline for a reader's shader development and a springboard for inspiring new ideas. Finally, Chapter 21 compares other notable commercial shading languages, and Appendices A and B contain reference material for the language and the API entry points that support it.

The chapters are arranged to suit the needs of the reader who is least familiar with OpenGL and shading languages. Certain chapters can be skipped by readers who are more familiar with both topics. This book has somewhat compartmentalized chapters in order to allow such usage.

  • Chapter 1 reviews the fundamentals of the OpenGL API. Readers already familiar with OpenGL may skip to Chapter 2.
  • Chapter 2 introduces the OpenGL Shading Language and the OpenGL entry points that have been added to support it. If you want to know what the OpenGL Shading Language is all about and you have time to read only two chapters of this book, this chapter and Chapter 3 are the ones to read.
  • Chapter 3 thoroughly describes the OpenGL Shading Language. This material is organized to present the details of a programming language. This section serves as a useful reference section for readers who have developed a general understanding of the language.
  • Chapter 4 discusses how the newly defined programmable parts of the rendering pipeline interact with each other and with OpenGL's fixed functionality. This discussion includes descriptions of the built-in variables defined in the OpenGL Shading Language.
  • Chapter 5 describes the built-in functions that are part of the OpenGL Shading Language. This section is a useful reference section for readers with an understanding of the language.
  • Chapter 6 presents and discusses a fairly simple shader example. People who learn best by diving in and studying a real example will benefit from the discussion in this chapter.
  • Chapter 7 describes the entry points that have been added to OpenGL to support the creation and manipulation of shaders. Application programmers who want to use shaders in their application must understand this material.
  • Chapter 8 presents some general advice on shader development and describes the shader development process. It also describes tools that are currently available to aid the shader development process.
  • Chapter 9 begins a series of chapters that present and discuss shaders with a common characteristic. In this chapter, shaders that duplicate some of the fixed functionality of the OpenGL pipeline are presented.
  • Chapter 10 presents a few shaders that are based on the capability to store data in and retrieve data from texture maps.
  • Chapter 11 is devoted to shaders that are procedural in nature; that is, effects are computed algorithmically rather than being based on information stored in textures.
  • Chapter 12 presents several alternative lighting models that can be implemented with OpenGL shaders.
  • Chapter 13 discusses algorithms and shaders for producing shadows.
  • Chapter 14 delves into the details of shaders that implement more realistic surface characteristics, including refraction, diffraction, and more realistic reflection.
  • Chapter 15 describes noise and the effects that can be achieved with its proper use.
  • Chapter 16 contains examples of how shaders can create rendering effects that vary over time.
  • Chapter 17 contains a discussion of the aliasing problem and how shaders can be written to reduce the effects of aliasing.
  • Chapter 18 illustrates shaders that achieve effects other than photorealism. Such effects include technical illustration, sketching or hatching effects, and other stylized rendering.
  • Chapter 19 presents several shaders that modify images as they are being drawn with OpenGL.
  • Chapter 20 describes some of the techniques and algorithms used in a complex OpenGL application that makes extensive use of the OpenGL Shading Language.
  • Chapter 21 compares the OpenGL Shading Language with other notable commercial shading languages.
  • Appendix A contains the language grammar that more clearly specifies the OpenGL Shading Language.
  • Appendix B contains refere...

More About the Authors

Discover books, learn about writers, read author blogs, and more.

Customer Reviews

3.4 out of 5 stars
Share your thoughts with other customers

Most Helpful Customer Reviews

7 of 7 people found the following review helpful By W Boudville HALL OF FAMETOP 1000 REVIEWERVINE VOICE on February 7, 2006
Format: Paperback
Twenty years ago, I used to program graphics on an Evans and Sutherland PS340. It was then one of the top of the line graphics computers (costing $100k). It could labouriously do shading, but only Phong and Gouraud. Nowadays, many PCs have this ability, and much faster. But a problem still persists, where often the shading methods are restricted to what is implemented on the graphics chips.

In contrast, you have the approach in this definitive book on OpenGL Shading Language. This lets you implement in your code, shading routines of your own devising. To be sure, given the same shading method, one done in this language, and one in the hardware, then the latter will have better performance. But it turns out that today's computers are fast enough, and have enough RAM, that the difference in response might not be appreciable.

The book describes an extensive set of built-in convenience functions that come with the language. And the language's API is explained in detail. The author rightly recommends that you come at it with some experience in the standard OpenGL.

Since the language is still quite new, you are more or less on your own, when looking at development tools. This dearth is expected to be remedied in a few years. But right now, you'll have to rely on your wits. Along with a chapter that gives general principles of how you should develop your own shader. What may be even more use, however, is the second half of the book. Devoted to case studies of many shaders. Understanding these may be more beneficial than any IDE.

Oh, as you might expect from a graphics book, there is a lovely set of colour plates in the middle of the book, showing what custom shaders can do. Treat it as inspiration if you wish.
Comment Was this review helpful to you? Yes No Sending feedback...
Thank you for your feedback. If this review is inappropriate, please let us know.
Sorry, we failed to record your vote. Please try again
15 of 18 people found the following review helpful By calvinnme HALL OF FAMETOP 1000 REVIEWERVINE VOICE on February 17, 2006
Format: Paperback
The recent trend in graphics hardware has been to replace fixed functionality with programmability in areas that have grown exceedingly complex (e.g., vertex processing and fragment processing). The OpenGL Shading Language has been designed to allow application programmers to express the processing that occurs at those programmable points of the OpenGL pipeline. Independently compilable units that are written in this language are called shaders. A program is a set of shaders that are compiled and linked together. The OpenGL Shading Language is based on ANSI C and many of the features have been retained except when they conflict with performance or ease of implementation. This shading language is without a doubt the most important addition to OpenGL since its inception, and this book provides an excellent guide to programming with it. The author was one of the primary contributors to the development of the language, and he provides a well-written and insightful explanation of the language and its use.
The book begins with a review of OpenGL basics, followed by an introduction to shaders and how they fit into the pipeline. It then covers the language itself, including data types, operators, interaction with the OpenGL state machine and fixed function pipeline, built-in functions, and more. It also introduces and explains the OpenGL APIs needed to use shaders.
The last half of the book focuses on shader development, including general process and workflow, and coverage of many specific techniques, such as procedural textures and GPU-based animation. It even includes a section on implementing the fixed function pipeline using shaders.
Read more ›
Comment Was this review helpful to you? Yes No Sending feedback...
Thank you for your feedback. If this review is inappropriate, please let us know.
Sorry, we failed to record your vote. Please try again
8 of 11 people found the following review helpful By Trousers on January 18, 2010
Format: Paperback
The code is often broken, the book has typos, and the examples are rarely ever complete. The portions missing from the examples are the critical aspects for those new to GL 3.
Comment Was this review helpful to you? Yes No Sending feedback...
Thank you for your feedback. If this review is inappropriate, please let us know.
Sorry, we failed to record your vote. Please try again
2 of 3 people found the following review helpful By Scott Johnson on March 8, 2007
Format: Paperback Verified Purchase
I definitely recommend this book for anyone working with OpenGL's new Shading Language. I would, however, say that probably the most difficult part of working with GLSL is getting it working in the first place. Especially on Linux, this is somewhat confusing - some cards support GL 2.0, some don't, but still support the GLSL if using the ARB function calls. I would also make sure to point out to new users that GLEW is close to essential when working with the GLSL - you can download it from sourceforge. It might be worth mentioning in future versions of the book, along with ARB functions which are the same as the GLSL standard functions shown in the book.
Comment Was this review helpful to you? Yes No Sending feedback...
Thank you for your feedback. If this review is inappropriate, please let us know.
Sorry, we failed to record your vote. Please try again

What Other Items Do Customers Buy After Viewing This Item?