Programmable graphics shaders, programs that can be downloaded to a graphics processor (GPU) to carry out operations outside the fixed-function pipeline of earlier standards, have become a key feature of computer graphics. This book is designed to open computer graphics shader programming to the student, whether in a traditional class or on their own. It is intended to complement texts based on fixed-function graphics APIs, specifically OpenGL. It introduces shader programming in general, and specifically the GLSL shader language. It also introduces a flexible, easy-to-use tool, glman, that helps you develop, test, and tune shaders outside an application that would use them.
Table of Contents
The Fixed-Function Graphics Pipeline The Traditional View The Vertex Pipeline The Triangle-Rendering Part of the Pipeline State in the Graphics Pipeline How the Traditional View is Implemented Vertex Processing Rendering Processing Homogeneous Coordinates in the Fixed-Function Pipeline Vertex Arrays Conclusions Exercises Fundamental Shader Concepts History of Shaders Shaders in the Graphics Pipeline Vertex Shaders A Warning on Shader Code Efficiency Fragment Shaders Geometry Shaders The GLSL Shading Language Exercises Using glman Using glman Loading a GLIB File Editing GLIB and Shader Source Files GLIB Scene Creation Window and Viewing Transformations Defining Geometry Specifying Textures Specifying Shaders Miscellaneous Specifying Uniform Variables Examples of GLIB Files More on Textures and Noise Using Textures Using Noise Functions in the glman Interface Window Generating and Displaying a Copy of Your Scene Global Scene Transformation Eye Transformation Texture Transformation Object Picking and Transformation Monitoring the Frame Rate Miscellaneous Exercises The GLSL Shader Language Factors that Shape Shader Languages Graphics Card Capabilities Parallellism in Graphics Cards The Need to Support Graphics Operations Built-In Data General GLSL Language Concepts Extended Function and Operator Capabilities New Functions New Variable Types New Function Parameter Types Language Details Omitted Language Features New Matrix and Vector Types Functions Extended to Matrices and Vectors Operations Extended to Matrices and Vectors New Functions Name Sets Swizzle New Data Types New Function Parameter Types Shared Namespaces What's Coming in GLSL Version . Deprecation New Functionality in GLSL. Summary Exercises Lighting The ADS Lighting Model The ADS Lighting Model Function Kinds of Lights Positional Lights Directional Lights Spot Lights Setting Up Lighting for Shading Flat Shading Smooth (Gouraud) Shading Phong Shading Anisotropic Shading Exercises Vertex Shaders Vertex Shaders in the Graphics Pipeline Input to Vertex Shaders Output from Vertex Shaders Fixed-Function Processing After the Vertex Shader The Relation of Vertex Shaders to Geometry Shaders Replacing Fixed-Function Graphics with Vertex Shaders Standard Vertex Processing Going Beyond the Fixed-Function Pipeline with Vertex Shaders Vertex Modification Dome Geometry Example Issues in Vertex Shaders Exercises Fragment Shaders and Surface Appearance Basic Function of a Fragment Shader Inputs to Fragment Shaders Particularly Important Varying Variables Coordinate Systems Fragment Shader Processing Outputs from Fragment Shaders Replacing Fixed-Function Processing with Fragment Shaders Shading Traditional Texture Mapping False Coloring What Follows a Fragment Shader? Additional Shader Effects Discarding Pixels Phong Shading Exact Shading Anisotropic Shading Data-Driven Coloring Exercises Texture Mapping in Fragment Shaders Texture Coordinates Traditional Texture Mapping GLSL Texture Mapping The Texture Context Standard Texture Operations Samplers Textures Procedural Textures Bump Mapping Cube Maps Render to Texture Exercises Noise Fundamental Noise Concepts Three Types of Noise: Value, Gradient, and Value+Gradient Cubic and Quintic Interpolation Noise Equations Other Noise Concepts Fractional Brownian Motion (FBM, /f, Octaves) Noise in Two and Three Dimensions Using Noise with glman Turbulence Some Examples of Noise in Different Environments Marble Shader Cloud Shader Wood Shader Advanced Noise Topics Using noisegraph Exercises Image Manipulation with Shaders Basic Concepts Single-Image Manipulation Luminance CMYK Conversions Hue Shifting Image Filtering Image Blurring Chromakey Images Stereo Anaglyphs D TV Edge Detection Embossing Toon Shader Artistic Effects Image Flipping, Rotation, and Warping The Image Blending Process Blending an Image with a Constant Base Image Color Negative Brightness Contrast Blending an Image with a Version of Itself Saturation Sharpness Blending Two Different Images Dissolve Other Combinations Notes Exercises Geometry Shader Concepts and Examples What Does the Geometry Shader Do? New Adjacency Primitives New OpenGL API Functions New GLSL Variables and Variable Types Communication Between a Vertex Shader and a Geometry Shader Normals in Geometry Shaders Examples Bezier Curves Shrinking Triangles Sphere Subdivision D Object Silhouettes Exercises The OpenGL API Shaders in the OpenGL Programming Process Handling OpenGL Extensions How Is a GLSL Shader Created? Creating and Compiling Shader Objects The CheckGLErrors Function Creating, Attaching, Linking, and Activating Shader Programs Creating a Shader Program and Attaching Shader Objects Linking Shader Programs Activating a Shader Program Passing Data into Shaders Application-Defined Uniform Variables Application-Defined Per-Vertex Attribute Variables A C++ Class to Handle Shader Program Creation Exercises Using Shaders for Scientific Visualization Image-Based Visualization Techniques Image Negative Image Edge Detection Toon Rendering Hyperbolic Geometry D Scalar Data Visualization Point Clouds Cutting Planes Volume Probe Direct Volume Rendering Transfer Functions Passing in Data Values with Your Geometry Flow Visualization D Line Integral Convolution D Line Integral Convolution Extruding Objects for Streamlines Geometry Visualization Silhouettes Hedgehog Plots Exercises Serious Fun Light Interference Diffraction Gratings Oil Slicks Lens Effects Atmospheric Effects Rainbows The Glory Fun with One Using the glman Timer Function Disco Ball Fog, With and Without Noise Algorithmic Art An Explosion Shader Exercises A. GLSL Program Class Source Code The Header File The Program Body References Index
Mike Bailey, Oregon State University, Corvallis, USA Steve Cunningham, Professor Emeritus, California State University Stanislaus, USA