Chapter 10
Advanced Lighting
WHAT’S IN THIS CHAPTER?
- Learning the different lamp types
- Implementing global per-pixel lighting using normal maps
- Implementing a directional lamp
- Implementing a point light
- Learning how to handle light attenuation
- Implementing a spherical point light
- Implementing a spot light with soft edges
- Learning the basics to implement a dynamic lighting system
In this chapter, I will strictly focus on teaching you how to create multiple types of per-pixel lamps using normal mapping (since I personally don’t see the point of per-pixel lighting without normal maps). You will revisit what you learned about lighting earlier in this book and push the implementation to the next level.
You will first start learning about the main categories of lamps that exist in the real world. Then you will gradually implement different types of lamps in conjunction with other lighting-related effects to finally end up creating a somewhat complex and dynamic lighting system that you can then easily reuse inside your games and 3D apps.
TYPES OF LAMPS
In the real world, there are basically three categories of lamps that you see in your everyday life. In order to create realistic 3D worlds, you will have to be able to identify them and handle them in code. That said, here are the three basic types of lamps that you will have to deal with:
- Directional: This type is determined when a light source has constant direction parallel light rays which do not diminish with distance. The best ...