ptgmedia.pearsoncmg.comptgmedia.pearsoncmg.com/images/0321334892/index/rost_index.pdf · clipping...
TRANSCRIPT
705
1D noise function octaves, 390–3911D shadow sampler, 203–2041D texture map, 4811D textures, 26, 28, 141, 203, 6691/f noise, 3912D noise, 394–3952D Perlin noise, 3942D shadow sampler, 2042D textures, 26, 141, 204, 268, 376, 669
glyphs, 272pixel values, 28
3D noise function, 3953D noise textures, 396–3983D textures, 2, 26–28, 6693Dlabs, 2, 56, 225, 226, 251, 505, 5443Dlabs developer Web site, 32, 63, 96,
165, 213, 2303Dlabs Web site, 63, 95, 208, 226, 230,
233, 257, 340, 3964D noise function, 395
A
abs function, 128, 130, 458Absent qualifier, 81Absolute value, 137Accumulation buffer, 7, 18, 669acos function, 126, 530Active attributes, 192–193, 598–600, 669Active samplers, 204, 669Active texture unit, 27, 31, 254, 258, 669Active uniform variables, 201, 601–604,
669
Adaptive analyticantialiasing fragment shader, 442prefiltering, 440–443
ADD blend mode, 491Addition operator (+), 85, 88Additive operators, 94
Advanced RenderMan: Creating CGI for Motion Pictures
(Apodaca and Gritz), 147, 230, 323, 405, 444, 454
Aerial perspective, 525–529Aggregate types, initializing, 75AGL routines, 6Airbrush and pen illustrations, 463Akeley, Kurt, 4Aliasing, 433–436, 443, 670Aliasing artifacts, 164, 454
AlienRockArt,
513
AlienRockArt
altgrad texture, 522–523
AlienRockArt
planet, 532all function, 89, 141all token, 92Alpha, 670Alpha test, 17, 670Alpha value, 17Altgrad map, 522–524
AlienRockArt,
522–523
DragonRidges,
523–524snow, 522
Altitude angle, 268, 271Ambient component, 368Ambient light, 334Ambient occlusion, 334–338, 342, 670
0.Index
Rost_Index.fm Page 705 Wednesday, December 21, 2005 12:40 PM
706 Index
Ambient variable, 289Amplitude, 427, 670Amplitude variable, 427Analytic integration, 443–446Ancient Chinese art of chi ting, 313Angle functions, 124–126Animatable for cloudy sky effect fragment
shader, 413–414Animation, 411
blending factor, 414–415fading object in or out, 417key-frame interpolation, 414–416linear blend, 414morphing, 414–416on/off, 412particle systems, 418–426threshold, 413vertex noise, 417–418wobble, 426–430
Animation effects, 38, 411–413Anisotropic, 670Anisotropic glint, 365Anisotropic reflection, 369ANSI C programming language, 50Antialiased brick fragment shader, 446–447Antialiased checkerboard fragment shader,
448–449Antialiased stripe example, 437
adaptive analytic prefiltering, 440–443analytic integration, 443–446antialiased brick fragment shader, 446–447generating stripes, 437–439
Antialiasing, 16, 433, 454, 670area sampling, 444frequency clamping, 447–449hatching example, 454high-quality full-screen, 7increasing resolution, 436–437low-pass filtering, 439user programmable methods, 38value of integral over area of filter, 445
any function, 89, 141API (application programming interface), 1, 670Apodaca, Tony, 323Apple, 2Application developers, 37ARB (Architecture Review Board), 49ARB prefix extensions, 3
ARB_fragment_program extension, 56Arbitrary matrix, 23Arbitrary per-vertex data, 10ARB_vertex_program extension, 56Arc cosine, 126Arc sine, 126Arc tangent, 126Area lights, 312Area sampling, 444, 670Arithmetic operators, 88Array element operator ([]), 197Arrays, 72–74
indexing, 86two-dimensional, 494
Artifacts, 434asin function, 126Aspect ratio, 25Assembly language interfaces, 60Assignment operators (+=, -=, *=, and /=), 86, 89atan function, 126ATI, 2ATI developer Web site, 32, 231Atmosphere shaders, 543Atmospheric effects
aerial perspective, 525–529RealWorldz, 525–532sky shading, 529–532
atmospheric shell function, 526–528Attenuation, 237–238, 670Attribute aliasing, 189, 670Attribute qualified variables, 67, 78–79Attribute qualifiers, 78–79Attribute variables, 40–41, 51, 78, 80–81, 168,
671built-in, 41–42, 97data types, 186initializing, 75location of, 607–608querying attribute binding for named vertex
shader, 189–190user-defined, 41–42, 97vertex shader, 99
Attributes, 79, 99–100accessing in vertex shader, 97locations, 185three-dimensional, 22vertex, 184–195
Automatic mipmap generation, 2
Rost.book Page 706 Wednesday, December 21, 2005 12:21 PM
Index 707
Automatic state-tracking mechanism, 101Auxiliary buffers, 7, 671AVERAGE blend mode, 488Azimuth angle, 268, 271
BBack buffer, 6–7Back-end processing and images, 20Backface culling, 40Back-facing polygons, 15Background variable, 423Bains, Inderaj, 233Baker, Dan, 312Baldwin, Dave, 149, 233, 444, 448, 468, 544Barzel, Ronan, 322Base color, 490Base image, 488, 491–492BEHIND blend mode, 488Bent normal, 338, 671bias parameter, 142binormal variable, 191–192, 372Binormal vector, 303Bitmap rasterization, 479Bitmaps, 18Bitwise operators, 53, 94Bit-wise shift operators, 94Blend image, 491Blend Modes, 487Blend modes, 486–500
ADD blend mode, 491AVERAGE blend mode, 488BEHIND blend mode, 488CLEAR blend mode, 489COLOR BURN blend mode, 490COLOR DODGE blend mode, 490CONVOLUTION blend mode, 493–495DARKEN blend mode, 489default, 488DIFFERENCE blend mode, 492DISSOLVE blend mode, 488edge detection, 498EXCLUSION blend mode, 492HARD LIGHT blend mode, 491INVERSE DIFFERENCE blend mode, 492LIGHTEN blend mode, 489MULTIPLY blend mode, 489NORMAL blend mode, 488OPACITY blend mode, 492–493OVERLAY blend mode, 490–491
pixel-by-pixel blending, 487SCREEN blend mode, 490smoothing, 495–497SOFT LIGHT blend mode, 491SUBTRACT blend mode, 492
Blend variable, 416Blending, 17Blending functions, 2Blinn, Jim, 313bool data type, 52, 67–69Boolean constructors, 77Boolean values, 50, 69Border color, 29Border region, 512Box filter, 443–444Boyd, Chas, 312BRDF (Bidirectional Reflectance Distribution
Function), 368–375, 671BRDF PTMs, 377–378
application setup, 378–379light factor texture, 378–379stored as mipmap textures, 383surface rendering fragment shader, 382–383vertex shader, 379–381
break keyword, 82Brick fragment shader, 162–163Brick pattern, 149
aliasing artifacts, 164color, 161–162depth, 164ease of modification, 158fragment shader, 157–164modeling coordinate position, 158mortar color, 161–162number, 159remaining constant, 156row number, 159size of bricks, 164vertex shaders, 151–157
Brick shadersapplication code, 208–212description of overall effect, 150overview, 150–151
Brick vertex shader, 157BrickPct variable, 161Brightness, 484Buffer object, 12Buffers, 17–18, 671A Bug’s Life, 544
Rost.book Page 707 Wednesday, December 21, 2005 12:21 PM
708 Index
Built-inattribute variables, 41–42, 97, 190attributes, 79constants, 98–99, 113–114macros, 90noise function, 399–400sine functions, 84–85texture functions, 249, 482uniform variables, 42, 46, 51, 97, 105,
108–113, 196, 202varying variables, 43, 97, 102–103, 105
Built-in functions, 52, 84–85, 123angle functions, 124–126common functions, 126, 128–134exponential functions, 126–127fragment processing functions, 144–145geometric functions, 136–138HLSL, 552interesting effects in shaders, 124matrix functions, 138–139noise functions, 145–146overloading, 52overriding, 84–85shader development, 219texture access functions, 141–144trigonometry functions, 124–126usage, 124variants, 123–124vector relational functions, 139–141vectors, 69
Built-in variables, 51, 67, 78, 81, 97, 101, 152, 546
global scope, 107mapping OpenGL state values to, 113vectors, 69
Bump function, 366Bump mapping, 300, 671
application setup, 303–304fragment shader, 306–308increasing object realism, 301light source, 301location of bumps, 306normal maps, 308–309number of bumps per unit, 307small effects to surfaces, 301
Bump mapping, continuedsurface normal at each fragment location,
301surface-local coordinate space, 302
tangent vector, 303–304texture coordinates, 308vertex shader, 306width of bumps, 307
Bump maps, 308, 671Bump pattern characteristics, 306–307BumpDensity variable, 303, 306–307BumpSize variable, 303, 307“bumpy/shiner” shader pair, 268Bunnell, Michael, 338, 343bvec2 data type, 69bvec3 data type, 69bvec4 data type, 69
CC functions
generating 3D noise texture, 396–397installing brick shaders, 210–212obtaining OpenGL and OpenGL Shading
Language version information, 169–170printing information log for object, 182–183
C programming languagedrawing particles as points, 422drawing silhouette edges on simple objects,
464features not supported, 53integers, 68ISL (Interactive Shading Language) based on,
547literal floating-point numbers, 68updating time variable each frame, 423vertex data for particles, 420–421
C++ programming language, 68The C++ Programming Language (Stroustrup),
95–96The C Programming Language (Kernighan and
Ritchie), 95, 96Calahan, Sharon, 323Call by value-return, 54, 671Calling conventions, 83–84Cameras, 23Caustic texture map, 536CDs and diffraction grating, 365ceil function, 128, 132Ceramic effect, 271Cerberus planet, 524Cg, 55, 544, 552–554Cg Runtime library, 552–553Cg shaders, 359, 552
Rost.book Page 708 Wednesday, December 21, 2005 12:21 PM
Index 709
The Cg Tutorial (Fernando and Kilgard), 359CgFX, 553Character buffer, 193Characters, 53Chromatic aberration, 362–363, 672Chromatic dispersion, 362, 672CIE (Committee Internationale de L’_clairage),
482CIE system, 482–483clamp function, 129, 133–134, 435Clamping and fog factor, 246class keyword, 72CLEAR blend mode, 489Client-side memory, 12Client-side state, 8Clip space, 25, 672Clipping, 116–117, 672
point size, 115primitives, 14–15
Clipping coordinate system, 25, 672Clipping coordinates transformations, 234Clipping planes, 15, 25Cloud shader, 413–414Cloud texture, 260–261Cloud vertex shader, 401Clouds, 537–539Cohen, Elaine, 463ColAdjust variable, 272Color, 41
applying fog to compute final value, 246to attach to fragment, 67computing for vertex, 242final surface computation, 242final values with no lighting, 244fragments, 157–158mapping values, 481new alpha value, 250Pixel group, 19primary, 242replacing with value computed through
texture access, 30RGB representation of, 365secondary, 242terrain, 521–522
Color buffers, 19, 593–595COLOR BURN blend mode, 490Color components, initializing, 18Color display, 5COLOR DODGE blend mode, 490
Color index attribute, 100Color pickers, 158Color pixel rectangles, 18Color space conversions, 482–483Color sum, 16, 672Color values
accessing, 50current array, 11
color variable, 162Color vector, 69Commands
N in name, 186out-of-order execution, 5processing, 4storing for later execution, 11
Common coordinate system, 22Common math operations, 52Compaq, 1Compiled codes storage, 170Compiler front end, 225–226, 672Compiler/linker, 56–57Compilers, 54–55
ill-formed programs, 94–95initial state, 92optimization, 60
Compile-time constants, 73, 80–81Compiling shader objects, 172–173, 581–582Complex number plane, 468–469, 472Complex numbers, 468–469Complex shapes, 7Components, 87–89Component-wise operation, 87–90Composite images, 7Compressed textures, 2, 28Computer Graphics Laboratory (Stanford), 544Confetti cannon vertex shader, 423–426const qualified variables, 80const qualifiers, 78, 83Constant qualified variables, 75constant qualifiers, 80–81Constants, 152
built-in, 113–114compile-time, 80
Constructive interference, 366Constructors, 52–53, 75–77, 672Containing tile, 512continue keyword, 82Contrast, 485Control constructs, 543
Rost.book Page 709 Wednesday, December 21, 2005 12:21 PM
710 Index
Control texture, 287, 672Convolution, 443, 672CONVOLUTION blend mode, 493–495Convolution filter, 443, 493–495, 672Convolution kernel, 443, 493–495, 672Convolution operation
edge detection, 498general fragment shader, 496–497neighborhood averaging, 495–496
Cook, Rob, 543coord texture coordinate, 143–144Coordinate spaces, 21, 546Coordinate system, 22Coordinate transforms, 21–26Coordinates and units of measurement, 22coord.s texture coordinate, 143coord.t texture coordinate, 143cos function, 124–125Cosine, 125CRC Standard Mathematical Tables and Formulas
(Zwillinger), 148createPoints subroutine, 420cross function, 136Cross product, 136Cube map textures, 2, 27–28, 247Cube mapping, 265, 673Cube mapping example, 265–268Cube maps, 26, 316, 672
accessing, 265–266blending with stars, nebula, and atmosphere
color, 530built-in functions to access, 256environment mapping, 267–268faces, 266OpenGL shaders, 265
Culling, 15, 673currHdH variable, 520Curves, rendering with evaluators, 12
DDAG (directed acyclic graph), 227DARKEN blend mode, 489Data binding, 5Data structure, 55Data types
arguments linearly mapped to normalized range, 186
arrays, 73–74automatic promotion, 53conversing, 53
converting, 153matrices, 70OpenGL Shading Language, 546passed by value, 84promotion, 75providing name, 68RenderMan, 546samplers, 71–72scalars, 67–69structures, 72uniform qualified variables, 79user-defined attribute variable, 192vectors, 69–70void, 74
Daytime texture, 260, 263–264Debevec, Paul, 315–316, 322Debug pragma, 91Debugging shaders, 91, 220–222Decimal integer constant, 90Decrement operator (--), 88Default blend modes, 488Deferred shading, 673
soft shadows, 346–347for volume shadows, 346–354
#define directives, 90, 172defined operator, 90Degrees, converting radians to, 125degrees function, 125deLight program, 338, 340–341Dell, 2Delphi3D Web site, 32density variable, 245Dependent texture read, 46, 673Depth buffer, 7, 19, 673Depth comparison modes, 340Depth comparison values, 29Depth component textures, 340Depth components, 18Depth map, 339, 673Depth range, 40Depth test, 17, 673depth texture, 142Depth textures, 119, 253, 256Depth-cuing, 244, 673Depth-of-field effects, 7“The Design of the OpenGL Graphics Interface”
(Segal and Akeley), 32The Design of the OpenGL Graphics Interface (Segal
and Akeley), 33Destination buffer, 18
Rost.book Page 710 Wednesday, December 21, 2005 12:21 PM
Index 711
Development aids, 206–207dFdx function, 145, 440–441, 456dFdy function, 145, 440–441, 456DIFFERENCE blend mode, 492Diffraction, 363–368, 673Diffraction gratings, 363–365, 673Diffraction vertex shader, 365Diffuse component, 368Diffuse environment maps, 317Diffuse lighting effects, 218Diffuse lighting factor, 264Diffuse reflection, 152–155, 317–319, 368DiffuseColor variable, 289diffuseContribution constant, 156Digital Equipment Corporation, 1Directional light sources, 13Directional lights, 236–237, 241DirectionalLight function, 243Directives, overriding earlier, 92DirectX 9, 549
.fx Effect format, 553Software Development Kit, 544
DirectX Effects Framework, 551disable behavior, 92–93discard keyword, 82, 106–108, 221, 300, 417Discontinuous jump at arbitrary point, 134Discontinuous stair-step pattern, 130, 132Disney, Walt, 411Disney Animation-The Illusion of Life (Thomas
and Johnston), 415Displacement shaders, 546Display, 5Display list mode, 11, 673Display lists, 11, 673Display memory, 5–6, 674Display of The Earth Taking Into Account
Atmosphere Scattering (Nishita, Shirai, Tadamura, and Nakamae), 525
DISSOLVE blend mode, 488Distance, 136Distance attenuation, 116distance function, 136–137distanceShape, 327Distant objects, 525Dithering, 17Divide operator (/), 85Doss, Joshua, 233, 272dot function, 136Dot product, 136Dot product function, 481
Dot product operation, 155, 360Double buffering, 6–7, 674Double-buffered windows, 7Double-precision floats, 53do-while statement, 82DragonRidges altgrad map, 523–524DragonRidges sky, 529–530Drawing
images, 18–21immediate mode, 11primitives, 9–11
Drawing geometryfragment processing, 16frame buffer operations, 17–18geometry specification, 9–12per-fragment operations, 16–17per-vertex operations, 12–14primitive assembly, 14primitive processing, 14–15rasterization, 15–16
drawPoints function, 422Driver model, 54–56Drivers, 54, 674Dynamic Ambient Occlusion and Indirect
Lighting, 338
EEarth texture, 259ecPosition variable, 153–154Edge detection, 498Edge flag attribute, 100Effect nodes, 223Effect workspace, 223–224Effects, technical illustration example, 463Effects group, 223–224Effects group nodes, 223–224#elif directive, 90#else directive, 90else substatement, 74Embedded structures, 72Embossing effects, 491Empirical BRDF models, 370enable behavior, 93#endif directive, 90Entry points, 167Enumerated types, 53Environment mapping, 265, 267–268, 674Environment mapping example, 268–271Environment maps, 268, 316–317, 360Environments, tying OpenGL into, 6
Rost.book Page 711 Wednesday, December 21, 2005 12:21 PM
712 Index
equal function, 89, 140Equal operator (==), 89Equality operators (== !=), 86Equality operators (==, and !=), 89, 94Equirectangular texture map, 268, 674Error handling, 94–95#error message directive, 90–91Error messages, 91Eta variable, 359Evaluators, 12Example shader pair, 65–67EXCLUSION blend mode, 492Executables, 36, 674
code storage, 170installing, 56
Execution model, 4–5exp function, 127exp (base e) function, 245exp2 function, 127, 481Explicit type conversions constructors, 77Exponential functions, 126–127Exponential operations, 52Expressions, 93–94, 145EXT prefix extensions, 3#extension directive, 92Extensions, 3–4, 92Extrapolation, 483–486Eye coordinate system, 23–24, 674Eye coordinates, 23
light positions, 234–235object position, 154
Eye space, 23–25, 235, 674EyeDir variable, 270EyePosition variable, 289
Ffaceforward function, 137false literal Boolean constant, 68fBm, 391Fernando, Randima, 323__FILE__ macro, 90Filter width, 444–445Filtering, 435, 493–495, 674Finding Nemo, 323, 544Fixed functionality, 9, 674
convolution operation, 493disabling, 176distance attenuation algorithm, 116enabling texture on texture unit, 254fragment processing, 39
graphics operations, 44–45lighting model, 311setting texture function for texture unit, 254vertex processors, 39
Fixed-function processing, 47Flat shading, 15, 674float data type, 52, 67–69, 101, 106, 192Floating-point matrix types, 51Floating-point numbers, 70Floating-point values, 50, 68, 113Floating-point vector, 69floor function, 128, 130, 132, 445–446Flow control
built-in functions, 84–85calling conventions, 83–84functions, 82–83
Flow-control constructs, 69fltransform function, 138Focus point, 23Fog, 16, 244–246, 675Fog effect, 245Fog factor, clamping, 246For coordinate value, 103for statement, 74, 82Formal function parameters, 78fract function, 128, 132, 159, 161, 438, 446, 510Fractal terrains, 508–509
noise functions, 510surface normals, 513
Fractals, 675Fractional Brownian motion, 391Fragment processing, 2, 16, 35–36, 675
fixed functionality, 39functions, 144–145
Fragment processor, 38–39, 42–47, 675fragment processing functions, 144programmable, 39special input variables, 106special output variables, 107–108uniform variables, 105–106varying variables, 104–105
Fragment shaders, 36, 44, 258, 675accessing current state, 42accessing texture, 255–256adaptive analytic antialiasing, 442adding together two images, 487animatable for cloudy sky effect, 413–414animation effects, 426antialiased brick, 446–447antialiased checkerboard, 448–449
Rost.book Page 712 Wednesday, December 21, 2005 12:21 PM
Index 713
attributes, 79bias parameter, 142BRDF PTM surface rendering, 382–383brick pattern, 157–164brightness, 484built-in constants, 113built-in varying variables, 97bump mapping, 306–308chromatic aberration effect, 363cloudy sky effect, 402color, depth, and arbitrary values, 46color value, 107common functions, 126, 128–134communicating results to processing stages,
97contrast, 485cube mapping example, 267–268defining values passed on to, 153discard keyword, 221, 300empty shader objects, 209environment mapping example, 269–271executing in parallel, 513exponential functions, 126–127fog factor, 246Fresnel reflection/refraction effect, 361–362general convolution computation, 497generating shadows, 343–346geometric functions, 136–138glyph bombing, 277–281Gooch shading, 466–467granite, 405image-based lighting, 318, 336–337infrequently changing values to, 46input variables, 97lighting computation, 153lighting operation, 301main function, 82Mandelbrot example, 472–474marble, 404matrix functions, 138–139maximum number of texture image units, 119mitigating aliasing effects, 437multiple values for fragments, 204multitexturing example, 263–265neighborhood averaging convolution, 496noise, 401–402noise functions, 145–146obtaining input data, 105OpenGL Shading Language, 546output, 107
output and debugging, 221–222perturbation calculation, 427perturbation factor, 427–428procedurally discarding part of object, 300procedurally generated wood, 406–408process texture values, 480processing fragments, 480random offsets, 279rapidly changing characteristics, 218reading
multiple values from texture, 46varying qualified shader, 80varying variables, 102
refracted vector, 358rendering with BRDF model, 374results from preceding processing, 97saturation, 485shader computation, 218shadow maps, 343–346sharpness, 486sky color texture map lookup, 530–531soft volume shadow algorithm, 350, 353special built-in fragment shader input
variables, 97special input variables, 104specialized functions, 52spherical harmonics lighting, 322state, 46, 97subset of varying variables, 43sun surface, 403supersampling, 436supporting parallelism argument-processing
level, 44technical illustration example, 466–467texture access functions, 141–144texture maps, 104texturing, 118–120, 259tile sets, 518–519time to generate texture map, 525toy ball, 294–299trigonometry functions, 124–126überlight model, 326–329uniform variables, 104unsharp masking, 499–500varying variables, 104, 163vector relational functions, 139–141vertex shader communications, 79–80visual feedback about, 221–222wobble effect, 429–430woodcut-style rendering, 461–462
Rost.book Page 713 Wednesday, December 21, 2005 12:21 PM
714 Index
Fragments, 15, 17, 35, 675color, 157–158color computing, 51color to attach to, 67creation of, 66depth computing, 51depth value, 107, 157–158discarding, 108facing direction, 106front facing, 106generated by rasterizing front-facing
primitive, 45generating, 20location within current brick, 160modeling coordinates, 159parallel processing, 39position within stripe pattern, 290preventing from updating frame buffer, 82RGB values, 250window coordinate position, 45
Frame buffers, 5–7, 8auxiliary buffers, 7buffers, 17–18characteristics for windows, 6drawing graphics into, 4initializing values, 18nonwindowed system, 6operations, 17–18preventing update, 221reading back values stored in, 4updating single location in, 35windowing system, 6
Framebuffer operations, 675Freq uniform variable, 428Freq variable, 427Frequency, 427, 675Frequency clamping, 447–449Fresnel approximation equation, 360Fresnel effect, 358, 675Fresnel equations, 358–359Fresnel reflection/refraction effect, 361–362FresnelPower, 360Freudenberg, Bert, 437, 454, 460–461Front buffer, 6–7Front-facing polygons, 15Front-facing primitive, 106Frustum, 40, 675Frustum clipping, 25, 676ftransform function, 118, 136, 157, 349, 416
Full OpenGL Pipeline shader, 233Full-screen antialiasing, 7Function tree, 519–521Functions, 82–83
accessing values in texture memory, 52actual value, 447aliasing variables within, 54average value, 447avoiding calls to expensive, 520built-in, 36, 52, 84–85, 123calling, 82calling by value-return, 36calling conventions, 83–84convolution, 443declaring, 52definition (body) or declaration must be in
scope, 82empty parameter list, 82–83encoding complex with textures, 220existing from, 83gradient, 441input parameters, 54lacunarity, 393never producing negative values, 130noise values for procedural texturing effects,
52output parameters, 54overloading, 36, 52, 82, 123query functions, 178–184recursively calling, 83returning no value, 74returning value or returning nothing, 84structures and arrays passed as arguments, 84void type, 84when to copy parameters, 83
Fuzz variable, 290Fuzzing transition region, 291fwidth function, 145, 441, 444–445.fx Effect format, 553
GGaussian filter, 496–497Gaussian reflectance model, 371General computation, 38General convolution shader, 496–497Generic attribute index, 189Generic vertex attribute array
defining, 657–659enabling or disabling, 188, 596–597
Rost.book Page 714 Wednesday, December 21, 2005 12:21 PM
Index 715
Generic vertex attributes, 41–42, 186associating index with named attribute
variables, 578–580explicitly binding to attribute variable,
188–189parameters, 194–195, 624–626querying state, 194–195value of, 651–656vertex array pointer for, 187
Geometric functions, 136–138Geometric image transforms, 480Geometric operations, 52Geometric primitives, 9, 676Geometry
drawing with vertex arrays, 99sending data to OpenGL, 9–12
Geometry specification, 9–12getUniLoc function, 210glAccum, 18GL_ACTIVE_ATTRIBUTED parameter, 180GL_ACTIVE_ATTRIBUTE_MAX_LENGTH
parameter, 180glActiveTexture, 27, 254GL_ACTIVE_UNIFORM_MAX_LENGTH
parameter, 180GL_ACTIVE_UNIFORMS parameter, 180GL_ADD symbolic constant, 249–250Glaeser, Georg, 532glAlphaFunc, 17Glanville, Steve, 272GL_ATTACHED_SHADERS parameter, 180glAttachObjectARB function, 660glAttachShader function, 55, 57, 167, 173–174,
576–577, 660GL_AUX0 symbolic constant, 351GL_AUXi symbolic constant, 205gl_BackColor constant, 105gl_BackColor variable, 103, 114–115, 117, 243GL_BACK_LEFT symbolic constant, 205, 349glBackMaterial.shininess value, 243GL_BACK_RIGHT symbolic constant, 205gl_BackSecondaryColor variable, 103, 105,
114–115, 117, 243glBegin function, 9–10, 14glBindAttribLocation function, 42, 57, 168,
188–189, 191, 303, 372, 578–580, 660glBindAttribLocationARB function, 660glBindBuffer command, 12glBindTexture, 28, 254
glBitmap, 18, 480GL_BLEND symbolic constant, 249–250, 351glBlendColor, 17glBlendEquation, 17glBlendFunc, 17, 351glBufferData command, 12glBufferSubData command, 12glCallList function, 11glCallLists function, 11glClear, 18glClearAccum, 18glClearColor, 18glClearDepth, 18glClearStencil, 18glClientActiveTexture, 30glClipPlane function, 15, 25, 116gl_ClipVertex variable, 43, 102, 116glColor function, 10, 13, 99gl_Color variable, 41, 100, 103–105, 184, 423glColorMask function, 18glColorPointer function, 11–12GL_COMBINED_TEXTURE_IMAGE_UNITS
constant, 204glCompileShader function, 55, 57, 167, 172,
209, 581–582, 660glCompileShaderARB function, 660GL_COMPILE_STATUS parameter, 178glCompressedTexImage1D/2D/3D, 28glCompressedTexSubImage1D/2D/3D, 28glCopyPixels, 19–20glCopyTexImage, 19–20glCopyTexImage1D/2D, 28glCopyTexImage2D, 351glCopyTexSubImage, 19–20glCopyTexSubImage1D/2D/3D, 28glCreateProgram function, 57, 167, 173,
583–584, 660glCreateProgramObjectARB function, 660glCreateShader function, 54, 57, 167, 171,
585–586, 660glCreateShaderObjectARB function, 660glCullFace, 15GL_CURRENT_COLOR symbolic constant, 8GL_CURRENT_PROGRAM symbolic constant,
183, 575Gl_CURRENT_PROGRAM symbolic constant,
661GL_CURRENT_VERTEX_ATTRIB parameter, 195GL_DECAL symbolic constant, 249–250
Rost.book Page 715 Wednesday, December 21, 2005 12:21 PM
716 Index
glDeleteObjectARB function, 660glDeleteProgram function, 57, 177, 587–588,
660glDeleteShader function, 58, 177, 589–590, 660GL_DELETE_STATUS parameter, 178–179GL_DEPTH_COMPONENT, 119, 256glDepthFunc, 17glDepthRange, 15, 26glDetachObjectARB function, 660glDetachShader function, 58, 177, 591–592, 660glDisable, 115 function, 235glDisable function, 8glDisableClientState function, 8glDisableVertexAttribArray function, 58, 188,
661glDisableVertexAttribArrayARB function, 661glDrawArrays function, 11, 99, 188glDrawBuffer, 18glDrawBuffers function, 18, 108, 205–206, 349,
593–595, 664glDrawBuffersARB function, 664glDrawElements function, 11glDrawPixels, 18–19, 28, 480, 487glDrawRangeElements function, 11glEnable function, 8, 15–16, 25, 115, 235, 254,
351glEnableClientState function, 8, 422glEnable/glDisable function, 13, 27glEnableVertexArrayPointer, 168glEnableVertexAttribArray function, 58, 188,
422, 596–597, 661glEnableVertexAttribArrayARB function, 661glEnd function, 10glEndList function, 11GL_EXP symbolic constant, 245GL_EXP2 symbolic constant, 245GL_EXTENSIONS symbolic constant, 3, 20GL_EYE_LINEAR symbolic constant, 246, 248glFinish, 18GL_FLOAT symbolic constant, 193GL_FLOAT_MAT2 symbolic constant, 193GL_FLOAT_MAT3 symbolic constant, 193GL_FLOAT_MAT4 symbolic constant, 193GL_FLOAT_VEC2 symbolic constant, 193GL_FLOAT_VEC3 symbolic constant, 193GL_FLOAT_VEC4 symbolic constant, 193glFlush, 18glFog, 16, 103gl_fog.color uniform variable, 51
GL_FOG_COORDINATE symbolic constant, 103, 105
gl_Fog.density variable, 245gl_Fog.end variable, 245gl_FogFragCoord variable, 103, 117, 245gl_Fog.start variable, 245gl_FragColor variable, 46, 51, 67, 78, 107–108,
160–163, 402gl_FragCoord variable, 45, 106–107gl_FragData array, 204gl_FragData variable, 46, 107–108gl_FragDepth variable, 46, 51, 107–108GL_FRAGMENT_DEPTH symbolic constant, 103,
105GL_FRAGMENT_SHADER, 171gl_FrontColor variable, 103, 105, 114–115, 117,
242, 314, 365–366glFrontFace, 16, 106gl_FrontFacing variable, 45, 106GL_FRONT_LEFT symbolic constant, 205gl_FrontLightModelProduct.sceneColor variable,
242glFrontMaterial.shininess value, 243GL_FRONT_RIGHT symbolic constant, 205gl_FrontSecondaryColor variable, 103, 105,
114–115, 117, 242glFrustum function, 25glGet function, 8, 13, 27, 98, 100–101, 103, 106,
113–114, 118, 183, 203, 661glGetActiveAttrib function, 58, 192–193,
598–600, 661glGetActiveAttribARB function, 661glGetActiveUniform function, 58, 201–203,
601–604, 661glGetActiveUniformARB function, 661glGetAttachedObjectsARB function, 661glGetAttachedShaders function, 58, 183,
605–606, 661glGetAttribLocation function, 58, 168, 189–190,
607–608, 661glGetAttribLocationARB function, 661glGetclipPlane function, 8glGetError function, 8glGetHandleARB function, 661glGetInfoLogARB function, 661glGetLight function, 8glGetMaterial function, 8glGetObjectParameterARB function, 663glGetObjectParameterfvARB function, 663
Rost.book Page 716 Wednesday, December 21, 2005 12:21 PM
Index 717
glGetProgram function, 58, 177, 193, 609–611, 663
glGetProgramInfoLog function, 58, 175, 612–613, 661
glGetProgramiv function, 179–180glGetShader function, 58, 172, 177, 209,
614–615, 663glGetShaderInfoLog function, 58, 172, 181–182,
616–617, 661glGetShaderiv function, 178–179glGetShaderSource function, 58, 180–181,
618–619, 663glGetShaderSourceARB function, 663glGetString function, 3, 20, 168–169glGetUniform function, 58, 197, 199, 620–621,
663glGetUniformARB function, 663glGetUniformfv function, 199–200glGetUniformiv function, 199–200glGetUniformLocation function, 42, 58, 168,
196–197, 199–200, 622–623, 663glGetUniformLocationARB function, 663glGetVertexAttrib function, 58, 624–626, 663glGetVertexAttribARB function, 663glGetVertexAttribdv function, 194glGetVertexAttribfv function, 194glGetVertexAttribiv function, 194glGetVertexAttribPointer function, 58, 627–628,
663glGetVertexAttribPointerARB function, 663glGetVertexAttribPointerv function, 195GL_INFO_LOG_LENGTH parameter, 179–180glInterleavedArrays function, 11GL_LEQUAL, 464GL_LESS, 464glLight function, 13, 24GL_LIGHTING symbolic constant, 13glLightModel function, 13–14gl_LightSource[i] uniform variable, 51GL_LINEAR symbolic constant, 244, 482GL_LINE_SMOOTH symbolic constant, 16glLineStipple, 16glLineWidth, 16GL_LINE_WIDTH symbolic constant, 8glLinkProgram function, 55, 58, 167, 189, 210,
422, 632–635, 663glLinkProgramARB function, 663GL_LINK_STATUS parameter, 179glLoadIdentity, 23glLoadMatrix function, 13, 23
glLogicOp, 17gllsProgram function, 58, 184, 629–630, 664gllsShader function, 58, 184, 631, 664glMapBuffer function, 12glMaterial, 13glMatrixMode function, 13, 25, 31GL_MAX_COMBINED_TEXTURE_IMAGE_
UNITS symbolic constant, 119, 207, 574GL_MAX_DRAW_BUFFERS symbolic constant,
108, 207, 574GL_MAX_FRAGMENT_UNIFORM_
COMPONENTS symbolic constant, 106, 207, 574
gl_MaxLights, 114GL_MAX_LIGHTS symbolic constant, 13GL_MAX_TEXTURE_COORDS symbolic
constant, 103, 119, 207, 574GL_MAX_TEXTURE_IMAGE_UNITS symbolic
constant, 119, 203–204, 207, 574GL_MAX_TEXTURE_UNITS symbolic constant,
118–119GL_MAX_VARYING_FLOATS symbolic constant,
103, 207, 574GL_MAX_VERTEX_ATTRIBS symbolic constant,
100, 207, 574GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS
symbolic constant, 119, 203–204, 207, 574GL_MAX_VERTEX_UNIFORM_COMPONENTS
symbolic constant, 101, 207, 575gl_ModelViewMatrix variable, 51, 100, 152–153gl_ModelViewProjectionMatrix variable, 152GL_MODULATE symbolic constant, 249glMultiDrawArrays function, 11glMultiDrawElements function, 11glMultiTexCoord function, 30gl_MultiTexCoord0 variable, 100, 184gl_MultiTexCoord1 variable, 100, 184gl_MultiTexCoord2 variable, 100, 184glMultMatrix function, 13GL_NEAREST, 482glNewList function, 11GL_NONE symbolic constant, 205glNormal function, 10, 41, 99gl_Normal variable, 41, 79, 100, 152, 154, 184,
372, 416GL_NORMALIZE symbolic constant, 235GL_NORMAL_MAP symbolic constant, 247gl_NormalMatrix variable, 152, 154glNormalPointer function, 11–12gl_NormalScale variable, 235
Rost.book Page 717 Wednesday, December 21, 2005 12:21 PM
718 Index
Global lighting parameters, 14Global variables and initializers, 82GL_OBJECT_LINEAR symbolic constant, 246,
248GL_ONE, 348, 351GL_ONE_MINUS_DEST_ALPHA, GL_DST_
ALPHA blend mode, 537glOrtho function, 25Gloss maps, 260, 262, 676Gloss texture, 260glPixelMap function, 19glPixelStore, 19, 21glPixelTransfer, 19glPixelZoom, 20glPointParameter, 16glPointSize function, 16, 115–116gl_PointSize variable, 43, 101, 115GL_POINT_SMOOTH symbolic constant, 16glPolygonMode, 16glPolygonOffset function, 16, 339GL_POLYGON_SMOOTH symbolic constant, 16glPolygonStipple, 16glPopAttrib function, 8glPopClientAttrib function, 8glPopMatrix, 24gl_Position variable, 43, 51, 67, 78, 101, 117,
138, 153, 163, 365–366, 400, 424, 455glPushAttrib function, 8glPushClientAttrib function, 8glPushMatrix, 24glRasterPos function, 20, 117glReadBuffer function, 20, 351glReadPixels, 19–20GL_REFLECTION_MAP symbolic constant, 247GL_REPLACE symbolic constant, 249glRotate function, 13, 24glScale function, 13, 24glSeconaryColor function, 13glSecondaryColor function, 16gl_SecondaryColor variable, 100, 103–105, 184glShadeModel function, 15glShaderSource function, 54, 58, 167, 171, 209,
636–637, 663glShaderSourceARB function, 663GL_SHADER_SOURCE_LENGTH parameter, 179GL_SHADER_TYPE parameter, 171, 178GL_SHADING_LANGUAGE_VERSION symbolic
constant, 169, 575GLSL. See OpenGL Shading Language
GLSL demo, 396GLSL validate, 226GLSLdemo file, 257GLSLParserTest, 226GL_SPHERE_MAP symbolic constant, 247GL_SRC_ALPHA, 348, 351glStencilFunc, 17glStencilMask function, 18glStencilOp, 17gl_TexCoord[] array, 103, 105, 117glTexCoord function, 10, 30, 99gl_TexCoord[0] variable, 258glTexCoordPointer, 30glTexEnv function, 27, 30–31, 254glTexGen function, 27, 30glTexImage function, 18–20, 27, 254glTexImage1D function, 28glTexImage2D function, 28, 257glTexImage3D function, 28, 398glTexParameter function, 27, 29, 254, 256–257glTexSubImage function, 18–20glTexSubImage1D/2D/3D functions, 28GL_TEXTURE_1D, 119GL_TEXTURE_2D, 119GL_TEXTURE_3D, 119GL_TEXTURE_CUBE_MAP, 119gl_TextureMatrix variable, 235gl_TextureMatrix[1] variable, 342glTranslate function, 13, 24gluLookAt function, 24glUniform function, 42, 59, 168, 197, 199–200,
638–644, 663glUniform function, 197glUniformv function, 198glUniform1i data type, 198, 203glUniform1iv data type, 198, 203glUniformARB function, 663glUniformMatrixfv function, 198glUnmapBuffer function, 12gluPerspective function, 25glUseProgram function, 56, 59, 167, 176, 184,
210, 645–648, 664glUseProgramObjectARB function, 664glValidateProgram function, 59, 206, 649–650,
664glValidateProgramARB function, 664GL_VALIDATE_STATUS symbolic constant, 180GL_VERSION symbolic constant, 169glVertex function, 10, 41, 100, 184, 186
Rost.book Page 718 Wednesday, December 21, 2005 12:21 PM
Index 719
gl_Vertex variable, 41, 79, 100, 138, 152–153, 156, 184, 192, 372, 381, 416, 423
glVertex2 function, 187glVertex3 function, 187glVertex4 function, 187glVertexAttrib function, 42, 59, 100, 168,
185–187, 190, 372, 651–656, 664glVertexAttrib4 function, 185–186glVertexAttrib4N function, 186glVertexAttrib4Nub function, 186glVertexAttribARB function, 664GL_VERTEX_ATTRIB_ARRAY_ENABLED
parameter, 194GL_VERTEX_ATTRIB_ARRAY_NORMALIZED
parameter, 195GL_VERTEX_ATTRIB_ARRAY_SIZE parameter,
194GL_VERTEX_ATTRIB_ARRAY_STRIDE parameter,
194GL_VERTEX_ATTRIB_ARRAY_TYPE parameter,
195glVertexAttribPointer function, 59, 168, 187,
657–659, 664glVertexAttribPointerARB function, 664glVertexPointer function, 11–12GL_VERTEX_PROGRAM_POINT_SIZE symbolic
constant, 115GL_VERTEX_PROGRAM_TWO_SIDE symbolic
constant, 115GL_VERTEX_SHADER, 171glViewport, 15, 26glWindowPos, 20GLX routines, 6Glyph bombing, 676
application setup, 272–276diffuse factor, 276fragment shader, 277–281looping, 275, 277–278random number texture, 278scaled texture coordinates, 277vertex shader, 276–277
Glyphscorresponding rotation matrix, 278–279placing randomly, 272probability of drawing in cell, 274–275random angle of rotation, 274, 278random color, 272random offsets, 273–274scaling size, 274smoothly antialiased edge, 279
Gooch, Amy, 463Gooch, Bruce, 463Gooch shader, 466Gooch shading, 676
automatically generating important edges, 463–464
black curves representing important edges, 463
color ramp, 465computing colors, 465diffuse reflection factor, 465drawing silhouette edges for simple objects,
464edges rendered as antialiased black lines, 463fragment shader, 466–467luminance values, 465luminance values conveying information
about curvature, 464–465shading of object, 465specular highlights, 464warm-to-cool color gradient, 465
Gooch vertex shader, 466goto keyword, 82Gourad shading, 676GPU Gems (Glanville), 272, 323, 343, 364GPU Gems 2, 338Gradient noise, 393, 676Gradient vectors, 440–441, 676Gradients, 441, 457, 676GrainScale variable, 408Grammar
OpenGL Shading Language in terms of tokens, 559–571
output of lexical analysis tokens, 559Gram-Schmidt orthonormalization, 381Granite, 404–405Granite fragment shader, 405Graphics accelerators, 5, 676Graphics contexts, 6, 8, 676Graphics hardware
based on programmable processor technology, 49
capabilities, 2double buffering, 6–7exposing programmability, 48parallel processing, 49prorammability, 4RenderMan, 546single-precision floating-point calculations,
520
Rost.book Page 719 Wednesday, December 21, 2005 12:21 PM
720 Index
Graphics primitives, 18, 25Graphics processing pipeline, 8–9, 676Grayscale display, 5Grayscale pixel rectangles, 18greaterThan function, 140greaterThanEqual function, 140Gritz, Larry, 323, 448Gruschel, Jens, 487
HHaeberli, Paul, 483Hanrahan, Pat, 318–319HARD LIGHT blend mode, 491Hardware
exposing functionality, 123exposing new functionality, 3graphics accelerators, 5optimal performance on wider range, 60vector-processing capabilities, 69
Hardware independence, 2hardware independence, 48Hash-based operators (#, ##, etc.), 94Hatching example
adding character, 459–460antialiasing, 454application setup, 455density too high, 457generating hatching strokes, 456hatching fragment shader, 461–462imperfections, 459–460noise added to stripe pattern, 460simulating lighting, 458–459softening edge, 458uniform line sensity, 456–458vertex shader, 455–456
Hatching fragment shader, 461–462Hatching shader, 454–455HDR (high dynamic range) images, 316,
320–321HDRShop, 316–317HDTV standard, 483Hemisphere lighting, 311–313, 676
ambient occlusion, 335–336ground color, 314sky color, 314vertex shader, 314–315
Heterofractals, 508–509Hidden-surface removal, 7HIL (high-level intermediate language), 225
HLSL (High-Level Shader Language), 55, 223, 544, 549–552
HLSL pixel shader, 551HLSL shaders, problems with, 551HLSL vertex shaders, 550Homogeneous vertex position, 157
IIBM, 1–2IDE (integrated development environment), 223Identity matrix, 23#if directive, 90if statement, 74, 82#ifdef directive, 90if-else statement, 82#ifndef directive, 90Ill-formed programs, 94–95Image processing, 38An Image Synthesizer (Perlin), 148Image-based lighting, 315–318, 336–337, 677Imager shaders, 546Images
averaging, 488back-end processing, 20blend modes, 486–500brightening base color, 490brightness, 484combining blend image with base image,
491contrast, 485darkening, 489–490difference between blend and base image,
492drawing, 18–21edge detection, 498extrapolation, 483–486filtering, 493–495hard light, 491interpolation, 483–486lightening, 489luminance, 490–491multiplying inverse, 490multiplying values, 489muting, 491opacity, 492–493pixel transfer, 19–20pixel unpacking, 19randomness, 488raster position, 20
Rost.book Page 720 Wednesday, December 21, 2005 12:21 PM
Index 721
rasterization, 20read control, 20–21saturation, 485sharpening, 499–500sharpness, 486smoothing, 495–497soft contrast, 492–493soft light, 491subtracting blend image from base image,
492for texture memory, 18vanishing point, 25zoom factor, 20
Imaging, 479color space conversions, 482–483geometric image transforms, 480lookup table operations, 481–482mathematical mappings, 481multiple pixel access, 480operations, 479scale-and-bias, 481single pixel access, 480
Imaging subset, 19–20, 677Immediate mode, 11, 677Implementation-dependent
API values, 574–575constants, 113–114values, 113, 207
Improving Noise (Perlin), 148in qualifier, 54, 83Incident vector, 154#include directives, 53Increment operator (++), 88Index of refraction, 358, 677Index ([]) operator, 85Indexing, 86Industrial Light & Magic, 338Information log, 172–173, 175
error messages, 91length of, 182program objects, 182, 210, 612–613reviewing, 220shader objects, 181, 616–617shaders, 209
init2Dtexture function, 262Initializers, 75–77
brace syntax “/,” 75const qualified variables, 80constructors, 52
global variables, 82inorout counter, 295inout qualifier, 54, 83Input function box filter, 443–444int data type, 67–69Integer, 128Integers, 132
precision, 68vector types, 50
Integrating the OpenGL Shading Language (Lichtenbelt), 120–121
Intel, 1–2Interactive Rendering withArbitrary BRDFs Using
Separable Approximations (Kautz and McCool), 381
Interior region, 512Interpolated varying variables, 45Interpolation, 483–486INVERSE DIFFERENCE blend mode, 492inversesqrt function, 127Iris GL (Graphics Library), 1–2ISL (Interactive Shading Language), 547–549ISL shaders, 547–549Isotropic, 677ITU-R Recommendation BT.709 (HDTV color
standard), 481, 483ivec2 data type, 69ivec3 data type, 69ivec4 data type, 69
JJohnston, Scott, 454Julia sets, 474–475Jurassic Park, 544Jurassic Park III, 338
KKd variable, 289Kessenich, John, 149, 268, 304, 396Key-frame interpolation, 414–416, 677Koren, Steve, 149, 468
LLabels, 82Lacunarity, 393, 677lambda2rgb function, 365–366Lander, Jeff, 464Lander technique, 466
Rost.book Page 721 Wednesday, December 21, 2005 12:21 PM
722 Index
Landis, Hayden, 338Laplacian operator, 498Latitude-longitude texture map, 677Lat-long environment map, 316Lat-long texture map, 268Lattice, 299–300Lawrence Berkeley Laboratory, 370LCcamera variable, 325LCnorm variable, 325LCpos variable, 325length function, 136–137, 237, 457lessThan function, 139lessThanEqual function, 89, 140Level-of-detail, 142, 677
argument, 28bias, 256clamping and biasing value, 29
Lexical analysis, 225, 677Licea-Kane, Bill, 292Lichtenbelt, Barthold, 208, 257Light
attenuation factor, 326–327behavior of visible, 364diffraction, 363–368intensity interpolated value, 158reflection, 155, 327refraction, 358–363separating based on wavelength, 364shape and placement, 323soft edge, 324surface-local, 306transforming, 302wavelengths, 364
Light coordinate system, 326Light direction vector, 154–155Light factor texture, 378–379Light positions
eye coordinates, 234–235texture unit, 258transforming by modelview matrix, 234–235wobbles, 427
Light probe, 315, 678Light probe gallery, 319Light probe images, 315–316, 318–319, 322, 678Light shaders, 543, 546, 549Light sources, 301
accessing properties, 101ambient, diffuse, and specular contributions,
241
area lights, 312attenuation, 237–238computation performed with dot products,
301directional lights, 13, 236–237invisible surfaces, 339looping to compute contributions from all
enabled, 241manipulating attributes, 13point lights, 13, 237–239position, 152reflection direction, 153–154shadow maps, 340shadows from, 339spotlights, 239–240strong, 338technical illustration example, 463traditional illumination model, 312transforming positions, 24viewing direction, 153–154visible surfaces, 339
LightColor variable, 289LIGHTEN blend mode, 489Lighting
artifacts, 302clouds, 537–539computed before texturing, 249–250global parameters, 14hemisphere, 311–314image-based, 315–318material properties and, 240–242none enabled, 244primary and secondary color for vertex, 13RealWorldz, 524simulating in hatching example, 458–459with spherical harmonics, 318–322traditional equation, 462two-sided, 243viewing direction, 240–241
Lighting calculations, 14, 24, 152, 190, 236artifacts, 304eye space, 24, 235
Lighting designers, 323Lighting effects, 13, 38, 153, 316Lighting state, 152LightIntensity variable, 153, 156, 401–402, 427LightPos variable, 400LightPosition variable, 154, 289, 303lightVec variable, 154, 155
Rost.book Page 722 Wednesday, December 21, 2005 12:21 PM
Index 723
LightWork Design, 287Limestone textures, 523#line directive, 90–91__LINE__ macro, 90Line rasterization, 479Linear filtering, 257Linear-algebraic matrix multiplication, 138–139Lines, uniform density, 456–458Linking
program objects, 632–635shaders, 173–176
Literal floating-point numbers, 68Literal integers, 68Local variables, defining, 159Local viewer computation, 241Locations, 196“Lod” functions, 142log function, 127log2 function, 127, 481Logical and operator (&&), 82, 86, 89Logical exclusive or operator (^^), 82, 86Logical inclusive or operator (||), 82, 86, 89Logical not operator (-!), 85, 89Logical operations, 17Logical operators, 69, 94Lookat point, 23lookup function, 343Lookup table operations, 481–482Looping, 82The Lord of the Rings: The Two Towers, 544Low-pass filtering, 439, 678Lucasfilm, 418Luminance, 490–491Luminance mapping function, 481Luminance (LRGB) PTMs (polynomial texture
maps), 376, 378Luxo Jr., 292L-values, 87, 677
MMacintosh environment, 2, 6Macros, 90Magi, 387Magnification filter, 29main function, 50, 65, 82, 159, 344Making Noises (Peachey), 389Malan, Hugh, 346Mandelbrot, Benoit, 469Mandelbrot example, 467
color selection algorithm, 474fragment shader, 472–474Julia sets, 474–475Mandelbrot set, 468–471maximum number of iterations, 472points inside and outside set, 472values outside set, 472vertex shader, 471–472
Mandelbrot set, 468–471, 474Mapping coordinates, 26Marble fragment shader, 404Masking complex operations, 7mat2 data type, 51, 70, 186, 189, 192mat3 data type, 51, 70, 186, 189, 192mat4 data type, 51, 70, 186, 189, 192Materials
index of refraction, 358lighting, 240–242measured reflectance data, 370–372non-photorealistic, 38properties, 13, 240–242realistic, 38reflectivity, 358–359specular highlights, 369
Mathematical mappings, 481Matrices
accessing as array of column vectors, 70columns as vectors, 86component-wise multiplication, 138–139constructors, 76data types, 70floating-point numbers, 70indexing, 86linear-algebraic multiplication, 138–139manipulating, 23natively supporting operations, 36organized in column major order, 70reading out of arguments, 77selecting, 23selecting columns, 51
Matrix functions, 138–139Matrix multiplication operation, 153matrixCompMult function, 138–139Matte objects in technical illustration example,
463Matters of Light & Depth (Lowell), 323max function, 129, 133–134, 155McMaster-Carr Supply Company, 316MCposition variable, 153, 156, 158, 400–401
Rost.book Page 723 Wednesday, December 21, 2005 12:21 PM
724 Index
Member selection (.), 85Meran planet, 524Meran world, 516Microsoft, 1, 544, 549min function, 129, 133–134Minification filter, 29Mini-Mandelbrots, 471Mipmap level, 29, 678Mipmap textures, 28–29, 142, 398, 435, 678Mipmaps
automatic generation, 253automatically computing levels, 30
mix function, 130, 162, 279, 408, 435, 458, 491MixRatio variable, 268mod function, 128, 132, 438Model space, 22, 678Model transformation matrix, 23, 678Modeling, 21–22, 678Modeling coordinate system, 22, 678Modeling coordinates, 22, 159, 326Modeling matrix, 23Modeling transformation, 23–24, 678Modelview matrix, 152–153, 678
accessing current, 100setting to viewing transformation, 23–24transforming light positions, 234–235transforming light source positions, 24
Modelview-projection matrix, 15, 152, 157, 678MODIS (Moderate Resolution Imaging
Spectroradiometer), 257Modular shaders, 217–218Modulus, 128MojoWorld, 393, 508–510Monofractals, 508–509Monsters, Inc., 323, 544Morphing, 414–417Mountainfractals, 508–509Moving objects, 7Mulititextures, 2Multifractals, 393, 508–509, 519–520, 678Multi-Pass Programmable Shading (Peercy, Airey,
and Ungar), 546Multipass rendering position invariance,
117–118Multiple render targets, 204–206Multiple vertex arrays, 2Multiplication operator (*), 85, 88, 138–139, 153Multiplicative operators, 94MULTIPLY blend mode, 489
Multisample buffer, 7, 679Multitexturing, 30, 119Multitexturing example
application setup, 262cloud texture, 260–261cloud/gloss texture, 263daytime texture, 260, 263–264fragment shader, 263–265nighttime texture, 260, 263–264reflection of sunlight off water, 260vertex shader, 262–263
Musgrave, Ken, 389Mushroom transformation, 514–515MyData variable, 191–192
NName spaces and structures, 72Named attribute variables, 578–580NASA Web site, 257NASA/Goddard Space Flight Center, 257Natural exponentiation of x, 127Natural logarithm of x, 127Natural phenomena, 38Negative Laplacian operator, 499Neighborhood averaging, 495–496, 679Newell, Martin, 21Nighttime texture, 260, 263–264Nodes and child nodes, 227Noise, 387–388, 679
aliasing artifacts, 393animation, 417–418application setup, 400defining, 388–394fragment shader, 401–402granite, 404–405higher dimensions, 395marble, 404number of octaves and multifractals, 520OpenGL shaders, 395random, 488RealWorldz values and derivatives, 517–518stripe pattern, 460sun surface shader, 403trade-offs, 399–400turbulence, 402–404two-dimensional, 394–395vertex shader, 400wood, 405–408
noise function, 395, 399–400
Rost.book Page 724 Wednesday, December 21, 2005 12:21 PM
Index 725
Noise functions, 145–146, 508behaving differently at different locations,
393characteristics, 146cubic interpolation method, 390definition of, 543faded to average value which aliasing
artifacts occur, 393folding, 402fractal terrains, 510ideal, 389linear interpolation, 390MojoWorld, 510randomness, 389range of, 517sampling, 512texture maps, 396, 399time aspect, 395user-defined, 399–400valid result, 398varying frequency and amplitude, 390
Noise textures, 396–398, 510, 517bilinearly filtered texture read, 521creation of, 510–511tiling pattern, 511–512
noise1 function, 146noise2 function, 146noise3 function, 146, 396–397, 417–418noise4 function, 146NoiseFunctionDerivative, 513NoiseScale, 407Non-mipmapped textures values, 142Non-photorealistic materials, 38Non-power-of-2 textures, 3Nonqualified globals, 81Nonqualified user-defined variables, 81Nonscalar constants, 80Nonwindowed system frame buffers, 6NORMAL blend mode, 488Normal maps, 308–309, 679Normal transformation matrix, 154, 235Normal variable, 270Normal vectors, 11Normalization, 235, 307normalize function, 113, 136–137, 154, 294Normalized device coordinate space, 26, 679Normals
hatching shader, 455inconsistently defined, 304
transformed by current normal matrix, 113transforming, 154transforming into eye coordinates, 152
Not equal operator (!=), 89not function, 89, 141notEqual function, 89, 141NPR (non-photorealistic rendering), 453, 679NPR effects, 454NumEnabledLights constant, 241NVIDIA, 2, 552NVIDIA developer Web site, 32, 231
OObject coordinate system, 679Object coordinates, 22Object space, 22, 116, 679Objects
applying opaque image to portion of, 250brick pattern, 149–164default color, 273deleting, 177distant, 525dynamic, 419dynamic contour lines, 246–247interreflections between, 311–312mirrorlike qualities, 265modeling, 21–22nondeterministic shape and appearance,
419origin, 22polygonal representation of, 21primitive particles defining volume, 419random color, 273three-dimensional attributes, 22transforming into world coordinates, 22–23unique identifier, 170
Occlusion factors, computing, 334–335Occlusion queries, 2Ocean
RealWorldz, 532–537reflected sky, 536reflections, 532–536rendering, 536–537underwater caustics, 536water ripples, 537
Octave, 390, 679Offscreen buffers
depth buffering, 346values written to, 108
Rost.book Page 725 Wednesday, December 21, 2005 12:21 PM
726 Index
Offscreen memory, 5–6, 679Offset texture, 519ogl2brick file, 208ogl2demo file, 208, 257Old Town Square light probe image, 319One-dimensional texture maps, 26On/off animation, 412On/off state, 412OPACITY blend mode, 492–493Opacity variable, 190–192Open GL API (application programming
interface), 1OpenGL
assembly language programming, 47backward compatibility, 3current versions, 2evolution, 3–4extensions, 3–4, 47fixed functionality, 9, 40, 233fixed-function pipeline, 2frame buffer, 5–7history of, 1–3interaction fixed functionality, 114–120maintaining state, 6modifying, 3normalization, 235obtaining version information, 168–170opening processing pipeline for user
control, 2operating environments, 2processing commands, 4processing pipeline, 37, 39rasterization stage, 479sending geometry data to, 9setting up for rendering into multiple target
buffers, 205–206OpenGL 1.5 to OpenGL 2.0 GLSL Migration
Guide, 660–663OpenGl 2.0 Shading Language White Paper, Version
1.0 (Baldwin), 165, 233OpenGL API execution model, 4–5OpenGL ARB (Architecture Review Board), 1–2,
32OpenGL driver, 54–55OpenGL extension registry Web site, 3The OpenGL Graphics System: A Specification
(Version 2.0) (Segal and Akeley), 32, 33, 63, 96, 121, 148, 165, 213
OpenGL Performer, 229
OpenGL Performer Web site, 231OpenGL Programming Guide, Fifth Edition: The
Official Guide to Learning OpenGL (Shreiner, Neider, Davis, and Woo), 32, 213
OpenGL Reference Manual, Fourth Edition: The Official Reference to OpenGL, 32, 213
OpenGL Shader Language, 679OpenGL Shader Language API, 679OpenGL shaders, 36, 544, 547–549, 679
code to transfer CIE values to RGB, 483code to transform RGB values to CIE, 483cube map, 265noise, 395
OpenGL Shading Language, 544added features, 50–52additions from C++, 52basics, 35–37built-in
functions, 48math functions, 547variables, 546
C programming language, 50, 53compiler front end, 225–226compiler/linker, 54–57cross-vendor assembly language, 60data types, 546defining capabilities for hardware, 549as descendent of RenderMan, 547design considerations, 47–50ease of use, 49exposing hardware capabilities, 48exposing performance of graphics hardware,
49exposing programmability of hardware, 549fragment shaders, 546hardware independence, 48as high-level language, 60–61key benefits, 59–61keywords, 547libraries or executables, 61longevity, 49mapping onto graphics hardware, 546modular programming support, 61obtaining version information, 168–170open, cross-platform standard, 60OpenGL environment, 48overview, 47–54parallel processing, 49precedence of operators, 547
Rost.book Page 726 Wednesday, December 21, 2005 12:21 PM
Index 727
processing numerical data, 53RenderMonkey, 223runtime compilation, 59standardization, 49syntax, 65tight integration with OpenGL, 59transformations, 234–235type qualifiers, 36types, 36unnecessary language features, 49variable nodes, 224vector types, 50–51version 110, 92version number, 90vertex shaders, 546
The OpenGL Shading Language, Version 1.10 (Kessenich, Baldwin, and Rost), 63, 95, 96, 121, 147, 165, 213
OpenGL Shading Language API, 57–59, 167implementation-dependent values, 207
OpenGL stateaccessing current, 42, 109–112automatic tracking mechanism, 101client-side, 8controlling with scene graphs, 227–228derived, 112fragment shaders, 97maintaining, 6manipulating, 108modifying, 196on or off, 8pushing and popping values on stack, 8server-side, 8settings, 8texture units, 27tracking, 196user-defined, 67vertex shaders, 97
OpenGL SuperBible, Third Edition (Wright and Lipchak), 32–33
OpenGL utility library, 24OpenGL.org Web site, 32OpenSceneGraph Web site, 231OpenSG, 229OpenSG Web site, 231Operating environments, 2Operations
accelerating, 123component-wise, 87–90
indexing, 86operators, 85–86swizzling, 87
Operators, 85–86applied to vector, 87–88vector types, 50
Optimizations, 91Optimize pragma, 91Optional set of imaging functionality, 2Origin, 22Orlano, Marc, 544Orthonormal basis, 303OSG (OpenSceneGraph), 229out qualifier, 54, 83Overhanging terrain, 513–517OVERLAY blend mode, 490–491Overloading
built-in functions, 52functions, 36, 52, 82, 123
Overridingbuilt-in functions, 84–85earlier directives, 92
PParallel projection, 25Parameters, 83, 440Parsing, 225, 679Particle systems, 418–426, 680
application setup, 420–423assumptions, 419complexity, 419confetti cannon vertex shader, 423–424
Particle Systems—A Technique for Modeling a Class of Fuzzy Objects, 419
Particles, 419–425ParticleTime variable, 423Pass nodes, 224PCs, 2Peachey, Darwyn, 149, 272, 444Pearl Harbor, 338Pellacini, Fabio, 323, 343Percentage variable, 274Per-fragment operations, 16–17, 680Perlin, Ken, 145, 387–388, 543Perlin heterofractal, 509Perlin noise, 393, 460, 508, 510–512, 680Perspective divide, 26, 40Perspective projections, 15, 25Perspective view, 15
Rost.book Page 727 Wednesday, December 21, 2005 12:21 PM
728 Index
Perspective-correct projective texture coordinates, 341–342
Perturbation normal, 307Perturbation vector, 307Per-vertex arbitrary data, 10Per-vertex attributes, 185per-vertex attributes, 10Per-vertex lighting, 154Per-vertex operations, 12–14Per-vertex values, interpolating, 67Phong exponent, 317Phong lighting equation, 524Phong lighting model, 464Photorealism, 453, 680Pixar Animation Studios, 322, 543Pixel group, 19, 680Pixel ownership test, 17, 680Pixel packing, 21, 680Pixel Pipeline shader, 233Pixel rectangles, 680
color, 18grayscale, 18pixel transfer, 19–20rasterization, 479read control, 20–21
Pixel shaders and HLSL (High-Level Shader Language), 551
Pixel transfer, 19–20, 680Pixel unpacking, 19, 21, 680Pixel zoom, 480PixelFlow, 543–544Pixels, 5, 433–434
visible or obscured, 17window coordinate system, 26
Planetsfractal terrains, 508–510overhanging terrain, 513–517shading, 507–508surface normals, 513terrain-rendering structure, 506–507
Point light sources, 13Point lights, 237–239
attenuation, 237–238computation, 238–239direction of maximum highlights, 237spotlight cutoff angle, 241
Point primitive, 101Point R, 532Point rasterization, 2, 479
Point sampling, 434, 680Point size, clipping, 115Point size mode, 115–116Point sprites, 3, 16, 425, 681Pointers, 53, 627–628PointLight function, 243Polygon mode, 40Polygon offset, 40Polygon primitives, culling, 15Polygon rasterization, 479Polygons, 16, 21Polynomial texture mapping with BRDF data,
375–384Position invariance, 117–118Position values, accessing, 50position variable, 159, 471Position vector, 69position.x variable, 445Positive square root, 127Postfix decrement operator (--), 85Postfix increment operator (++), 85pow function, 127, 481#pragma directive, 90–91Pragmas, reserving for future use, 91Prefix decrement operator (--), 85Prefix increment operator (++), 85Preprocessor, 90–94Primary color, 242Primitives, 681
antialiasing, 16assembly, 14, 40, 66, 681clipping, 14–15drawing large number with single function
call, 11processing, 14–15specifying type, 14starting and ending, 10
printShaderInfoLog function, 209Procedural texture shaders, 285–287, 681Procedural textures, 38Procedural texturing, 285, 681Processing pipeline, 8–9Program objects, 55–56, 681
active attribute variable information, 598–600
active uniform variable information, 601–604
attaching shader objects, 55, 173, 209–210, 576–577
Rost.book Page 728 Wednesday, December 21, 2005 12:21 PM
Index 729
creation of, 583–584defining, 173deleting, 177, 587–588detaching shader objects, 177, 591–592failure of linking, 175handles of shader objects attached, 605–606information log, 175, 182, 210, 612–613installing as part of rendering state, 645–648linking, 174, 632–635listing active uniform variables, 201–203loading uniform variables into, 197–198names, 184, 629–630parameters, 609–611queriable parameters, 179–180querying list of shader objects attached to,
183querying state, 179–180state, 197validating, 649–650value of uniform variable for, 638–644
Programmable fragment processors, 39Programmable processors
fragment processors, 38–39, 43–47stream processing, 39successfully installing executable, 176vertex processors, 38–39, 40–43
Programmable shaders, 233Programmable vertex processors, 39Programs, 36, 681
diagnostic information, 206–207ill-formed, 94–95installing as part of rendering state, 176managing shader objects, 176
Projection matrix, 25, 681Projection transformation, 25, 681Projective texturing, 142PTMs (polynomial texture maps), 375–378, 681Pulse train, 444, 681
QQualified variables, 67Qualifiers, 51, 78
absent qualifier, 81attribute qualifiers, 79constant qualifiers, 80–81type, 78uniform qualifiers, 79varying qualifiers, 79–80
Queriable values, 575
Query functions, 178–184Querying
attribute binding for vertex shader attribute variable, 189–190
locations of user-defined uniform variables, 196–197
shader objects, 183user-defined variable current value, 199–200
Rrad variable, 427–428Radians, 125radians function, 125Ramamoorthi, Ravi, 318–319RandomRotate variable, 274RandomScale variable, 274Raster position, 20, 117, 682Rasterization, 15–16, 20, 682Rasterization stage, 479Ratio between reflected light and refracted light,
359Read control, 20–21, 682Realism, 453Real-time atmospherics, 525–529Real-Time Stroke-based Halftoning (Freudenberg),
454RealWorldz, 505
2D instead of 3D noise, 510Altgrad map, 522–524atmospheric effects, 525–532caustic effects, 536clouds, 537–539DLU node, 509features, 505–506fractal terrains, 508–510function tree, 509, 519–521implementation, 517–525internals, 506–517lighting, 524LOD (level-of-detail), 507Math node, 509Multifractal node, 509mushroom transformation, 514–515node types, 509noise texture creation, 510–511noise values and derivatives, 517–518ocean, 532–537overhanging terrain, 513–517performance considerations, 524–525
Rost.book Page 729 Wednesday, December 21, 2005 12:21 PM
730 Index
RealWorldz, continuedplanet creation, 506–517planetary landscapes, 506postprocessing height field terrain, 514quadtree structure, 506–507separate terrain function trees, 516–517shading, 507–508sky color, 529–532smoke, 539surface normals, 513terrain color, 521–522texture map, 507, 525textures, 505–506tile set noise, 511–512tile sets, 518–519VBO (vertex buffer object), 506
Reciprocal of positive square root, 127Recursive function, 469Reeves, Bill, 418–419reflect function, 137, 154, 267, 360, 373Reflectance model, 368ReflectDir variable, 268Reflected vector, 360Reflection vector, 154, 156reflectionDir vector, 271Reflections
AlienRockArt planet, 532computing, 248, 368–375direction, 137, 153–154, 271divider cone, 534horizon cone, 534ocean, 532–536point R, 532properties, 534reducing, 338terrain, 532–536
Reflections on Spheres and Cylinders of Revolution (Glaeser), 532
Reflectivity, 358–359reflectVec variable, 156refract function, 137, 358, 360Refracted vector, 358, 360Refraction, 358–363
Cg shaders, 359ratio of indices, 137wavelength dependent, 362
Refraction effect, 358Regular patterns, 287–288
amount of fuzz (blurriness), 291
antialiased transitions between stripe colors, 291
smooth transitions between stripe color and background color, 290
stripes fragment shader, 290–291stripes vertex shader, 289–290
Relational and equality operators (>, <=, >, >=, ==, !=), 139
Relational operations based on vectors, 52Relational operators (<, >, <=, and >=), 69, 85,
89, 94Render targets, multiple, 3, 204–206Rendering, 5, 479, 682
advanced effects, 38double buffering, 6–7installing program as part of state, 176installing program objects as part of state,
645–648objects with mirrorlike qualities, 265ocean, 536–537passes, 223sampling pixels multiple times, 7scene graphs, 227windows supporting, 6
Rendering algorithmsunderstanding, 216user-created, 2
Rendering Outdoor Light Scattering in Real Time (Hoffman and Preetham), 526
Rendering pipeline, 8, 682RenderMan, 340, 545–547The RenderMan Companion: A Programmer’s Guide
to Realistic Computer Graphics (Upstill), 147–148
RenderMan Interface Specification, 148, 543, 544–547
RenderMan shader, 149RenderMan Shading Language, 546RenderMonkey, 222–225Repeat wrapping behavior, 257Repeating patterns, 518–519, 524require behavior, 93Rescaling normalization, 235Resolution, increasing and antialiasing, 436–437Restricted to cone of light, 239return keyword, 83RGB color space, 481RGB PTMs (polynomial texture maps), 376, 378RGB representation of color, 365
Rost.book Page 730 Wednesday, December 21, 2005 12:21 PM
Index 731
RGBA (red, green, blue and alpha component), 19
RGBA texture, 396Rideout, Philip, 257, 329, 338, 341, 343, 415Ring planet, 524Ring world, 509Ripple texture map, 537Ritter, Brad, 375Rivero, Michael, 467RO1 variable, 278Runtime compilation, 59R-values, 87, 682
Ssample3D data type, 203sampler data type, 141sampler1D data type, 51, 71, 141, 203, 255sampler1DShadow data type, 71, 203sampler1DShadow sampler, 119sampler2D data type, 51, 71, 141, 203, 255sampler2DShadow data type, 71, 203sampler2DShadow sampler, 119sampler3D data type, 71, 255samplerCube data type, 71, 203, 255Samplers, 51, 71–72, 203–204, 255, 682samplerShadow1D data type, 255samplerShadow2D data type, 255SamplesPerCell variable, 275Saturation, 485Sawtooth wave, 438Scalar Booleans, 82, 89Scalar components, 86Scalar constants, 80Scalars
binary operation, 88data types, 67–69
Scale-and-bias, 481ScaleFactor variable, 272Scaling modeling coordinates, 164Scanning, 682Scene graphs, 227–229, 682Scenes
global ambient lighting value, 14Schlick, Christophe, 359Scissor test, 17, 682Scope of variables, 74SCREEN blend mode, 490Secondary color, 242
Segal, Mark, 4Selection, 82Selection of flat or smooth shading, 40Selection operator (?:), 82, 86Self-shadows, 344Semantic analysis, 225, 682Sequence operator (,), 86, 90Server-side stack, 8Server-side state, 8setNoiseFrequency function, 396SGI (Silicon Graphics, Inc.), 1–2, 544SGI OpenGL Web site, 33SGI prefix for extensions, 3Shader development
analyzing algorithm, 219built-in function, 219general principles, 215–218modularity, 217–218person writing, 222–223progressively adding complexity, 216–217reducing complexity, 223reviewing information logs, 220set of parameters, 217simplicity, 217testing, 217textures to encode complex functions, 220understanding problem, 216vectors, 220
Shader development toolsOpenGL Shading Language compiler front
end, 225–226RenderMonkey, 222–225
Shader languagesCg, 544, 552–554HLSL, 544OpenGL Shader, 544OpenGL Shading Language, 544Stanford Real-Time Shading Language, 544
Shader objects, 54, 682attaching to program objects, 55, 173–174,
209–210, 576–577compiling, 172–173, 581–582container for, 55creation of, 170–172, 585–586deleting, 177–178, 589–590detaching from program objects, 177,
591–592empty, 171, 209
Rost.book Page 731 Wednesday, December 21, 2005 12:21 PM
732 Index
Shader objects, continuedGL_COMPILE_STATUS parameter, 209handles of attached for program objects,
605–606information about, 178information log, 172–173, 181, 616–617linking, 173–176names, 184, 631obtaining current shader string from,
180–181parameters, 614–615queriable parameters, 178–179querying, 183replacing source code, 636–637source code string, 618–619support for multiple, 55–56
ShaderGen, 233Shaders, 36, 134, 682
accessing current, 109accessing state, 51accessing texture maps, 254–256algorithm defining, 285analyzing code, 219animation effect, 411–412bump-mapping, 216classification of, 543common interfaces, 61compiling and annotating, 91compiling to machine code, 55computational frequency, 218computations done once on CPU, 219debugging, 91declaring OpenGL Shading Language
version, 91–92defining source code, 171description of effect, 150developing, 91diagnostic messages returned from
compiling, 56easier to understand and maintain, 123example pair, 65–67failing compilation, 209first pass of volume shadow algorithm,
349–350getting information into and out of, 78highly customized, 222implementing as collection, 61improving performance, 219inability to manipulate sampler values, 72
information log, 209interface, 78–81length, 36linking, 173–176lookup table operations, 481managing input and output, 51modifying attributes, 79modifying behavior, 196noise, 395overriding built-in function, 84–85parameterized with uniform variables, 42passing to OpenGL as strings, 208passing to renderer through RenderMan
interface, 546performance considerations, 218–220programmable, 233qualifiers, 78–81range of effects possible with, 37–38reading and writing variables, 81reasons for using, 37–38receiving samplers, 71referring to existing state, 48rendering procedural brick pattern, 149runtime checking, 206–207saving instruction space, 219second pass volume shadow algorithm,
350–354sharing same array, 74simpler to develop, 123source code, 54source strings, 56two-dimensional images, 479uniform variables, 100–101unpacking noise texture sample into
function value, 517–518usage, 173–176
Shading effects, 106Shading languages
chronology of, 543–544compiler, 55HLSL (High-Level Shader Language),
549–552OpenGL Shader, 547–549
Shading planets, 507–508Shadow Map Antialiasing, 343Shadow mapping, 683
aliasing artifacts, 339depth comparison, 339lights capable of casting shadows, 346
Rost.book Page 732 Wednesday, December 21, 2005 12:21 PM
Index 733
matrix transforming vertex positions for light source, 340–341
modeling matrix, 341projection matrix, 341rendering passes for light sources, 346scale and bias matrix, 341view matrix, 341
Shadow mapping algorithm, 339Shadow maps, 338–340, 683
application setup, 340–341bias depth values, 339depth precision problems with illuminated
faces, 340depth texture, 343fragment shader, 343–346lookup, 343per-light passes, 339precision problems on surfaces facing away
from light, 340sampling multiple times, 344vertex shader, 341–342
shadow texture, 142Shadow volume, 347–348shadow1D function, 119, 144, 255–256shadow1DLod function, 144shadow1DProj function, 144shadow1DProjLod function, 144shadow2D function, 119, 144, 256, 344shadow2DLod function, 144shadow2DProj function, 144, 343shadow2DProjLod function, 144Shadowing algorithm, 339Shadows, 253, 333
aliasing artifacts, 343artifact-free, 340comparison functions, 2complex, 334compositing, 347from light sources, 339object-generated, 344soft, 334soft with deferred shading, 346–347storing depth values, 2uses for, 333well-defined, 338
Sharpening images, 499–500Sharpness, 486Shirley, Peter, 463sign function, 128, 130
sin function, 124–125, 426Sine, 125sine function, 426, 509Sine functions, 84–85Sine noise, 510Single-buffered windows, 7sizeof operator, 94Sky
color texture map lookup in fragment shader, 530–531
optical depth, 530reflected in ocean, 536shading, 529–532
Sliders, 158Smoke, 539Smooth shading, 15, 683Smoothing
blending modes, 495–497general convolution shader, 496–497images, 495–497neighborhood averaging, 495–496
Smoothing filters, 683smoothstep function, 130, 135, 164, 291,
296–297, 324, 413, 435, 439–440, 442, 459Snell’s law, 358Snow planet, 522, 529Soft fill light, 338SOFT LIGHT blend mode, 491Source code, 170–173Source image interpolation, 484Source strings, 90–91Special input variables, 104, 106Special operations, 69Special output variables, 101–102, 107–108Specular color component, 14Specular component, 155, 368Specular contribution, computing separately,
242Specular glint, 366Specular highlights, 14, 156, 369
applied after texturing, 242Gooch shading, 464
Specular lighting effects, 218Specular reflection, 152–154, 156, 260, 368Specular variable, 289SpecularColor variable, 289specularContribution constant, 156SpecularFactor variable, 303, 307sphere, 416
Rost.book Page 733 Wednesday, December 21, 2005 12:21 PM
734 Index
Sphere map computations, 248Sphere mapping, 265, 683Sphere morph vertex shader, 415–417Spherical harmonics lighting, 318–322, 337Spline function, 414SpotLight function, 243Spotlights, 13, 239–240sqrt function, 127, 352Stöckli, Reto, 257Stam, Jos, 363Standard attributes, 99–100, 190Stanford Real-Time Shading Language, 544Stanford Shading Language, 55Star Trek II: The Wrath of Khan, 418Star Wars Episode 1: The Phantom Menace, 544StartRad variable, 427StartTime variable, 423State of the Art in Hardware Shading, 304static variables, 81STDGL pragma, 91STDGL token, 91Steep slopes and textures, 513–514Stencil buffer, 7, 17, 19, 683Stencil components, initializing, 18Stencil functionality, 3Stencil test, 17, 683Stencil wrapping behavior, 2step function, 130, 134, 161, 164, 439, 456, 458Stereo viewing, 7Stored texture shader, 287Stored textures, 287Stream processing, 39Strings, 53Strings of characters, concatenating, 56Stripe patterns
colors smoothly “fuzzed” boundary in transition region, 291
noise, 460Stripe shader, 287–288Stripes fragment shader, 290–291Stripes vertex shader, 289–290Structure field operator (.), 197Structure variables, 80Structures, 72
bit fields, 53constructors, 76grouping collection of parameters, 112
SUBTRACT blend mode, 492
Subtraction operator (-), 85, 88Sun Microsystems, 2Sun surface fragment shader, 403Superellipse function, 323–324Superellipses, 324, 326superEllipseShape, 326Supersampling, 683Surface normals, 41, 154–155, 513, 539
eye space, 24–25transforming, 235
Surface shaders, 543, 546, 549SurfaceColor variable, 303, 307Surface-local
coordinates, 303eye direction, 306light direction, 306transformation matrix, 306
Surface-local coordinate space, 302, 683Surfaces
computing color, 242computing reflection, 368–375reconstructing color under varying lighting,
375rendering with evaluators, 12
switch keyword, 82Swizzle, 684Swizzle operator (.), 85, 87Swizzling, 87Symbolic constants, 8Syntactic analysis, 225, 684System
driver model, 54–56overview, 54–59
Ttan function, 125Tangent space, 303, 684tangent variable, 372Tangent vectors, 302–304Tangents, 125, 304Target buffers, rendering into multiple, 205–206Target image extrapolation, 484Taylor, Philip, 312Technical illustration example, 462
application setup, 466common characteristics for color, 463effects, 463fragment shader, 466–467
Rost.book Page 734 Wednesday, December 21, 2005 12:21 PM
Index 735
light source, 463matte objects, 463vertex shader, 466warmth or coolness of color, 463
Technical illustrations, 462Tejada, Antonio, 426Temperature values, 66Temporal aliasing, 435, 684Ternary selection operator (?:), 89–90Terrain
color, 521–522high frequency features, 515–516reflections, 532–536separate terrain function trees, 516–517steep slopes and textures, 513–514
Terrain function tree, 519–521TexCoord variable, 381, 383Texels, 29, 684texName texture object, 257texNT function, 521Text application, 684Texture access, 31, 46, 684Texture access functions, 141–144Texture application, 31Texture bombing, 676, 684Texture coordinate sets, 118–119Texture coordinates, 41, 255, 307
automatically generating, 30–31built-in array, 73clamping to range, 279generating, 246–248perturbing, 426random scaling, 279reference frame from, 272simple environment mapping, 247transforming, 235
Texture environmentcolor, 250parameters, 30
Texture environment function, 30Texture formats, 2Texture functions
built-in, 249, 482shadow variants, 142
Texture generation functions, 31Texture image units, 113, 118–120Texture lookups, 71–72, 118Texture mapping, 16, 26, 684
example, 256–259extending scope, 253limits related, 119
Texture maps, 376accessing from shaders, 51, 254–256cube maps, 26daylight colors, 260defining behavior of filtering operation, 42drawing shadow, 348fragment shader, 104implementing noise function, 399index values, 271levels of gray, 272–273locations accessed, 255no lighting, 260noise function, 396one-dimensional, 26parameters, 46RealWorldz, 507storing previously computed noise function,
395three-dimensional, 26time to generate, 525two-dimensional, 26vertex shader, 99
Texture matrix stack, modifying, 31Texture memory, 16, 249, 684
accessing arbitrary number of times, 46directly updating, 20images for, 18new uses for, 38vertex processors reading from, 42
Texture objects, 2, 28–30, 203, 253, 684Texture pattern, 272Texture target, 28Texture units, 27, 30, 258, 685Texture values, 51Texture wrap mode, 253texture1D function, 87, 143, 255texture1DLod function, 143texture1DProj function, 143texture1DProjLod function, 143texture2D function, 143, 255texture2DLod function, 143texture2DProj function, 143texture2DProjLod function, 143texture3D function, 143, 255texture3DLod function, 143
Rost.book Page 735 Wednesday, December 21, 2005 12:21 PM
736 Index
texture3DProj function, 143texture3DProjLod function, 143Texture-access functions, 255Texture-combine environment mode, 250–251textureCube function, 144, 255–256textureCubeLod function, 144, 256Texture-enables and fixed function hierarchy, 119Textures, 16
accessing from shader, 46accessing multiple simultaneously, 253aliasing, 435application, 249–251color components, 309comparison operation, 29compressed image formats, 28creation of, 28defined algorithmically, 286encoding complex functions, 220fixed to geometric model, 246generated procedurally, 285level-of-detail, 142modifying, 28no fixed area or resolution, 286non-power-of-2, 2–3normal perturbation values, 308priority to be assigned to, 29projecting on object, 142properties, 142RealWorldz, 505–506RGB values, 250setting state, 141setting up for use, 254sizes not restricted to powers of 2, 28steep slopes, 513–514switching between, 28three-dimensional, 253transformation, 31type accessed, 203, 255uses for, 253–254
Texturing, 26–31additional capabilities, 2lighting computed before, 249–250undefined results, 142
Texturing and Modeling: A Procedural Approach, Third Edition (Ebert et al.), 149, 165, 213, 230–231, 272, 389, 393, 444
Texturing example, 256–259Theoretical BRDF models, 370
Three-dimensional attributes, 22Three-dimensional texture maps, 26Threshold animation, 413Tile set noise, 511–512Tile sets, 518–519Tileable 3D texture and Perlin noise, 460Time variable, 423, 455T&L (transformation and lighting), 13, 684, 685tnorm variable, 154–155Tokens, 91Tom Nuyden’s Web site, 32Topmost matrix, 24Toy ball, 292
application setup, 293defining sphere, 293diffuse-only lighting, 298dot product, 296fragment shader, 294–299fragments in stripe pattern, 293half-space computations, 295–296inorout counter, 297lighting calculation, 297–298smoothly antialiased transition, 296specular highlight, 298star pattern, 292–293surface color for fragment, 297surface location, 294–295surface points, 297uniform variables, 293vertex positions, 293vertex shader, 294
Toy Story, 323, 544Traditional illumination model, 311–312Traditional lighting equation, 462Traditional lighting model, 463Transformation matrix, 302Transformations, 21, 234–235Transformed vertices, 67Transforming, 235Trigonometric operations, 52Trigonometry functions, 124–126Tron, 387true literal Boolean constant, 68Tufte, Edward, 462Turbulence, 402–404, 510, 685Two-dimensional arrays, 494Two-dimensional images, 479Two-dimensional texture maps, 26
Rost.book Page 736 Wednesday, December 21, 2005 12:21 PM
Index 737
Two-sided color mode, 114–115Two-sided lighting, 40, 243Type casting without conversion, 53Type conversions, 77Type matching, 75Type qualifiers, 36, 40typedef keyword, 72Types, 36
larger and smaller, 53strict with, 36
UüberLight controls, 323überlight model
fragment shader, 326–329positioning lights, 323vertex shader, 325–326
überlight shader, 322–324, 329Unary negation (-!) operator, 85, 88Unary operators, 94#undef directive, 90Under the Shade of the Rendering Tree (Lander), 464Underwater caustics, 536Uniform line sensity, 456–458uniform qualified sampler, 71Uniform qualified variables, 67, 78–79Uniform qualifiers, 78–79, 547Uniform variables, 78–81, 100, 106, 152, 158,
195, 685accessed when shader is executed, 201application-defined, 101built-in, 42, 46, 51, 97, 105, 108–113, 196,
202changes to, 42declared as arrays, 199declared as structures, 199declaring, 195–196defined as sampler types, 198fragment shader, 104initializing, 75, 210list of active, 201–203loading defined as sampler types, 203loading into program object, 197–198location of, 622–623return value, 620–621sampler type, 255setting parts, 200–201setting values, 208
size, 202user-defined, 42, 46, 97, 105, 202, 233value for program object, 638–644vertex shader, 99
union enum keyword, 72Unions, 53Unit vectors, 154Units of measurement, 22UNIX-based systems, 2Unqualified variables, 81Unsharp masking, 486, 499–500, 685User clip planes, 116, 249User clipping, 25, 40, 102, 116–117, 249, 685User programmable antialising methods, 38User-defined attribute variables, 41–42, 97, 168
data types, 192mapping generic vertex attributes to,
190–192User-defined attributes, 79User-defined clipping planes, 15User-defined functions, 399User-defined noise functions, 399–400User-defined state, 67User-defined uniform variables, 42, 46, 97, 105,
202, 233querying current value, 199–200querying locations, 196–197updating value, 196
User-defined varying variables, 43, 45, 103Utah teapot, 21–22
VValue noise, 389, 685Values, 77, 133–134Vanishing point, 25Variable nodes, 224Variables
attribute, 81built-in, 51, 78, 81, 97, 101, 152, 546declaring, 36, 52, 74–75global scope, 78, 102initializing, 53, 75naming, 74qualified as const, 80–81reading and writing, 102scope, 74uniform, 81unqualified, 81
Rost.book Page 737 Wednesday, December 21, 2005 12:21 PM
738 Index
varying mechanism, 81Varying qualified variables, 67, 78–80varying qualifiers, 78–80, 547Varying variables, 43, 51, 78, 104, 685
built-in, 43, 102–103, 105fragment shader, 104, 163initializing, 75interpolated values, 80user-defined, 43, 45, 103vertex processor, 99vertex shader, 163
Varyings, 79–80VBO (vertex buffer object), 506vec2 data type, 50, 52, 69, 101, 150, 192vec3 data type, 50, 52–54, 69, 101, 153, 192vec4 data type, 50, 52, 69, 153, 192, 272Vector components, 86Vector relational functions, 139–141Vectors
accessing components, 50binary operation, 88built-in constructors, 76built-in functions, 69built-in variables, 69compile-time checking, 70component access, 69component selection names, 70data types, 69–70Euclidean distance between two points, 137indexed as zero-based arrays, 70indexing, 86length, 136with length of 1, 136names available for selecting components, 69natively supporting operations, 36normalizing, 154operators, 50, 87–88shader development, 220special operations, 69swizzling components, 87
Velocity variable, 423#version directive, 91–92__VERSION__ macro, 90Vertex arrays, 2, 11
drawing geometry, 99interface, 185specifying different texture coordinate
arrays, 30storing data in server-side memory, 12
Vertex attribute arraydefining, 657–659enabling or disabling, 596–597
Vertex attributes, 10–11, 41–42, 185–187, 651–656, 686
Vertex buffer objects, 2, 185Vertex noise, 417–418Vertex positions, 41
built-in attributes, 421current array, 11transforming to eye coordinates, 360
Vertex processing, 2, 12–14, 35–36, 686Vertex processors, 38, 41, 686
built-in varying variables, 102–103data values as inputs, 40data values produced by, 40executing vertex shaders, 98fixed functionality, 39operating on one vertex at a time, 42output, 43passing data values from application, 42programmable, 39reading from texture memory, 42sending standard OpenGL vertex attributes,
41special output variables, 101–102uniform variables, 100–101user-defined varying variables, 103varying variables, 99vertex attributes, 99–100vertex shaders, 40
Vertex shaders, 36, 40, 686attribute variables, 40–41, 99attributes, 97bias parameter, 142BRDF PTMs, 379–381brick pattern, 151–157built-in
attribute variables, 163constants, 99, 113variables to access standard types of data,
184varying variables, 97
bump mapping, 306characteristics that don’t change, 218chromatic aberration effect, 362–363common functions, 126, 128–134communicating results to fragment shader,
79–80
Rost.book Page 738 Wednesday, December 21, 2005 12:21 PM
Index 739
communicating to subsequent processing, 97
computing homogeneous vertex position, 153
computing vertex position in eye coordinates, 153
confetti cannon, 423–424cube mapping example, 266–267current state, 42defining, 151–152diffraction effect, 367–368displacement mapping algorithms, 42distance attenuation, 116empty shader objects, 209environment mapping example, 269example, 65–67executing, 42, 98–99explicitly binding vertex attribute to
attribute variable, 188–189exponential functions, 126–127fog factor, 246fragment shader, 65–67Fresnel reflection/refraction effect, 361generating shadows, 342generic attributes, 100generic vertex attributes, 42geometric functions, 136–138glyph bombing, 276–277hatching example, 455–456hemisphere lighting, 314–315hemisphere lighting with ambient occlusion,
335–336HLSL (High-Level Shader Language), 551identity mapping of input geometry, 494image-based lighting, 317light position, 258lighting computation, 153main function, 82, 153Mandelbrot example, 471–472matrix functions, 138–139maximum number of texture image units,
119multitexturing example, 262–263noise, 400noise functions, 145–146noise to modify and animate shape, 418OpenGL Shading Language, 546output, 43output and debugging, 221
output variables, 97passing texture coordinates from, 103per-vertex values, 80point size mode, 115–116position invariance, 117–118raster position, 117rendering with BRDF model, 373shader computation, 218shadow maps, 341–342soft volume shadow algorithm, 350, 351–352special built-in vertex shader output
variables, 97sphere morph, 415–417spherical harmonics lighting, 321, 337standard attributes, 100state, 46, 97technical illustration example, 466texture, 255–256texture access functions, 141–144texture maps, 99texturing, 118–120texturing example, 258–259toy ball, 294transforming incoming vertex position, 113trigonometry functions, 124–126two-sided color mode, 114–115überlight model, 325–326uniform variables, 99user clipping, 102, 116–117user-defined attribute variables, 168user-defined varying variable, 43varying qualified variables, 80varying variables, 43, 102, 163vector relational functions, 139–141
Vertex-at-a-time interface, 184Vertex-at-a-time method, 9–10Vertices, 685
attributes, 14, 99–100, 184–195completion of, 186computing color, 242data from client-side memory, 12end of data definition, 10eye coordinate position of incoming, 153interpolating values, 80normal, 152parallel processing, 39position, 101, 152primary and secondary color, 13, 15transforming and lighting single, 43
Rost.book Page 739 Wednesday, December 21, 2005 12:21 PM
740 Index
Vertices, continuedtransforming position, 136, 138, 234values result of executing vertex shader,
98–99Vidimice, Kiril, 323View frustum, 686View volume, 15, 686Viewing direction, 153–154
lighting, 240–241transforming, 302
Viewing matrix, 23, 686Viewing parameters, 23Viewing position, 154Viewing transformation, 23, 686Viewing vector, 156Viewing volume, 25Viewport mapping, 40Viewport transformation, 26, 686ViewPosition variable, 326viewVec variable, 156Visible light behavior, 364Visual artifacts, 388Visual complexity, 145–146Visual Explanations (Tufte), 462Void data types, 74Volume shaders, 546Volume shadow algorithm, 349–354Volume shadows, 346–354Voorhies, Douglas, 483Voronoi mountainfractal, 509Voronoi multifractal, 509Voronoi noise, 508, 510–512, 517
WWard, Greg, 370–372warn behavior, 92–93
Water ripples, 537Wavelengths, 364–366WCLightPos variable, 326Weiblen, Mike, 227, 346WGL routines, 6while statement, 82White light component colors, 364Window coordinate system, 26, 687Window coordinates, 15Windowing system, 6Windows, 5–7, 106Wobble, 426–430Wobble effect
fragment shader, 429–430speeding up, 427
Wobble Tex variable, 427Wood, 405–408Wood shader application setup, 405–406Woodcut print, 454World coordinate system, 22, 687World coordinates, 22–23, 326World space, 22, 687
Xx raised to y power, 127X Window System environment, 6XML file format, 225Xunitvec constant, 271.xyz component selector, 295
YYunitvec constant, 271
ZZoom factor, 20
Rost.book Page 740 Wednesday, December 21, 2005 12:21 PM