Showing posts with label OpenGL. Show all posts
Showing posts with label OpenGL. Show all posts

Wednesday, December 15, 2010

Advanced Graphics Programming Techniques Using OpenGL













Contents
1 Introduction 1
1.1 OpenGLVersion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 CourseNotesandSlideSetOrganization . . . . . . . . . . . . . . . . . . . . . . . 1
1.3 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.4 Acknowledgments for 1997 Course Notes . . . . . . . . . . . . . . . . . . . . . . 2
1.5 CourseNotesWeb Site . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 About OpenGL 4
3 Modeling 5
3.1 ModelingConsiderations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.2 Decomposition and Tessellation . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.3 GeneratingModelNormals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.3.1 ConsistentVertexWinding . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.3.2 SmoothShading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.4 Triangle-stripping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.4.1 GreedyTri-stripping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.5 CappingClippedSolidswiththeStencilBuffer . . . . . . . . . . . . . . . . . . . 15
3.6 ConstructiveSolidGeometrywiththeStencilBuffer . . . . . . . . . . . . . . . . 16
4 Geometry and Transformations 25
4.1 StereoViewing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.1.1 FusionDistance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.1.2 ComputingtheTransforms . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.2 DepthofField . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4.3 TheZCoordinateandPerspectiveProjection . . . . . . . . . . . . . . . . . . . . 28
4.3.1 DepthBuffering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.4 Image Tiling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
4.5 Moving the Current Raster Position . . . . . . . . . . . . . . . . . . . . . . . . . 34
4.6 PreventingClippingofWideLinesandPoints . . . . . . . . . . . . . . . . . . . . 34
4.7 DistortionCorrection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
5 Texture Mapping 39
5.1 Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
5.1.1 Filtering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
5.1.2 TextureEnvironment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
5.2 MipmapGeneration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
5.3 TextureMapLimits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.4 Anisotropic Texture Filtering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
5.5 PagingTextures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
5.5.1 TextureSubloading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
5.5.2 PagingImages inSystemMemory . . . . . . . . . . . . . . . . . . . . . . 49
5.6 TransparencyMappingandTrimmingwithAlpha . . . . . . . . . . . . . . . . . . 50
5.7 Billboards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
5.8 RenderingText . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
5.9 TextureMosaicing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
5.10 TextureCoordinateGeneration . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
5.11 ColorCodingandContouring . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
5.12 AnnotatingMetrics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
5.13 ProjectiveTextures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
5.13.1 HowtoProject aTexture . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
5.14 EnvironmentMapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
5.15 ImageWarpingandDewarping . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
5.16 3DTextures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
5.16.1 Using3DTextures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
5.16.2 3DTextures toRenderSolidMaterials . . . . . . . . . . . . . . . . . . . . 60
5.16.3 3D Textures as Multidimensional Functions . . . . . . . . . . . . . . . . . 60
5.17 Line Integral Convolution (LIC) with Texture . . . . . . . . . . . . . . . . . . . . 61
5.17.1 Sampling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
5.17.2 Using OpenGL to Create Line Integral Convolution (LIC) Images . . . . . 63
5.17.3 Line Integral Convolution Procedure . . . . . . . . . . . . . . . . . . . . . 64
5.17.4 Details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
5.17.5 MaximizingContrast . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
5.17.6 GoingFarther . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
5.18 DetailTextures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
5.18.1 SignedIntensityDetailTextures . . . . . . . . . . . . . . . . . . . . . . . 68
5.18.2 MakingDetailTextures . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
5.19 GradualCutawayViews . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
5.19.1 Steps toGeneratingaCutawayShell . . . . . . . . . . . . . . . . . . . . . 70
5.19.2 Refinements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
5.19.3 RenderingaSurfaceTexturedShell . . . . . . . . . . . . . . . . . . . . . 72
5.19.4 AlphaBufferApproach . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
5.19.5 NoAlphaBufferApproach . . . . . . . . . . . . . . . . . . . . . . . . . . 73
5.20 ProceduralTextureGeneration . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
5.20.1 Filtered Noise Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 74


Another OpenGL Books
Another Multimedia Books
Download


