Vertex and Fragment Shading
The rendering of the models we’ve achieved thus far has used OpenGL’s deprecated API calls along with mathematics calculated on the CPU by Python to draw, texture, and light images on the screen. If you have tried to render models with many vertices using the current project, you’ll have noticed how slow the methods become as the vertex count increases. Even the original teapot model from Chapter 8, Reviewing Our Knowledge of Triangles, starts to slow down the application.
To speed up rendering, a graphics card (GPU) can be used to process vertices and pixels in parallel. To move the logic and algorithms we’ve written thus far onto the GPU, we must first learn how to write shader programs that are compiled and executed on the GPU.
To this end, in this chapter, we will cover the following topics:
- Understanding shaders
- Transferring processing from the CPU to the GPU
- Processing pixel by pixel
As we refactor...