Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • OpenGL 4 Shading Language Cookbook
  • Toc
  • feedback
OpenGL 4 Shading Language Cookbook

OpenGL 4 Shading Language Cookbook

By : David A Wolff, Wolff
3.6 (9)
close
OpenGL 4 Shading Language Cookbook

OpenGL 4 Shading Language Cookbook

3.6 (9)
By: David A Wolff, Wolff

Overview of this book

OpenGL 4 Shading Language Cookbook, Third Edition provides easy-to-follow recipes that first walk you through the theory and background behind each technique, and then proceed to showcase and explain the GLSL and OpenGL code needed to implement them. The book begins by familiarizing you with beginner-level topics such as compiling and linking shader programs, saving and loading shader binaries (including SPIR-V), and using an OpenGL function loader library. We then proceed to cover basic lighting and shading effects. After that, you'll learn to use textures, produce shadows, and use geometry and tessellation shaders. Topics such as particle systems, screen-space ambient occlusion, deferred rendering, depth-based tessellation, and physically based rendering will help you tackle advanced topics. OpenGL 4 Shading Language Cookbook, Third Edition also covers advanced topics such as shadow techniques (including the two of the most common techniques: shadow maps and shadow volumes). You will learn how to use noise in shaders and how to use compute shaders. The book provides examples of modern shading techniques that can be used as a starting point for programmers to expand upon to produce modern, interactive, 3D computer-graphics applications.
Table of Contents (13 chapters)
close

What this book covers

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 2Working 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.

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech
bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete