[Book Review] OpenGL 4.0 Shading Language Cookbook

Heaven Benchmark - OpenGL Rendering Mode

“Modern hardware’s have completely superseded the fixed functionality (FFP) with programmability in complex graphics processing areas such as vertex, fragment and geometry processing. The Shading Language has been designed to allow application programmers to take control of this pipeline (GPU Rendering Pipeline) to produce desired results. In graphics processing hardware terms these independently compilable units are called shader units, and the language is known as the Shading Language. Shader program is a set of two or more shaders that are compiled and linked together. Shaders are part of major graphics API as such as DirectX and OpenGL. The OpenGL Shading Language, widely known as GLSL as defined by the ARB of OpenGL, is based on ANSI C that is capable of doing vector and matrix operations, typical operations in 3D graphics. Shaders are a hot topic and 3D game developers/researchers have shown that they can be put into some powerful use to produce remarkable scene effects and with increased performance. Shaders were widely used in GPGPU early to CUDA and OpenCL as they are capable of accessing GPU processing power. OpenGL 4.00 is the latest major revision, announced on March, 2011 to give a hard competition to DirectX 11 providing extensions for geometry tessellation, 64-bit double precision float point, addition of Sampler objects, instanced arrays and timer query. This book presents these topics with nice examples and in-depth explanation.”


OpenGL 4.0 Shading Language Cookbook

Author David Wolff
Pages 340
Publisher Packt Publishing Ltd.
Rating 9.5/10
ISBN 978-1849514767
About the Book “Over 60 highly focused, practical recipes to maximize your use of the OpenGL Shading Language”

The Author

David Wolff is an associate professor in the Computer Science and Computer Engineering Department at Pacific Lutheran University (PLU). He received his PhD in Physics from Oregon State University. He has a passion for computer graphics and the intersection between art and science. He has been teaching computer graphics to undergraduates at PLU for over 10 years, using OpenGL. (This information has been taken directly from the book)

At RateMyProfessor.com, Prof. David Wolff has been rated a 4 out of 5 and the following comments has been given by the students:

“Comment 1: Intro to Computer Graphics focuses on RealTime graphics using openGL. This is Wolff’s area of expertise & a GREAT class to take from him. His passion shows through in the class. If you’re interested in 3D graphics or realtime sim this is a great class. Linear Algebra is a pre-req but basic knowledge of vector and matrix math is really what is key

Comment 2: Prof. Wolffe is the coolest. very clear concrete examples, and clear work expectations. If you’re willing to do a little work, then you will be rewarded for it in spades….”

Unfortunately, the book contains only small intro about David Wolff and not much information is available on the internet. I will probably do a nasty Google scan and update this section at the later time. 🙂

Brief Introduction

‘OpenGL 4.0 Shading Language Cookbook’ was published in July, 2011 by Packt Publishers under the ISBN 978-1849514767. The book covers OpenGL Shading Language core profile 4 and its coupling with the modern hardware, especially, NVIDIA GeForce 400 & 500 series and ATI Radeon HD 5000 & 6000 series. The chapters included are on choosing libraries for GLSL programming, the basic shading technique, Lighting, Shading Effects, and optimizations, using textures in GLSL, image processing and screen spacing techniques, Using geometry and Tessellation shaders, rendering advanced shadows with AA and Ambient occlusion, Noise effect with shaders and animation & particles. The book’s web-page is maintained by the Packt Publishers. The page contains sample chapters, table of contents, and errata info. The book can be purchased in PDF and hard-back forms. Exclusive source code and resource access is only for Packt premium members. For more information on the purchase, please visit the Packt Publishers Page. The book’s preface is short, precise and gives an ultimate overview of the contents of the book. The preface mentions the conventions used in the book.

Not for every living creature…

Caution! GLSL is an advanced topic. Author presumes that you understand 3D and its operations such as 3D transformation, normalizations, coordinate systems and projections at a primitive level.

