Home > Store

ROST:OPENGL SHADING LANG _p1

Register your product to gain access to bonus material or receive a coupon.

ROST:OPENGL SHADING LANG _p1

Book

  • Sorry, this book is no longer in print.
Not for Sale

About

Features

The definitive reference and cookbook for the OpenGL Shading Language, the most exciting addition to OpenGL in years!

° Shading languages are the most important new development in graphics programming in years

° The author is at the very center of the activity surrounding the OpenGL Shading Language

° Both a tutorial and a reference, with lots of practical examples

Description

  • Copyright 2004
  • Edition: 1st
  • Book
  • ISBN-10: 0-321-19789-5
  • ISBN-13: 978-0-321-19789-4

Praise for OpenGL® Shading Language

OpenGL® Shading Language provides a timely, thorough, and entertaining introduction to the only OpenGL ARB-approved high-level shading language in existence. Whether an expert or a novice, there are gems to be discovered throughout the book, and the reference pages will be your constant companion as you dig into the depths of the shading APIs. From algorithms to APIs, this book has you covered.”

     —Bob Kuehne
         CEO, Blue Newt Software

“Computer graphics and rendering technologies just took a giant leap forward with hardware vendors rapidly adopting the new OpenGL Shading Language. This book presents a detailed treatment of these exciting technologies in a way that is extremely helpful for visualization and game developers.”

     —Andy McGovern
         Founder, Virtual Geographics, Inc.

“The OpenGL Shading Language is at the epicenter of the programmable graphics revolution, and Randi Rost has been at the center of the development of this significant new industry standard. If you need the inside track on how to use the OpenGL Shading Language to unleash new visual effects, and unlock the supercomputer hiding inside the new generation of graphics hardware, then this is the book for you.”

     —Neil Trevett
         Senior Vice President Market Development, 3Dlabs

"The author has done an excellent job at setting the stage for shader development, what the purpose is, how to do it, and how it all fits together."
—Jeffery Galinovsky
Strategic Software Program Manager, Intel Corporation

The OpenGL® Shading Language, a high-level procedural shading language for OpenGL®, is the most important new development in graphics programming to emerge in years. OpenGL is the leading cross-platform 3D-graphics API, and the OpenGL Shading Language allows developers to take total control over the most important stages of the graphics-processing pipeline.

OpenGL® Shading Language is the experienced application programmer's guide to writing shaders. Part reference, part tutorial, this book thoroughly explains the shift from fixed-functionality graphics hardware to the new era of programmable graphics hardware and the additions to the OpenGL API that support this programmability. With OpenGL and shaders written in the OpenGL Shading Language, applications can perform better, achieving stunning graphics effects by utilizing the capabilities of both the visual processing unit and the central processing unit.

In this book, you will find a detailed introduction to the OpenGL Shading Language and the new OpenGL function calls that support it. The text begins by describing the syntax and semantics of this high-level programming language. Once this foundation has been established, the book explores the creation and manipulation of shaders using new OpenGL function calls.

OpenGL® Shading Language features extensive examples of shaders and their underlying algorithms, including

  • Procedural texturing
  • Noise
  • Particle systems
  • Hatching
  • Analytic antialiasing
  • Image processing

The color plate section illustrates the power and sophistication of the OpenGL Shading Language. The API Function Reference at the end of the book is an excellent quick reference to the API entry points that support the OpenGL Shading Language. An enhanced online index allows readers to quickly and easily search the entire text for specific topics.



Sample Content

Online Sample Chapter

A Simple OpenGL Shading Example

Downloadable Sample Chapter

Download the Sample Chapter related to this title.

Table of Contents



Foreword.


Preface.


About the Author.


About the Contributors.


Acknowledgments.


1. Review of OpenGL Basics.

OpenGL History.

Evolving OpenGL.

Execution Model.

The Frame Buffer.

State.

Processing Pipeline.

Drawing Geometry.

Specifying Geometry.

Per-Vertex Operations.

Primitive Assembly.

