Gamasutra: The Art & Business of Making Gamesspacer
View All     RSS
October 22, 2017
arrowPress Releases






If you enjoy reading this site, you might also want to check out these UBM Tech sites:


 

[Book Review] OpenGL 4.0 Shading Language Cookbook

by Abhishek Dey on 11/15/11 12:44:00 pm   Featured Blogs

The following blog post, unless otherwise noted, was written by a member of Gamasutra’s community.
The thoughts and opinions expressed are those of the writer and not Gamasutra or its parent company.

 

 

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.

Likes

  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.

Dislikes

  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:

RATING COMPONENT 

RATING

CONTENT* 10/10
TOPIC EXPLANATION – BASIC* 10/10
TOPIC EXPLANATION – IN-DEPTH* 10/10
TONE OF THE BOOK* 10/10
BEGINNER’S APPROACH* 10/10
RELEVANCE TO THE OpenGL Shading Language* 10/10
CONFUSION CREATED** 0/10
MISC FEATURE – GRAPHS, ALGORITHMS AND FORMULAE* 10/10
GENERAL AUDIENCE LET DOWN** (NA) 0/10
QUALITY OF EXAMPLES* 10/10
SOURCE CODE (ONLY QT BASED)* 9.5/10

Overall Rating for the book

9.5/10

* 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!

Related Jobs

iGotcha Studios
iGotcha Studios — Stockholm, Sweden
[10.21.17]

Tools Developer
Infinity Ward / Activision
Infinity Ward / Activision — Woodland Hills, California, United States
[10.21.17]

Senior Core Systems Engineer
Infinity Ward / Activision
Infinity Ward / Activision — Woodland Hills, California, United States
[10.21.17]

UI Engineer
Naughty Dog
Naughty Dog — Santa Monica, California, United States
[10.20.17]

Graphics Programmer (Game Team)





Loading Comments

loader image