O'Reilly logo

OpenGL 4 Shading Language Cookbook Second Edition by David Wolff

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 2. The Basics of GLSL Shaders

In this chapter, we will cover:

  • Implementing diffuse, per-vertex shading with a single point light source
  • Implementing per-vertex ambient, diffuse, and specular (ADS) shading
  • Using functions in shaders
  • Implementing two-sided shading
  • Implementing flat shading
  • Using subroutines to select shader functionality
  • Discarding fragments to create a perforated look

Introduction

Shaders were first added into OpenGL in Version 2.0, introducing programmability into the formerly fixed-function OpenGL pipeline. Shaders give us the power to implement alternative rendering algorithms and a greater degree of flexibility in the implementation of those techniques. With shaders, we can run custom code directly on the GPU, providing us with ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required