Primitive Processing.

Rasterization.

Fragment Processing.

Per-Fragment Operations.

Frame Buffer Operations.

Drawing Images.

Pixel Unpacking.

Pixel Transfer.

Rasterization and Back-End Processing.

Read Control.

Coordinate Transforms.

Texturing.

Summary.

Further Information.



2. Basics.

Introduction to the OpenGL Shading Language.

Why Write Shaders?

OpenGL Programmable Processors.

Vertex Processor.

Fragment Processor.

Language Overview.

Language Design Considerations.

C Basis.

Additions to C.

Additions from C++.

C Features Not Supported.

Other Differences.

System Overview.

Driver Model.

OpenGL Shading Language Compiler/Linker

OpenGL API Extensions.

Key Benefits.

Summary.

Further Information.



3. Language Definition.

Example Shader Pair.

Data Types.

Scalars.

Vectors.

Matrices.

Samplers.

Structures.

Arrays.

Void.

Declarations and Scope.

Type Matching and Promotion.

Initializers and Constructors.

Type Conversions.

Qualifiers and Interface to a Shader.

Attribute Qualifiers.

Uniform Qualifiers.

Varying Qualifiers.

Constant Qualifiers.

Absent Qualifier.

Flow Control.

Functions.

Calling Conventions.

Built-in Functions.

Operations.

Indexing.

Swizzling.

Component-wise Operation.

Preprocessor.

Preprocessor Expressions.

Error Handling.

Summary.

Further Information.



4. The OpenGL Programmable Pipeline.

The Vertex Processor.

Vertex Attributes.

Uniform Variables.

Special Output Variables.

Built-in Varying Variables.

User-Defined Varying Variables.

The Fragment Processor.

Varying Variables.

Uniform Variables.

Special Input Variables.

Special Output Variables.

Built-in Uniform Variables.

Built-in Constants.

Interaction with OpenGL Fixed Functionality.

Two-Sided Color Mode.

Point Size Mode.

Clipping.

Raster Position.

Position Invariance.

Texturing.

Summary.

Further Information.



5. Built-in Functions.

Angle and Trigonometry Functions.

Exponential Functions.

Common Functions.

Geometric Functions.

Matrix Functions.

Vector Relational Functions.

Texture Access Functions.

Fragment Processing Functions.

Noise Functions.

Summary.

Further Information.



6. Simple Shading Example.

Brick Shader Overview.

Vertex Shader.

Fragment Shader.

Observations.

Summary.

Further Information.



7. OpenGL Shading Language API.

Creating Shader Objects.

Compiling Shader Objects.

Linking and Using Shaders.

Cleaning Up.

Query Functions.

Specifying Vertex Attributes.

Specifying Uniform Variables.

Samplers.

Development Aids.

Implementation-Dependent API Values.

Application Code for Brick Shaders.

Summary.

Further Information.



8. Shader Development.

General Principles.

Understand the Problem.

Add Complexity Progressively.

Test and Iterate.

Strive for Simplicity.

Modularity.

Performance Considerations.

Consider Computational Frequency.

Analyze Your Algorithm.

Use the Built-in Functions.

Use Vectors.

Use Textures to Encode Complex Functions.

Review the Info Logs.

Shader Debugging.

Use the Vertex Shader Output.

Use the Fragment Shader Output.

Use Simple Geometry.

Shader Development Tools.

RenderMonkey.

OpenGL Shading Language Compiler Front End.

Summary.

Further Information.



9. Traditional Shaders.

Transformation.

Light Sources.

Directional Lights.

Point Lights.

Spotlights.

Material Properties and Lighting.

Two-Sided Lighting.

No Lighting.

Fog.

Texture Coordinate Generation.

User Clipping.

Texture Application.

Summary.

Further Information.



10. Stored Texture Shaders.

Accessing Texture Maps from a Shader.

Simple Texturing Example.

Application Setup.

Vertex Shader.

Fragment Shader.

Multitexturing Example.

Application Setup.

