Creating a GLSL Library
IntroductionThere are plenty of examples of GLSL shaders available in print or on the web. In this article, rather than showing an a la carte example, we will go through the creation of a shader library. Since the two most likely requirements in and OpenGL program are texturing and lighting the scene, those will be the two things we'll be doing. Specifically we'll be covering Texturing, and as an extension Multi-Texturing, and Per-pixel Lighting for Directional, Point, and Spot Lights. There a couple assumptions that are made in this article. First, it is assumed that you already know how to properly compile, link and use a shader in OpenGL. Second, it is assumed that you do not need an explanation on the Phong Lighting Model. The references for this article cover those things so look to those if you want a thorough explanation of either of those things. First thing we're going to do is create the Texturing library. This library is fairly simple, and admittedly overkill, but it provides a basis for going to the more complex Lighting library.
|