View Full Version : Book about shaders?

04-05-2010, 12:11 PM
I don't know anything about shaders, but i will learn. Which book do you recommend me to buy?

I'm looking to buy the Opengl Shading Language one, but i'm not sure because it says for OpenGl 2.0. Maybe anyone knows a book that talks about opengl 3.0 shaders or greater?


04-05-2010, 12:31 PM
Sure! OpenGL Shading Language 3rd Edition!

04-05-2010, 02:50 PM
yeah! but, this book explains the last implementation of GLSL? or only 3.2?

Well i am pretty new at this but the opengl 3.2 shaders are the same that opengl 4.0 ones?


Dark Photon
04-05-2010, 05:34 PM
yeah! but, this book explains the last implementation of GLSL? or only 3.2?
GLSL 1.4 (GL 3.1).

Yes there have been GLSL 1.5, 3.3, and 4.0 since then, but none of these is a rewrite -- just some extra goodies added.

GLSL 1.2->1.3 was the biggest leap for basic workhorse shaders (vertex and fragment), because it deprecated nearly all the legacy "built-in identifiers". And that's covered by the book.

Well i am pretty new at this but the opengl 3.2 shaders are the same that opengl 4.0 ones?
Yeah pretty much the same, if your talking the workhorse shaders (vertex and fragment).

Of course, GLSL 1.5 added geometry shaders, and GLSL 4.0 adds the tessellation shaders. But learn vertex and fragment shaders first and then the rest will make a lot more sense. Bottom line, the Orange book is still a good starting point.
Also don't forget the OpenGL wiki and on-line GLSL tutorials.

What GPU do you have? You may not even care about some of these newer features yet if your GPU doesn't support them.

04-05-2010, 06:03 PM
I have The Orange Book and highly recommend it.

I agree with Dark Photon. Don't worry too much about doing things however the latest/greatest spec deems it. I don't think there are any drivers out yet which can do 3.3/4.0 yet anyway. Not to mention that nvidia's sm5-capable cards have only just been announced and amazon/newegg have only just started taking preorders. I guess if you have an ATI HD 5000 series..;)

First get the basics down, learn how to do GLSL to old GL2.1 way. OpenGL 2.1 / GLSL 1.2 is a good combo. The Red/Orange books, even in the latest edition, primarily focus on compatibility profile/mode anyway.

Once you're familiar with that stuff, then you can start using the spec PDFs to learn what's new and how to change it. Those are available at http://www.opengl.org/documentation/specs/. (http://www.opengl.org/documentation/specs/) I've found them to be refreshingly readable.

There's a good program out there called GPU Caps Viewer which will tell you what the highest version of OpenGL your card/driver supports is. Check to see that it tells you that GL 3.0 at least is supported. If it's lower than 3.2, update your drivers as the latest nVidia/ATI drivers should support that on any GL3-capable cards. If after the update it still just says OpenGL 2.1 you'll need a new card.

Also lighthouse3d.com has an invaluable tutorial that is still applicable.

04-06-2010, 01:23 AM
Ok, things are clear now :). I have a Nvidia 8800 GTS and opengl 3.2 drivers.

I will buy this book hehe thank you!

04-06-2010, 09:49 AM
It will be very tempting to use the built in OpenGL variable especially when transitioning to shaders. i.e. glMatrixMode, glLoadmatrix, glRotate etc. and other reserved variables which pull from the OpenGL state machine for useful uniforms.

Do NOT use these if you want to be future-proof.

You have to roll your own for everything from matrices to lighting and set them as arbitrary application defined uniforms. This means building some small framework or system for mapping your conventions through to your shaders, but this is the way APIs are going.

Don't lean on the crutch of classical state based uniforms except perhaps when porting fixed function graphics code.

It now means you have to learn graphics from simpler foundational principles before you can light a polygon but this is probably a good thing.

04-07-2010, 01:27 AM
OpenGL Shading Language is a very good toolkit.