Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying OpenGL 4 Shading Language Cookbook
  • Table Of Contents Toc
  • Feedback & Rating feedback
OpenGL 4 Shading Language Cookbook

OpenGL 4 Shading Language Cookbook

By : David A Wolff, Wolff
3.6 (9)
close
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
close

To get the most out of this book

The recipes in this book use some of the latest and greatest features in OpenGL 4.x. Therefore, in order to implement them, you'll need graphics hardware (graphics card or onboard GPU) and drivers that support at least OpenGL 4.6. However, many of the recipes will work with earlier versions. If you're unsure about what version of OpenGL your setup can support, there are a number of utilities available for determining this information. One option is GLview from Realtech VR, available at: http://www.realtech-vr.com/glview/.

If you're running Windows or Linux, drivers are readily available for most modern hardware. However, if you're using macOS, unfortunately, you're stuck with OpenGL 4.1. Apple has officially deprecated OpenGL, so there won't be any official updates coming. However, a large number of these recipes will function under OpenGL 4.1 (sometimes with minor tweaks).

Once you've verified that you have the required OpenGL drivers, you'll also need the following: 

  • A C++ compiler. On Linux, the GNU Compiler Collection (gcc, g++, and so on) may already be available, and if not, it should be available through your distribution's package manager. On Windows, Microsoft Visual Studio will work fine, but if you don't have a copy, then the MinGW compiler (available from http://mingw.org/) is a good option.
  • The GLFW library Version 3.0 or later, available from http://www.glfw.org/.  This library provides OpenGL context creation, window support, and support for user input events.
  • The GLM library Version 0.9.6 or later, available from http://glm.g-truc.net/.  This provides mathematics support with classes for matrices, vectors, common transformations, noise functions, and much more

Download the example code files

You can download the example code files for this book from your account at www.packtpub.com. If you purchased this book elsewhere, you can visit www.packtpub.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at www.packtpub.com.
  2. Select the SUPPORT tab.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for Mac
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/OpenGL-4-Shading-Language-Cookbook-Third-EditionIn case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the color images

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "The shader would then access these values via built-in variables such as gl_Vertex and gl_Normal."

A block of code is set as follows:

void main() 
{ 
  Color = VertexColor; 
 
  gl_Position = vec4(VertexPosition,1.0); 
}

Any command-line input or output is written as follows:

Active attributes:
    1    VertexColor (vec3)
    0    VertexPosition (vec3)

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "Now that we have set up our buffer objects, we tie them together into a Vertex Array Object (VAO)."

Warnings or important notes appear like this.
Tips and tricks appear like this.

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

Create a Note

Modal Close icon
You need to login to use this feature.
notes
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

Delete Note

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

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY