Introduction |
|
xx | |
|
Part I: Performance Tips and Hints |
|
|
1 | (232) |
|
|
3 | (44) |
|
|
4 | (7) |
|
|
5 | (1) |
|
|
6 | (1) |
|
|
7 | (1) |
|
Using Buffers with Vertex Arrays |
|
|
7 | (3) |
|
Using Buffers with Index Arrays |
|
|
10 | (1) |
|
|
10 | (1) |
|
Vertex Buffer Object Examples |
|
|
11 | (1) |
|
|
11 | (5) |
|
|
12 | (1) |
|
Using Pixel Buffer Objects |
|
|
13 | (1) |
|
|
14 | (2) |
|
|
16 | (10) |
|
Framebuffer Object Overview |
|
|
17 | (1) |
|
Advantages of Framebuffer Objects |
|
|
17 | (1) |
|
|
18 | (2) |
|
|
20 | (2) |
|
Setting the Read and Draw Buffer |
|
|
22 | (1) |
|
|
22 | (2) |
|
|
24 | (1) |
|
|
24 | (1) |
|
|
25 | (1) |
|
|
26 | (6) |
|
|
27 | (5) |
|
|
32 | (2) |
|
Creating Floating-Point Buffers |
|
|
33 | (1) |
|
|
33 | (1) |
|
|
34 | (4) |
|
Creating and Destroying Queries |
|
|
35 | (1) |
|
|
35 | (2) |
|
|
37 | (1) |
|
|
38 | (7) |
|
How to Find a Plane Equation |
|
|
39 | (1) |
|
Specifying the Half Space to Cut |
|
|
40 | (1) |
|
Clip Planes and Planar Reflections |
|
|
40 | (4) |
|
Advanced Clipping Technique |
|
|
44 | (1) |
|
|
45 | (1) |
|
|
46 | (1) |
|
|
47 | (8) |
|
A Brief History of Shaders |
|
|
48 | (1) |
|
|
49 | (4) |
|
|
52 | (1) |
|
|
53 | (1) |
|
|
53 | (1) |
|
|
53 | (1) |
|
|
54 | (1) |
|
|
55 | (24) |
|
|
55 | (13) |
|
|
55 | (1) |
|
|
56 | (1) |
|
|
56 | (1) |
|
Example 1: Vertex Program |
|
|
57 | (1) |
|
OpenGL Functions for ARB_vertex_program |
|
|
58 | (1) |
|
Explicit Program Parameters |
|
|
59 | (1) |
|
Source-Vector Modifications |
|
|
60 | (1) |
|
Example 2: Vertex Interpolation |
|
|
60 | (2) |
|
Generic Vertex Attributes and Matrices |
|
|
62 | (2) |
|
|
64 | (1) |
|
|
65 | (1) |
|
Example 3: Vertex Interpolation with Lighting and Fog |
|
|
65 | (3) |
|
|
68 | (1) |
|
|
68 | (1) |
|
|
68 | (10) |
|
Example 4: Procedural Shading |
|
|
69 | (5) |
|
|
74 | (1) |
|
Example 5: Per-Pixel Reflection |
|
|
75 | (2) |
|
KIL: Kill Fragment Instruction |
|
|
77 | (1) |
|
|
77 | (1) |
|
|
78 | (1) |
|
The OpenGL Shading Language |
|
|
79 | (100) |
|
|
79 | (1) |
|
What Is the OpenGL Shading Language? |
|
|
79 | (43) |
|
|
81 | (7) |
|
|
88 | (4) |
|
|
92 | (4) |
|
|
96 | (4) |
|
Program Statements and Structures |
|
|
100 | (4) |
|
|
104 | (3) |
|
|
107 | (6) |
|
|
113 | (9) |
|
The OpenGL Shading Language C API |
|
|
122 | (25) |
|
Vertex- and Fragment-Shader Setup |
|
|
122 | (2) |
|
|
124 | (2) |
|
Shader and Program Management |
|
|
126 | (2) |
|
Supplying Shaders with Information |
|
|
128 | (15) |
|
Shader and Program Object Information Query Functions |
|
|
143 | (4) |
|
Using the OpenGL Shading Language |
|
|
147 | (29) |
|
Shader Management Classes |
|
|
147 | (3) |
|
|
150 | (12) |
|
|
162 | (9) |
|
Using Multiple Render Targets |
|
|
171 | (5) |
|
Performance Tips and Hints |
|
|
176 | (2) |
|
|
176 | (1) |
|
Do as Much as You Can as Early as You Can |
|
|
176 | (1) |
|
Prefer ALU Operations to Texture Fetches |
|
|
177 | (1) |
|
|
177 | (1) |
|
Avoid Using Vectors to Store Scalars |
|
|
177 | (1) |
|
Use Compile-Time Constants Where Possible |
|
|
177 | (1) |
|
|
177 | (1) |
|
Try to Perform Vector Operations |
|
|
177 | (1) |
|
Avoid Unnecessary State Changes |
|
|
177 | (1) |
|
Be Careful of Ubershaders |
|
|
178 | (1) |
|
|
178 | (1) |
|
|
178 | (1) |
|
|
179 | (54) |
|
|
180 | (1) |
|
|
181 | (4) |
|
Automatic Texture Compression |
|
|
182 | (2) |
|
Loading Precompressed Textures |
|
|
184 | (1) |
|
Floating-Point Textures and Buffers |
|
|
185 | (2) |
|
Querying Texture Component Types |
|
|
186 | (1) |
|
|
187 | (1) |
|
Non-Power-of-Two Textures and Texture Rectangles |
|
|
187 | (2) |
|
Non-Power-of-Two Textures |
|
|
188 | (1) |
|
|
188 | (1) |
|
|
189 | (1) |
|
|
189 | (10) |
|
|
190 | (1) |
|
|
191 | (2) |
|
|
193 | (6) |
|
|
199 | (1) |
|
|
199 | (1) |
|
|
199 | (8) |
|
|
201 | (2) |
|
|
203 | (1) |
|
|
204 | (1) |
|
|
204 | (3) |
|
|
207 | (1) |
|
|
207 | (4) |
|
|
207 | (1) |
|
|
208 | (1) |
|
|
209 | (2) |
|
|
211 | (1) |
|
|
211 | (3) |
|
|
213 | (1) |
|
|
214 | (1) |
|
|
214 | (10) |
|
|
216 | (2) |
|
Parallel Texture Projections |
|
|
218 | (1) |
|
Fixed-Function Projective Texturing |
|
|
218 | (4) |
|
Eliminating Unwanted Artifacts |
|
|
222 | (1) |
|
Projective-Texture Implementation Using Shaders |
|
|
222 | (2) |
|
|
224 | (7) |
|
Offscreen Rendering with pbuffers |
|
|
226 | (1) |
|
RTT Method 1: glReadPixels() |
|
|
227 | (1) |
|
RTT Method 2: glCopyTexSublmage() |
|
|
228 | (1) |
|
RTT Method 3: WGL_ARB_render_texture |
|
|
229 | (1) |
|
RTT Method 4: GL_EXT_framebuffer_object |
|
|
230 | (1) |
|
|
231 | (2) |
|
Part II: Graphics Toolbox |
|
|
233 | (310) |
|
Advanced Lighting and Shading |
|
|
235 | (74) |
|
Advanced Lighting and Materials |
|
|
235 | (14) |
|
Review of the OpenGL Lighting Model |
|
|
236 | (2) |
|
|
238 | (1) |
|
|
239 | (1) |
|
|
240 | (3) |
|
|
243 | (2) |
|
|
245 | (3) |
|
|
248 | (1) |
|
|
248 | (1) |
|
|
249 | (18) |
|
Limitations of Forward Shading |
|
|
250 | (1) |
|
Deferred Shading Overview |
|
|
251 | (1) |
|
Working with the G-Buffer |
|
|
252 | (8) |
|
|
260 | (5) |
|
|
265 | (1) |
|
Transparency and Anti-aliasing |
|
|
266 | (1) |
|
|
266 | (1) |
|
|
266 | (1) |
|
High Dynamic Range Lighting and Rendering |
|
|
267 | (17) |
|
|
268 | (2) |
|
|
270 | (2) |
|
|
272 | (1) |
|
Image-Based Lighting and Rendering |
|
|
273 | (1) |
|
|
273 | (1) |
|
|
274 | (1) |
|
|
275 | (1) |
|
|
276 | (1) |
|
|
277 | (1) |
|
|
278 | (1) |
|
Image-Based Lighting Example |
|
|
279 | (4) |
|
|
283 | (1) |
|
|
283 | (1) |
|
Non-Photorealistic Rendering |
|
|
284 | (24) |
|
|
285 | (1) |
|
|
285 | (15) |
|
|
300 | (5) |
|
|
305 | (2) |
|
|
307 | (1) |
|
|
308 | (1) |
|
|
309 | (82) |
|
|
310 | (7) |
|
|
310 | (5) |
|
|
315 | (2) |
|
Introduction to Particle Systems |
|
|
317 | (12) |
|
|
318 | (3) |
|
|
321 | (3) |
|
|
324 | (1) |
|
|
324 | (4) |
|
|
328 | (1) |
|
|
328 | (1) |
|
Enhanced Particle Systems |
|
|
329 | (17) |
|
|
329 | (4) |
|
Adding Basic Scripting to the Particle System |
|
|
333 | (8) |
|
Improving Particle Systems with the GPU |
|
|
341 | (4) |
|
|
345 | (1) |
|
|
346 | (7) |
|
|
347 | (5) |
|
Specular-Component-Based Glow |
|
|
352 | (1) |
|
Planar Reflections and Refractions |
|
|
353 | (9) |
|
|
354 | (2) |
|
Stencil-Buffer Reflections |
|
|
356 | (5) |
|
|
361 | (1) |
|
Robust Multilevel Reflections |
|
|
362 | (13) |
|
|
363 | (1) |
|
Multilevel Reflections in Game Engines |
|
|
363 | (1) |
|
|
364 | (1) |
|
Rendering Stencil Multilevel Reflections |
|
|
365 | (8) |
|
Limiting Maximum Reflection Level |
|
|
373 | (1) |
|
|
374 | (1) |
|
|
375 | (1) |
|
|
375 | (14) |
|
|
376 | (1) |
|
|
376 | (3) |
|
|
379 | (4) |
|
|
383 | (5) |
|
|
388 | (1) |
|
|
389 | (1) |
|
|
389 | (2) |
|
|
391 | (42) |
|
|
391 | (14) |
|
What Makes Water Look Like Water? |
|
|
392 | (2) |
|
|
394 | (4) |
|
Implementation and Results |
|
|
398 | (7) |
|
|
405 | (4) |
|
|
406 | (1) |
|
Performance Optimizations |
|
|
406 | (1) |
|
|
407 | (1) |
|
|
408 | (1) |
|
|
409 | (15) |
|
|
409 | (2) |
|
|
411 | (4) |
|
|
415 | (4) |
|
|
419 | (1) |
|
|
420 | (2) |
|
|
422 | (2) |
|
Implementation Notes and Suggestions |
|
|
424 | (1) |
|
|
424 | (1) |
|
|
424 | (7) |
|
|
425 | (2) |
|
|
427 | (1) |
|
|
428 | (2) |
|
|
430 | (1) |
|
|
431 | (1) |
|
|
431 | (2) |
|
|
433 | (56) |
|
|
433 | (8) |
|
|
436 | (2) |
|
|
438 | (1) |
|
|
438 | (2) |
|
|
440 | (1) |
|
|
441 | (8) |
|
|
442 | (1) |
|
|
443 | (1) |
|
|
444 | (1) |
|
|
445 | (2) |
|
|
447 | (1) |
|
|
447 | (1) |
|
|
448 | (1) |
|
|
449 | (28) |
|
|
451 | (3) |
|
Mapping a Sky Image onto the Dome |
|
|
454 | (1) |
|
|
455 | (1) |
|
Making Skydome Textures from Cubemaps |
|
|
456 | (2) |
|
Using Color Tables for Skydome Simulation |
|
|
458 | (3) |
|
Using Sky Maps for Skydome Simulation |
|
|
461 | (3) |
|
Physically Based Sky Color Computation |
|
|
464 | (10) |
|
Getting the Color at the Horizon |
|
|
474 | (1) |
|
|
474 | (2) |
|
|
476 | (1) |
|
|
476 | (1) |
|
|
477 | (10) |
|
|
477 | (1) |
|
|
478 | (3) |
|
|
481 | (1) |
|
Spherical Implicit Equations |
|
|
482 | (1) |
|
Implementation with Volume Rendering in OpenGL |
|
|
482 | (4) |
|
|
486 | (1) |
|
|
487 | (1) |
|
|
487 | (2) |
|
|
489 | (54) |
|
|
490 | (2) |
|
|
492 | (7) |
|
|
492 | (1) |
|
|
493 | (2) |
|
|
495 | (2) |
|
|
497 | (1) |
|
|
498 | (1) |
|
|
499 | (1) |
|
|
499 | (35) |
|
|
500 | (9) |
|
|
509 | (4) |
|
|
513 | (21) |
|
|
534 | (7) |
|
|
534 | (1) |
|
Creating a Single Texture |
|
|
534 | (2) |
|
|
536 | (1) |
|
|
537 | (4) |
|
|
541 | (1) |
|
|
541 | (2) |
|
Part III: Elements of a Game |
|
|
543 | |
|
3D Models and Skeletal Animation |
|
|
545 | (20) |
|
|
545 | (2) |
|
|
545 | (1) |
|
What You Will Learn in This Chapter |
|
|
546 | (1) |
|
Basic Model Loading and the OBJ Format |
|
|
547 | (2) |
|
|
549 | (14) |
|
What Is Skeletal Animation? |
|
|
550 | (2) |
|
|
552 | (4) |
|
|
556 | (7) |
|
|
563 | (1) |
|
|
564 | (1) |
|
|
565 | |
|
|
566 | (2) |
|
|
566 | (1) |
|
|
567 | (1) |
|
|
567 | (1) |
|
What Is Scene Management? |
|
|
568 | (5) |
|
|
568 | (3) |
|
|
571 | (2) |
|
Portal-and-BSP Scene Management |
|
|
573 | (17) |
|
|
573 | (6) |
|
BSP Trees: Where We Are and What We See |
|
|
579 | (8) |
|
Visibility Determination Using Occlusion Queries |
|
|
587 | (2) |
|
|
589 | (1) |
|
|
589 | (1) |
|
Other Scene-Management Techniques |
|
|
590 | (14) |
|
|
590 | (1) |
|
|
591 | (5) |
|
|
596 | (8) |
|
|
604 | |
|
|
604 | |
|
Appendix A Low-Level Shading Languages Reference |
|
|
1 | (1) |
|
|
1 | (5) |
|
|
6 | (3) |
|
ARB_vertex_program Attribute Vectors |
|
|
9 | (1) |
|
ARB_vertex_program Result Vectors |
|
|
9 | (1) |
|
ARB_fragment_program Attribute Vectors |
|
|
10 | (1) |
|
ARB_fragment_program Result Vectors |
|
|
10 | |
|
Appendix B OpenGL Shading Language Reference |
|
|
1 | (606) |
|
|
1 | (3) |
|
|
1 | (1) |
|
|
1 | (1) |
|
|
2 | (1) |
|
|
2 | (1) |
|
|
2 | (1) |
|
|
2 | (1) |
|
|
2 | (1) |
|
|
3 | (1) |
|
|
3 | (1) |
|
Texture Environment and Generation |
|
|
4 | (1) |
|
|
4 | (1) |
|
|
4 | (603) |
|
|
4 | (1) |
|
|
5 | (1) |
|
|
6 | (1) |
|
|
6 | (1) |
|
|
6 | (1) |
|
|
7 | (1) |
|
|
7 | (1) |
|
|
8 | (1) |
|
glEnableVertexAttribArray() / glDisableVertexAttribArray() |
|
|
8 | (1) |
|
|
9 | (1) |
|
|
10 | (1) |
|
|
11 | (1) |
|
|
11 | (1) |
|
|
12 | (1) |
|
|
12 | (1) |
|
|
13 | (1) |
|
|
13 | (1) |
|
|
14 | (1) |
|
|
15 | (1) |
|
|
15 | (1) |
|
|
16 | (1) |
|
glGetVertexAttribPointer() |
|
|
17 | (1) |
|
|
17 | (1) |
|
|
17 | (1) |
|
|
18 | (1) |
|
|
18 | (1) |
|
|
19 | (2) |
|
|
21 | (1) |
|
|
21 | (1) |
|
|
22 | (2) |
|
|
24 | (583) |
Index |
|
607 | |