GPUToaster mandates that the reader is aware of GPU technologies, brief understanding of major Graphics API such as DirectX and OpenGL, Basic OpenGL programming (at the least hands-on with OpenGL FFP), understanding of GPU pipeline processors such as fragment and vertex shaders or the Unified Shader Architecture, must know different OpenGL versions and extensions, must be hands-on with one IDE such as Visual Studio (as the visual studio is the major developing environment) and setting programming environment with GLSL such as linking DLL’s and libraries, must know basic C/C++ programming, must have a NVIDIA (400/500 Series)/AMD ATI adeon (HD 5000/6000 series) GPU installed either in single or SLI/Crossfire mode, Must know specific driver versions that will expose the GLSL extensions and has installed the same (For specific driver version kindly ID your GPU and search on the respective GPU vendor site), and last but not the least – a great passion for 3D programming. It also recommended that the reader understands and ready to solve Mathematics.

Considering you have set up the proper environment either on Windows / Linux/ Mac, you are good to go further and discover the GLSL 4.0 core profile.

Chapter Tour

Considering that you are all set to get dirty with GLSL, the first chapter gives an excellent introduction to the OpenGL Shading language, Core profile compatibility with new hardware architectures, explains the deprecation model that started from core profile 3.0. The chapter gives you a complete insight on the GLEW and GLM libraries that are used to access the GL extensions and core mathematical support designed especially for GLSL respectively. Good examples are given to integrate GLM in your program. Furthermore, author takes you to the in-depth step-by-step tour of how GLSL programs work, which includes writing vertex and fragment shaders, determining GLSL version, compiling the shader, linking the shader and finally deleting the context. This chapter also explains VBO to send the data for processing per vertex with a complete program, uniform variables for infrequently changing data that are suited for transformations and projections. The overall chapter has a smooth transition from topic to topic. I observed no jump; author has been focusing on the chapter’s objective to briefly introduce the GLSL and its programming techniques. Readers will find this chapter a bit time-consuming for the first time, but believe me this chapter is a must-read for GLSL beginners.

The second chapter starts with showing the complete architectural working of Vertex and Fragment shader pipelines of OpenGL. The near most exclusive content includes the replication of the FF using GLSL 4.0. The chapter covers the standard ambient, diffuse, and specular (ADS/Phong) shading algorithm, the implementation of two-sided rendering, and flat shading along with the functions, subroutines and use of discard keyword to generate an effect where the fragment shaders are haulted for writing onto buffer. This chapter is designed for those who are beginners with GLSL (assuming OpenGL previous experience) and also those who have previously worked on previous GLSL profiles. The chapter present’s algorithms to form the basis of the GLSL programming. For the new learners, this is the perfectly recommended chapter. Additionally, the new learners are presented with mathematical explanations and beautifully narrating the effects using highly detailed schematic diagrams before presenting the program to avoid confusion.

The following chapter introduces the reader to produce shading effects such as spotlights, fogs, cartoon style shading, multiple light sources, realistic effect with per-fragment shading, shading efficiency improvement using half-way vectors and directional light sources. The chapter actually extends the previous chapter with advanced techniques and emphases on lighting optimizations. Author has also presented the allowed constants for desired effects in a tabular form. The values and its effects are presented in a tabular form for good understandability. This chapter is recommended too for the GLSL beginners. In short, both the chapters are perfectly designed for the GLSL beginners. These chapters are guaranteed to provide ultimate satisfaction to the readers, especially GLSL beginners. Author uses the same approach that has been followed in the previous chapter.

The fourth chapter shows the importance of textures and how shader opens a huge range of possibilities with shading parameters, displacement maps, normal vectors, or other vertex data. The chapter starts with basic application of 2D color textures via sampler variables, alpha maps for transparency (emphasis on discard keyword), normal maps for creating bumps and wrinkles to the texture (or the faking technique), reflections and refractions with cube maps, technique of image based lighting, texture projection on 3D objects and RTT. The chapter contains full of important techniques that are frequently used in games and designing game engines.

The fifth chapter focuses on the image processing such as edge detection, Gaussian blur, bloom effect, gamma correction and screen space techniques such as MSAA & deferred shading. This is an exclusive chapter that is prepared for both games and computer vision field.

Geometry and Tessellation Shaders are the two new additions to the OpenGL API and hence the 4.0 profile. The chapter starts by explaining the extended shader pipeline that is specific to the newer hardware with full ‘4.0’ support. The chapter covers point sprites with geometry shader, drawing a wireframe and silhouette lines on a shaded mesh, Tessellating a Curve (Bezier Curve), 2D Quad, 3D Surface, and Tessellation based on depth. Chapter 6 is one more interesting chapter that begins with new topics gradually by giving the reader the simplest examples first and then moving to the more advanced concepts.

