Real-time Shader Programming

To quote an editorial review of the book;

A compelling writing style, color illustrations throughout, and scores of online resources make Real-time Shader Programming an indispensable tutorial/reference for the game developer, graphics programmer, game artist, or visualization programmer, to create countless real-time 3D effects.

The book was designed to fill a gap that I discovered when talking to folks about using shaders - namely that it was such a paradigm shift going from the fixed-function pipeline found in Direct3D and OpenGL to programming shaders that only a few of the leading developers were actually using shaders in their programs.

This book is not a collection of shaders - this is the book that you want that'll explain exactly how those shaders work so you can go about creating your own. I go pretty heavily into detail of the mathematics of shading & lighting in an effort to illustrate how a shader can be written. Give a man a fish.....you get the idea. The book does contain shaders, though these tend to be basic building blocks, not complete, focused shaders.

For example, I discuss the diffuse vs. specular vs. ambient vs. emissive lighting equations and show you how you can use variations of these particular equations to mix and match to get different effects. Creating shaders isn't a cut & paste operation - it's a creative artistic endeavor, and this book gives you the tools and the theoretical knowledge to understand how to create your own. It's not chock full of creative tricks (though there are a few useful ones), it's more an examination of the basic building blocks of shader writing.

The book is focused at both the beginning 3D graphics programmer/artist and the advanced. There's a short section on introductory 3D math (vertices, points, alimentary 3D graphics math) followed by a lengthy chapter on the mathematics of lighting and shading (from the math used in 3D graphics cards (the fixed-function pipeline) , though more advanced lighting equations, BRDF's and non-photorealistic lighting equations).

This is followed by a chapter devoted to setting-up Direct3D (DX8 and DX9) to use shaders (including vertex streams). There's a short chapter on current shader resources that can be found on-line (from ISV's, Microsoft, etc.) including a tool I wrote for the book that illustrates the different methods of handling color over-saturation.

The next chapter is the "shader buffet" - a collection of various shader programs - all included on the CD - that illustrate the basics of shader writing and how to code various variations of a theme - Phong specular lighting vs. Blinn specular for example.

The final chapter is the DX8/DX9 shader reference for low-level shader language. The high level language is not covered in this book - DX9 was delayed too much for me to even attempt to cover it. (Besides - the book is over 400 pages, my contractual limit was supposed to be 400 pages maximum).

The book is full-color throughout, so when I talk about an effect, it's followed immediately by an image.

I worked hard with the publisher to try to create a book that I - as a graphics developer - would like to have. In Morgan-Kaufmann I found a publisher who was as enthusiastic as I was about creating a full-color 3D graphics book, with CD-ROM, and not charging you an outrageous price for it (Yes I negotiated this and yes, I get less money this way. I talked to five publishers before settling on MK). I hope you enjoy the book as much as I enjoyed writing it.

Ron Fosner

If you notice any errors, or have suggestions, please send me email.

NOTE: I'm still posting sections from the book - if you're anxious to see some part send me an email...

Corrections -Errata - Updates

None yet!