BOTW: OpenGL Shading Language, the ‘Orange Book’

Over the past two weeks I read “OpenGL Shading Language”, also known the ‘Orange Book’ due to its cover. As you would expect it covers the OpenGL Shading Language (GLSL). This edition focuses on [shaders][] of course, but takes into account all of the updates in OpenGL 2.0 which are related to the subject matter.

Personally I wanted to read this book because I still consider graphics programming a weakness in my tool-set, and as a game developer that is an important area in which I wish to improve. More specifically, I was hoping to learn some cool ideas and tricks to use for shaders in LÖVE.

Did the Orange Book meet my hopes and expectations?

Yes, And Then Some

The book begins with an overview of OpenGL in general and a stroll through the history of its development. It is not crucial to know such things in order to create and work with shaders. But I did appreciate the refresher about OpenGL basics and how the technology progressed to the point of including shaders.

The second chapter begins the discussion of GLSL itself. Personally I am not a fan of books that quickly dive into code and then return later to explain the details; I prefer a gradual build-up like the kind seen in “Real World Haskell”. However, the second chapter’s rapid pace of conceptual introductions did not bother me because, despite being terse, they still pack more meat in content than a lot of other programming books I’ve read which try to do the same.

Chapter three is where the Orange Book dives deep into the design of GLSL. The previous chapter does a great job of pointing out the high-level differences between GLSL and C, which GLSL emulates in most respects. Chapter three is a terrific follow-up that builds on that by exposing all of the important differences you will need to know, e.g. the different names you can use to access vec3 variables, i.e. vectors of three elements—you can, for instance, refer to the three members as x, y, z or r, g, b, whatever semantically makes the most sense for your code.

I am not going to break down my opinions about every chapter. But the thorough explanations in chapter three represent a pervasive quality of the Orange Book: a lot of chapters stand on their own as useful, individual references. For example:

  • Chapter Three: Language Definition
  • Chapter Five: Built-in Functions
  • Chapter Seven: OpenGL Shading Language API
  • Chapter Twelve: Lighting

I feel like the text strikes a wonderful balance between presenting a natural progression on how it teaches the subject matter at hand while also structuring the chapters into nuggets of information that easily stand on their own as reference material. I love programming books which read nicely from cover to cover while also managing to serve as handy tomes to keep within arm’s reach for when you need to look up a certain primitive or such. The Orange Book executes this structure in impressive style.

The Orange Book also makes good use of diagrams, which I think are one of the best tools at an author’s disposal when writing about computer graphics. However, I do believe the book would benefit from more of those diagrams. The prose itself succeeds in sufficiently explaining what it sets out to teach. But personally, when it comes to computer graphics, I am one of those readers who believes ‘the more diagrams the better’. So I would have liked to see more.

On a related note, the typography for the math is clear, easy to read, and helps amplify the learning experience when you see it placed right next to the code that uses that math.

Overall I will absolutely recommend the Orange Book to any programmer who wants to improve his or her understanding of GLSL. The book is well-written, well-structure, flows nicely, and is dense in information without sacrificing readability. I set out wanting to better understand shaders in general and more specifically how I could use them to improve the shaders in my own game. The Orange Book left me a very satisfied programmer on those subjects when it was all said and done. And thanks to the stand-alone reference nature of some chapters I know I will be re-reading parts of this book in the months to come.

Whether you’re completely new to GLSL or not, the Orange Book deserves your time.

Next Book of the Week

Since I mentioned “Real World Haskell” I decided I am going to re-read that this week. Due to the length I would usually give myself two weeks. But because I already read it once some years ago I feel confident that I can get through it in a week. And since I use Lua so much these days it will be fun to work with a language that could hardly be more difficult.

Advertisements

Add Your Thoughts

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s