Vertex Shader.

Fragment Shader.

Environment Mapping Example.

Application Setup.

Vertex Shader.

Fragment Shader.

Polynomial Texture Mapping with BRDF Data.

Application Setup.

Vertex Shader.

Fragment Shader.

Summary.

Further Information.



11. Procedural Texture Shaders.

Regular Patterns.

Stripes vertex shader.

Stripes Fragment Shader.

Toy Ball.

Application Setup.

Vertex Shader.

Fragment Shader.

Lattice.

Bump Mapping.

Application Setup.

Vertex Shader.

Fragment Shader.

Normal Maps.

Summary.

Further Information.



12. Noise.

Defining Noise.

2D Noise.

Higher Dimensions of Noise.

Using Noise in OpenGL Shaders.

Noise Textures.

Trade-offs.

A Simple Noise Shader.

Application Setup.

Vertex Shader.

Fragment Shader.

Turbulence.

Sun Surface Shader.

Marble.

Granite.

Wood.

Application Setup.

Fragment Shader.

Summary.

Further Information.



13. Animated Shaders.

On/Off.

Threshold.

Translation.

Key-Frame Interpolation.

Key-Frame Interpolation Vertex Shader.

Other Blending Effects.

Particle Systems.

Application Setup.

Confetti Cannon Vertex Shader.

Confetti Cannon Fragment Shader.

Further Enhancements.

Wobble.

Summary.

Further Information.



14. Antialiasing Procedural Textures.

Sources of Aliasing.

Avoiding Aliasing.

Increasing Resolution.

Antialiased Stripe Example.

Generating Stripes.

Analytic Prefiltering.

Adaptive Analytic Prefiltering.

Analytic Integration.

Antialiased Brick Fragment Shader.

Frequency Clamping.

Antialiased Checkerboard Fragment Shader.

Summary.

Further Information.



15. Non-Photorealistic Shaders.

Hatching Example.

Application Setup.

Vertex Shader.

Generating Hatching Strokes.

Obtaining Uniform Line Density.

Lighting.

Adding Character.

Hatching Fragment Shader.

Technical Illustration Example.

Application Setup.

Vertex Shader.

Fragment Shader.

Mandelbrot Example.

About the Mandelbrot Set.

Vertex Shader.

Fragment Shader.

Julia Sets.

Summary.

Further Information.



16. Shaders for Imaging.

Geometric Image Transforms.

Mathematical Mappings.

Lookup Table Operations.

Color Space Conversions.

Image Interpolation and Extrapolation.

Brightness.

Contrast.

Saturation.

Sharpness.

Blend Modes.

Normal.

Average.

Dissolve.

Behind.

Clear.

Darken.

Lighten.

Multiply.

Screen.

Color Burn.

Color Dodge.

Overlay.

Soft Light.

Hard Light.

Add.

Subtract.

Difference.

Inverse Difference.

Exclusion.

Opacity.

Convolution.

Smoothing.

Edge Detection.

Sharpening.

Summary.

Further Information.



17. Language Comparison.

Chronology of Shading Languages.

RenderMan.

OpenGL Shader (ISL).

HLSL.

Cg.

Summary.

Further Information.



Appendix A. Language Grammar.


Appendix B. API Function Reference.

glAttachObjectARB.

glBindAttribLocationARB.

glCompileShaderARB.

glCreateProgramObjectARB.

glCreateShaderObjectARB.

glDeleteObjectARB.

glDetachObjectARB.

glEnableVertexAttribArrayARB.

glGetActiveAttribARB.

glGetActiveUniformARB.

glGetAttachedObjectsARB.

glGetAttribLocationARB.

glGetHandleARB.

glGetInfoLogARB.

glGetObjectParameterARB.

glGetShaderSourceARB.

glGetUniformARB.

glGetUniformLocationARB.

glGetVertexAttribARB.

glGetVertexAttribPointervARB.

glLinkProgramARB.

glShaderSourceARB.

glUniformARB.

glUseProgramObjectARB.

