Opengl Shading Language PDF Download
Opengl Shading Language PDF Download
https://ebookbell.com/product/opengl-shading-language-981838
https://ebookbell.com/product/opengl-shading-language-rost-randi-
jginsburg-danlichtenbelt-22104632
https://ebookbell.com/product/opengl-shading-language-2nd-edition-
randijrost-929564
https://ebookbell.com/product/opengl-4-shading-language-cookbook-3rd-
edition-david-wolff-23946184
https://ebookbell.com/product/opengl-4-shading-language-cookbook-2nd-
edition-david-wolff-5496506
Openglr Shading Language 2nd Edition 2nd Edition Randi J Rost
https://ebookbell.com/product/openglr-shading-language-2nd-
edition-2nd-edition-randi-j-rost-1463316
https://ebookbell.com/product/openglr-shading-language-randi-j-
rost-1354912
https://ebookbell.com/product/opengl-40-shading-language-cookbook-
david-wolff-2381738
https://ebookbell.com/product/opengl-build-high-performance-graphics-
learning-path-1st-edition-muhammad-mobeen-movania-david-wolff-raymond-
c-h-lo-47374330
https://ebookbell.com/product/opengl-programming-guide-the-official-
guide-to-learning-opengl-versions-30-and-31-r-5th-edition-
shreiner-22104630
Contents
1. main
2. Table of Contents
3. Copyright
4. Praise for OpenGL® Shading Language
5. Foreword
6. Preface
7. Intended Audience
8. About This Book
9. About the Shader Examples
10. Errata
11. Typographical Conventions
12. About the Author
13. About the Contributors
14. Acknowledgments
15. Color Plates
16. Chapter 1. Review of OpenGL Basics
17. 1.1 OpenGL History
18. 1.2 Evolving OpenGL
19. 1.3 Execution Model
20. 1.4 The Frame Buffer
21. 1.5 State
22. 1.6 Processing Pipeline
23. 1.7 Drawing Geometry
24. 1.8 Drawing Images
25. 1.9 Coordinate Transforms
26. 1.10 Texturing
27. 1.11 Summary
28. 1.12 Further Information
29. Chapter 2. Basics
30. 2.1 Introduction to the OpenGL Shading Language
31. 2.2 Why Write Shaders?
32. 2.3 OpenGL Programmable Processors
33. 2.4 Language Overview
34. 2.5 System Overview
35. 2.6 Key Benefits
36. 2.7 Summary
37. 2.8 Further Information
38. Chapter 3. Language Definition
39. 3.1 Example Shader Pair
40. 3.2 Data Types
41. 3.3 Initializers and Constructors
42. 3.4 Type Conversions
43. 3.5 Qualifiers and Interface to a Shader
44. 3.6 Flow Control
45. 3.7 Operations
46. 3.8 Preprocessor
47. 3.9 Preprocessor Expressions
48. 3.10 Error Handling
49. 3.11 Summary
50. 3.12 Further Information
51. Chapter 4. The OpenGL Programmable Pipeline
52. 4.1 The Vertex Processor
53. 4.2 The Fragment Processor
54. 4.3 Built-in Uniform Variables
55. 4.4 Built-in Constants
56. 4.5 Interaction with OpenGL Fixed Functionality
57. 4.6 Summary
58. 4.7 Further Information
59. Chapter 5. Built-in Functions
60. 5.1 Angle and Trigonometry Functions
61. 5.2 Exponential Functions
62. 5.3 Common Functions
63. 5.4 Geometric Functions
64. 5.5 Matrix Functions
65. 5.6 Vector Relational Functions
66. 5.7 Texture Access Functions
67. 5.8 Fragment Processing Functions
68. 5.9 Noise Functions
69. 5.10 Summary
70. 5.11 Further Information
71. Chapter 6. Simple Shading Example
72. 6.1 Brick Shader Overview
73. 6.2 Vertex Shader
74. 6.3 Fragment Shader
75. 6.4 Observations
76. 6.5 Summary
77. 6.6 Further Information
78. Chapter 7. OpenGL Shading Language API
79. 7.1 Creating Shader Objects
80. 7.2 Compiling Shader Objects
81. 7.3 Linking and Using Shaders
82. 7.4 Cleaning Up
83. 7.5 Query Functions
84. 7.6 Specifying Vertex Attributes
85. 7.7 Specifying Uniform Variables
86. 7.8 Samplers
87. 7.9 Development Aids
88. 7.10 Implementation-Dependent API Values
89. 7.11 Application Code for Brick Shaders
90. 7.12 Summary
91. 7.13 Further Information
92. Chapter 8. Shader Development
93. 8.1 General Principles
94. 8.2 Performance Considerations
95. 8.3 Shader Debugging
96. 8.4 Shader Development Tools
97. 8.5 Summary
98. 8.6 Further Information
99. Chapter 9. Traditional Shaders
100. 9.1 Transformation
101. 9.2 Light Sources
102. 9.3 Material Properties and Lighting
103. 9.4 Two-Sided Lighting
104. 9.5 No Lighting
105. 9.6 Fog
106. 9.7 Texture Coordinate Generation
107. 9.8 User Clipping
108. 9.9 Texture Application
109. 9.10 Summary
110. 9.11 Further Information
111. Chapter 10. Stored Texture Shaders
112. 10.1 Accessing Texture Maps from a Shader
113. 10.2 Simple Texturing Example
114. 10.3 Multitexturing Example
115. 10.4 Environment Mapping Example
116. 10.5 Polynomial Texture Mapping with BRDF Data
117. 10.6 Summary
118. 10.7 Further Information
119. Chapter 11. Procedural Texture Shaders
120. 11.1 Regular Patterns
121. 11.2 Toy Ball
122. 11.3 Lattice
123. 11.4 Bump Mapping
124. 11.5 Summary
125. 11.6 Further Information
126. Chapter 12. Noise
127. 12.1 Defining Noise
128. 12.2 Noise Textures
129. 12.3 Trade-offs
130. 12.4 A Simple Noise Shader
131. 12.5 Turbulence
132. 12.6 Granite
133. 12.7 Wood
134. 12.8 Summary
135. 12.9 Further Information
136. Chapter 13. Animated Shaders
137. 13.1 On/Off
138. 13.2 Threshold
139. 13.3 Translation
140. 13.4 Key-Frame Interpolation
141. 13.5 Other Blending Effects
142. 13.6 Particle Systems
143. 13.7 Wobble
144. 13.8 Summary
145. 13.9 Further Information
146. Chapter 14. Antialiasing Procedural Textures
147. 14.1 Sources of Aliasing
148. 14.2 Avoiding Aliasing
149. 14.3 Increasing Resolution
150. 14.4 Antialiased Stripe Example
151. 14.5 Frequency Clamping
152. 14.6 Summary
153. 14.7 Further Information
154. Chapter 15. Non-Photorealistic Shaders
155. 15.1 Hatching Example
156. 15.2 Technical Illustration Example
157. 15.3 Mandelbrot Example
158. 15.4 Summary
159. 15.5 Further Information
160. Chapter 16. Shaders for Imaging
161. 16.1 Geometric Image Transforms
162. 16.2 Mathematical Mappings
163. 16.3 Lookup Table Operations
164. 16.4 Color Space Conversions
165. 16.5 Image Interpolation and Extrapolation
166. 16.6 Blend Modes
167. 16.7 Convolution
168. 16.8 Summary
169. 16.9 Further Information
170. Chapter 17. Language Comparison
171. 17.1 Chronology of Shading Languages
172. 17.2 RenderMan
173. 17.3 OpenGL Shader (ISL)
174. 17.4 HLSL
175. 17.5 Cg
176. 17.6 Summary
177. 17.7 Further Information
178. Appendix A. Language Grammar
179. Appendix B. API Function Reference
180. glAttachObjectARB
181. glBindAttribLocationARB
182. glCompileShaderARB
183. glCreateProgramObjectARB
184. glCreateShaderObjectARB
185. glDeleteObjectARB
186. glDetachObjectARB
187. glEnableVertexAttribArrayARB
188. glGetActiveAttribARB
189. glGetActiveUniformARB
190. glGetAttachedObjectsARB
191. glGetAttribLocationARB
192. glGetHandleARB
193. glGetInfoLogARB
194. glGetObjectParameterARB
195. glGetShaderSourceARB
196. glGetUniformARB
197. glGetUniformLocationARB
198. glGetVertexAttribARB
199. glGetVertexAttribPointervARB
200. glLinkProgramARB
201. glShaderSourceARB
202. glUniformARB
203. glUseProgramObjectARB
204. glValidateProgramARB
205. glVertexAttribARB
206. glVertexAttribPointerARB
207. Afterword
208. Glossary
209. Further Reading
Table of Contents
OpenGL Shading Language
By Randi J. Rost
• 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.
Table of Contents
OpenGL Shading Language
By Randi J. Rost
Publisher: Addison Wesley
Pub Date: February 20, 2004
ISBN: 0-321-19789-5
Pages: 608
Copyright
Praise for OpenGL Shading Language
Foreword
Preface
Intended Audience
About This Book
About the Shader Examples
Errata
Typographical Conventions
Chapter 2. Basics
Section 2.1. Introduction to the OpenGL Shading Language
Section 2.2. Why Write Shaders?
Section 2.3. OpenGL Programmable Processors
Section 2.4. Language Overview
Section 2.5. System Overview
Section 2.6. Key Benefits
Section 2.7. Summary
Section 2.8. Further Information
Afterword
Glossary
Further Reading
< Day Day Up >
The author and publisher have taken care in the preparation of this
book, but make no expressed or implied warranty of any kind and
assume no responsibility for errors or omissions. No liability is assumed
for incidental or consequential damages in connection with or arising
out of the use of the information or programs contained herein.
International Sales
(317) 581-3793
[email protected]
"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. He then develops on the advanced topics covering a great
breadth in the appropriate level of detail. Truly a necessary book to
own for any graphics developer!"
—Jeffery Galinovsky
Strategic Software Program Manager, Intel Corporation
—Bob Kuehne
CEO, Blue Newt Software
—Andy McGovern
Founder, Virtual Geographics, Inc.
—Neil Trevett
Senior Vice President Market Development, 3Dlabs
< Day Day Up >
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 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-so-rewarding 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.
For just about as long as there has been graphics hardware, there has
been programmable graphics hardware. Over the years, building
flexibility into graphics hardware designs has been a necessary way of
life for hardware developers. Graphics APIs continue to evolve, and
because a hardware design can take two years or more from start to
finish, the only way to guarantee a hardware product that can support
the then-current graphics APIs at its release is to build in some degree
of programmability from the very beginning.
The primary audience for this book is application programmers that are
interested in writing shaders. This book is intended to be used as both a
tutorial and a reference book by people interested in learning to write
shaders with the OpenGL Shading Language. Some will use the book
in one fashion and some in the other. It is hoped that the organization
will be amenable to both uses. It is not expected that most people will
read the book in sequential order from back to front.
This book has three main parts. Chapters 1 through 8 are aimed at
teaching the reader about the OpenGL Shading Language and how to
use it. This part of the book covers details of the language and details
of the OpenGL commands that are used to create and manipulate
shaders. In order to provide the reader with a basis for writing shaders,
Chapters 9 through 16 contain a gallery of shader examples and some
explanation of the underlying algorithms. This part of the book is
intended to be used as a basis for the reader's shader development and
as a springboard to inspire new ideas. Finally, Chapter 17 contains a
comparison with other notable commercial shading languages, and
Appendices A and B contain reference material for the language and
the API entry points that support it.
The chapters are arranged to suit the needs of the reader who is least
familiar with OpenGL and shading languages. Certain chapters can be
skipped by readers who are more familiar with both topics. People
don't necessarily read technical books from front to back, and this
book is designed to have somewhat compartmentalized chapters in
order to allow such usage.
The source code for these shaders is written in a way that I believe
represents a reasonable trade-off between source code clarity,
portability, and performance. Use them to learn the OpenGL Shading
Language, and improve upon them for use in your own projects.
With the exception of the images produced for the toy ball shader
(which were produced by ATI Research, Inc. on ATI hardware), all of
the images produced for this book were done on the first graphics
accelerator to provide support for the OpenGL Shading Language, the
3Dlabs Wildcat VP. This implementation has a variety of limitations, so
in a number of cases the image was generated with a shader that could
run on this hardware but contained hardware- or driver-dependent
idiosyncracies. A cleaned up version of such shaders is then presented
and discussed in this book. I have taken as much care as possible to
present shaders that are done "the right way" for the OpenGL Shading
Language rather than those with idiosyncracies due to being developed
on the very first implementation. I also have tried to be as careful as I
could be during the translation to cleaned up versions of the shaders.
The latest and greatest versions of these shaders will be available
through a link at this book's Web site at http://3dshaders.com.
Errata
I know that this book contains some errors, but I've done my best to
keep them to a minimum. If you find any errors, please report them to
me ([email protected]) and I will keep a running list on this book's
Web site at http://3dshaders.com.
Randi has been involved in the graphics industry for more than 25 years
and has participated in emerging graphics standards efforts for over 15
years. He has been involved with the design and evolution of OpenGL
since before version 1.0 was released in 1992. He is one of the few
people credited as a contributor for each major revision of OpenGL,
up through and including OpenGL 1.5. He was one of the chief
architects and the specification author for PEX, and he was a member
of the Graphics Performance Characterization (GPC) Committee
during the development of the Picture-Level Benchmark (PLB). He
served as 3Dlabs' representative to the Khronos Group from the time
the group started in 1999 until the OpenML 1.0 specification was
released, and he chaired the graphics subcommittee of that organization
during this time. He received the National Computer Graphics
Association (NCGA) 1993 Achievement Award for the Advancement
of Graphics Standards.
Randi received his B.S. degree in computer science and math from
Minnesota State University, Mankato, in 1981 and his M.S. in
computing science from the University of California, Davis, in 1983.
Data binding for OpenGL occurs when commands are issued, not
when they are executed. Data passed to an OpenGL command is
interpreted when the command is issued, and copied into OpenGL
memory if needed. Subsequent changes to this data by the application
have no effect on the data that is now stored within OpenGL.
< Day Day Up >
There are quite a few server-side state values in OpenGL that have just
two states: on or off. To turn a mode on, you must pass the appropriate
symbolic constant to the OpenGL command glEnable. To turn a mode
off, you pass the symbolic constant to glDisable. Client-side state (such
as pointers used to define vertex arrays) can be enabled by calling
glEnableClientState and disabled by calling glDisableClientState.
ebookbell.com