The earliest lighting algorithms used simple equations to render perfect Lambertian diffuse reflective surfaces and specular highlights. Complex illumination models such as ray tracing and radiosity, and programmable fragment shaders that simulate complex material reflectance properties, employ these simple diffuse and specular lighting equations as building blocks. In fact, simple diffuse and specular lighting suffice for the vast majority of nonphotorealistic interactive computer graphics applications today. As a low-level graphics API, OpenGL has no direct support for ray tracing and radiosity. It does support ambient, diffuse, and specular lighting, however. This chapter describes how to set OpenGL lighting parameters and coefficients for the typical lighting requirements of most applications. Chapter 6, "Texture Mapping," demonstrates enhanced lighting effects using texture mapping. If your application requires advanced lighting effects beyond the capabilities of OpenGL lighting and texture mapping, such as per-pixel lighting or bidirectional reflectance distribution functions, you should consider using OpenGL vertex and fragment shaders. appendix A, "Other Features," discusses this feature briefly. For more in-depth treatment, see OpenGL® Shading Language. What You'll LearnThe following aspects of OpenGL lighting are covered in this chapter:
What You Won't LearnThe following aspects of OpenGL lighting are not covered in this chapter:
Though useful in some rendering circumstances, these features are outside the scope of this book. If your application requires this functionality, see OpenGL® Programming Guide and OpenGL® Reference Manual. |