glValidateProgramARB.

glVertexAttribARB.

glVertexAttribPointerARB.



Afterword.


Glossary.


Further Reading.


Index.

Foreword

This book is an amazing measure of how far and how fast interactive shading has advanced. Not too many years ago, procedural shading was something done only in offline production rendering, creating some of the great results we all know from the movies, but were not anywhere close to interactive. Then a few research projects appeared, allowing a slightly modified but largely intact type of procedural shading to run in real-time. Finally, in a rush, widely accessible commercial systems started to support shading. Today, we've come to the point where a real-time shading language developed by a cross-vendor group of OpenGL participants has achieved official designation as an OpenGL Architecture Review Board approved extension. This book, written by one of those most responsible for spearheading the development and acceptance of the OpenGL shading language, is your guide to that language and the extensions to OpenGL that let you use it.

I came to my interest in procedural shading from a strange direction. In 1990, I started graduate school at the University of North Carolina in Chapel Hill because it seemed like a good place for someone whose primary interest was interactive 3D graphics. There, I started working on the Pixel-Planes project. This project had produced a new graphics machine with several interesting features beyond its performance at rendering large numbers of polygons per second. One feature in particular had an enormous impact on the research directions I've followed for the past 13 years. Pixel-Planes 5 had programmable pixel processors--lots of them. Programming these processors was similar in many ways to the assembly-language fragment programs that have burst onto the graphics scene in the past few years.

Programming them was exhilarating, yet also thoroughly exasperating.

I was far from the only person to notice both the power and pain of writing low-level code to execute per-pixel. Another group within the Pixel-Planes team built an assembler for shading code to make it a little easier to write, although it was still both difficult to write a good shader and ever-sorewarding once you had it working. The shaders produced will be familiar to anyone who has seen demos of any of the latest graphics products, and not surprisingly you'll find versions of many of them in this book: wood, clouds, brick, rock, reflective wavy water, and (of course) the Mandelbrot fractal set.

The rewards and difficulties presented by Pixel-Planes 5 shaders guided many of the design decisions behind the next machine, PixelFlow. PixelFlow was designed and built by a university/industry partnership with industrial participation first by Division, then by Hewlett-Packard. The result was the first interactive system capable of running procedural shaders compiled from a high-level shading language. PixelFlow was demonstrated at the SIGGRAPH conference in 1997. For a few years thereafter, if you were fortunate enough to be at UNC-Chapel Hill, you could write procedural shaders and run them in real-time when no one else could. And, of course, the only way to see them in action was to go there.

I left UNC for a shading project at SGI, with the hopes of providing a commercially supported shading language that could be used on more than just one machine at one site. Meanwhile, a shading language research project started up at Stanford, with some important results for shading on PC-level graphics hardware. PC graphics vendors across the board started to add low-level shading capabilities to their hardware. Soon, people everywhere could write shading code similar in many ways to that that had so inspired me on the Pixel Planes 5 machine. And, not surprisingly, soon people everywhere also knew that we were going to need a higher-level language for interactive shading.

Research continues into the use, improvement, and abuse of these languages at my lab at University of Maryland, Baltimore County; and at many, many others. However, the mere existence of real-time high-level shading languages is no longer the subject of that research. Interactive shading languages have moved from the research phase to wide availability. There are a number of options for anyone wanting to develop an application using the shading capabilities of modern graphics hardware. The principal choices are Cg, HLSL, and the OpenGL Shading Language. The last of which has the distinction of being the only one that has been through a rigorous multivendor review process. I participated in that process, as did over two dozen representatives from a dozen companies and universities.

This brings us back full circle to this book. If you are holding this book now, you are most likely interested in some of the same ideals that drove the creation of the OpenGL Shading Language, the desire for a cross-OS, crossplatform, robust and standardized shading language. You want to learn how to use all of that? Open up and start reading. Then get shading!

—Marc Olano
University of Maryland, Baltimore County, MD
September 2003

Index

Download the Index file related to this title.

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020