Realism is achieved with detailed scene effects and the shadows. With shadows, the overall lighting looks realistic. The chapter shows recipes for shadow mapping, Anti-Aliased shadows with PCF (Percentage closer filtering), soft shadows with random sampling, prebaked AO.

Sometimes too smooth surfaces produce unrealistic effects; introducing noise to the surfaces can simulate the imperfections of real surfaces. Chapter 8 deals with various ‘Noise’ introduction methods such as using ‘libnoise’ library (such as Perlin Noise), and using noise textures. Using these techniques readers will be able to learn how to create cloud like effect, wood grain effect, disintegration effect, paint spatter, and night-vision effect.

As shaders provide access to the GPU’s massively parallel architecture, they can be used for vertex transformations in the animations. Chapter 9 (Final Chapter) makes use of the ‘transform feedback’ feature that got introduced with OpenGL 3.2. The recipes include animating a surface with vertex displacement, Particle fountain, particle system with transform feedback and using instanced particles, fire particles, and finally smoke particles.


  1. Excellent introduction to GLSL programs.
  2. Clear and verbose explanation of code throughout the book.
  3. Flow charts are included for representing the effect.
  4. Algorithms presented by the author are very detailed.
  5. Very consistent flow of the GLSL techniques and the author has achieved a pure cookbook style of description.
  6. The author has presented outstanding and impressive content within second and third chapters (Advantageous for GLSL Beginners).
  7. All topics are outrageously well-researched and designed for a cookbook.
  8. Every shader example is explained in great details in “How to do it,” “How it works” and “There is more” sections. Linking topics have been mentioned in “See Also” section right, after “There is more” section.


  1. Programs included with this book are completely in QT.

Tone of the Book

The author shows his expertise not only with the content of this book but the highly professional explanation of the topics with clear distinction of theory and application.

The Final Verdict

Graphics hardware has emerged dramatically advanced and continues to do so. OpenGL shading language is the first (& only) cross platform open standard designed language and is the industry standard. With OpenGL and GLSL, applications perform better, achieving stunning graphics effects by using the capabilities of both the visual processing unit and the central processing unit. The book is designed for both beginners and experienced developers and artists. I have read OpenGL shading language books before by Randy Rost, and believe me this book is one of its kind. Author is veteran in the computer graphics field, and the content of the book is exactly what today’s GLSL developers need i.e. the GLSL capability, changing Modern GPU’s, closeness to natural phenomenon and real-life industry-standard applications.

Author has displayed his efforts in a pure cookbook style suitable for a variety of audience with graphics background. However, the source code included with this book is presented purely in QT. But reader need not worry as the GLSL code is completely separated out from the rendering code. I will try to present Visual Studio solutions that can be downloaded from the GPUToaster Download Area. Keep an eye on that section for updates.
Additionally, I would recommend you to refer GLSL specification, online GLSL tutorials and algorithm research papers for improved understanding.

Recommended reading : Ozone3D.net. Download GeeXLab 0.3 (a GLSL Tool)

To rate this book, I have compiled final rating depending on the following components:



CONTENT* 10/10
RELEVANCE TO THE OpenGL Shading Language* 10/10

Overall Rating for the book


* higher is Better. ** Lower is better.

GPUToaster Rates this book 9.5/10.

OpenGL 4.0 Shading Language Cookbook

"Go Ahead" and "Buy", Meets all expectations!

[Book Review] Unreal Development Kit 3 – Beginner’s Guide

Exclusive Post

