Chapter 1, Getting Started with GLSL, explains the steps needed to compile, link, and use GLSL shaders within an OpenGL program. It also covers how to save and load shader binaries, and how to use SPIR-V with OpenGL. It covers the use of the GLM library for mathematics support.
Chapter 2, Working with GLSL Programs, introduces the basic of communication between the shader programs and the OpenGL program. It covers how to send data to shaders using attributes and uniform variables, how to enumerate variables, how to work with shader pipelines, and offers an example of a shader program class.
Chapter 3, The Basics of GLSL Shaders, introduces you to the basics of GLSL programming with per-vertex shading. In this chapter, you see examples of basic shading techniques such as the Phong model, two-sided shading, and flat shading. It also covers examples of basic GLSL concepts such as functions and subroutines.
Chapter 4, Lighting and Shading, continues with basic shading techniques, with a focus on the fragment shader. It introduces you to techniques such as the Blinn-Phong model, spotlights, per-fragment shading, toon shading, fog, and a physically based reflection model.Â
Chapter 5, Using Textures, provides a variety recipes involving the use of textures in GLSL shaders. Textures can be used for a variety of purposes besides simply "pasting" an image onto a surface. In this chapter, we cover the basic application of one or more 2D textures, as well as a variety of other techniques including alpha maps, normal maps, parallax mapping, cube maps, projected textures, rendering to a texture, and diffuse image based lighting. We also cover sampler objects, a relatively new feature that decouples sampling parameters from the texture object itself.
Chapter 6, Image Processing and Screen Space Techniques, explains common techniques for the post-processing of rendered images and some other screen-space techniques. Image post-processing is becoming a crucially important part of modern game engines and other rendering pipelines. This chapter discusses how to implement some of the more common post-processing techniques such as tone mapping, bloom, blur, gamma correction, and edge detection. We also cover some screen-space rendering techniques such as deferred shading, multisample anti-aliasing, screen-space ambient occlusion, and order-independent transparency.
Chapter 7, Using Geometry and Tessellation Shaders, covers techniques that demonstrate how to use these powerful shader stages. After reading this chapter, you should be comfortable with their basic functionality and understand how to use them. We cover techniques such as geometry-shader-generated point sprites, silhouette lines, depth-based tessellation, Bezier surfaces, and more.
Chapter 8, Shadows, introduces basic techniques for producing real-time shadows. This chapter includes recipes for the two most common shadow techniques: shadow maps and shadow volumes. We cover common techniques for anti-aliasing shadow maps, as well as how to use the geometry shader to help produce shadow volumes.Â
Chapter 9, Using Noise in Shaders, covers the use of Perlin noise for creating various effects. The first recipe shows you how to create a wide variety of textures containing noise data using GLM (a powerful mathematics library). Then we move on to recipes that use noise textures for creating a number of effects such as wood grain, clouds, disintegration, paint, and static.
Chapter 10, Particle Systems and Animation, focuses on techniques for creating particle systems. We see how to create a particle system to simulate fire, smoke, and water. We also make use of the OpenGL feature called transform feedback, in order to gain additional efficiency by moving the particle updates onto the GPU.
Chapter 11, Using Compute Shaders, introduces you to several techniques that make use of one of the newest features in OpenGL, the compute shader. The compute shader provides us with the ability to do general computation on the GPU within OpenGL. In this chapter, we discuss how to use the compute shader for particle simulations, cloth simulation, edge detection, and the generation of a procedural fractal texture. After reading this chapter, the reader should have a good feel for how to use the compute shader for arbitrary computational tasks.