| Foreword |
|
xix | |
| Preface |
|
xxiii | |
|
1 The Fixed-Function Graphics Pipeline |
|
|
1 | (24) |
|
|
|
2 | (6) |
|
|
|
2 | (4) |
|
The Fragment Processing Part of the Pipeline |
|
|
6 | (1) |
|
State in the Graphics Pipeline |
|
|
7 | (1) |
|
How the Traditional View Is Implemented |
|
|
8 | (9) |
|
|
|
9 | (1) |
|
|
|
10 | (4) |
|
Homogeneous Coordinates in the Fixed-Function Pipeline |
|
|
14 | (3) |
|
|
|
17 | (3) |
|
|
|
20 | (1) |
|
|
|
21 | (4) |
|
2 OpenGL Shader Evolution |
|
|
25 | (14) |
|
|
|
27 | (3) |
|
|
|
30 | (4) |
|
|
|
30 | (1) |
|
|
|
31 | (1) |
|
|
|
32 | (1) |
|
|
|
33 | (1) |
|
What's Behind These Developments? |
|
|
34 | (1) |
|
|
|
34 | (1) |
|
How Can You Respond to These Changes? |
|
|
35 | (1) |
|
Our Approach in this Book |
|
|
36 | (1) |
|
|
|
36 | (1) |
|
|
|
37 | (2) |
|
3 Fundamental Shader Concepts |
|
|
39 | (30) |
|
Shaders in the Graphics Pipeline |
|
|
39 | (15) |
|
|
|
42 | (5) |
|
|
|
47 | (3) |
|
|
|
50 | (3) |
|
|
|
53 | (1) |
|
The GLSL Shading Language |
|
|
54 | (5) |
|
Passing Data from Your Application into Shaders |
|
|
59 | (8) |
|
Defining Attribute Variables in Your Application |
|
|
59 | (3) |
|
Defining Uniform Variables in Your Application |
|
|
62 | (2) |
|
A Convenient Way to Transition to the Newer Versions of GLSL |
|
|
64 | (3) |
|
|
|
67 | (2) |
|
|
|
69 | (22) |
|
|
|
71 | (1) |
|
|
|
72 | (1) |
|
Editing GLIB and Shader Source Files |
|
|
72 | (1) |
|
|
|
72 | (10) |
|
|
|
73 | (1) |
|
|
|
73 | (1) |
|
|
|
73 | (3) |
|
|
|
76 | (1) |
|
|
|
77 | (1) |
|
|
|
78 | (1) |
|
Specifying Uniform Variables |
|
|
79 | (2) |
|
|
|
81 | (1) |
|
More on Textures and Noise |
|
|
82 | (4) |
|
|
|
82 | (2) |
|
|
|
84 | (2) |
|
Functions in the glman Interface Window |
|
|
86 | (4) |
|
Generating and Displaying a Hardcopy of Your Scene |
|
|
86 | (1) |
|
Global Scene Transformation |
|
|
86 | (1) |
|
|
|
87 | (1) |
|
Object Picking and Transformation |
|
|
87 | (1) |
|
|
|
88 | (1) |
|
Monitoring the Frame Rate |
|
|
88 | (1) |
|
|
|
89 | (1) |
|
|
|
90 | (1) |
|
5 The GLSL Shader Language |
|
|
91 | (32) |
|
Factors that Shape Shader Languages |
|
|
92 | (3) |
|
Graphics Card Capabilities |
|
|
93 | (2) |
|
General GLSL Language Concepts |
|
|
95 | (3) |
|
|
|
95 | (1) |
|
Extended Function and Operator Capabilities |
|
|
96 | (1) |
|
|
|
97 | (1) |
|
|
|
97 | (1) |
|
New Function Parameter Types |
|
|
98 | (1) |
|
|
|
98 | (16) |
|
Omitted Language Features |
|
|
98 | (1) |
|
New Matrix and Vector Types |
|
|
99 | (1) |
|
|
|
100 | (1) |
|
|
|
101 | (1) |
|
Functions Extended to Matrices and Vectors |
|
|
102 | (3) |
|
Operations Extended to Matrices and Vectors |
|
|
105 | (1) |
|
|
|
106 | (6) |
|
|
|
112 | (1) |
|
New Function Parameter Types |
|
|
112 | (1) |
|
|
|
113 | (1) |
|
|
|
114 | (6) |
|
Defining Compatibility Mode |
|
|
114 | (1) |
|
OpenGL 2.1 Built-in Data Types |
|
|
114 | (6) |
|
|
|
120 | (1) |
|
|
|
120 | (3) |
|
|
|
123 | (16) |
|
|
|
124 | (3) |
|
The ADS Lighting Model Function |
|
|
125 | (2) |
|
|
|
127 | (4) |
|
|
|
128 | (1) |
|
|
|
128 | (1) |
|
|
|
129 | (2) |
|
Setting Up Lighting for Shading |
|
|
131 | (6) |
|
|
|
132 | (1) |
|
|
|
133 | (1) |
|
|
|
134 | (1) |
|
|
|
135 | (2) |
|
|
|
137 | (2) |
|
|
|
139 | (18) |
|
Vertex Shaders in the Graphics Pipeline |
|
|
140 | (6) |
|
|
|
140 | (2) |
|
Output from Vertex Shaders |
|
|
142 | (3) |
|
Fixed-Function Processing After the Vertex Shader |
|
|
145 | (1) |
|
The Relation of Vertex Shaders to Tessellation Shaders |
|
|
146 | (1) |
|
The Relation of Vertex Shaders to Geometry Shaders |
|
|
146 | (1) |
|
Replacing Fixed-Function Graphics with Vertex Shaders |
|
|
146 | (2) |
|
Standard Vertex Processing |
|
|
147 | (1) |
|
Going Beyond the Fixed-Function Pipeline with Vertex Shaders |
|
|
148 | (1) |
|
|
|
148 | (4) |
|
|
|
151 | (1) |
|
|
|
152 | (1) |
|
|
|
153 | (1) |
|
|
|
154 | (3) |
|
8 Fragment Shaders and Surface Appearance |
|
|
157 | (22) |
|
Basic Function of a Fragment Shader |
|
|
158 | (5) |
|
Inputs to Fragment Shaders |
|
|
158 | (3) |
|
Particularly Important "In" Variables for the Fragment Shader |
|
|
161 | (1) |
|
|
|
162 | (1) |
|
Fragment Shader Processing |
|
|
163 | (1) |
|
Outputs from Fragment Shaders |
|
|
163 | (1) |
|
Replacing Fixed-Function Processing with Fragment Shaders |
|
|
163 | (5) |
|
|
|
164 | (1) |
|
Traditional Texture Mapping |
|
|
165 | (1) |
|
|
|
166 | (2) |
|
What Follows a Fragment Shader? |
|
|
168 | (1) |
|
Additional Shader Effects |
|
|
169 | (8) |
|
|
|
169 | (1) |
|
|
|
169 | (1) |
|
Shading with Analytic Normals |
|
|
170 | (2) |
|
|
|
172 | (1) |
|
|
|
173 | (2) |
|
|
|
175 | (2) |
|
|
|
177 | (2) |
|
9 Surface Textures in the Fragment Shader |
|
|
179 | (34) |
|
|
|
180 | (1) |
|
Traditional Texture Mapping |
|
|
180 | (2) |
|
|
|
182 | (23) |
|
|
|
184 | (1) |
|
Texture Environments in the Fixed-Function World |
|
|
185 | (1) |
|
Texture Sampling Parameters |
|
|
186 | (1) |
|
|
|
186 | (1) |
|
|
|
187 | (6) |
|
|
|
193 | (7) |
|
|
|
200 | (5) |
|
|
|
205 | (4) |
|
Render to Texture for Multipass Rendering in glman |
|
|
209 | (3) |
|
|
|
212 | (1) |
|
|
|
213 | (26) |
|
Fundamental Noise Concepts |
|
|
214 | (6) |
|
Three Types of Noise: Value, Gradient, and Value+Gradient |
|
|
214 | (1) |
|
Cubic and Quintic Interpolation |
|
|
215 | (1) |
|
|
|
216 | (4) |
|
|
|
220 | (8) |
|
Fractional Brownian Motion (FBM, 1/f, Octaves) |
|
|
220 | (1) |
|
Noise in Two and Three Dimensions |
|
|
221 | (2) |
|
|
|
223 | (2) |
|
Using Noise with the Built-In GLSL Functions |
|
|
225 | (1) |
|
|
|
225 | (3) |
|
Some Examples of Noise in Different Environments |
|
|
228 | (7) |
|
|
|
230 | (1) |
|
|
|
231 | (2) |
|
|
|
233 | (2) |
|
|
|
235 | (1) |
|
|
|
235 | (2) |
|
|
|
237 | (2) |
|
11 Image Manipulation with Shaders |
|
|
239 | (52) |
|
|
|
240 | (1) |
|
Single-Image Manipulation |
|
|
241 | (29) |
|
|
|
241 | (2) |
|
|
|
243 | (3) |
|
|
|
246 | (2) |
|
|
|
248 | (1) |
|
|
|
249 | (2) |
|
|
|
251 | (1) |
|
|
|
252 | (4) |
|
|
|
256 | (3) |
|
|
|
259 | (1) |
|
|
|
260 | (2) |
|
|
|
262 | (2) |
|
|
|
264 | (1) |
|
Image Flipping, Rotation, and Warping |
|
|
265 | (5) |
|
The Image Blending Process |
|
|
270 | (1) |
|
Blending an Image with a Constant Base Image |
|
|
271 | (4) |
|
|
|
272 | (1) |
|
|
|
273 | (1) |
|
|
|
274 | (1) |
|
Blending an Image with a Version of Itself |
|
|
275 | (2) |
|
|
|
275 | (1) |
|
|
|
276 | (1) |
|
Blending Two Different Images |
|
|
277 | (9) |
|
|
|
278 | (3) |
|
|
|
281 | (5) |
|
|
|
286 | (1) |
|
|
|
287 | (4) |
|
12 Geometry Shader Concepts and Examples |
|
|
291 | (24) |
|
What Does the Geometry Shader Do? |
|
|
292 | (9) |
|
|
|
294 | (1) |
|
Layouts for Input and Output Variables |
|
|
295 | (1) |
|
|
|
296 | (3) |
|
New GLSL Variables and Variable Types |
|
|
299 | (1) |
|
Communication between a Vertex or Tessellation Shader and a Geometry Shader |
|
|
299 | (2) |
|
Normals in Geometry Shaders |
|
|
301 | (1) |
|
|
|
301 | (11) |
|
|
|
301 | (2) |
|
|
|
303 | (2) |
|
|
|
305 | (4) |
|
|
|
309 | (3) |
|
|
|
312 | (3) |
|
|
|
315 | (38) |
|
What Are Tessellation Shaders? |
|
|
315 | (3) |
|
Tessellation Shaders or Geometry Shaders? |
|
|
317 | (1) |
|
Tessellation Shader Concepts |
|
|
318 | (5) |
|
Issues in Setting Tessellation Levels |
|
|
323 | (1) |
|
|
|
323 | (27) |
|
|
|
324 | (3) |
|
|
|
327 | (7) |
|
|
|
334 | (7) |
|
Whole Sphere Subdivision while Adapting to Screen Coverage |
|
|
341 | (3) |
|
|
|
344 | (6) |
|
|
|
350 | (1) |
|
|
|
351 | (2) |
|
|
|
353 | (22) |
|
Shaders in the OpenGL Programming Process |
|
|
353 | (2) |
|
Handling OpenGL Extensions |
|
|
355 | (1) |
|
How Is a GLSL Shader Program Created? |
|
|
355 | (2) |
|
Creating and Compiling Shader Objects |
|
|
357 | (3) |
|
The CheckGLErrors Function |
|
|
359 | (1) |
|
Creating, Attaching, Linking, and Activating Shader Programs |
|
|
360 | (4) |
|
Creating a Shader Program and Attaching Shader Objects |
|
|
361 | (1) |
|
|
|
361 | (1) |
|
Activating a Shader Program |
|
|
362 | (2) |
|
Passing Data into Shaders |
|
|
364 | (8) |
|
Defining Uniform Variables in Your Application |
|
|
364 | (3) |
|
Uniform Variables in Compatibility Mode |
|
|
367 | (1) |
|
Defining Attribute Variables in Your Application |
|
|
368 | (2) |
|
Attribute Variables in Compatibility Mode |
|
|
370 | (1) |
|
A C++ Class to Handle Shader Program Creation |
|
|
371 | (1) |
|
|
|
372 | (3) |
|
15 Using Shaders for Scientific Visualization |
|
|
375 | (50) |
|
Image-Based Visualization Techniques |
|
|
376 | (2) |
|
|
|
376 | (1) |
|
|
|
377 | (1) |
|
|
|
377 | (1) |
|
|
|
378 | (3) |
|
3D Scalar Data Visualization |
|
|
381 | (17) |
|
|
|
383 | (4) |
|
|
|
387 | (3) |
|
|
|
390 | (2) |
|
|
|
392 | (6) |
|
More on Transfer Functions |
|
|
398 | (5) |
|
Passing in Data Values with Your Geometry |
|
|
403 | (2) |
|
|
|
405 | (3) |
|
|
|
408 | (8) |
|
2D Line Integral Convolution |
|
|
408 | (3) |
|
3D Line Integral Convolution |
|
|
411 | (2) |
|
Extruding Objects for Streamlines |
|
|
413 | (3) |
|
|
|
416 | (4) |
|
|
|
416 | (1) |
|
|
|
417 | (3) |
|
|
|
420 | (5) |
|
|
|
425 | (40) |
|
|
|
426 | (7) |
|
|
|
427 | (4) |
|
|
|
431 | (2) |
|
|
|
433 | (5) |
|
|
|
438 | (2) |
|
|
|
440 | (8) |
|
|
|
441 | (4) |
|
|
|
445 | (3) |
|
|
|
448 | (1) |
|
Using the glman Timer Function |
|
|
449 | (1) |
|
|
|
449 | (3) |
|
Fog, with and without Noise |
|
|
452 | (1) |
|
|
|
453 | (3) |
|
|
|
456 | (3) |
|
|
|
456 | (3) |
|
Making Information Visible Through Motion |
|
|
459 | (2) |
|
|
|
461 | (1) |
|
|
|
462 | (3) |
|
|
|
|
|
|
465 | (4) |
|
|
|
469 | (4) |
|
|
|
473 | (4) |
|
|
|
477 | (6) |
| References |
|
483 | (4) |
| Index |
|
487 | |