Double kill! Multi kill! Mega Kill! ULTRA KILL!!! M-M-M-MONSTER KILL! With LUDACRIS KILL! And H O L Y S H I T! Coming after Monster Kill (or Killing Spree)” – These phrases from Unreal Tournament, from the “UT announcer-The god of the Arena!”, which was used as awards for getting 6 or more kills in a short amount of time without dying/spawning. Unreal Tournament (UT) was one of the most advanced multi-shooter FPS game released after the Quake, which was essentially designed for death-matches. UT is extremely known for its bot AI. In the year 1996, Quake was the first game to announce the online death-match game mode but then UT took the whole gaming experience to the next level with its AI and graphics. Powered by the world’s best game engine, Unreal tournament emerged as a successful arena game that scored an average review of 94%. Tim Sweeny, the architect of the Unreal Engine, started developing games in his parent’s basement with ZZT which drove the early growth of the company known as the EPIC Games. UDK is the most successful game engine that has survived this massively emerging 3D technology. Today Unreal Engine is a tough competitor to the top industry game engines. It features an unmatched flexible and modular architecture that most of the Game Engines lack as a whole. The game engine not only provides fantastic real life and a natural scenic effect, Unreal Engine also extends its support to the select SoC’s (System-on-Chip) such as the iPhone, iPad and iPod.


Unreal Development Kit 3-Beginner’s Guide

Author Richard J. Moore
Pages 244
Publisher Packt Publishing Ltd.
Rating 6/10
ISBN 978-1849690522
About the Book “A fun, quick, step-by-step guide to level design and creating your own game world”

“Unreal Development Kit 3 Beginners Guide” is the first edition that primarily focuses on the UDK 3.0. The book was published by Packt Publishers on August 2011. The guide introduces to the UDK 3.0 environment with topics chosen with a great taste. The topics include Level Design, UDK environment navigation and menu system, Lighting effects, UDK basic game elements, animating the game elements, Terrain, Game play elements, Events and flow graphs and Materials.

The book’s web-page is maintained by the Packt Publishers. The page contains sample chapters, table of contents, and errata info. The book can be purchased in PDF and hard-back forms. For more information on the purchase, please visit the Packt Publishers Page.

The Author

Author Richard J. Moore, graduated from the Hull school of art and design, as a video game designer. He has worked on projects extending his creativity by designing web templates, logos, brochures, business cards, web banners, animated graphics, and e-mail marketing campaigns. In 3D art, his passion includes creating and designing environments, texturing and high resolution rendering, and conceptual drawings. The Author showcased his work and secured a position in top three during the Platform Expo’s 2011 – Hulls video game expo. At leisure, he reviews games for an online magazine. Author has a strong belief that 2011 is the start of the new era for game designers. Lastly, he possess extensive experience in designing 3D environments with UDK.

The Book and the UDK

The book starts with a clear UDK introduction and the installation. Book’s preface is adequate for setting up the PC/system with good detailed system requirements to run UDK as expected. The preface also mentions the conventions that are used in the book chapters. Author has not mentioned any specific version of the UDK being used. For UDK beginners, please remember that 3.0 in UDK is the major iteration of the Unreal Engine and the UDK. UDK thereafter has been entered into the Beta release channel. Each specific beta version is stamped with the month name. Mostly, the releases will have same basic functionality. For this book review, August’s release was used, which incorporates few significant changes. If you are a core designer or you are planning to develop commercial games, then you must use the 64-bit version of the editor as 64-bit will enable developing of game levels with huge number of textures. This is possible as 64-bit is capable of addressing memory more than 4 GB. UDK also supports in-editor DirectX 11 for newer GPUs.

Unreal Engine has powered more than 50 games, until now and more releases are planned for future. This is the same Toolset that has powered some of the all-time-hit games Gears of War, Infinity Blade, Medal Of Honor, Batman : Arkham City, Bioshock and Mass Effect. Even the upcoming Frostbite Engine is based on the Unreal Engine 3 which has powered the Medal Of Honor 2010 and Battlefield 3 (Released this month).

UDK Powered List of Games [Complete]

Unreal Development Environment
Infinity blafe for iOS
Unreal Tournament
Unreal Engine Rendering Exteriors and complex environment geometry

Before you start…

Author expects no previous experience on level designing. The book is purely designed for aspiring game developers so that they could create their own game levels, maps, worlds, and environments. Furthermore, if you are completely new to the 3D technology author welcomes you to learn this awesome tool.

Chapter Tour

