CHAPTER 10: OpenGL ES 2, Shaders, and... (^309)
If this sounds like a lot of work for each fragment of each object in your scene roaring
along at 60 fps, you are right. But fundamentally, shaders are small programs that are
actually loaded and run on the graphics hardware itself and, as a result, are very,
very fast.
OpenGL application Geometry and texture
Vertex shader Lighting, transform, scale, etc
Texture, shading
Generate Fragments
Framebuffer Stencil, alpha, z-tests, blending
Eyeballs "Hey, that's really cool!"
Rasterization
Fragment Shader
Figure 10-1. Overview of OpenGL ES 2 architecture
Shader Structure
Both vertex and fragment shaders are similar in structure and look a little like a small C
program. The entry point is always called main() as in C (and Objective-C), while the
syntax is likewise very C-ish.
The shader language, called GLSL (not to be confused with its Direct3d counterpart,
HLSL), contains a rich set of built-in functions that belong to one of three main
categories:
Math operations oriented toward graphics processing such as matrix,
vector, trig, derivative, and logic functions
Texture sampling
Small helper utilities such as modulo, comparisons, and valuators
singke
(singke)
#1