5.20.2 GeneratingNoiseFunctions . . . . . . . . . . . . . . . . . . . . . . . . . 74
5.20.3 High Resolution Filtering . . . . . . . . . . . . . . . . . . . . . . . . . . 75
5.20.4 Spectral Synthesis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
5.20.5 OtherNoiseFunctions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
5.20.6 Turbulence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
5.20.7 Example: ImageWarping . . . . . . . . . . . . . . . . . . . . . . . . . . 78
5.20.8 Generating3DNoise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
5.20.9 Generating2DNoisetoSimulate3DNoise . . . . . . . . . . . . . . . . . 79
5.20.10Trade-offsBetween 3Dand2DTechniques . . . . . . . . . . . . . . . . . 79
6 Blending 80
6.1 Compositing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
6.2 AdvancedBlending . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
6.3 Painting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
6.4 BlendingwiththeAccumulationBuffer . . . . . . . . . . . . . . . . . . . . . . . 81
6.5 BlendingTransitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
7 Antialiasing 84
7.1 Line andPointAntialiasing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
7.2 Polygon Antialiasing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
7.3 Multisampling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
7.4 AntialiasingWithTextures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
7.5 AntialiasingwithAccumulationBuffer . . . . . . . . . . . . . . . . . . . . . . . . 87
8 Lighting 90
8.1 Phong Shading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
8.1.1 Phong Highlightswith Texture . . . . . . . . . . . . . . . . . . . . . . . . 90
8.1.2 ImprovedHighlightShape . . . . . . . . . . . . . . . . . . . . . . . . . . 90
8.1.3 SpotlightEffects usingProjectiveTextures . . . . . . . . . . . . . . . . . 91
8.1.4 Phong Shading by Adaptive Tessellation . . . . . . . . . . . . . . . . . . 93
8.2 LightMaps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
8.2.1 2DTextureLightMaps . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
8.2.2 3DTextureLightMaps . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
8.3 OtherLightingModels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
8.4 Global Illumination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
8.5 BumpMappingwithTextures . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
8.5.1 TangentSpace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
8.5.2 Going for Higher Quality . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
8.5.3 Blending . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
8.5.4 WhyDoesThisWork? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
8.5.5 Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
8.6 ChoosingMaterial Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
8.6.1 ModelingMaterialType . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
8.6.2 ModelingMaterial Smoothness . . . . . . . . . . . . . . . . . . . . . . . 107
9 Scene Realism 110
9.1 MotionBlur . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
9.2 DepthofField . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
9.3 Reflections andRefractions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
9.3.1 PlanarReflectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
9.3.2 SphereMapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
9.4 CreatingShadows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
9.4.1 ProjectionShadows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
9.4.2 ShadowVolumes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
9.4.3 ShadowMaps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
9.4.4 Soft Shadows by Jittering Lights . . . . . . . . . . . . . . . . . . . . . . . 133
9.4.5 SoftShadowsUsingTextures . . . . . . . . . . . . . . . . . . . . . . . . 133
10 Transparency 135
10.1 Screen-DoorTransparency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
10.2 AlphaBlending . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
10.3 Sorting. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
10.4 UsingtheAlphaFunction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
10.5 UsingMultisampling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
11 Natural Phenomena 139
11.1 Smoke . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
11.2 VaporTrails . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
11.3 Fire . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
11.4 Explosions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
11.5 Clouds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
11.6 Water . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
11.7 LightPoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
11.8 OtherAtmosphericEffects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
11.9 ParticleSystems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
11.9.1 RepresentingParticles . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
11.9.2 ParticleSizes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
11.9.3 Large andSmallPoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
11.9.4 Antialiasing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
11.9.5 “Fat”Particles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
11.9.6 ParticleSystems inaScene . . . . . . . . . . . . . . . . . . . . . . . . . . 149
11.10Precipitation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
12 Image Processing 152
12.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
12.1.1 ThePixelTransferPipeline . . . . . . . . . . . . . . . . . . . . . . . . . . 152
12.1.2 GeometricDrawingandTexturing . . . . . . . . . . . . . . . . . . . . . . 153
12.1.3 TheFramebuffer andPer-FragmentOperations . . . . . . . . . . . . . . . 153
12.1.4 The ImagingSubset inOpenGL1.2 . . . . . . . . . . . . . . . . . . . . . 154
12.2 Colors and Color Spaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
12.2.1 TheAccumulationBuffer: InterpolationandExtrapolation . . . . . . . . . 155
12.2.2 PixelScale andBiasOperations . . . . . . . . . . . . . . . . . . . . . . . 157
12.2.3 Look-Up Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
12.2.4 TheColorMatrixExtension . . . . . . . . . . . . . . . . . . . . . . . . . 160
12.3 Convolutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
12.3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
12.3.2 The Convolution Operation . . . . . . . . . . . . . . . . . . . . . . . . . 163
12.3.3 Convolutions Using the Accumulation Buffer . . . . . . . . . . . . . . . . 165
12.3.4 The Convolution Extension . . . . . . . . . . . . . . . . . . . . . . . . . 167
12.3.5 Useful Convolution Filters . . . . . . . . . . . . . . . . . . . . . . . . . . 168
12.3.6 CorrelationandFeatureDetection . . . . . . . . . . . . . . . . . . . . . . 171
12.4 ImageWarping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
12.4.1 ThePixelZoomOperation . . . . . . . . . . . . . . . . . . . . . . . . . . 172
12.4.2 WarpsUsingTextureMapping . . . . . . . . . . . . . . . . . . . . . . . . 173
13 Volume Visualization with Texture 174
13.1 Overviewof theTechnique . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
13.2 3DTextureVolumeRendering . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
13.3 2DTextureVolumeRendering . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
13.4 BlendingOperators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
13.4.1 Over . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
13.4.2 Attenuate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
13.4.3 MaximumIntensityProjection . . . . . . . . . . . . . . . . . . . . . . . . 178
13.4.4 Under . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
13.5 SamplingFrequency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
13.6 ShrinkingtheVolume Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
13.7 VirtualizingTextureMemory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
13.8 MixingVolumetric andGeometricObjects . . . . . . . . . . . . . . . . . . . . . . 180
13.9 TransferFunctions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
13.10Volume Cutting Planes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
13.11ShadingtheVolume . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
13.12WarpedVolumes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
14 Using the Stencil Buffer 183
14.1 DissolveswithStencil . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
14.2 DecalingwithStencil . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
14.3 FindingDepthComplexitywiththeStencilBuffer . . . . . . . . . . . . . . . . . . 189
14.4 Compositing Images with Depth . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
15 Line Rendering Techniques 192
15.1 WireframeModels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
15.2 HiddenLines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
15.2.1 glPolygonOffset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
15.2.2 glDepthRange . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
15.3 HaloedLines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
15.4 Silhouette Edges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
15.5 PreventingSmoothWideLineOverlap . . . . . . . . . . . . . . . . . . . . . . . . 198
15.6 EndCapsOnWideLines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
16 Tuning Your OpenGL Application 199
16.1 What IsPipelineTuning? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
16.1.1 Three-StageModelof theGraphicsPipeline . . . . . . . . . . . . . . . . . 199
16.1.2 Finding Bottlenecks in Your Application . . . . . . . . . . . . . . . . . . 200
16.2 OptimizingYourApplicationCode . . . . . . . . . . . . . . . . . . . . . . . . . . 201
16.2.1 OptimizeCache andMemoryUsage . . . . . . . . . . . . . . . . . . . . . 201
16.2.2 StoreData inaFormatThat isEfficient forRendering . . . . . . . . . . . 202
16.2.3 Per-PlatformTuning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
16.3 TuningtheGeometrySubsystem . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
16.3.1 UseExpensiveModesEfficiently . . . . . . . . . . . . . . . . . . . . . . 204
16.3.2 OptimizingTransformations . . . . . . . . . . . . . . . . . . . . . . . . . 204
16.3.3 OptimizingLightingPerformance . . . . . . . . . . . . . . . . . . . . . . 205
16.3.4 AdvancedGeometry-LimitedTuningTechniques . . . . . . . . . . . . . . 207
16.4 TuningtheRasterSubsystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
16.4.1 Using Backface/Frontface Removal . . . . . . . . . . . . . . . . . . . . . 207
16.4.2 MinimizingPer-PixelCalculations . . . . . . . . . . . . . . . . . . . . . . 208
16.4.3 OptimizingTextureMapping . . . . . . . . . . . . . . . . . . . . . . . . . 209
16.4.4 ClearingtheColor andDepthBuffersSimultaneously . . . . . . . . . . . 210
16.5 RenderingGeometryEfficiently . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
16.5.1 Using Peak-Performance Primitives . . . . . . . . . . . . . . . . . . . . . 210
16.5.2 UsingVertexArrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
16.5.3 UsingDisplayLists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
16.5.4 Balancing Polygon Size and Pixel Operations . . . . . . . . . . . . . . . . 213
16.6 RenderingImagesEfficiently . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
16.7 TuningAnimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
16.7.1 FactorsContributingtoAnimationSpeed . . . . . . . . . . . . . . . . . . 214
16.7.2 OptimizingFrameRatePerformance . . . . . . . . . . . . . . . . . . . . 214
16.8 TakingTimingMeasurements . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
16.8.1 BenchmarkingBasics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
16.8.2 AchievingAccurateTimingMeasurements . . . . . . . . . . . . . . . . . 216
16.8.3 AchievingAccurateBenchmarkingResults . . . . . . . . . . . . . . . . . 217
17 Portability Considerations 218
17.1 GeneralConcerns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
17.1.1 Handle Runtime Feature Availability Carefully . . . . . . . . . . . . . . . 218
17.1.2 ExtensionsandOpenGLVersioning . . . . . . . . . . . . . . . . . . . . . 219
17.1.3 Source Compatibility Across OpenGL SDKs . . . . . . . . . . . . . . . . 220
17.1.4 CharacterizePlatformPerformance . . . . . . . . . . . . . . . . . . . . . 220
17.2 Windows versus UNIX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
17.3 3D Texture Portability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
18 List of Demo Programs 223
19 GLUT, the OpenGL Utility Toolkit 228
20 Equations 229
20.1 ProjectionMatrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
20.1.1 PerspectiveProjection . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
20.1.2 Orthographic Projection . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
20.1.3 Perspective z-CoordinateTransformations . . . . . . . . . . . . . . . . . . 229
20.2 LightingEquations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
20.2.1 AttenuationFactor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
20.2.2 SpotlightEffect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
20.2.3 AmbientTerm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
20.2.4 DiffuseTerm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
20.2.5 SpecularTerm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
20.2.6 Putting It All Together . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
21 References 233