The book starts with introducing the UDK 3.0 and helps in setting up the development environment as expected. As mentioned in the previous section, there is no specific beta version specified. It’s definitely a good idea to download the latest beta version so that you are in sync with the UDK technology and stable updates. The first chapter is a must-read chapter for novice readers as it contains vital information to use UDK appropriately. Author follows a very tender approach in explaining the UDK folder structure and then by switching to the UDK UI environment. This chapter introduces to the Content Browser or the asset browser which is the heart of the UDK. There is a small but enough info on BSP brushes, which are largely used in the games for performance and other in-built geometry/brush builder. It also introduces to the UDK viewports that are used for visualizing the scene from four common angles. If you are familiar with 3DS Max/Maya/XSI environment, then UDK environment is nothing new except UDK specific window options.

The second chapter takes the reader to the UDK viewports for action. A very good explanation for creating CSG (Constructive Solid Geometry) which allows you to create complex geometry often can be seen in CAD applications. Author has given exact steps with screenshots to assist the reader for performing drawing operations. This chapter is little interesting as author lets you use the builder brush to create rooms, placing lights, player spawn point, a hallway to connect second room and finally applying textures and materials, adding bots to the level using the in-game command line. This requires some manual work, which may be time – consuming and the brush tool may not be handy for the first time. While following the chapters, novice readers may find certain screen shots misleading as there are changes in the newer versions. If the reader encounters any kind of uncertainty in following the tutorials, it is recommended to refer an online resource or a video tutorial or use Unreal forum to answer your queries. Rest of the chapter will be a fun that is definitely assured.

UDK uses different lighting mechanisms to render as light maps for CSG surfaces and static meshes to reflect light of objects. This chapter is quite interesting as the reader will learn UDK light component properties that are tactically used in commercial games to produce realistic effects. UDK allows you to create and add as many lights you want to. Note that, too many lights may hamper the overall level performance. Since dynamically lighting the environment causes a performance drop as the engine constantly calculates the lighting functions. To overcome this issue UDK features something known as the Unreal Lightmass (Swarm Agent), which is the high-quality static global illumination solver in Unreal Engine 3 and is one of the utilities in UDK with extreme computational needs. Even on an 8-core system, rebuilding lighting for a large or complex level can take enough time that iteration performance can suffer. Keeping user aware of this tool is necessary because this application will keep on popping up when a build action happens. Unfortunately, Author has failed to provide this information. In layman’s term, the swarm agent simply bakes the lighting effects into the map as material rather than calculating it dynamically. These materials are then stored in the level map package.

Chapter 4 shows the reader to how to use the inbuilt particle editor and other effects such as Fog, water, height, etc. The chapter begins with an in-depth and clear introduction of the particle tool. In this chapter, the first particle effect presents the smoke effect tutorial. New users may find it difficult to follow the flow graph which is used to create the initial material for the particle. For instance, a node labeled as ‘2’ is a constant node and a value of 2 is assigned to it. Importing and assigning textures is another confusing operation. It is recommended to use the content browser for importing textures and then by selecting the texture which was just imported, & then add a texture node by right clicking in the flow-graph area. As there is no resource files available for smoke in new UDK 3.0 updates, reader may have to download textures from the internet or download it from the GPUToaster Resource area. Later in this chapter, there is a brief info to add fogs and creating surfaces. One more interesting part of this chapter is to add a water volume and then make it swimmable.

Chapter 5 provides guidance in adding animation to the objects which are imported into the map. The tutorials include basic and UT style elevator/door animation, continuous looping and rotating animation and attaching an object to other objects. The whole animation is governed by the flow-graphs. These flow-graphs can be created and accessed by opening the Unreal Kismet. Kismet is a gameplay scripting tool for the Unreal Engine 3. It enables level designers to create scripts in Unreal Script for gameplay events using a visual interface. This chapter is a satisfying chapter as it introduces how the flow graphs work with the map elements. The explanation is gradual, clear and author has not jumped between the topics.

The next chapter takes the reader out to the open world – Terrain. The chapter will show how to create a terrain and add material and lighting to it. It also gives a very brief intro to the terrain brush tool. The chapter topics are well defined but unfortunately, the information presented here is not adequate enough.

