ShaderX2: Introductions and Tutorials with DirectX 9.0

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

ShaderX2: Introductions & Tutorials with DirectX 9 is a collection of articles that provide an introduction to vertex and pixel shader programming using DirectX 9. Nearly a dozen experts in the graphics programming and software engineering fields share their knowledge on a variety of shader programming subjects, including how to integrate shaders written in the High Level Shading Language into your application and how to create shader-friendly 3D models. Other topics discussed are implementing shadow maps and shadow volumes to create realistic-looking shadow effects, using advanced lighting models, adding fog effects to increase a scene’s realism, and unlocking the new features of the pixel and vertex shader 3.0 models. Additionally, facilitating the shader prototyping process using a new shader development tool is addressed.

ON THE CD: The companion CD contains examples and source code discussed in the articles.

Author(s): Wolfgang F. Engel
Series: ShaderX 2
Publisher: Wordware Publishing, Inc.
Year: 2004

Language: English
Pages: 729

Team DDU......Page 1
Articles......Page 6
Contents......Page 8
Preface......Page 14
About the Authors......Page 18
Introduction......Page 22
Introduction......Page 24
A Simple Example......Page 25
Assembly Language and Compile Targets......Page 27
Compilation Failure......Page 29
The Command-line Compiler - fxc......Page 30
Keywords......Page 31
Data Types......Page 32
Type Modifiers......Page 35
Storage Class Modifiers......Page 36
Working with Vectors......Page 37
Type Casting......Page 38
Samplers......Page 40
Intrinsics......Page 42
Math Intrinsics......Page 43
Texture Sampling Intrinsics......Page 46
Uniform Input......Page 48
Varying Input......Page 50
Shader Outputs......Page 52
An Example Shader......Page 54
Optimization......Page 62
Matrix Data Type Usage......Page 63
Integer Data Type Usage......Page 64
Flow Control and Performance......Page 65
Importance of Input Type Declarations......Page 67
Precision Issues (logp, expp, lit)......Page 68
Using the ps_1_x Compile Targets......Page 69
Integration into an Engine Using D3DX Effects......Page 74
Effect Files......Page 75
The Effect API......Page 80
Integration into an Engine without Using D3DX Effects......Page 81
The Constant Table......Page 82
Acknowledgments......Page 84
Introduction......Page 86
Flexible Input and Output Declarations......Page 87
Predication......Page 88
Static and Dynamic Flow Control......Page 89
Arbitrary Swizzle......Page 92
Destination Write Masks on Texture Instructions......Page 93
Registers......Page 94
Texture Sampling......Page 96
Vertex Stream Frequency......Page 99
Registers......Page 101
Instructions......Page 103
References......Page 105
Introduction......Page 106
Phong's Lighting Equation......Page 107
Vertex and Pixel Shaders 2.0......Page 108
Vertex and Pixel Shaders 3.0......Page 120
Per-pixel Environment Bump Mapping with Fresnel Term......Page 131
Mathematical Background......Page 132
Vertex Shader......Page 135
Pixel Shader 1.4......Page 138
Pixel Shader 2.0......Page 140
HLSL Version......Page 142
Spherical Coordinates......Page 145
Roughness of a Surface......Page 146
Masking and Shadowing......Page 147
The Oren-Nayar Model......Page 148
Shaders......Page 150
HLSL Version......Page 154
Cook-Torrance Model......Page 157
Shaders 2.0......Page 159
Shaders 1.4......Page 163
HLSL Version......Page 166
Quality Comparison......Page 170
Conclusion......Page 171
References......Page 172
Introduction......Page 174
The Theory behind Fog Calculations......Page 175
Fog Equation......Page 177
Implementation......Page 178
Technique Two: Exponential Fog......Page 180
Fog Equation......Page 181
Implementation......Page 182
Technique Three: Exponential Squared Fog......Page 185
Fog Equation......Page 186
Implementation......Page 187
Technique Four: Layered Fog......Page 189
Theory and Equations......Page 190
Implementation......Page 191
Technique Five: Animated Fog......Page 197
Theory and Equations......Page 198
Implementation......Page 199
Conclusion......Page 201
References......Page 202
Introduction......Page 204
Shadow Algorithm......Page 205
Depth Bias Problem......Page 206
Shadow Map Filtering......Page 208
Shaders for Shadow Map Creation......Page 210
Shaders for Final Rendering......Page 211
Conclusion......Page 217
References......Page 218
Introduction......Page 220
Shadow Volume Concept......Page 222
Depth-pass (z-pass)......Page 224
Depth-fail (z-fail)......Page 228
Finite Shadow Cover......Page 232
Ghost Shadow......Page 233
View Frustum Clipping......Page 235
How It Is Done......Page 243
Silhouette Determination......Page 244
Forming the Shadow Volume......Page 248
Shadow Volume Capping......Page 254
Depth-pass Stenciling Operations (DepthPassCPU)......Page 256
Depth-fail Stenciling Operations (DepthFailCPU)......Page 261
Rendering Shadow Volume Capping......Page 264
Implementation on GPU (Shaders)......Page 266
How It Is Done......Page 267
Preprocessing of Data......Page 268
Forming Shadow Volume in Shaders......Page 272
Vertex Shader Implementation (FiniteGPU)......Page 273
Vertex Shader Implementation (InfiniteGPU)......Page 279
Better with Shaders?......Page 283
DirectX 9 HLSL Samples......Page 285
Use Less for More......Page 290
Cheat Whenever You Can......Page 292
Fighting the Invisible......Page 293
Scene Management Inside and Out......Page 294
The End......Page 298
References......Page 299
Introduction......Page 302
Overview of the IDE......Page 304
Creation of Basic Illumination Effect......Page 305
Run-Time Database Overview......Page 306
Workspace View......Page 308
Variable Creation and Management......Page 309
Predefined RenderMonkey Variables......Page 311
Stream Mapping Module......Page 313
Model Management......Page 316
Managing Effects......Page 317
Pixel and Vertex Shaders......Page 318
Editing Shaders......Page 319
Vertex Shader Setup and Editing......Page 321
Shader Assembly or Compilation Errors......Page 325
Editing Assembly......Page 326
Pixel Shader Setup and Editing......Page 329
Preview Window......Page 331
Editing Variables......Page 333
Render State Block Management......Page 337
Texturing in RenderMonkey......Page 340
Texture Objects......Page 341
Using Textures with HLSL Shaders......Page 345
Render Passes......Page 347
Renderable Texture Support......Page 348
Editing a Renderable Texture......Page 354
Artist Editor......Page 355
Editing Variables in the Artist Editor Module......Page 357
Summary......Page 360
Tips for Creating Shader-Friendly 3D Models......Page 362
Generating Suitable Texture Coordinates......Page 363
The Influence of "Vertex Weight"......Page 364
Problems with Non-Convex Surfaces......Page 366
Conclusion......Page 368
Index......Page 378