Sunday, September 5, 2010

OpenGL SuperBible 3rd Edition












OpenGL® SuperBible, Third Edition
By Richard S. Wright Jr., Benjamin Lipchak

Publisher : Sams Publishing
Pub Date : June 30, 2004
ISBN : 0-672-32601-9
Pages : 1200



OpenGL SuperBible, Third Edition is a comprehensive, hands-on guide for Mac and Windows programmers who need to know how to program with the new version of OpenGL. This book will help readers master and expand their knowledge of 3D graphics programming and OpenGL implementation. Seasoned OpenGL programmers will also find this learning tool serves as a reference that can be used time and again. This book explains how to draw lines, points, and polygons in space; move around in a virtual world; utilize raster graphics and image processing in OpenGL. In addition readers learn how to use fog and blending special effects; explore the use of OpenGL extensions; use shaders to create procedural textures; write vertex programs for dynamic special effects.

Copyright
About the Authors
Acknowledgments
We Want to Hear from You!
Introduction
What's in This Book
Conventions Used in This Book
About the Companion CD
Dare to Dream in 3D!
Part I. Classic OpenGL
Chapter 1. Introduction to 3D Graphics and OpenGL
What's This All About?
A Brief History of Computer Graphics
A Survey of 3D Effects
Common Uses for 3D Graphics
Basic 3D Programming Principles
Summary
Chapter 2. Using OpenGL
What Is OpenGL?
How Does OpenGL Work?
OpenGL: An API, Not a Language
API Specifics
Platform Independence
Animation with OpenGL and GLUT
The OpenGL State Machine
OpenGL Errors
Identifying the Version
Getting a Clue with glHint
Using Extensions
Summary
Reference
Chapter 3. Drawing in Space: Geometric Primitives and Buffers
Drawing Points in 3D
Setting Up a 3D Canvas
A 3D Point: The Vertex
Draw Something!
Setting the Point Size
Drawing Lines in 3D
Drawing Triangles in 3D
Building Solid Objects
Other Primitives
Other Buffer Tricks
Summary
Reference
Chapter 4. Geometric Transformations: The Pipeline
Is This the Dreaded Math Chapter?
Understanding Transformations
The Matrix: Mathematical Currency for 3D Graphics
Using Projections
Advanced Matrix Manipulation
Moving Around in OpenGL Using Cameras and Actors
Bringing It All Together
Summary
Reference
Chapter 5. Color, Materials, and Lighting: The Basics
What Is Color?
PC Color Hardware
PC Display Modes
Using Color in OpenGL
Color in the Real World
Materials in the Real World
Adding Light to a Scene
Using a Light Source
Lighting Effects
Putting It All Together
Shadows
Summary
Reference
Chapter 6. More on Colors and Materials
Blending
Fog
Accumulation Buffer
Other Color Operations
Summary
Reference
Chapter 7. Imaging with OpenGL
Bitmaps
Pixel Packing
Pixmaps
More Fun with Pixels
The Imaging "Subset"
Summary
Reference
Chapter 8. Texture Mapping: The Basics
Loading Textures
Mapping Textures to Geometry
A Simple 2D Example
Texture Environment
Texture Parameters
Texture Objects
Summary
Reference
Chapter 9. Texture Mapping: Beyond the Basics
Secondary Color
Anisotropic Filtering
Texture Compression
Texture Coordinate Generation
Multitexture
Texture Combiners
Summary
Reference
Chapter 10. Curves and Surfaces
Built-in Surfaces
Bézier Curves and Surfaces
NURBS
Tessellation
Summary
Reference
Chapter 11. It's All About the Pipeline: Faster Geometry Throughput
Model Assembly 101
Display Lists
Measuring Performance
Vertex Arrays
Summary
Reference
Chapter 12. Interactive Graphics
Selection
A Feedback Example
Summary
Reference
Part II. OpenGL Everywhere
Chapter 13. Wiggle: OpenGL on Windows
OpenGL Implementations on Windows
Basic Windows Rendering
Putting It All Together
Windows Palettes
OpenGL and Windows Fonts
Full-Screen Rendering
Multithreaded Rendering
OpenGL and WGL Extensions
Summary
Reference
Chapter 14. OpenGL on MacOS X
The Basics
Using the AGL and Carbon APIs
Using the Cocoa API
Summary
Reference
Chapter 15. GLX: OpenGL on Linux
The Basics
The OpenGL Extension for the X Window System
Creating Bitmap Fonts for OpenGL
Offscreen Rendering
Using the Motif Library
Summary
Reference
Part III. OpenGL: The Next Generation
Chapter 16. Buffer Objects: It's Your Video Memory; You Manage It!
First, You Need Vertex Arrays
Migration to Buffer Objects
Loading Data into Buffer Objects
A Few Loose Ends
Summary
Reference
Chapter 17. Occlusion Queries: Why Do More Work Than You Need To?
The World Before Occlusion Queries
Bounding Boxes
Querying the Query Object
Summary
Reference
Chapter 18. Depth Textures and Shadows
Be That Light
A New Kind of Texture
Draw the Shadows First?!
And Then There Was Light
Two Out of Three Ain't Bad
A Few Words About Polygon Offset
Summary
Reference
Chapter 19. Programmable Pipeline: This Isn't Your Father's OpenGL
Out with the Old
In with the New
Introduction to Shader Extensions
Summary
Chapter 20. Low-Level Shading: Coding to the Metal
Managing Low-Level Shaders
Instruction Sets
Variable Types
Input and Output Modifiers
Resource Consumption and Queries
Shader Options
Summary
Reference
Chapter 21. High-Level Shading: The Real Slim Shader
Managing High-Level Shaders
Variables
Expressions
Control Flow
Summary
Reference
Chapter 22. Vertex Shading: Do-It-Yourself Transform, Lighting, and Texgen
Getting Your Feet Wet
Diffuse Lighting
Specular Lighting
Improved Specular Lighting
Per-Vertex Fog
Per-Vertex Point Size
Customized Vertex Transformation
Vertex Blending
Summary
Chapter 23. Fragment Shading: Empower Your Pixel Processing
Color Conversion
Image Processing
Lighting
Procedural Texture Mapping
Summary
Appendix A. Further Reading
Other Good OpenGL Books
3D Graphics Books
Web Sites
Appendix B. Glossary
Appendix C. OpenGL ES
Reduction of Data Types
Totally Gone
Greatly Reduced Functionality
Conclusion
CD-ROM
What's on the CD-ROM
Windows Installation Instructions
License Agreement
Index

Download
Another OpenGL Books
Another Mac
Related Posts with Thumbnails

Put Your Ads Here!