The following chapters bring in the most enthralling stuff. This chapter will let you add Unreal Tournament game elements that are already present in the UDK package, to the level so far you have designed. These include map naming convention (UDK recognizes these conventions and sets prerequisites for the map), Player and bot spawn point, pickups such as health vial, weapons and weapon factory, jump pads, teleporters, adding flag base, vehicle factory, assigning paths to bot for AI and bot discovery. At the end, the level will be completely playable in UT style. Cut scenes (using movable cameras and define paths) and text notifications are also vital part of the game level designing. With UT event designer – Kismet, the job becomes easy. It uses the flow graphs to extend the node functionality. The chapter gives a good outline over the flow graph controls for basic construction of the scenes. UDK Kismet supports thousands of visual scripting nodes, which have not been covered such as adding Physics, Custom Shaders, etc. This is understandable as UT kismet alone requires a complete cookbook.

The final chapter deals with the Materials for the game environment. This chapter covers all the aspects of creating a material from a texture, adding metal effect, normal maps, specular highlights to the material. This is done using the UDK material editor. Once the material is created, the effects can be attached using flow graphs. Do not get confused between material flow graphs and Kismet, as UDK scripting is a very powerful tool that enables a developer to customize every element in the environment.

The Appendix of the book contains the quiz answers.


  1. The topics covered in this book are well chosen for a complete in-depth focus on the Unreal Engine and the development environment.
  2. The book contains adequate screenshots for explaining the topics.
  3. The most statements in the book follow point approach rather than a theory/paragraph approach. This allows a smooth transition of tutorial steps without mixing one another.
  4. Flow of the book is designed keeping the beginners approach in mind.
  5. Explanation of every example is given in a different section which is docked at the end of each topic. This helps explain the whole process that the reader has just performed in the UDK.


  1. Chapter 4, 5, and 6 are poorly designed and encompasses inadequate information that was least expected. It is recommended to follow UDK training sites such as 3dmotive.com, which will help assist learning and development.
  2. At the end of each topic there is a “Quiz”. I found the quiz questions very predictive, easy and short. Some chapters contain only a single question. Expecting an exclusive content in future edition.
  3. In the “Applying lighting Effect” chapter, there are certain parameters that are not explained properly. Novice readers may find this difficult to figure out. For example, light functions(Explanation: Which are mathematical representations of how lights illuminate the scene). To find more about component parameters, there is a very extensive description on the UDK tutorial site.
  4. While explaining flow graphs, every single important node should have been explained with a real-life example. Reader may get confused while adding a ‘Lerp’ to the flow graph, which actually means Linear Interpolation.
  5. The topic “Foliage layers” is confusing and placement of this topic seems to be context-less.
  6. Terrain chapter should have been in more details. This chapter lacks important contents such as adding vegetation and mountain, Rain effect, ambient lighting, night effect or time of the day.
  7. Chapter 8 explains deprecated feature – UIScenes (The old UI) that has been removed long back and has been replaced by Scaleform advanced UI system.

    Sacleform UI for UDK

  8. The second most essential chapter “Material” is the last chapter. In my opinion, this chapter should have been placed before digging into the flow-graphs.

Tone of the Book

The tone of the book is quite open and communicates you in a class-room style manner. The explanation of the book energizes the reader to explore the UDK more and more.

The Final Verdict

Unreal Engine and UDK have come a long way and has emerged as a very successful game engine technology. UDK is one the most flexible engine where the developers can integrate lots of third party API’s to make their game better in every sense. This guide will introduce and glue your hands on UDK environment since the Author, Richard J. Moore has chosen great topics for this edition, and the chapter flow is completely designed in a “Beginner’s guide” way. With little R&D and patience, I could create a level just like Unreal Tournament Deathmatch level, reminded me of my early days. Watch this video:

Unfortunately, author has failed to provide certain necessary information vital to the feature discussion. Because of some unexplained content, the book may create additional confusion.

The book requires a total revamp as there are certain things presumed to be done by the reader. Besides author explains few topics that do not fully comply with the UDK’s actual working.

To learn UDK, I would suggest you to read blogs, watch online tutorials and UDK site itself for improved understanding. I have compiled a final rating based on the following table:






* higher is Better. ** Lower is better.

GPUToaster rates this book 6/10.

Unreal Development Kit 3 - Beginner's Guide

This book is available from the publishers site, Packt as well as from all major sites such as AmazonBarnes and Nobel.

Unreal Development Kit 3 - Beginner's Guide does not fully meet GPUToaster's expectation.